|
1 | | -import { chakra, HTMLChakraProps, keyframes } from '@chakra-ui/system'; |
2 | | -import isChromatic from 'chromatic/isChromatic'; |
| 1 | +import { chakra, HTMLChakraProps } from "@chakra-v2/react"; |
| 2 | +import isChromatic from "chromatic/isChromatic"; |
| 3 | +import { keyframes } from "@emotion/react"; |
3 | 4 |
|
4 | | -import * as S from './storybook.js'; |
| 5 | +import * as S from "./storybook.js"; |
5 | 6 |
|
6 | 7 | interface DemoOptions { |
7 | 8 | title?: string; |
8 | 9 | animate?: boolean; |
9 | 10 | } |
10 | 11 |
|
11 | 12 | const resize = keyframes({ |
12 | | - '0%': { |
13 | | - width: '12rem', |
14 | | - height: '12rem', |
| 13 | + "0%": { |
| 14 | + width: "12rem", |
| 15 | + height: "12rem", |
15 | 16 | }, |
16 | | - '50%': { |
17 | | - width: '24rem', |
18 | | - height: '24rem', |
| 17 | + "50%": { |
| 18 | + width: "24rem", |
| 19 | + height: "24rem", |
19 | 20 | }, |
20 | | - '100%': { |
21 | | - width: '12rem', |
22 | | - height: '12rem', |
| 21 | + "100%": { |
| 22 | + width: "12rem", |
| 23 | + height: "12rem", |
23 | 24 | }, |
24 | 25 | }); |
25 | 26 |
|
26 | 27 | const DemoContainer = ({ |
27 | 28 | title, |
28 | 29 | animate, |
29 | 30 | ...props |
30 | | -}: DemoOptions & HTMLChakraProps<'div'>) => ( |
| 31 | +}: DemoOptions & HTMLChakraProps<"div">) => ( |
31 | 32 | <chakra.div |
32 | 33 | {...props} |
33 | 34 | position="relative" |
34 | 35 | padding={8} |
35 | 36 | bg="green.300" |
36 | 37 | color="black" |
37 | 38 | __css={{ |
38 | | - '& > div:first-of-type': { |
39 | | - width: '12rem', |
40 | | - height: '12rem', |
41 | | - willChange: 'width, height', |
42 | | - animationName: animate ? resize.toString() : 'none', |
43 | | - animationDuration: '2s', |
44 | | - animationIterationCount: 'infinite', |
| 39 | + "& > div:first-of-type": { |
| 40 | + width: "12rem", |
| 41 | + height: "12rem", |
| 42 | + willChange: "width, height", |
| 43 | + animationName: animate ? resize.toString() : "none", |
| 44 | + animationDuration: "2s", |
| 45 | + animationIterationCount: "infinite", |
45 | 46 | }, |
46 | 47 | }} |
47 | 48 | /> |
48 | 49 | ); |
49 | 50 |
|
50 | 51 | export const demo = |
51 | 52 | ({ |
52 | | - title = 'Container', |
| 53 | + title = "Container", |
53 | 54 | animate = !isChromatic(), |
54 | 55 | }: DemoOptions = {}): S.Decorator => |
55 | | - (Story) => |
56 | | - ( |
57 | | - <DemoContainer animate={animate}> |
58 | | - <Story /> |
59 | | - <chakra.div position="absolute" top="0.5rem" left="0.5rem"> |
60 | | - {title} |
61 | | - </chakra.div> |
62 | | - </DemoContainer> |
63 | | - ); |
| 56 | + (Story) => ( |
| 57 | + <DemoContainer animate={animate}> |
| 58 | + <Story /> |
| 59 | + <chakra.div position="absolute" top="0.5rem" left="0.5rem"> |
| 60 | + {title} |
| 61 | + </chakra.div> |
| 62 | + </DemoContainer> |
| 63 | + ); |
0 commit comments