/
presets-demo.js
101 lines (99 loc) · 2.78 KB
/
presets-demo.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/** @jsx jsx */
import { jsx, Themed, components, Select } from 'theme-ui'
import { ThemeContext } from '@emotion/react'
import { MDXProvider } from '@mdx-js/react'
import { useState } from 'react'
import { Helmet } from 'react-helmet'
import * as presets from '@theme-ui/presets'
import {
TypeScale,
TypeStyle,
HeadingStyle,
ColorPalette,
FontFamily,
} from '@theme-ui/style-guide'
import Lorem from './lorem.mdx'
export default function PresetsDemo() {
const [theme, setTheme] = useState('base')
const preset = presets[theme]
return (
<div>
<Helmet>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Montserrat:400,700|Poppins:400,700,900|Roboto:400,600|Architects+Daughter"
/>
</Helmet>
<div
sx={{
'*': {
transition: 'all .2s ease-out',
},
}}
>
<label
htmlFor="theme"
sx={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
mb: 4,
gap: 2,
}}
>
<span>Preset:</span>
<Select
id="theme"
sx={{ display: 'inline-flex' }}
value={theme}
onChange={(e) => {
setTheme(e.target.value)
}}
>
{Object.keys(presets).map((key) => (
<option key={key} children={key} />
))}
</Select>
</label>
<ThemeContext.Provider value={preset}>
<Themed.root sx={{ bg: 'background', color: 'text', p: 3 }}>
<Themed.h2>Colors</Themed.h2>
<ColorPalette omit={['modes', 'header']} />
<Themed.h2>Typography</Themed.h2>
<TypeStyle fontSize={7}>
Body: <FontFamily name="body" />
</TypeStyle>
<HeadingStyle
fontFamily="heading"
fontWeight="heading"
lineHeight="heading"
fontSize={7}
>
Heading: <FontFamily name="heading" />
</HeadingStyle>
<Themed.h2>Type Scale</Themed.h2>
<TypeScale />
<MDXProvider components={components}>
<Lorem />
</MDXProvider>
<Themed.h2 id="json">Raw JSON</Themed.h2>
<textarea
value={JSON.stringify(preset, null, 2)}
rows={16}
readOnly
aria-labelledby="json"
sx={{
width: '100%',
fontFamily: 'monospace',
bg: 'muted',
border: 0,
borderRadius: 4,
color: 'text'
}}
/>
</Themed.root>
</ThemeContext.Provider>
</div>
</div>
)
}