forked from components-ai/css.gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpace.tsx
More file actions
40 lines (38 loc) · 1.11 KB
/
Space.tsx
File metadata and controls
40 lines (38 loc) · 1.11 KB
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
import { useState } from 'react'
import { codegen, Editor, styled } from '@compai/css-gui'
export const SpaceExample = () => {
const [styles, setStyles] = useState({
marginTop: { value: 1, unit: 'rem' },
marginBottom: { value: 1, unit: 'rem' },
marginLeft: { value: 1, unit: 'rem' },
marginRight: { value: 1, unit: 'rem' },
paddingTop: { value: 1, unit: 'rem' },
paddingBottom: { value: 1, unit: 'rem' },
paddingLeft: { value: 1, unit: 'rem' },
paddingRight: { value: 1, unit: 'rem' },
})
return (
<div>
<div
sx={{
':first-child > div': {
display: 'grid',
gap: '.5rem',
},
}}
>
{/** @ts-ignore */}
<Editor styles={styles} onChange={setStyles} />
</div>
<div sx={{ border: 'thin solid', borderColor: 'border', mt: [3, 4, 5] }}>
<styled.p styles={{ ...styles, border: 'thin solid' }}>
Fun with space!
</styled.p>
</div>
{/** @ts-ignore */}
<pre>{codegen.css(styles)}</pre>
<hr />
<pre>{JSON.stringify(styles, null, 2)}</pre>
</div>
)
}