Skip to content

Commit

Permalink
refactor(indicator): move to script setup (jdf2e#3000)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Mar 27, 2024
1 parent 9e200d4 commit 5ad673a
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 106 deletions.
1 change: 1 addition & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@
"name": "Indicator",
"cName": "指示器",
"desc": "显示一个任务或流程的进度,常用语开通流程。",
"setup": true,
"author": "senyawang"
},
{
Expand Down
8 changes: 8 additions & 0 deletions src/packages/__VUE/indicator/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ app.use(Indicator)
| align | Alignment, which takes effect only when `block` is `true`. optional value `left`, `right`, `center` | string | `left` |
| fill-zero | Whether to add 0 before singular number | boolean | `true` |

### Types version

The component exports the following type definitions:

```ts
import type { IndicatorAlign, IndicatorProps, IndicatorInstance } from '@nutui/nutui'
```

## Theming

### CSS Variables
Expand Down
8 changes: 8 additions & 0 deletions src/packages/__VUE/indicator/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ app.use(Indicator)
| align | 对齐方式,仅在 `block``true` 时生效, 可选值 `left`, `right`, `center` | string | `left` |
| fill-zero | 单数前面是否补 0 | boolean | `true` |

### 类型定义 version

组件导出以下类型定义:

```ts
import type { IndicatorAlign, IndicatorProps, IndicatorInstance } from '@nutui/nutui'
```

## 主题定制

### 样式变量
Expand Down
8 changes: 8 additions & 0 deletions src/packages/__VUE/indicator/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ app.use(Indicator)
| align | 对齐方式,仅在 `block``true` 时生效, 可选值 `left`, `right`, `center` | string | `left` |
| fill-zero | 单数前面是否补 0 | boolean | `true` |

### 类型定义 version

组件导出以下类型定义:

```ts
import type { IndicatorAlign, IndicatorProps, IndicatorInstance } from '@nutui/nutui-taro'
```

## 主题定制

### 样式变量
Expand Down
13 changes: 13 additions & 0 deletions src/packages/__VUE/indicator/index.taro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Indicator from './indicator.taro.vue'
import type { ComponentPublicInstance } from 'vue'
import { withInstall } from '@/packages/utils'

withInstall(Indicator)

export type { IndicatorProps } from './indicator.taro.vue'

export type { IndicatorAlign } from './types'

export type IndicatorInstance = ComponentPublicInstance & InstanceType<typeof Indicator>

export { Indicator, Indicator as default }
53 changes: 0 additions & 53 deletions src/packages/__VUE/indicator/index.taro.vue

This file was deleted.

13 changes: 13 additions & 0 deletions src/packages/__VUE/indicator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Indicator from './indicator.vue'
import type { ComponentPublicInstance } from 'vue'
import { withInstall } from '@/packages/utils'

withInstall(Indicator)

export type { IndicatorProps } from './indicator.vue'

export type { IndicatorAlign } from './types'

export type IndicatorInstance = ComponentPublicInstance & InstanceType<typeof Indicator>

export { Indicator, Indicator as default }
53 changes: 0 additions & 53 deletions src/packages/__VUE/indicator/index.vue

This file was deleted.

44 changes: 44 additions & 0 deletions src/packages/__VUE/indicator/indicator.taro.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<view :class="classes">
<template v-for="item in size" :key="item">
<view v-if="item === current" class="nut-indicator--number">
{{ (fillZero && padZero(item)) || item }}
</view>
<view v-else class="nut-indicator--dot"></view>
</template>
</view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { padZero } from '@/packages/utils/util'
import type { IndicatorAlign } from './types'
defineOptions({
name: 'NutIndicator'
})
export type IndicatorProps = Partial<{
size: number
current: number
block: boolean
align: IndicatorAlign
fillZero: boolean
}>
const props = withDefaults(defineProps<IndicatorProps>(), {
size: 3,
current: 1,
block: false,
align: 'center',
fillZero: true
})
const classes = computed(() => {
const prefixCls = 'nut-indicator'
return {
[prefixCls]: true,
[`${prefixCls}--block`]: props.block,
[`${prefixCls}--align__${props.align}`]: props.block && props.align
}
})
</script>
44 changes: 44 additions & 0 deletions src/packages/__VUE/indicator/indicator.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<view :class="classes">
<template v-for="item in size" :key="item">
<view v-if="item === current" class="nut-indicator--number">
{{ (fillZero && padZero(item)) || item }}
</view>
<view v-else class="nut-indicator--dot"></view>
</template>
</view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { padZero } from '@/packages/utils/util'
import type { IndicatorAlign } from './types'
defineOptions({
name: 'NutIndicator'
})
export type IndicatorProps = Partial<{
size: number
current: number
block: boolean
align: IndicatorAlign
fillZero: boolean
}>
const props = withDefaults(defineProps<IndicatorProps>(), {
size: 3,
current: 1,
block: false,
align: 'center',
fillZero: true
})
const classes = computed(() => {
const prefixCls = 'nut-indicator'
return {
[prefixCls]: true,
[`${prefixCls}--block`]: props.block,
[`${prefixCls}--align__${props.align}`]: props.block && props.align
}
})
</script>

0 comments on commit 5ad673a

Please sign in to comment.