mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 12:39:49 +08:00
demo: improve the use of Segmented (#51324)
This commit is contained in:
parent
cc85109fb1
commit
6e12a903c7
@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button, Flex, Segmented } from 'antd';
|
import { Button, Flex, Segmented } from 'antd';
|
||||||
import type { FlexProps, SegmentedProps } from 'antd';
|
import type { FlexProps } from 'antd';
|
||||||
|
|
||||||
const boxStyle: React.CSSProperties = {
|
const boxStyle: React.CSSProperties = {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@ -26,9 +26,9 @@ const App: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<Flex gap="middle" align="start" vertical>
|
<Flex gap="middle" align="start" vertical>
|
||||||
<p>Select justify :</p>
|
<p>Select justify :</p>
|
||||||
<Segmented options={justifyOptions} onChange={setJustify as SegmentedProps['onChange']} />
|
<Segmented options={justifyOptions} onChange={setJustify} />
|
||||||
<p>Select align :</p>
|
<p>Select align :</p>
|
||||||
<Segmented options={alignOptions} onChange={setAlignItems as SegmentedProps['onChange']} />
|
<Segmented options={alignOptions} onChange={setAlignItems} />
|
||||||
<Flex style={boxStyle} justify={justify} align={alignItems}>
|
<Flex style={boxStyle} justify={justify} align={alignItems}>
|
||||||
<Button type="primary">Primary</Button>
|
<Button type="primary">Primary</Button>
|
||||||
<Button type="primary">Primary</Button>
|
<Button type="primary">Primary</Button>
|
||||||
|
@ -34,7 +34,7 @@ const App: React.FC = () => {
|
|||||||
<ConfigProvider button={{ style: { width: buttonWidth, margin: 4 } }}>
|
<ConfigProvider button={{ style: { width: buttonWidth, margin: 4 } }}>
|
||||||
<Segmented
|
<Segmented
|
||||||
options={['Show', 'Hide', 'Center']}
|
options={['Show', 'Hide', 'Center']}
|
||||||
onChange={(val: 'Show' | 'Hide' | 'Center') => setArrow(val)}
|
onChange={setArrow}
|
||||||
style={{ marginBottom: 24 }}
|
style={{ marginBottom: 24 }}
|
||||||
/>
|
/>
|
||||||
<Flex vertical justify="center" align="center" className="demo">
|
<Flex vertical justify="center" align="center" className="demo">
|
||||||
|
@ -32,10 +32,7 @@ const App: React.FC = () => {
|
|||||||
const [renderType, setRenderType] = React.useState<QRCodeProps['type']>('canvas');
|
const [renderType, setRenderType] = React.useState<QRCodeProps['type']>('canvas');
|
||||||
return (
|
return (
|
||||||
<Space id="myqrcode" direction="vertical">
|
<Space id="myqrcode" direction="vertical">
|
||||||
<Segmented
|
<Segmented options={['canvas', 'svg']} value={renderType} onChange={setRenderType} />
|
||||||
options={['canvas', 'svg']}
|
|
||||||
onChange={(val) => setRenderType(val as QRCodeProps['type'])}
|
|
||||||
/>
|
|
||||||
<div>
|
<div>
|
||||||
<QRCode
|
<QRCode
|
||||||
type={renderType}
|
type={renderType}
|
||||||
|
@ -168,7 +168,7 @@ const App: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
<Segmented
|
<Segmented
|
||||||
value={count}
|
value={count}
|
||||||
onChange={(value: number) => setCount(value)}
|
onChange={setCount}
|
||||||
options={[
|
options={[
|
||||||
{ label: 'None', value: 0 },
|
{ label: 'None', value: 0 },
|
||||||
{ label: 'Less', value: 4 },
|
{ label: 'Less', value: 4 },
|
||||||
|
@ -19,9 +19,9 @@ const App: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Segmented
|
<Segmented
|
||||||
defaultValue="center"
|
value={alignValue}
|
||||||
style={{ marginBottom: 8 }}
|
style={{ marginBottom: 8 }}
|
||||||
onChange={(value) => setAlignValue(value as Align)}
|
onChange={setAlignValue}
|
||||||
options={['start', 'center', 'end']}
|
options={['start', 'center', 'end']}
|
||||||
/>
|
/>
|
||||||
<Tabs
|
<Tabs
|
||||||
|
@ -28,7 +28,7 @@ const App: React.FC = () => {
|
|||||||
<Segmented
|
<Segmented
|
||||||
value={arrow}
|
value={arrow}
|
||||||
options={['Show', 'Hide', 'Center']}
|
options={['Show', 'Hide', 'Center']}
|
||||||
onChange={(val: 'Show' | 'Hide' | 'Center') => setArrow(val)}
|
onChange={setArrow}
|
||||||
style={{ marginBottom: 24 }}
|
style={{ marginBottom: 24 }}
|
||||||
/>
|
/>
|
||||||
<Flex vertical justify="center" align="center" className="demo">
|
<Flex vertical justify="center" align="center" className="demo">
|
||||||
|
Loading…
Reference in New Issue
Block a user