Skip to content

Commit 03dfc94

Browse files
committed
Add Skeleton
1 parent 5ea8a59 commit 03dfc94

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { type ComponentProps } from 'react'
2+
import LoadingSkeleton from 'react-loading-skeleton'
3+
import { createGlobalStyle } from 'styled-components'
4+
5+
import useTheme from 'hooks/useTheme'
6+
7+
export type SkeletonProps = ComponentProps<typeof LoadingSkeleton>
8+
9+
const SKELETON_CONTAINER_CLASSNAME = 'ks-skeleton-container'
10+
11+
const SkeletonGlobalStyle = createGlobalStyle`
12+
.${SKELETON_CONTAINER_CLASSNAME} {
13+
display: block;
14+
line-height: 0;
15+
}
16+
`
17+
18+
const Skeleton = ({ baseColor, containerClassName, highlightColor, ...props }: SkeletonProps) => {
19+
const theme = useTheme()
20+
const mergedContainerClassName = containerClassName
21+
? `${SKELETON_CONTAINER_CLASSNAME} ${containerClassName}`
22+
: SKELETON_CONTAINER_CLASSNAME
23+
24+
return (
25+
<>
26+
<SkeletonGlobalStyle />
27+
<LoadingSkeleton
28+
{...props}
29+
baseColor={baseColor ?? theme.background}
30+
containerClassName={mergedContainerClassName}
31+
highlightColor={highlightColor ?? theme.buttonGray}
32+
/>
33+
</>
34+
)
35+
}
36+
37+
export default Skeleton

apps/kyberswap-interface/src/pages/Earns/PoolDetail/components/PoolChartState.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { type ReactNode } from 'react'
22
import { Text } from 'rebass'
33
import styled from 'styled-components'
44

5+
import Skeleton from 'components/Skeleton'
56
import { HStack, Stack } from 'components/Stack'
67
import useTheme from 'hooks/useTheme'
7-
import PositionSkeleton from 'pages/Earns/components/PositionSkeleton'
88

99
const DEFAULT_CHART_HEIGHT = 360
1010

@@ -64,19 +64,19 @@ const PoolChartStateLayout = ({
6464
export const PoolChartSkeleton = ({ height = DEFAULT_CHART_HEIGHT }: PoolChartSkeletonProps) => {
6565
return (
6666
<PoolChartStateLayout gap={12} height={height}>
67-
<PositionSkeleton height={height} width="100%" />
67+
<Skeleton height={height} width="100%" />
6868
</PoolChartStateLayout>
6969
)
7070
}
7171

7272
const LiquidityFlowChartSkeleton = ({ height = DEFAULT_CHART_HEIGHT }: PoolChartSkeletonProps) => {
7373
return (
74-
<Stack gap={8}>
74+
<Stack gap={12}>
7575
<PoolChartSkeleton height={height} />
7676
<HStack gap={16} justify="center" wrap="wrap">
7777
{Array.from({ length: 3 }).map((_, index) => (
7878
<HStack align="center" gap={16} key={index}>
79-
<PositionSkeleton height={16} width={120} />
79+
<Skeleton height={14.5} width={120} />
8080
</HStack>
8181
))}
8282
</HStack>
@@ -99,10 +99,10 @@ const EarningChartSkeleton = ({ height = DEFAULT_CHART_HEIGHT }: PoolChartSkelet
9999
sx={{ margin: '0 auto' }}
100100
width={isCompact ? '100%' : 'fit-content'}
101101
>
102-
<PositionSkeleton style={{ borderRadius: 999 }} height={breakdownChartSize} width={breakdownChartSize} />
103-
<Stack gap={8} width="fit-content">
102+
<Skeleton circle height={breakdownChartSize} width={breakdownChartSize} />
103+
<Stack gap={12} width="fit-content">
104104
{Array.from({ length: 4 }).map((_, index) => (
105-
<PositionSkeleton key={index} height={14} width={120} />
105+
<Skeleton height={17} key={index} width={120} />
106106
))}
107107
</Stack>
108108
</Stack>

0 commit comments

Comments
 (0)