forked from jdf2e/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(indicator): move to script setup (jdf2e#3000)
- Loading branch information
Showing
10 changed files
with
139 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |