@didaoktv/didaoui-uniapp 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
class="dd-step"
|
|
4
|
+
:class="[`dd-step--${direction}`, `dd-step--${status}`, `dd-step--${size}`]"
|
|
5
|
+
:style="colorStyle"
|
|
6
|
+
>
|
|
3
7
|
<template v-if="direction === 'horizontal'">
|
|
4
8
|
<view class="dd-step__head">
|
|
5
|
-
<view
|
|
6
|
-
v-if="!isLast"
|
|
7
|
-
class="dd-step__line"
|
|
8
|
-
:class="{ 'dd-step__line--first': isFirst }"
|
|
9
|
-
:style="lineStyle"
|
|
10
|
-
></view>
|
|
9
|
+
<view v-if="!isLast" class="dd-step__line" :style="lineStyle"></view>
|
|
11
10
|
<view class="dd-step__circle" :style="circleStyle">
|
|
12
|
-
<dd-icon
|
|
11
|
+
<dd-icon
|
|
12
|
+
v-if="icon || status === 'finish'"
|
|
13
|
+
:name="icon || 'success'"
|
|
14
|
+
class="dd-step__circle-text"
|
|
15
|
+
/>
|
|
13
16
|
<text v-else class="dd-step__circle-text">{{ index + 1 }}</text>
|
|
14
17
|
</view>
|
|
15
18
|
</view>
|
|
@@ -22,7 +25,11 @@
|
|
|
22
25
|
<template v-else>
|
|
23
26
|
<view class="dd-step__head dd-step__head--vertical">
|
|
24
27
|
<view class="dd-step__circle" :style="circleStyle">
|
|
25
|
-
<dd-icon
|
|
28
|
+
<dd-icon
|
|
29
|
+
v-if="icon || status === 'finish'"
|
|
30
|
+
:name="icon || 'success'"
|
|
31
|
+
class="dd-step__circle-text"
|
|
32
|
+
/>
|
|
26
33
|
<text v-else class="dd-step__circle-text">{{ index + 1 }}</text>
|
|
27
34
|
</view>
|
|
28
35
|
<view
|
|
@@ -50,11 +57,14 @@ type StepStatus = 'wait' | 'process' | 'finish'
|
|
|
50
57
|
interface Props {
|
|
51
58
|
title?: string
|
|
52
59
|
description?: string
|
|
60
|
+
/** 圆点内图标(dd-icon 名称),传入后替代序号/完成对勾 */
|
|
61
|
+
icon?: string
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
const props = withDefaults(defineProps<Props>(), {
|
|
56
65
|
title: '',
|
|
57
66
|
description: '',
|
|
67
|
+
icon: '',
|
|
58
68
|
})
|
|
59
69
|
|
|
60
70
|
const ctx = inject<any>('ddSteps', null)
|
|
@@ -64,6 +74,8 @@ const direction = computed<'horizontal' | 'vertical'>(() =>
|
|
|
64
74
|
ctx ? ctx.direction.value : 'horizontal'
|
|
65
75
|
)
|
|
66
76
|
|
|
77
|
+
const size = computed<'sm' | 'md' | 'lg'>(() => (ctx ? ctx.size.value : 'md'))
|
|
78
|
+
|
|
67
79
|
const status = computed<StepStatus>(() => {
|
|
68
80
|
if (!ctx) return 'wait'
|
|
69
81
|
const active = ctx.active.value
|
|
@@ -73,23 +85,24 @@ const status = computed<StepStatus>(() => {
|
|
|
73
85
|
})
|
|
74
86
|
|
|
75
87
|
const isLast = computed(() => (ctx ? index === ctx.count.value - 1 : true))
|
|
76
|
-
const isFirst = computed(() => index === 0)
|
|
77
88
|
|
|
78
|
-
const activeColor = computed(() => (ctx ? ctx.activeColor.value : '
|
|
79
|
-
const inactiveColor = computed(() => (ctx ? ctx.inactiveColor.value : '
|
|
89
|
+
const activeColor = computed(() => (ctx ? ctx.activeColor.value : ''))
|
|
90
|
+
const inactiveColor = computed(() => (ctx ? ctx.inactiveColor.value : ''))
|
|
80
91
|
|
|
81
|
-
|
|
92
|
+
// 仅在外部传入自定义色时覆盖组件私有 CSS 变量,默认色由样式层 token 提供
|
|
93
|
+
const colorStyle = computed(() => {
|
|
94
|
+
const vars: Record<string, string> = {}
|
|
95
|
+
if (activeColor.value) vars['--dd-step-active'] = activeColor.value
|
|
96
|
+
if (inactiveColor.value) vars['--dd-step-inactive'] = inactiveColor.value
|
|
97
|
+
return vars
|
|
98
|
+
})
|
|
82
99
|
|
|
83
100
|
const circleStyle = computed(() => ({
|
|
84
|
-
background: isActive.value ? activeColor.value : '#2A2A2A',
|
|
85
|
-
color: isActive.value ? '#FFFFFF' : inactiveColor.value,
|
|
86
101
|
// z-index 统一取 libs/config/zIndex.js(圆点 base 档内 +1,盖住连接线)
|
|
87
102
|
zIndex: zIndexConfig.base + 1,
|
|
88
103
|
}))
|
|
89
104
|
|
|
90
|
-
// ponytail: 水平连接线整段按本步骤 status 着色,current/首个 wait 左半段颜色为近似值
|
|
91
105
|
const lineStyle = computed(() => ({
|
|
92
|
-
background: status.value === 'finish' ? activeColor.value : inactiveColor.value,
|
|
93
106
|
// z-index 统一取 libs/config/zIndex.js(连接线垫底取 base 档)
|
|
94
107
|
zIndex: zIndexConfig.base,
|
|
95
108
|
}))
|
|
@@ -100,6 +113,25 @@ const lineStyle = computed(() => ({
|
|
|
100
113
|
@import '../../scss/mixins';
|
|
101
114
|
|
|
102
115
|
.dd-step {
|
|
116
|
+
/* 组件私有变量:默认取主题 token,外部传 activeColor/inactiveColor 时由 :style 覆盖 */
|
|
117
|
+
--dd-step-active: var(--dd-primary, #{$dd-primary});
|
|
118
|
+
--dd-step-inactive: var(--dd-step-inactive-color, #{$dd-step-inactive-color});
|
|
119
|
+
--dd-step-circle-bg: var(--dd-surface-container-high, #{$dd-surface-container-high});
|
|
120
|
+
--dd-step-circle-fg: #{$dd-color-white};
|
|
121
|
+
/* 尺寸档位:圆点直径 + 圆点/标题/描述字号 */
|
|
122
|
+
--dd-step-circle-size: #{$dd-size-icon-md};
|
|
123
|
+
--dd-step-font-size: #{$dd-font-size-caption};
|
|
124
|
+
|
|
125
|
+
&--sm {
|
|
126
|
+
--dd-step-circle-size: #{$dd-size-icon-sm};
|
|
127
|
+
--dd-step-font-size: #{$dd-font-size-overline};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&--lg {
|
|
131
|
+
--dd-step-circle-size: #{$dd-size-icon-lg};
|
|
132
|
+
--dd-step-font-size: #{$dd-font-size-body};
|
|
133
|
+
}
|
|
134
|
+
|
|
103
135
|
&--horizontal {
|
|
104
136
|
flex: 1;
|
|
105
137
|
display: flex;
|
|
@@ -108,56 +140,79 @@ const lineStyle = computed(() => ({
|
|
|
108
140
|
min-width: 0;
|
|
109
141
|
}
|
|
110
142
|
|
|
143
|
+
/* 垂直:左侧圆点+连接线,右侧文字 */
|
|
144
|
+
&--vertical {
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: stretch;
|
|
147
|
+
}
|
|
148
|
+
|
|
111
149
|
&__head {
|
|
112
150
|
position: relative;
|
|
113
151
|
width: 100%;
|
|
114
|
-
height:
|
|
152
|
+
height: var(--dd-step-circle-size);
|
|
115
153
|
display: flex;
|
|
116
154
|
align-items: center;
|
|
117
155
|
justify-content: center;
|
|
118
156
|
|
|
119
157
|
&--vertical {
|
|
120
|
-
width:
|
|
158
|
+
width: var(--dd-step-circle-size);
|
|
121
159
|
height: auto;
|
|
122
160
|
flex-direction: column;
|
|
161
|
+
/* 最后一步无连接线时圆点仍需顶部对齐,否则会被 head 垂直居中 */
|
|
162
|
+
justify-content: flex-start;
|
|
123
163
|
align-self: stretch;
|
|
164
|
+
flex-shrink: 0;
|
|
124
165
|
}
|
|
125
166
|
}
|
|
126
167
|
|
|
127
168
|
&__line {
|
|
128
169
|
position: absolute;
|
|
129
170
|
top: 50%;
|
|
130
|
-
left:
|
|
131
|
-
|
|
171
|
+
left: 50%;
|
|
172
|
+
/* 延伸到下一个圆点圆心(各步骤等宽) */
|
|
173
|
+
right: -50%;
|
|
132
174
|
height: 1px;
|
|
175
|
+
background: var(--dd-step-inactive);
|
|
133
176
|
transform: translateY(-50%);
|
|
134
177
|
|
|
135
|
-
&--first {
|
|
136
|
-
left: 50%;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
178
|
&--vertical {
|
|
140
179
|
position: static;
|
|
141
180
|
transform: none;
|
|
142
181
|
width: 1px;
|
|
182
|
+
height: auto;
|
|
143
183
|
flex: 1;
|
|
144
184
|
min-height: 32rpx;
|
|
145
|
-
|
|
185
|
+
/* 不留底部间隙,让线接到下一个圆点 */
|
|
186
|
+
margin: $dd-space-1 0 0;
|
|
146
187
|
}
|
|
147
188
|
}
|
|
148
189
|
|
|
149
190
|
&__circle {
|
|
150
191
|
position: relative;
|
|
151
|
-
width:
|
|
152
|
-
height:
|
|
192
|
+
width: var(--dd-step-circle-size);
|
|
193
|
+
height: var(--dd-step-circle-size);
|
|
153
194
|
border-radius: $dd-radius-full;
|
|
154
195
|
@include dd-flex-center;
|
|
155
196
|
flex-shrink: 0;
|
|
197
|
+
background: var(--dd-step-circle-bg);
|
|
198
|
+
color: var(--dd-step-inactive);
|
|
156
199
|
@include dd-transition(all 0.3s ease);
|
|
157
200
|
}
|
|
158
201
|
|
|
202
|
+
/* 进行中/已完成:圆点取品牌色,文字取反白色 */
|
|
203
|
+
&--process &__circle,
|
|
204
|
+
&--finish &__circle {
|
|
205
|
+
background: var(--dd-step-active);
|
|
206
|
+
color: var(--dd-step-circle-fg);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* 连接线按下一步骤状态着色:仅已完成段为品牌色 */
|
|
210
|
+
&--finish &__line {
|
|
211
|
+
background: var(--dd-step-active);
|
|
212
|
+
}
|
|
213
|
+
|
|
159
214
|
&__circle-text {
|
|
160
|
-
font-size:
|
|
215
|
+
font-size: var(--dd-step-font-size);
|
|
161
216
|
font-weight: 700;
|
|
162
217
|
line-height: 1;
|
|
163
218
|
}
|
|
@@ -176,7 +231,7 @@ const lineStyle = computed(() => ({
|
|
|
176
231
|
}
|
|
177
232
|
|
|
178
233
|
&__title {
|
|
179
|
-
font-size:
|
|
234
|
+
font-size: var(--dd-step-font-size);
|
|
180
235
|
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
181
236
|
line-height: $dd-line-height-caption;
|
|
182
237
|
}
|
|
@@ -184,7 +239,7 @@ const lineStyle = computed(() => ({
|
|
|
184
239
|
&__desc {
|
|
185
240
|
display: block;
|
|
186
241
|
margin-top: $dd-space-1;
|
|
187
|
-
font-size:
|
|
242
|
+
font-size: var(--dd-step-font-size);
|
|
188
243
|
color: var(--dd-text-tertiary, #{$dd-text-tertiary});
|
|
189
244
|
line-height: 1.4;
|
|
190
245
|
}
|
|
@@ -13,6 +13,8 @@ interface Props {
|
|
|
13
13
|
direction?: 'horizontal' | 'vertical'
|
|
14
14
|
activeColor?: string
|
|
15
15
|
inactiveColor?: string
|
|
16
|
+
/** 圆点与文字尺寸档位 */
|
|
17
|
+
size?: 'sm' | 'md' | 'lg'
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -20,6 +22,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
20
22
|
direction: 'horizontal',
|
|
21
23
|
activeColor: '',
|
|
22
24
|
inactiveColor: '',
|
|
25
|
+
size: 'md',
|
|
23
26
|
})
|
|
24
27
|
|
|
25
28
|
const count = ref(0)
|
|
@@ -34,8 +37,9 @@ function register(): number {
|
|
|
34
37
|
provide('ddSteps', {
|
|
35
38
|
active: computed(() => props.active),
|
|
36
39
|
direction: computed(() => props.direction),
|
|
37
|
-
activeColor: computed(() => props.activeColor
|
|
38
|
-
inactiveColor: computed(() => props.inactiveColor
|
|
40
|
+
activeColor: computed(() => props.activeColor),
|
|
41
|
+
inactiveColor: computed(() => props.inactiveColor),
|
|
42
|
+
size: computed(() => props.size),
|
|
39
43
|
count,
|
|
40
44
|
register,
|
|
41
45
|
})
|