|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { Button, Segmented, Slider } from 'antd'; |
| 3 | +import { Flex } from 'dt-react-component'; |
| 4 | +import type { IFlexProps } from 'dt-react-component/flex'; |
| 5 | + |
| 6 | +const alignOptions = ['flex-start', 'center', 'flex-end']; |
| 7 | +const justifyOptions = [ |
| 8 | + 'flex-start', |
| 9 | + 'center', |
| 10 | + 'flex-end', |
| 11 | + 'space-between', |
| 12 | + 'space-around', |
| 13 | + 'space-evenly', |
| 14 | +]; |
| 15 | + |
| 16 | +export default () => { |
| 17 | + const [align, setAlign] = useState<IFlexProps['align']>('center'); |
| 18 | + const [justify, setJustify] = useState<IFlexProps['justify']>('center'); |
| 19 | + const [vertical, setVertical] = useState<string>('false'); |
| 20 | + const [gap, setGap] = useState<number>(4); |
| 21 | + return ( |
| 22 | + <> |
| 23 | + <p>Select align :</p> |
| 24 | + <Segmented |
| 25 | + value={align} |
| 26 | + options={alignOptions} |
| 27 | + onChange={(val) => setAlign(val as IFlexProps['align'])} |
| 28 | + /> |
| 29 | + <p>Select justify :</p> |
| 30 | + <Segmented |
| 31 | + value={justify} |
| 32 | + options={justifyOptions} |
| 33 | + onChange={(val) => setJustify(val as IFlexProps['justify'])} |
| 34 | + /> |
| 35 | + <p>Select vertical :</p> |
| 36 | + <Segmented |
| 37 | + value={vertical} |
| 38 | + options={['true', 'false']} |
| 39 | + onChange={(val) => setVertical(val as string)} |
| 40 | + /> |
| 41 | + <p>Select gap :</p> |
| 42 | + <Slider value={gap} max={20} min={0} onChange={setGap} /> |
| 43 | + <br /> |
| 44 | + <br /> |
| 45 | + <Flex |
| 46 | + gap={gap} |
| 47 | + vertical={vertical === 'true'} |
| 48 | + align={align} |
| 49 | + justify={justify} |
| 50 | + style={{ border: '1px solid #5D9EFA', height: 200 }} |
| 51 | + > |
| 52 | + <Button>button</Button> |
| 53 | + <Button>button</Button> |
| 54 | + <Button>button</Button> |
| 55 | + <Button>button</Button> |
| 56 | + </Flex> |
| 57 | + </> |
| 58 | + ); |
| 59 | +}; |
0 commit comments