Skip to content

Commit badbb1f

Browse files
authored
[EuiBasicTable] Do not animate loading bar when user prefers reduced motion (#9095)
1 parent 78d4202 commit badbb1f

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**Accessibility**
2+
3+
- Make `EuiBasicTable` respect user's reduced motion setting by not animating when in loading state.

packages/eui/src/components/basic_table/basic_table.styles.ts

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
import { css, keyframes } from '@emotion/react';
1010

11-
import { logicalCSS, euiCantAnimate } from '../../global_styling';
11+
import {
12+
logicalCSS,
13+
euiCantAnimate,
14+
highContrastModeStyles,
15+
preventForcedColors,
16+
} from '../../global_styling';
1217
import { UseEuiTheme } from '../../services';
1318

1419
const tableLoadingLine = keyframes`
@@ -33,23 +38,40 @@ const tableLoadingLine = keyframes`
3338
}
3439
`;
3540

36-
export const euiBasicTableBodyLoading = ({ euiTheme }: UseEuiTheme) => css`
37-
position: relative;
38-
overflow: hidden;
39-
40-
&::before {
41-
position: absolute;
42-
content: '';
43-
${logicalCSS('width', '100%')}
44-
${logicalCSS('height', euiTheme.border.width.thick)}
45-
background-color: ${euiTheme.colors.primary};
46-
animation: ${tableLoadingLine} 1s linear infinite;
47-
48-
${euiCantAnimate} {
49-
animation-duration: 2s;
41+
export const euiBasicTableBodyLoading = (euiThemeContext: UseEuiTheme) => {
42+
const { euiTheme } = euiThemeContext;
43+
44+
return css`
45+
position: relative;
46+
overflow: hidden;
47+
48+
&::before {
49+
position: absolute;
50+
content: '';
51+
${logicalCSS('width', '100%')}
52+
${logicalCSS('height', euiTheme.border.width.thick)}
53+
background-color: ${euiTheme.colors.primary};
54+
animation: ${tableLoadingLine} 1s linear infinite;
55+
56+
${euiCantAnimate} {
57+
animation: none;
58+
background: repeating-linear-gradient(
59+
-45deg,
60+
${euiTheme.colors.backgroundBasePlain},
61+
${euiTheme.colors.backgroundBasePlain} ${euiTheme.size.xs},
62+
${euiTheme.colors.primary} ${euiTheme.size.xs},
63+
${euiTheme.colors.primary} ${euiTheme.size.s}
64+
);
65+
66+
${highContrastModeStyles(euiThemeContext, {
67+
forced: `
68+
${preventForcedColors(euiThemeContext)}
69+
`,
70+
})}
71+
}
5072
}
51-
}
52-
`;
73+
`;
74+
};
5375

5476
// Fix to make the loading indicator position correctly in Safari
5577
// For whatever annoying reason, Safari doesn't respect `position: relative;`

0 commit comments

Comments
 (0)