File size: 2,006 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"use client"

import {
  Box,
  Center,
  SimpleGrid,
  Stack,
  Text,
  VStack,
  defaultSystem,
} from "@chakra-ui/react"
import { TokenDoc } from "./token-doc"

const { _config: config, tokens } = defaultSystem

const allKeyframes = Object.keys(config.theme?.keyframes || {}).filter(
  (keyframe) => !keyframe.match(/expand|collapse|bg-|position|circular/),
)

export const KeyframeDoc = () => {
  return (
    <TokenDoc title="theme.keyframes" mt="8">
      <SimpleGrid minChildWidth="160px" gap="20" fontSize="sm">
        {allKeyframes.map((animationName) => {
          return (
            <Stack key={animationName}>
              <Box
                boxSize="12"
                bg="pink.200"
                animation={`${animationName} 1s ease-in-out infinite alternate`}
              />
              <Text fontWeight="medium">{animationName}</Text>
            </Stack>
          )
        })}
      </SimpleGrid>
    </TokenDoc>
  )
}

const allDurations = Array.from(tokens.categoryMap.get("durations")!.entries())
  .sort(
    ([, a], [, b]) => parseFloat(b.originalValue) - parseFloat(a.originalValue),
  )
  .map(([key]) => key)

export const DurationTokenDoc = () => {
  return (
    <TokenDoc title="theme.tokens.durations" mt="8">
      <SimpleGrid minChildWidth="160px" gap="20" fontSize="sm">
        {allDurations.map((durationName) => {
          return (
            <VStack key={durationName}>
              <Center h="20">
                <Box
                  bg="pink.200"
                  height="1"
                  width="20"
                  animationName="spin"
                  animationDuration={durationName}
                  animationTimingFunction="ease-in-out"
                  animationIterationCount="infinite"
                  animationDirection="alternate"
                />
              </Center>
              <Text fontWeight="medium">{durationName}</Text>
            </VStack>
          )
        })}
      </SimpleGrid>
    </TokenDoc>
  )
}