Commit 11f7b398 authored by tom's avatar tom

fix skeleton theme

parent a5d61d61
import { Skeleton as SkeletonComponent } from '@chakra-ui/react'; import { Skeleton as SkeletonComponent } from '@chakra-ui/react';
import {
defineStyle,
defineStyleConfig,
} from '@chakra-ui/styled-system';
import { keyframes } from '@chakra-ui/system'; import { keyframes } from '@chakra-ui/system';
import type { SystemStyleFunction } from '@chakra-ui/theme-tools';
import { getColor, mode } from '@chakra-ui/theme-tools'; import { getColor, mode } from '@chakra-ui/theme-tools';
const shine = () => const shine = () =>
...@@ -8,14 +11,13 @@ const shine = () => ...@@ -8,14 +11,13 @@ const shine = () =>
to: { backgroundPositionX: '-200%' }, to: { backgroundPositionX: '-200%' },
}); });
const baseStyle: SystemStyleFunction = (props) => { const baseStyle = defineStyle((props) => {
const defaultStartColor = mode('blackAlpha.50', 'whiteAlpha.50')(props); const defaultStartColor = mode('blackAlpha.50', 'whiteAlpha.50')(props);
const defaultEndColor = mode('blackAlpha.100', 'whiteAlpha.100')(props); const defaultEndColor = mode('blackAlpha.100', 'whiteAlpha.100')(props);
const { const {
startColor = defaultStartColor, startColor = defaultStartColor,
endColor = defaultEndColor, endColor = defaultEndColor,
speed,
theme, theme,
} = props; } = props;
...@@ -28,17 +30,17 @@ const baseStyle: SystemStyleFunction = (props) => { ...@@ -28,17 +30,17 @@ const baseStyle: SystemStyleFunction = (props) => {
borderColor: start, borderColor: start,
background: `linear-gradient(90deg, ${ start } 8%, ${ end } 18%, ${ start } 33%)`, background: `linear-gradient(90deg, ${ start } 8%, ${ end } 18%, ${ start } 33%)`,
backgroundSize: '200% 100%', backgroundSize: '200% 100%',
animation: `${ speed }s linear infinite ${ shine() }`,
}; };
}; });
const Skeleton = { const Skeleton = defineStyleConfig({
baseStyle, baseStyle,
}; });
export default Skeleton; export default Skeleton;
SkeletonComponent.defaultProps = { SkeletonComponent.defaultProps = {
...SkeletonComponent.defaultProps, ...SkeletonComponent.defaultProps,
speed: 1, speed: 1,
animation: `1s linear infinite ${ shine() }`,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment