From 57ed81ee16cc63bd937da8be7ddf7dd14fb2f991 Mon Sep 17 00:00:00 2001 From: eiinu Date: Fri, 15 Dec 2023 15:43:18 +0800 Subject: [PATCH] chore(radio): split demo --- .../src/dentry/pages/radio/basic.vue | 11 + .../src/dentry/pages/radio/disabled.vue | 11 + .../src/dentry/pages/radio/event.vue | 13 ++ .../src/dentry/pages/radio/horizontal.vue | 11 + .../src/dentry/pages/radio/icon-size.vue | 11 + .../src/dentry/pages/radio/icon.vue | 19 ++ .../src/dentry/pages/radio/index.vue | 154 ++++++-------- .../src/dentry/pages/radio/position.vue | 11 + .../src/dentry/pages/radio/shape.vue | 11 + .../src/dentry/pages/radio/size.vue | 23 +++ packages/nutui-vite-plugins/src/markdown.ts | 2 +- scripts/copyh5.cjs | 2 +- scripts/copytaro.cjs | 2 +- src/packages/__VUE/radio/doc.en-US.md | 110 +++------- src/packages/__VUE/radio/doc.md | 188 ++++-------------- src/packages/__VUE/radio/doc.taro.md | 188 ++++-------------- 16 files changed, 287 insertions(+), 480 deletions(-) create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/basic.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/disabled.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/event.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/horizontal.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/icon-size.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/icon.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/position.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/shape.vue create mode 100644 packages/nutui-taro-demo/src/dentry/pages/radio/size.vue diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/basic.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/basic.vue new file mode 100644 index 0000000000..d206cd2c33 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/basic.vue @@ -0,0 +1,11 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/disabled.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/disabled.vue new file mode 100644 index 0000000000..25d93627f3 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/disabled.vue @@ -0,0 +1,11 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/event.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/event.vue new file mode 100644 index 0000000000..d8196cef49 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/event.vue @@ -0,0 +1,13 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/horizontal.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/horizontal.vue new file mode 100644 index 0000000000..5944f0ef66 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/horizontal.vue @@ -0,0 +1,11 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/icon-size.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/icon-size.vue new file mode 100644 index 0000000000..4ab70f1fa5 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/icon-size.vue @@ -0,0 +1,11 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/icon.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/icon.vue new file mode 100644 index 0000000000..fef8483ed8 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/icon.vue @@ -0,0 +1,19 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/index.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/index.vue index 96ceef40c0..ed8c182362 100644 --- a/packages/nutui-taro-demo/src/dentry/pages/radio/index.vue +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/index.vue @@ -1,102 +1,68 @@ - - diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/position.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/position.vue new file mode 100644 index 0000000000..a3dec00771 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/position.vue @@ -0,0 +1,11 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/shape.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/shape.vue new file mode 100644 index 0000000000..98f0df9a82 --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/shape.vue @@ -0,0 +1,11 @@ + + diff --git a/packages/nutui-taro-demo/src/dentry/pages/radio/size.vue b/packages/nutui-taro-demo/src/dentry/pages/radio/size.vue new file mode 100644 index 0000000000..f25e0b794d --- /dev/null +++ b/packages/nutui-taro-demo/src/dentry/pages/radio/size.vue @@ -0,0 +1,23 @@ + + diff --git a/packages/nutui-vite-plugins/src/markdown.ts b/packages/nutui-vite-plugins/src/markdown.ts index a915ccbabd..4050ecb3aa 100644 --- a/packages/nutui-vite-plugins/src/markdown.ts +++ b/packages/nutui-vite-plugins/src/markdown.ts @@ -25,7 +25,7 @@ const TransformMarkdownDemo = (options: MarkdownOptions): Plugin => { transform(src, id) { if (fileRegex.test(id)) { return { - code: src.replace(/> demo: ([0-9a-z .]*)[\n|\r\n]/g, (_match, $1: string) => { + code: src.replace(/> demo: ([-0-9a-z .]*)[\n|\r\n]/g, (_match, $1: string) => { const [comp, demo, type] = $1.split(' '); const docPath = type ? path.resolve(options.docTaroRoot, type, 'pages', comp, `${demo}.vue`) diff --git a/scripts/copyh5.cjs b/scripts/copyh5.cjs index fbbe731f2e..14f6d0412f 100644 --- a/scripts/copyh5.cjs +++ b/scripts/copyh5.cjs @@ -7,7 +7,7 @@ const replaceFile = (file) => { if (err) throw err; // 修改文件内容 - data = data.replace(/> demo: ([0-9a-z .]*)[\n|\r\n]/g, (_match, $1) => { + data = data.replace(/> demo: ([-0-9a-z .]*)[\n|\r\n]/g, (_match, $1) => { const [left, right] = $1.split(' '); const target = path.resolve('src/packages/__VUE/', left, 'demo', `${right}.vue`); let code = ''; diff --git a/scripts/copytaro.cjs b/scripts/copytaro.cjs index 1f9e323b17..c6fb003dd2 100644 --- a/scripts/copytaro.cjs +++ b/scripts/copytaro.cjs @@ -7,7 +7,7 @@ const replaceFile = (file) => { if (err) throw err; // 修改文件内容 - data = data.replace(/> demo: ([0-9a-z .]*)[\n|\r\n]/g, (_match, $1) => { + data = data.replace(/> demo: ([-0-9a-z .]*)[\n|\r\n]/g, (_match, $1) => { const [left, right, type] = $1.split(' '); const target = path.resolve('packages/nutui-taro-demo/src', type, 'pages', left, `${right}.vue`); let code = ''; diff --git a/src/packages/__VUE/radio/doc.en-US.md b/src/packages/__VUE/radio/doc.en-US.md index 0215af1f45..42834d477c 100644 --- a/src/packages/__VUE/radio/doc.en-US.md +++ b/src/packages/__VUE/radio/doc.en-US.md @@ -17,97 +17,49 @@ app.use(RadioGroup); ### Basic Usage -Bind the **label** of the current option through **v-model**. And it must be used in combination with **nut-radio-group** and **nut-radio** +Bind the `label` field of an option through `v-model`. `nut-radio` must be used in conjunction with `nut-radio-group`. > demo: radio basic ### Horizontal +Set the direction through `direction`. The default value is `vertical` and can be set to `horizontal`. + > demo: radio horizontal -### Custom size - -:::demo - -```vue - - -``` +### Disabled -::: +> demo: radio disabled ### Custom icon -Customize the icon through the slot, it is recommended to set the `icon` and `checkedIcon` two slots at the same time - -:::demo - -```vue - - -``` +> demo: radio icon -::: - -### Trigger change event - -:::demo - -```vue - - -``` +### Text Position + +Set the text position through `text-position`. The default value is `right` and can be set to `left`. + +> demo: radio position + +### Icon Size + +> demo: radio icon-size + +### Shape + +Set the Radio shape through `shape`. The default value is `round` and can be set to `button`. + +> demo: radio shape + +### Custom Button Size v4.2.4 + +Set the Radio size through `size`, which only takes effect when `shape` is `button`. + +> demo: radio size + +### Event Trigger -::: +> demo: radio event ## API @@ -119,7 +71,7 @@ const handleChange = (value) => { | icon-size | [Icon Size](#/en-US/icon) | string \| number | `18` | | label | Radio box ID | string \| number \| boolean | - | | shape | Shape, optional values are `button`、`round` | string | `round` | -| size | Can be set to `small` `mini` `normal`, when `shape` = `button` | string | `normal` | +| size`v4.2.4` | Can be set to `small` `mini` `normal`, when `shape` = `button` | string | `normal` | ### Radio Slots diff --git a/src/packages/__VUE/radio/doc.md b/src/packages/__VUE/radio/doc.md index 201a7d622a..19c5a0c2e9 100644 --- a/src/packages/__VUE/radio/doc.md +++ b/src/packages/__VUE/radio/doc.md @@ -17,165 +17,49 @@ app.use(RadioGroup); ### 基础用法 -通过 **v-model** 绑定值当前选项的 **label** 。并且必须 **nut-radio-group** 和 **nut-radio** 相结合进行使用 - -:::demo - -```vue - - -``` +通过 `v-model` 绑定某个选项的 `label` 字段。`nut-radio` 必须与 `nut-radio-group` 相结合进行使用。 -::: - -### 水平使用 - -:::demo - -```vue - - -``` +> demo: radio basic -::: - -### 自定义尺寸 - -:::demo - -```vue - - -``` +### 水平方向 + +通过 `direction` 设置方向,默认值为 `vertical`,可设置为 `horizontal`。 + +> demo: radio horizontal -::: +### 禁用状态 + +> demo: radio disabled ### 自定义图标 -通过 `slot` 自定义图标,建议同时设置`icon`和`checkedIcon`两个插槽 - -:::demo - -```vue - - -``` +> demo: radio icon -::: - -### 触发 change 事件 - -:::demo - -```vue - - -``` +### 左侧文本 + +通过 `text-position` 设置文本位置,默认值为 `right`,可设置为 `left`。 + +> demo: radio position + +### 图标尺寸 + +> demo: radio icon-size + +### 设置形状 + +通过 `shape` 设置 Radio 形状,默认值为 `round`,可设置为 `button`。 + +> demo: radio shape + +### 自定义按钮尺寸 v4.2.4 + +通过 `size` 设置 Radio 大小,仅在 `shape` 为 `button` 时生效。 + +> demo: radio size + +### 触发事件 -::: +> demo: radio event ## API @@ -187,7 +71,7 @@ const handleChange = (value) => { | icon-size | [图标尺寸](#/zh-CN/component/icon) | string \| number | `18` | | label | 单选框标识 | string \| number \| boolean | - | | shape | 形状,可选值为 `button`、`round` | string | `round` | -| size | 尺寸,可选值为 `small` `mini` `normal`,仅在 shape 为 `button` 时生效 | string | `normal` | +| size`v4.2.4` | 尺寸,可选值为 `small` `mini` `normal`,仅在 shape 为 `button` 时生效 | string | `normal` | ### Radio Slots diff --git a/src/packages/__VUE/radio/doc.taro.md b/src/packages/__VUE/radio/doc.taro.md index 6dacd4aad7..8c8b530ff9 100644 --- a/src/packages/__VUE/radio/doc.taro.md +++ b/src/packages/__VUE/radio/doc.taro.md @@ -17,165 +17,49 @@ app.use(RadioGroup); ### 基础用法 -通过 **v-model** 绑定值当前选项的 **label** 。并且必须 **nut-radio-group** 和 **nut-radio** 相结合进行使用 - -:::demo - -```vue - - -``` +通过 `v-model` 绑定某个选项的 `label` 字段。`nut-radio` 必须与 `nut-radio-group` 相结合进行使用。 -::: - -### 水平使用 - -:::demo - -```vue - - -``` +> demo: radio basic -::: - -### 自定义尺寸 - -:::demo - -```vue - - -``` +### 水平方向 + +通过 `direction` 设置方向,默认值为 `vertical`,可设置为 `horizontal`。 + +> demo: radio horizontal -::: +### 禁用状态 + +> demo: radio disabled ### 自定义图标 -通过 `slot` 自定义图标,建议同时设置`icon`和`checkedIcon`两个插槽 - -:::demo - -```vue - - -``` +> demo: radio icon -::: - -### 触发 change 事件 - -:::demo - -```vue - - -``` +### 左侧文本 + +通过 `text-position` 设置文本位置,默认值为 `right`,可设置为 `left`。 + +> demo: radio position + +### 图标尺寸 + +> demo: radio icon-size + +### 设置形状 + +通过 `shape` 设置 Radio 形状,默认值为 `round`,可设置为 `button`。 + +> demo: radio shape + +### 自定义按钮尺寸 v4.2.4 + +通过 `size` 设置 Radio 大小,仅在 `shape` 为 `button` 时生效。 + +> demo: radio size + +### 触发事件 -::: +> demo: radio event ## API @@ -187,7 +71,7 @@ const handleChange = (value) => { | icon-size | [图标尺寸](#/zh-CN/component/icon) | string \| number | `18` | | label | 单选框标识 | string \| number \| boolean | - | | shape | 形状,可选值为 `button`、`round` | string | `round` | -| size | 尺寸,可选值为 `small` `mini` `normal`,仅在 shape 为 `button` 时生效 | string | `normal` | +| size`v4.2.4` | 尺寸,可选值为 `small` `mini` `normal`,仅在 shape 为 `button` 时生效 | string | `normal` | ### Radio Slots