mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 06:55:07 +08:00
docs(radio): add docs for size
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Layout, Playground, Attributes } from 'lib/components'
|
||||
import { Radio, Spacer, Code } from 'components'
|
||||
import { Radio, Spacer, Code, Text } from 'components'
|
||||
import { useState } from 'react'
|
||||
|
||||
export const meta = {
|
||||
@@ -39,6 +39,31 @@ Provides single user input from a selection of options.
|
||||
}
|
||||
`} />
|
||||
|
||||
<Playground
|
||||
title="Sizes"
|
||||
desc="Radio of different sizes."
|
||||
scope={{ Radio, Spacer, Text }}
|
||||
code={`
|
||||
<>
|
||||
<Text span size="12px" type="secondary">SINGLE</Text>
|
||||
<div style={{ paddingLeft: '.25rem', marginTop: '.25rem' }}>
|
||||
<Radio checked={false} size="mini">mini</Radio>
|
||||
<Radio checked={false} size="small">small</Radio>
|
||||
<Radio checked={false} size="medium">medium</Radio>
|
||||
<Radio checked={false} size="large">large</Radio>
|
||||
</div>
|
||||
<Spacer y={.5} />
|
||||
<Text span size="12px" type="secondary">GROUP</Text>
|
||||
<div style={{ paddingLeft: '.25rem', marginTop: '.25rem' }}>
|
||||
<Radio.Group size="mini">
|
||||
<Radio value="1">Option 1</Radio>
|
||||
<Radio value="2">Option 2</Radio>
|
||||
<Radio value="3">Option 3</Radio>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
</>
|
||||
`} />
|
||||
|
||||
<Playground
|
||||
title="Description"
|
||||
desc="`Description` can be combined with other components."
|
||||
@@ -95,8 +120,9 @@ Provides single user input from a selection of options.
|
||||
| **value** | unique ident value (in group) | `string` | - | - |
|
||||
| **id** | native attr | `string` | - | - |
|
||||
| **disabled** | disable current radio | `boolean` | - | `false` |
|
||||
| **size** | radio size | `NormalSizes` | [NormalSizes](#normalsizes) | `medium` |
|
||||
| **onChange** | change event | `(e: RadioEvent) => void` | - | - |
|
||||
| ... | native props | `InputHTMLAttributes` | `'name', 'alt', 'className', ...` | - |
|
||||
| ... | native props | `InputHTMLAttributes` | `'id', 'className', ...` | - |
|
||||
|
||||
<Attributes.Title>Radio.Group.Props</Attributes.Title>
|
||||
|
||||
@@ -106,14 +132,21 @@ Provides single user input from a selection of options.
|
||||
| **value** | selected child radio | `string` | - | - |
|
||||
| **useRow** | horizontal layout | `boolean` | - | `false` |
|
||||
| **disabled** | disable all radios | `boolean` | - | `false` |
|
||||
| **size** | size of all radios in the group | `NormalSizes` | [NormalSizes](#normalsizes) | `medium` |
|
||||
| **onChange** | change event | `(value: string) => void` | - | - |
|
||||
| ... | native props | `HTMLAttributes` | `'name', 'id', 'className', ...` | - |
|
||||
| ... | native props | `HTMLAttributes` | `'id', 'className', ...` | - |
|
||||
|
||||
<Attributes.Title alias="Radio.Desc">Radio.Description.Props</Attributes.Title>
|
||||
|
||||
| Attribute | Description | Type | Accepted values | Default
|
||||
| ---------- | ---------- | ---- | -------------- | ------ |
|
||||
| ... | native props | `HTMLAttributes` | `'name', 'id', 'className', ...` | - |
|
||||
| ... | native props | `HTMLAttributes` | `'id', 'className', ...` | - |
|
||||
|
||||
<Attributes.Title>NormalSizes</Attributes.Title>
|
||||
|
||||
```ts
|
||||
type NormalSizes = 'mini' | 'small' | 'medium' | 'large'
|
||||
```
|
||||
|
||||
</Attributes>
|
||||
|
||||
|
||||
@@ -39,6 +39,32 @@ export const meta = {
|
||||
}
|
||||
`} />
|
||||
|
||||
|
||||
<Playground
|
||||
title="大小"
|
||||
desc="不同大小的单选框"
|
||||
scope={{ Radio, Spacer, Text }}
|
||||
code={`
|
||||
<>
|
||||
<Text span size="12px" type="secondary">单个</Text>
|
||||
<div style={{ paddingLeft: '.25rem', marginTop: '.25rem' }}>
|
||||
<Radio checked={false} size="mini">极小</Radio>
|
||||
<Radio checked={false} size="small">较小</Radio>
|
||||
<Radio checked={false} size="medium">中等</Radio>
|
||||
<Radio checked={false} size="large">最大</Radio>
|
||||
</div>
|
||||
<Spacer y={.5} />
|
||||
<Text span size="12px" type="secondary">单选框组</Text>
|
||||
<div style={{ paddingLeft: '.25rem', marginTop: '.25rem' }}>
|
||||
<Radio.Group size="mini">
|
||||
<Radio value="1">选项 1</Radio>
|
||||
<Radio value="2">选项 2</Radio>
|
||||
<Radio value="3">选项 3</Radio>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
</>
|
||||
`} />
|
||||
|
||||
<Playground
|
||||
title="描述"
|
||||
desc="`Description` 属性可以与组件结合使用。"
|
||||
@@ -94,6 +120,7 @@ export const meta = {
|
||||
| **checked** | 是否选择 (仅在单独使用时有效) | `boolean` | - | `false` |
|
||||
| **value** | 唯一的鉴别值 (仅在组内使用时有效) | `string` | - | - |
|
||||
| **disabled** | 禁用当前选项 | `boolean` | - | `false` |
|
||||
| **size** | 单选框的大小 | `NormalSizes` | [NormalSizes](#normalsizes) | `medium` |
|
||||
| **onChange** | 选项变化事件 | `(e: RadioEvent) => void` | - | - |
|
||||
| ... | 原生属性 | `InputHTMLAttributes` | `'id', 'alt', 'className', ...` | - |
|
||||
|
||||
@@ -105,6 +132,7 @@ export const meta = {
|
||||
| **value** | 设置选中的子选项值 | `string` | - | - |
|
||||
| **useRow** | 水平对齐所有子单选框 | `boolean` | - | `false` |
|
||||
| **disabled** | 禁用组内所有单选框 | `boolean` | - | `false` |
|
||||
| **size** | 组内所有单选框的大小 | `NormalSizes` | [NormalSizes](#normalsizes) | `medium` |
|
||||
| **onChange** | 组的值变化事件 | `(value: string) => void` | - | - |
|
||||
| ... | 原生属性 | `HTMLAttributes` | `'name', 'id', 'className', ...` | - |
|
||||
|
||||
@@ -114,6 +142,12 @@ export const meta = {
|
||||
| ---------- | ---------- | ---- | -------------- | ------ |
|
||||
| ... | 原生属性 | `HTMLAttributes` | `'name', 'id', 'className', ...` | - |
|
||||
|
||||
<Attributes.Title>NormalSizes</Attributes.Title>
|
||||
|
||||
```ts
|
||||
type NormalSizes = 'mini' | 'small' | 'medium' | 'large'
|
||||
```
|
||||
|
||||
</Attributes>
|
||||
|
||||
export default ({ children }) => <Layout meta={meta}>{children}</Layout>
|
||||
|
||||
Reference in New Issue
Block a user