mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-05 11:21:11 +08:00
refactor(components): [steps] use useNamespace (#5944)
This commit is contained in:
parent
a995d4487b
commit
eb1adcd491
@ -1,10 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div :class="[ns.b(), ns.m(simple ? 'simple' : direction)]">
|
||||||
:class="[
|
|
||||||
'el-steps',
|
|
||||||
simple ? 'el-steps--simple' : `el-steps--${direction}`,
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -13,6 +8,7 @@
|
|||||||
import { defineComponent, watch, ref, provide } from 'vue'
|
import { defineComponent, watch, ref, provide } from 'vue'
|
||||||
|
|
||||||
import { CHANGE_EVENT } from '@element-plus/constants'
|
import { CHANGE_EVENT } from '@element-plus/constants'
|
||||||
|
import { useNamespace } from '@element-plus/hooks'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ElSteps',
|
name: 'ElSteps',
|
||||||
@ -54,6 +50,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
emits: [CHANGE_EVENT],
|
emits: [CHANGE_EVENT],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
const ns = useNamespace('steps')
|
||||||
const steps = ref([])
|
const steps = ref([])
|
||||||
|
|
||||||
watch(steps, () => {
|
watch(steps, () => {
|
||||||
@ -73,6 +70,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
steps,
|
steps,
|
||||||
|
ns,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -2,43 +2,43 @@
|
|||||||
<div
|
<div
|
||||||
:style="style"
|
:style="style"
|
||||||
:class="[
|
:class="[
|
||||||
'el-step',
|
ns.b(),
|
||||||
isSimple ? 'is-simple' : `is-${parent.props.direction}`,
|
ns.is(isSimple ? 'simple' : parent.props.direction),
|
||||||
isLast && !space && !isCenter && 'is-flex',
|
ns.is('flex', isLast && !space && !isCenter),
|
||||||
isCenter && !isVertical && !isSimple && 'is-center',
|
ns.is('center', isCenter && !isVertical && !isSimple),
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<!-- icon & line -->
|
<!-- icon & line -->
|
||||||
<div :class="['el-step__head', `is-${currentStatus}`]">
|
<div :class="[ns.e('head'), ns.is(currentStatus)]">
|
||||||
<div v-if="!isSimple" class="el-step__line">
|
<div v-if="!isSimple" :class="ns.e('line')">
|
||||||
<i class="el-step__line-inner" :style="lineStyle"></i>
|
<i :class="ns.e('line-inner')" :style="lineStyle"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div :class="['el-step__icon', `is-${icon ? 'icon' : 'text'}`]">
|
<div :class="[ns.e('icon'), ns.is(icon ? 'icon' : 'text')]">
|
||||||
<slot
|
<slot
|
||||||
v-if="currentStatus !== 'success' && currentStatus !== 'error'"
|
v-if="currentStatus !== 'success' && currentStatus !== 'error'"
|
||||||
name="icon"
|
name="icon"
|
||||||
>
|
>
|
||||||
<el-icon v-if="icon" class="el-step__icon-inner">
|
<el-icon v-if="icon" :class="ns.e('icon-inner')">
|
||||||
<component :is="icon" />
|
<component :is="icon" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<div v-if="!icon && !isSimple" class="el-step__icon-inner">
|
<div v-if="!icon && !isSimple" :class="ns.e('icon-inner')">
|
||||||
{{ index + 1 }}
|
{{ index + 1 }}
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
<el-icon v-else class="el-step__icon-inner is-status">
|
<el-icon v-else :class="[ns.e('icon-inner'), ns.is('status')]">
|
||||||
<check v-if="currentStatus === 'success'" />
|
<check v-if="currentStatus === 'success'" />
|
||||||
<close v-else />
|
<close v-else />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- title & description -->
|
<!-- title & description -->
|
||||||
<div class="el-step__main">
|
<div :class="ns.e('main')">
|
||||||
<div :class="['el-step__title', `is-${currentStatus}`]">
|
<div :class="[ns.e('title'), ns.is(currentStatus)]">
|
||||||
<slot name="title">{{ title }}</slot>
|
<slot name="title">{{ title }}</slot>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isSimple" class="el-step__arrow"></div>
|
<div v-if="isSimple" :class="ns.e('arrow')"></div>
|
||||||
<div v-else :class="['el-step__description', `is-${currentStatus}`]">
|
<div v-else :class="[ns.e('description'), ns.is(currentStatus)]">
|
||||||
<slot name="description">{{ description }}</slot>
|
<slot name="description">{{ description }}</slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -60,6 +60,7 @@ import {
|
|||||||
import { ElIcon } from '@element-plus/components/icon'
|
import { ElIcon } from '@element-plus/components/icon'
|
||||||
import { Close, Check } from '@element-plus/icons-vue'
|
import { Close, Check } from '@element-plus/icons-vue'
|
||||||
|
|
||||||
|
import { useNamespace } from '@element-plus/hooks'
|
||||||
import type { Ref, PropType, Component } from 'vue'
|
import type { Ref, PropType, Component } from 'vue'
|
||||||
|
|
||||||
export interface IStepsProps {
|
export interface IStepsProps {
|
||||||
@ -112,6 +113,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const ns = useNamespace('step')
|
||||||
const index = ref(-1)
|
const index = ref(-1)
|
||||||
const lineStyle = ref({})
|
const lineStyle = ref({})
|
||||||
const internalStatus = ref('')
|
const internalStatus = ref('')
|
||||||
@ -222,6 +224,7 @@ export default defineComponent({
|
|||||||
parent.steps.value = [...parent.steps.value, stepItemState]
|
parent.steps.value = [...parent.steps.value, stepItemState]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
ns,
|
||||||
index,
|
index,
|
||||||
lineStyle,
|
lineStyle,
|
||||||
currentStatus,
|
currentStatus,
|
||||||
|
Loading…
Reference in New Issue
Block a user