demo: improve the use of Segmented (#51324)

This commit is contained in:
thinkasany 2024-10-22 10:09:31 +08:00 committed by GitHub
parent cc85109fb1
commit 6e12a903c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 9 additions and 12 deletions

View File

@ -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>

View File

@ -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">

View File

@ -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}

View File

@ -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 },

View File

@ -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

View File

@ -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">