|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import styled from '@emotion/styled' |
4 | | -import { Stack, Skeleton as UltravioletSkeleton } from '@ultraviolet/ui' |
5 | | - |
6 | | -const SkeletonImage = styled(UltravioletSkeleton, { |
7 | | - shouldForwardProp: prop => !['height', 'width', 'direction'].includes(prop), |
8 | | -})<{ |
9 | | - width?: string |
10 | | - height?: string |
11 | | - direction: 'row' | 'column' |
12 | | -}>` |
13 | | - border-radius: ${({ theme, direction }) => |
14 | | - `${ |
15 | | - direction === 'column' |
16 | | - ? `${theme.radii.default} ${theme.radii.default} 0 0` |
17 | | - : `${theme.radii.default} 0 0 ${theme.radii.default}` |
18 | | - }`}; |
19 | | - width: ${({ width }) => width}; |
20 | | - height: ${({ height }) => height}; |
21 | | -` |
22 | | - |
23 | | -const StyledStack = styled(Stack)` |
24 | | - padding: ${({ theme }) => theme.space['3']}; |
25 | | -` |
| 3 | +import { Stack, Skeleton as UVSkeleton } from '@ultraviolet/ui' |
| 4 | +import { assignInlineVars } from '@vanilla-extract/dynamic' |
| 5 | +import { |
| 6 | + paddedStack, |
| 7 | + skeletonHeightVar, |
| 8 | + skeletonImage, |
| 9 | + skeletonWidthVar, |
| 10 | +} from './styles.css' |
26 | 11 |
|
27 | 12 | type SkeletonProps = { |
28 | 13 | direction: 'row' | 'column' |
29 | 14 | } |
30 | 15 |
|
31 | 16 | export const Skeleton = ({ direction }: SkeletonProps) => ( |
32 | 17 | <Stack direction={direction}> |
33 | | - <SkeletonImage |
34 | | - direction={direction} |
35 | | - height={direction === 'column' ? '120px' : 'unset'} |
| 18 | + <UVSkeleton |
| 19 | + className={skeletonImage[direction]} |
| 20 | + style={assignInlineVars({ |
| 21 | + [skeletonHeightVar]: direction === 'column' ? '120px' : 'unset', |
| 22 | + [skeletonWidthVar]: direction === 'row' ? '220px' : '100%', |
| 23 | + })} |
36 | 24 | variant="square" |
37 | | - width={direction === 'row' ? '220px' : undefined} |
38 | 25 | /> |
39 | | - <StyledStack gap={2}> |
40 | | - <UltravioletSkeleton variant="line" /> |
41 | | - <UltravioletSkeleton variant="line" /> |
42 | | - <UltravioletSkeleton variant="line" /> |
43 | | - <UltravioletSkeleton variant="line" /> |
44 | | - <UltravioletSkeleton variant="line" /> |
45 | | - </StyledStack> |
| 26 | + <Stack className={paddedStack} gap={2}> |
| 27 | + <UVSkeleton variant="line" /> |
| 28 | + <UVSkeleton variant="line" /> |
| 29 | + <UVSkeleton variant="line" /> |
| 30 | + <UVSkeleton variant="line" /> |
| 31 | + <UVSkeleton variant="line" /> |
| 32 | + </Stack> |
46 | 33 | </Stack> |
47 | 34 | ) |
0 commit comments