|
1 | 1 | import React from 'react'; |
2 | | -import { Button, Grid } from '@tiny-design/react'; |
| 2 | +import { Grid, Radio } from '@tiny-design/react'; |
| 3 | +import { DemoControlLabel, DemoControls, getDemoBlockStyle } from './shared'; |
| 4 | + |
| 5 | +type AlignmentValue = 'start' | 'center' | 'end' | 'stretch'; |
3 | 6 |
|
4 | 7 | export default function AlignmentGridDemo() { |
| 8 | + const [justify, setJustify] = React.useState<AlignmentValue>('stretch'); |
| 9 | + const [align, setAlign] = React.useState<AlignmentValue>('stretch'); |
| 10 | + |
5 | 11 | return ( |
6 | | - <Grid |
7 | | - columns={3} |
8 | | - gap="sm" |
9 | | - align="center" |
10 | | - justify="center" |
11 | | - style={{ |
12 | | - minHeight: 180, |
13 | | - padding: 16, |
14 | | - border: '1px dashed var(--ty-color-border)', |
15 | | - borderRadius: 12, |
16 | | - background: |
17 | | - 'linear-gradient(180deg, color-mix(in srgb, var(--ty-color-primary) 6%, transparent), color-mix(in srgb, var(--ty-color-primary-bg) 45%, transparent))', |
18 | | - }}> |
19 | | - <Button variant="solid" color="primary"> |
20 | | - Primary |
21 | | - </Button> |
22 | | - <Button>Default</Button> |
23 | | - <Button variant="outline" color="primary"> |
24 | | - Outline |
25 | | - </Button> |
26 | | - </Grid> |
| 12 | + <div> |
| 13 | + <DemoControls> |
| 14 | + <div> |
| 15 | + <DemoControlLabel>Justify</DemoControlLabel> |
| 16 | + <Radio.Group value={justify} onChange={(val) => setJustify(val as AlignmentValue)}> |
| 17 | + <Radio value="start">start</Radio> |
| 18 | + <Radio value="center">center</Radio> |
| 19 | + <Radio value="end">end</Radio> |
| 20 | + <Radio value="stretch">stretch</Radio> |
| 21 | + </Radio.Group> |
| 22 | + </div> |
| 23 | + <div> |
| 24 | + <DemoControlLabel>Align</DemoControlLabel> |
| 25 | + <Radio.Group value={align} onChange={(val) => setAlign(val as AlignmentValue)}> |
| 26 | + <Radio value="start">start</Radio> |
| 27 | + <Radio value="center">center</Radio> |
| 28 | + <Radio value="end">end</Radio> |
| 29 | + <Radio value="stretch">stretch</Radio> |
| 30 | + </Radio.Group> |
| 31 | + </div> |
| 32 | + </DemoControls> |
| 33 | + <Grid |
| 34 | + columns={3} |
| 35 | + gap="sm" |
| 36 | + align={align} |
| 37 | + justify={justify} |
| 38 | + style={{ |
| 39 | + minHeight: 180, |
| 40 | + padding: 16, |
| 41 | + border: '1px dashed var(--ty-color-border)', |
| 42 | + borderRadius: 12, |
| 43 | + background: 'color-mix(in srgb, var(--ty-color-primary) 4%, transparent)', |
| 44 | + }}> |
| 45 | + <div |
| 46 | + style={getDemoBlockStyle('strong', 64, { |
| 47 | + minHeight: 64, |
| 48 | + width: justify === 'stretch' ? undefined : 92, |
| 49 | + justifyContent: 'center', |
| 50 | + })}> |
| 51 | + {justify} |
| 52 | + </div> |
| 53 | + <div |
| 54 | + style={getDemoBlockStyle('base', 64, { |
| 55 | + minHeight: 64, |
| 56 | + width: justify === 'stretch' ? undefined : 92, |
| 57 | + justifyContent: 'center', |
| 58 | + })}> |
| 59 | + {align} |
| 60 | + </div> |
| 61 | + <div |
| 62 | + style={getDemoBlockStyle('soft', 64, { |
| 63 | + minHeight: 64, |
| 64 | + width: justify === 'stretch' ? undefined : 92, |
| 65 | + justifyContent: 'center', |
| 66 | + })}> |
| 67 | + items |
| 68 | + </div> |
| 69 | + </Grid> |
| 70 | + </div> |
27 | 71 | ); |
28 | 72 | } |
0 commit comments