Skip to content

Commit

Permalink
docs: update all components index.zh.md
Browse files Browse the repository at this point in the history
* docs: update gen script
  • Loading branch information
lcx15831 committed Jan 4, 2021
1 parent bc8ff33 commit 1b57a98
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 73 deletions.
30 changes: 16 additions & 14 deletions packages/components/badge/docs/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ cover:

### `ix-badge`

| 属性 | 说明 | 类型 | 全局配置 |
| --------------- | -------------------------------------------------------------- | --------------- | -------- |
| `dot` | 圆点徽标 | `boolean` | `false` |
| `count` | 数值徽标的值 | `number/string` | `-` |
| `overflowCount` | 最大数值徽标的值,超出以`${overflowCount}+`显示 | `number/string` | `99` |
| `showZero` | 数值为 0 时是否显示 | `boolean` | `false` |
| `color` | 徽标的颜色,数值徽标和圆点徽标为设置背景色,组件徽标为字体颜色 | `hex/rgb?a` | `-` |

### `slots`

| 方法 | 说明 | 参数 |
| --------- | ------------------ | ---- |
| `defalut` | 需要添加徽标的内容 |
| `count` | 自定义徽标 |
#### Props

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `dot` | 圆点徽标 | `boolean` | `false` || - |
| `count` | 数值徽标的值 | `number\|string` | `0` | - | - |
| `overflowCount` | 最大数值徽标的值 | `number\|string` | `99` || 超出以`${overflowCount}+`显示 |
| `showZero`| 数值为 0 时是否显示 | `boolean` | `false` || - |
| `color` | 徽标的颜色 | `string` | - | - | 数值徽标和圆点徽标为设置背景色,组件徽标为字体颜色 |

### Slots

| 名称 | 说明 | 参数类型 | 备注 |
| --- | --- | --- | --- |
| `defalut` | 需要添加徽标的内容 | - | - |
| `count` | 自定义徽标 | - | - |
6 changes: 3 additions & 3 deletions packages/components/badge/src/Badge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
</span>
</template>
<script lang="ts">
import type { ComputedRef } from 'vue'
import type { BadgeProps, SlotsExist } from './types'
import { computed, defineComponent, onUpdated, reactive } from 'vue'
import { isNumeric, PropTypes } from '@idux/cdk/utils'
import { useGlobalConfig } from '@idux/components/core/config'
import type { ComputedRef } from 'vue'
import type { BadgeProps, SlotsExist } from './types'
export default defineComponent({
name: 'IxBadge',
props: {
Expand Down
12 changes: 8 additions & 4 deletions packages/components/button/docs/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,28 @@ cover:

### `ix-button`

#### Props

> `mode` 不为 `link` 时,除以下表格之外还支持原生 `button` 元素的[所有属性](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/button)
> `mode``link` 时,除以下表格之外还支持原生 `a` 元素的[所有属性](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/a)
| 属性 | 说明 | 类型 | 全局配置| 默认值| 备注 |
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `mode` | 设置按钮种类 | `primary\|default\|dashed\|text\|link` | `default` | - |- |
| `mode` | 设置按钮种类 | `primary\|default\|dashed\|text\|link` | `default` | |- |
| `danger` | 设置危险状态 | `boolean` | - | - |- |
| `ghost` | 设置幽灵状态 | `boolean` | - | - |- |
| `disabled` | 设置禁用状态 | `boolean` | - | - |- |
| `loading` | 设置加载中状态 | `boolean` | - | - |- |
| `size` | 设置按钮大小 | `large\|medium\|small` | `medium` | - |- |
| `size` | 设置按钮大小 | `large\|medium\|small` | `medium` | |- |
| `shape` | 设置按钮形状 | `circle\|round` | - | - |- |
| `block` | 将按钮宽度调整为自适应其父元素的宽度 | `boolean` | - | - |- |
| `icon` | 设置图标类型 | `string` | - | - | `loading``true` 时无效 |

### `ix-button-group`

| 属性 | 说明 | 类型 | 全局配置| 默认值| 备注 |
#### GroupProps

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `mode` | 设置组内按钮种类 | `primary\|default\|dashed\|text\|link` | - | - |- |
| `size` | 设置组内按钮大小 | `large\|medium\|small` | - | - |- |
Expand Down
10 changes: 5 additions & 5 deletions packages/components/button/src/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
</template>

<script lang="ts">
import type { ComputedRef, Ref } from 'vue'
import type { ButtonConfig } from '@idux/components/core/config'
import type { ButtonMode } from '@idux/components/core/types'
import type { ButtonGroupProps, ButtonProps } from './types'
import { computed, defineComponent, inject, onUpdated, ref } from 'vue'
import { PropTypes } from '@idux/cdk/utils'
import { useGlobalConfig } from '@idux/components/core/config'
import { IxIcon } from '@idux/components/icon'
import { buttonGroupInjectionKey } from './button'
import type { ComputedRef, Ref } from 'vue'
import type { ButtonConfig } from '@idux/components/core/config'
import type { ButtonMode } from '@idux/components/core/types'
import type { ButtonGroupProps, ButtonProps } from './types'
export default defineComponent({
name: 'IxButton',
components: { IxIcon },
Expand Down
16 changes: 9 additions & 7 deletions packages/components/divider/docs/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ cover:

### `ix-divider`

| 属性 | 说明 | 类型 | 全局配置 | 默认值 | 备注 |
| --- | :-- | --- | :-- | --- | --- |
| `dashed` | 是否虚线 | boolean | false | - | - |
| `plain` | 文字是否显示为普通正文样式 | boolean |false| - | - |
| `position` | 文字显示位置 | `left`|`center`|`right` |`center`| - |-|
| `type` | 水平分割线还是垂直分割线 | `horizontal`|`vertical` | - |`horizontal`|
| `text` | 分割线显示文字 | `slot` |-| - | - |
#### Props

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `dashed` | 是否虚线 | `boolean` | `false` || - |
| `plain` | 文字是否显示为普通正文样式 | `boolean` | `false` || - |
| `position` | 文字显示位置 | `left\|center\|right` | `center`|| - |
| `type` | 水平分割线还是垂直分割线 | `horizontal\|vertical` | `horizontal` || - |
| `text` | 分割线显示文字 | `slot` | - | - | - |
22 changes: 12 additions & 10 deletions packages/components/icon/docs/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ cover:

### ix-icon

#### Props

> 当存在 @click 的时候,会被渲染为一个 `button` 元素,其他情况为 `i` 元素
| 参数 | 说明 | 类型 | 全局配置 |
| --- | --- | --- | --- |
| `name`| 图标名称 | `string` |
| `rotate` | 图标旋转角度, 为 `true` 时会循环旋转 | `boolean|number|string` | - |
| `iconfont` | 图标是否来自 `iconfont` | `boolean` | - |
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `name`| 图标名称 | `string` | - | - | - |
| `rotate` | 图标旋转角度, 为 `true` 时会循环旋转 | `boolean|number|string` | - | - | - |
| `iconfont` | 图标是否来自 `iconfont` | `boolean` | - | - | - |

### [helper]
### 工具函数

| 方法 | 说明 | 参数 |
| --- | --- | --- |
| `addIconDefinitions()` | 用于静态引入图标 | `IconDefinition[]` |
| `fetchFromIconfont()` | 用于从 [`iconfont`](https://www.iconfont.cn) 获取图标资源文件 | `string|string[]` |
| 名称 | 说明 | 参数类型 | 备注 |
| --- | --- | --- | --- |
| `addIconDefinitions()` | 用于静态引入图标 | `IconDefinition[]` | - |
| `fetchFromIconfont()` | 用于从 [`iconfont`](https://www.iconfont.cn) 获取图标资源文件 | `string|string[]` | - |
8 changes: 4 additions & 4 deletions packages/components/icon/src/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
</component>
</template>
<script lang="ts">
import type { Ref, SetupContext } from 'vue'
import type { IconConfig } from '@idux/components/core/config'
import type { IconProps } from './types'
import { computed, defineComponent, onMounted, onUpdated, ref, watch } from 'vue'
import { isNumeric, PropTypes, withUndefined } from '@idux/cdk/utils'
import { useGlobalConfig } from '@idux/components/core/config'
import { clearSVGElement, loadIconFontSvgElement, loadSVGElement } from './utils'
import type { Ref, SetupContext } from 'vue'
import type { IconConfig } from '@idux/components/core/config'
import type { IconProps } from './types'
export default defineComponent({
name: 'IxIcon',
props: {
Expand Down
30 changes: 16 additions & 14 deletions packages/components/image/docs/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ cover: 可预览的图片

## API

| 属性 | 说明 | 类型 | 全局配置 |
### `ix-image`

| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| `src` | 图片地址 | `string` | - | - | - |
| `width` | 图像宽度 | `string \| number` | - || - |
| `height` | 图像高度 | `string \| number` | - || - |
| `fallback` | 加载失败容错地址 | `string` | - || - |
| `preview` | 预览参数,为 `false` 时禁用 | `boolean` | - | - | - |
| `alt` | 图像描述 | `string` | - | - | - |
| `objectFit` | 确定图片如何适应容器框 | `string` | - | - | 同原生 [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) |

### Emits

| 名称 | 说明 | 参数类型 | 备注 |
| --- | --- | --- | --- |
| alt | 图像描述| string | - |
| fallback | 加载失败容错地址| string | - |
|height|图像高度|string \| number|-|
|preview|预览参数,为`false` 时禁用|boolean|-|
|src|图片地址|string|-|
|width|图像宽度|string \| number|-|
|objectFit|确定图片如何适应容器框,同原生 [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit)|string|-|

### Events

| 事件名称 | 说明 | 参数类型 |
| --- | --- | --- |
| statusChange | 图片加载状态改变时触发 | `loading\|loaded\|failed` |
| `statusChange` | 图片加载状态改变时触发 | `loading\|loaded\|failed` | - |
8 changes: 4 additions & 4 deletions packages/components/image/src/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
</div>
</template>
<script lang="ts">
import type { ImageProps, ImageStatus } from './types'
import { defineComponent, computed, ref, watchEffect, watch } from 'vue'
import { ImageProps, ImageStatus } from './types'
import ImgPreview from './ImgPreview.vue'
import { PropTypes, toCssPixel, withUndefined } from '@idux/cdk/utils'
import { useGlobalConfig } from '@idux/components/core/config'
import { toCssPixel } from '@idux/cdk/utils/convert'
import { PropTypes, withUndefined } from '@idux/cdk/utils'
import ImgPreview from './ImgPreview.vue'
export default defineComponent({
name: 'IxImage',
Expand Down
6 changes: 4 additions & 2 deletions packages/components/image/src/ImgPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
</template>

<script lang="ts">
import type { ImagePreviewProps } from './types'
import { defineComponent, ref, computed } from 'vue'
import { ImagePreviewProps } from './types'
import { IxIcon } from '@idux/components/icon'
import { PropTypes } from '@idux/cdk/utils'
import { IxIcon } from '@idux/components/icon'
const minScale = 0.2
const initScale = 1.0
const scaleStep = 0.1
Expand Down
2 changes: 1 addition & 1 deletion scripts/gen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if (moduleName === 'components') {
writeFileSync(`${componentDirname}/__tests__/${camelCaseComponentName}.spec.ts`, testTemplate)
}

const docsZhTemplate = getDocsZhTemplate(upperFirstComponentName, moduleName)
const docsZhTemplate = getDocsZhTemplate(compName, moduleName, upperFirstComponentName)
writeFileSync(`${componentDirname}/docs/index.zh.md`, docsZhTemplate)

const domeTemplate = getDomeTemplate(compName)
Expand Down
14 changes: 9 additions & 5 deletions scripts/gen/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ describe('use${compName}.ts', () => {
`
}

export function getDocsZhTemplate(compName: string, moduleName: string): string {
export function getDocsZhTemplate(compName: string, moduleName: string, upperFirstName: string): string {
return `---
category: ${moduleName}
type:
title: ${compName}
title: ${upperFirstName}
subtitle:
cover:
---
Expand All @@ -114,9 +114,13 @@ cover:
## API
| 属性 | 说明 | 类型 | 默认值 | | 全局配置 |
| --- | --- | --- | --- | --- |
| - | - | - | - | - |
### ix-${compName}
#### Props
| 名称 | 说明 | 类型 | 默认值 | 全局配置 | 备注 |
| --- | --- | --- | --- | --- | --- |
| - | - | - | - | ✅ | - |
`
}
Expand Down

0 comments on commit 1b57a98

Please sign in to comment.