Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 44 additions & 26 deletions components/Step.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<v-card class="pa-5">
<v-row align="center" @click="set_current_step(step_index)">
<v-col cols="auto">
<v-stepper-content :step="step_index + 1">
<v-row
align="center"
class="step-container"
@click="set_current_step(step_index)"
>
<v-col cols="auto" class="icon-container">
<v-icon
v-if="current_step_index > step_index"
icon="mdi-check-circle"
Expand All @@ -18,43 +22,43 @@
color="grey"
/>
</v-col>
<v-col cols="auto">
<p class="font-weight-bold">
<v-col class="title-container">
<p class="step-title font-weight-bold">
{{ steps[step_index].step_title }}
</p>
</v-col>
<v-col
v-if="
steps[step_index].chips.length && current_step_index >= step_index
"
class="chips-container"
>
<v-chip
v-for="(chip, chip_index) in steps[step_index].chips"
:key="chip_index"
class="step-chip"
>
{{ chip }}
</v-chip>
</v-col>
</v-row>
<Transition name="slide-fade">
<v-col v-if="step_index == current_step_index">
<component
:is="steps[step_index].component.component_name"
v-bind="steps[step_index].component.component_options"
@update_values="update_values_event"
@increment_step="increment_step()"
@decrement_step="decrement_step()"
/>
</v-col>
</Transition>
</v-card>
<component
v-if="step_index == current_step_index"
:key="step_index"
:is="steps[step_index].component.component_name"
v-bind="steps[step_index].component.component_options"
@update_values="update_values_event"
@increment_step="increment_step"
@decrement_step="decrement_step"
/>
</v-stepper-content>
</template>

<script setup>
const props = defineProps({
step_index: { type: Number, required: true },
})
const { step_index } = props

const stepper_tree = inject("stepper_tree")
const { current_step_index, steps } = toRefs(stepper_tree)

Expand All @@ -78,17 +82,31 @@
</script>

<style scoped>
.slide-fade-enter-active {
transition: all 0.5s ease-out;
.step-container {
margin-bottom: 16px;
padding: 8px;
}

.icon-container {
display: flex;
justify-content: center;
align-items: center;
}

.title-container {
margin-left: 8px;
}

.step-title {
margin: 0;
}

.slide-fade-leave-active {
transition: all 0.5s ease-in;
.chips-container {
display: flex;
gap: 4px;
}

.slide-fade-enter-from,
.slide-fade-leave-to {
transform: translateX(50px);
opacity: 0;
.step-chip {
background-color: #f5f5f5;
}
</style>
23 changes: 17 additions & 6 deletions components/Stepper.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
<template>
<v-card class="card">
<div v-for="(step, index) in steps" :key="index" class="pa-3">
<Step :step_index="index" />
</div>
</v-card>
<v-stepper-vertical v-model="current_step_index" class="stepper-container">
<v-stepper-items>
<Step v-for="(step, index) in steps" :key="step" :step_index="index" />
</v-stepper-items>
</v-stepper-vertical>
</template>

<script setup>
const stepper_tree = inject("stepper_tree")
const { steps } = stepper_tree
const { steps, current_step_index } = toRefs(stepper_tree)
</script>

<style scoped>
.stepper-container {
max-width: 600px;
margin: 0 auto;
padding: 16px;
background-color: #f9f9f9;
border-radius: 8px;
border: 1px solid #e0e0e0;
}
</style>
5 changes: 2 additions & 3 deletions test/components/FileSelector.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe("FileSelector.vue", async () => {
})

await flushPromises()
expect(wrapper.componentVM.files).toEqual(files)
expect(wrapper.componentVM.props.files).toEqual(files)
expect(wrapper.emitted()).toHaveProperty("update_values")
expect(wrapper.emitted().update_values).toHaveLength(1)
expect(wrapper.emitted().update_values[0][0]).toEqual({
Expand All @@ -123,8 +123,7 @@ describe("FileSelector.vue", async () => {
await flushPromises()

const file_uploader = wrapper.findComponent(FileUploader)
console.log("wrapper", wrapper)
expect(wrapper.vm.files).toEqual(files)
expect(wrapper.vm.props.files).toEqual(files)
const upload_files = vi.spyOn(file_uploader.vm, "upload_files")
expect(upload_files).not.toHaveBeenCalled()
})
Expand Down
Loading