forked from riccardoperra/codeimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkeleton.css.ts
More file actions
76 lines (70 loc) · 2 KB
/
Copy pathSkeleton.css.ts
File metadata and controls
76 lines (70 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {themeVars, withThemeMode} from '@codeimage/ui';
import {darkGrayScale} from '@codeimage/ui/themes/darkTheme';
import {createTheme, fallbackVar, keyframes, style} from '@vanilla-extract/css';
export const [skeletonTheme, skeletonVars] = createTheme({
startBackground: '#000',
midBackground: '#000',
lineWidth: '100%',
lineHeight: '16px',
radius: '4px',
});
export const shimmer = keyframes({
'0%': {
backgroundPosition: '-450px 0',
},
'100%': {
backgroundPosition: '450px 0',
},
});
export const withSkeletonItem = style([
skeletonTheme,
{
overflow: 'hidden',
position: 'relative',
selectors: {
...withThemeMode({
light: {
vars: {
[skeletonVars.startBackground]:
themeVars.backgroundColor.gray['300'],
[skeletonVars.midBackground]: themeVars.backgroundColor.gray['400'],
},
},
dark: {
vars: {
[skeletonVars.startBackground]: darkGrayScale.gray4,
[skeletonVars.midBackground]: darkGrayScale.gray6,
},
},
}),
},
':before': {
position: 'absolute',
content: '',
height: '100%',
width: '100%',
background: skeletonVars.startBackground,
backgroundImage: `linear-gradient(to right, ${skeletonVars.startBackground} 0%, ${skeletonVars.midBackground} 20%, ${skeletonVars.startBackground} 40%, ${skeletonVars.startBackground} 100%)`,
backgroundRepeat: 'no-repeat',
backgroundSize: '800px 200px',
animation: `${shimmer} 1s linear infinite`,
animationFillMode: 'forwards',
animationDelay: '0.2s',
},
},
]);
export const skeletonLine = style([
withSkeletonItem,
{
borderRadius: fallbackVar(skeletonVars.radius, '4px'),
height: skeletonVars.lineHeight,
width: skeletonVars.lineWidth,
},
]);
export const skeletonDivider = style({
height: skeletonVars.lineHeight,
width: '100%',
backgroundColor: 'transparent',
overflow: 'hidden',
position: 'relative',
});