Skip to content

Commit

Permalink
docs(Switch): sync api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Sep 3, 2024
1 parent d66c897 commit 84904cf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
18 changes: 10 additions & 8 deletions src/switch/README.en-US.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
:: BASE_DOC ::

## API

### Switch Props

name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
custom-value | Array | [true, false] | Typescript:`Array<SwitchValue>` | N
disabled | Boolean | false | \- | N
icon | Array | [] | Typescript:`string[]` | N
label | Array | [] | Typescript:`string[]` | N
loading | Boolean | false | \- | N
size | String | medium | options:small/medium/large | N
style | String | - | \- | N
disabled | Boolean | undefined | \- | N
icon | Array | [] | `0.27.0`。Typescript:`string[]` | N
label | Array | [] | `0.27.0`。Typescript:`string[]` | N
loading | Boolean | false | `0.27.0` | N
size | String | medium | `0.27.0`。options: small/medium/large | N
value | String / Number / Boolean | null | Typescript:`SwitchValue` `type SwitchValue = string \| number \| boolean`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/switch/type.ts) | N
default-value | String / Number / Boolean | undefined | uncontrolled property。Typescript:`SwitchValue` `type SwitchValue = string \| number \| boolean`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/switch/type.ts) | N

Expand All @@ -21,8 +23,8 @@ name | params | description
-- | -- | --
change | `(value: SwitchValue)` | \-


### CSS Variables

The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
Expand Down Expand Up @@ -56,4 +58,4 @@ Name | Default Value | Description
--td-switch-small-width | 78rpx | -
--td-switch-unchecked-color | @font-gray-4 | -
--td-switch-unchecked-disabled-color | @bg-color-component-disabled | -
--td-switch-width | 90rpx | -
--td-switch-width | 90rpx | -
19 changes: 11 additions & 8 deletions src/switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ isComponent: true
{{ size }}

## API

### Switch Props

名称 | 类型 | 默认值 | 说明 | 必传
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
custom-value | Array | [true, false] | 用于自定义开关的值,[打开时的值,关闭时的值]。默认为 [true, false]。示例:[1, 0]['open', 'close']。TS 类型:`Array<SwitchValue>` | N
disabled | Boolean | false | 是否禁用组件 | N
icon `v0.27.0` | Array | [] | 开关的图标;[打开时的图标,关闭时的图标]。TS 类型:`string[]` | N
label `v0.27.0` | Array | [] | 开关的标签;[打开时的标签,关闭时的标签]。TS 类型:`string[]` | N
loading `v0.27.0` | Boolean | false | 是否处于加载中状态 | N
size `v0.27.0` | String | medium | 开关尺寸。可选项:small/medium/large | N
disabled | Boolean | undefined | 是否禁用组件。优先级:Switch.disabled > Form.disabled | N
icon | Array | [] | `0.27.0`开关的图标;[打开时的图标,关闭时的图标]。TS 类型:`string[]` | N
label | Array | [] | `0.27.0`开关的标签;[打开时的标签,关闭时的标签]。TS 类型:`string[]` | N
loading | Boolean | false | `0.27.0`是否处于加载中状态 | N
size | String | medium | `0.27.0`开关尺寸。可选项:small/medium/large | N
value | String / Number / Boolean | null | 开关值。TS 类型:`SwitchValue` `type SwitchValue = string \| number \| boolean`[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/switch/type.ts) | N
default-value | String / Number / Boolean | undefined | 开关值。非受控属性。TS 类型:`SwitchValue` `type SwitchValue = string \| number \| boolean`[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/switch/type.ts) | N

Expand All @@ -64,8 +67,8 @@ default-value | String / Number / Boolean | undefined | 开关值。非受控属
-- | -- | --
change | `(value: SwitchValue)` | 数据发生变化时触发

### CSS Variables

### CSS 变量
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
Expand Down Expand Up @@ -99,4 +102,4 @@ change | `(value: SwitchValue)` | 数据发生变化时触发
--td-switch-small-width | 78rpx | -
--td-switch-unchecked-color | @font-gray-4 | -
--td-switch-unchecked-disabled-color | @bg-color-component-disabled | -
--td-switch-width | 90rpx | -
--td-switch-width | 90rpx | -
6 changes: 3 additions & 3 deletions src/switch/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const props: TdSwitchProps = {
type: Array,
value: [true, false],
},
/** 是否禁用组件 */
/** 是否禁用组件。优先级:Switch.disabled > Form.disabled */
disabled: {
type: Boolean,
value: false,
type: null,
value: undefined,
},
/** 开关的图标;[打开时的图标,关闭时的图标] */
icon: {
Expand Down
13 changes: 2 additions & 11 deletions src/switch/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

export interface TdSwitchProps {
export interface TdSwitchProps<T = SwitchValue> {
/**
* 用于自定义开关的值,[打开时的值,关闭时的值]。默认为 [true, false]。示例:[1, 0]、['open', 'close']
* @default [true, false]
Expand All @@ -14,8 +14,7 @@ export interface TdSwitchProps {
value?: Array<SwitchValue>;
};
/**
* 是否禁用组件
* @default false
* 是否禁用组件。优先级:Switch.disabled > Form.disabled
*/
disabled?: {
type: BooleanConstructor;
Expand Down Expand Up @@ -53,14 +52,6 @@ export interface TdSwitchProps {
type: StringConstructor;
value?: 'small' | 'medium' | 'large';
};
/**
* 自定义组件样式
* @default ''
*/
style?: {
type: StringConstructor;
value?: string;
};
/**
* 开关值
* @default null
Expand Down

0 comments on commit 84904cf

Please sign in to comment.