-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathHeading.ts
39 lines (35 loc) · 858 Bytes
/
Heading.ts
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
import { defineStyle, defineStyleConfig } from "@chakra-ui/react"
import { headingDefaultTheme } from "./components.utils"
const { sizes: defaultSizes } = headingDefaultTheme
const lineHeightScale = {
"4xl": "6xs",
"3xl": ["5xs", null, "6xs"],
"2xl": ["5xs", null, "4xs"],
xl: ["3xs", null, "2xs"],
lg: ["3xs", null, "2xs"],
md: "xs",
sm: "base",
xs: "base",
}
/*
* Instead of rewriting the entire sizes object, take the existing value from the
* default theme and replace the lineHeight values.
*/
const sizes = Object.entries(defaultSizes || {}).reduceRight(
(acc, [key, value]) => {
return {
...acc,
[key]: defineStyle({
...value,
lineHeight: lineHeightScale[key],
}),
}
},
{
...defaultSizes,
}
)
export const Heading = defineStyleConfig({
...headingDefaultTheme,
sizes,
})