Skip to content

Commit 0d0ef5b

Browse files
committed
fix(stepper): Fix the stepper's animation & style
1 parent 9393b9d commit 0d0ef5b

File tree

2 files changed

+62
-31
lines changed

2 files changed

+62
-31
lines changed

components/Step.vue

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<template>
2-
<v-card class="pa-5">
3-
<v-row align="center" @click="set_current_step(step_index)">
4-
<v-col cols="auto">
2+
<v-stepper-content :step="step_index + 1">
3+
<v-row
4+
align="center"
5+
class="step-container"
6+
@click="set_current_step(step_index)"
7+
>
8+
<v-col cols="auto" class="icon-container">
59
<v-icon
610
v-if="current_step_index > step_index"
711
icon="mdi-check-circle"
@@ -18,43 +22,45 @@
1822
color="grey"
1923
/>
2024
</v-col>
21-
<v-col cols="auto">
22-
<p class="font-weight-bold">
25+
<v-col class="title-container">
26+
<p class="step-title font-weight-bold">
2327
{{ steps[step_index].step_title }}
2428
</p>
2529
</v-col>
2630
<v-col
2731
v-if="
2832
steps[step_index].chips.length && current_step_index >= step_index
2933
"
34+
class="chips-container"
3035
>
3136
<v-chip
3237
v-for="(chip, chip_index) in steps[step_index].chips"
3338
:key="chip_index"
39+
class="step-chip"
3440
>
3541
{{ chip }}
3642
</v-chip>
3743
</v-col>
3844
</v-row>
39-
<Transition name="slide-fade">
40-
<v-col v-if="step_index == current_step_index">
41-
<component
42-
:is="steps[step_index].component.component_name"
43-
v-bind="steps[step_index].component.component_options"
44-
@update_values="update_values_event"
45-
@increment_step="increment_step()"
46-
@decrement_step="decrement_step()"
47-
/>
48-
</v-col>
45+
<Transition name="slide-fade" mode="out-in">
46+
<component
47+
v-if="step_index == current_step_index"
48+
:key="step_index"
49+
:is="steps[step_index].component.component_name"
50+
v-bind="steps[step_index].component.component_options"
51+
@update_values="update_values_event"
52+
@increment_step="increment_step"
53+
@decrement_step="decrement_step"
54+
/>
4955
</Transition>
50-
</v-card>
56+
</v-stepper-content>
5157
</template>
5258

5359
<script setup>
5460
const props = defineProps({
5561
step_index: { type: Number, required: true },
5662
})
57-
const { step_index } = props
63+
5864
const stepper_tree = inject("stepper_tree")
5965
const { current_step_index, steps } = toRefs(stepper_tree)
6066
@@ -78,17 +84,31 @@
7884
</script>
7985

8086
<style scoped>
81-
.slide-fade-enter-active {
82-
transition: all 0.5s ease-out;
87+
.step-container {
88+
margin-bottom: 16px;
89+
padding: 8px;
90+
}
91+
92+
.icon-container {
93+
display: flex;
94+
justify-content: center;
95+
align-items: center;
96+
}
97+
98+
.title-container {
99+
margin-left: 8px;
100+
}
101+
102+
.step-title {
103+
margin: 0;
83104
}
84105
85-
.slide-fade-leave-active {
86-
transition: all 0.5s ease-in;
106+
.chips-container {
107+
display: flex;
108+
gap: 4px;
87109
}
88110
89-
.slide-fade-enter-from,
90-
.slide-fade-leave-to {
91-
transform: translateX(50px);
92-
opacity: 0;
111+
.step-chip {
112+
background-color: #f5f5f5;
93113
}
94114
</style>

components/Stepper.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
<template>
2-
<v-card class="card">
3-
<div v-for="(step, index) in steps" :key="index" class="pa-3">
4-
<Step :step_index="index" />
5-
</div>
6-
</v-card>
2+
<v-stepper-vertical v-model="current_step_index" class="stepper-container">
3+
<v-stepper-items>
4+
<Step v-for="(step, index) in steps" :key="index" :step_index="index" />
5+
</v-stepper-items>
6+
</v-stepper-vertical>
77
</template>
88

99
<script setup>
1010
const stepper_tree = inject("stepper_tree")
11-
const { steps } = stepper_tree
11+
const { steps, current_step_index } = toRefs(stepper_tree)
1212
</script>
13+
14+
<style scoped>
15+
.stepper-container {
16+
max-width: 600px;
17+
margin: 0 auto;
18+
padding: 16px;
19+
background-color: #f9f9f9;
20+
border-radius: 8px;
21+
border: 1px solid #e0e0e0;
22+
}
23+
</style>

0 commit comments

Comments
 (0)