-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAlignmentGrid.tsx
More file actions
72 lines (69 loc) · 2.28 KB
/
Copy pathAlignmentGrid.tsx
File metadata and controls
72 lines (69 loc) · 2.28 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
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
import React from 'react';
import { Grid, Radio } from '@tiny-design/react';
import { DemoControlLabel, DemoControls, getDemoBlockStyle } from './shared';
type AlignmentValue = 'start' | 'center' | 'end' | 'stretch';
export default function AlignmentGridDemo() {
const [justify, setJustify] = React.useState<AlignmentValue>('stretch');
const [align, setAlign] = React.useState<AlignmentValue>('stretch');
return (
<div>
<DemoControls>
<div>
<DemoControlLabel>Justify</DemoControlLabel>
<Radio.Group value={justify} onChange={(val) => setJustify(val as AlignmentValue)}>
<Radio value="start">start</Radio>
<Radio value="center">center</Radio>
<Radio value="end">end</Radio>
<Radio value="stretch">stretch</Radio>
</Radio.Group>
</div>
<div>
<DemoControlLabel>Align</DemoControlLabel>
<Radio.Group value={align} onChange={(val) => setAlign(val as AlignmentValue)}>
<Radio value="start">start</Radio>
<Radio value="center">center</Radio>
<Radio value="end">end</Radio>
<Radio value="stretch">stretch</Radio>
</Radio.Group>
</div>
</DemoControls>
<Grid
columns={3}
gap="sm"
align={align}
justify={justify}
style={{
minHeight: 180,
padding: 16,
border: '1px dashed var(--ty-color-border)',
borderRadius: 12,
background: 'color-mix(in srgb, var(--ty-color-primary) 4%, transparent)',
}}>
<div
style={getDemoBlockStyle('strong', 64, {
minHeight: 64,
width: justify === 'stretch' ? undefined : 92,
justifyContent: 'center',
})}>
{justify}
</div>
<div
style={getDemoBlockStyle('base', 64, {
minHeight: 64,
width: justify === 'stretch' ? undefined : 92,
justifyContent: 'center',
})}>
{align}
</div>
<div
style={getDemoBlockStyle('soft', 64, {
minHeight: 64,
width: justify === 'stretch' ? undefined : 92,
justifyContent: 'center',
})}>
items
</div>
</Grid>
</div>
);
}