chore: Update wizard component UI (#12358)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
import Icon from 'next/icon/Icon.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
items: {
|
items: {
|
||||||
@@ -12,62 +13,67 @@ const props = defineProps({
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const activeIndex = computed(() => {
|
const activeIndex = computed(() => {
|
||||||
return props.items.findIndex(i => i.route === route.name);
|
const index = props.items.findIndex(i => i.route === route.name);
|
||||||
|
return index === -1 ? 0 : index;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isActive = item => {
|
const steps = computed(() =>
|
||||||
return props.items.indexOf(item) === activeIndex.value;
|
props.items.map((item, index) => {
|
||||||
};
|
const isActive = index === activeIndex.value;
|
||||||
|
const isOver = index < activeIndex.value;
|
||||||
const isOver = item => {
|
return {
|
||||||
return props.items.indexOf(item) < activeIndex.value;
|
...item,
|
||||||
|
index,
|
||||||
|
isActive,
|
||||||
|
isOver,
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<transition-group tag="div">
|
<transition-group tag="div">
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in items"
|
v-for="step in steps"
|
||||||
:key="item.route"
|
:key="step.route"
|
||||||
class="cursor-pointer flex items-start gap-6 relative after:content-[''] after:absolute after:w-0.5 after:h-full after:top-5 ltr:after:left-4 rtl:after:right-4 before:content-[''] before:absolute before:w-0.5 before:h-4 before:top-0 before:left-4 rtl:before:right-4 last:after:hidden last:before:hidden"
|
class="cursor-pointer flex items-start gap-6 relative after:content-[''] after:absolute after:w-0.5 after:h-full after:top-5 ltr:after:left-4 rtl:after:right-4 before:content-[''] before:absolute before:w-0.5 before:h-4 before:top-0 before:left-4 rtl:before:right-4 last:after:hidden last:before:hidden after:bg-n-slate-3 before:bg-n-slate-3"
|
||||||
:class="
|
|
||||||
isOver(item)
|
|
||||||
? 'after:bg-n-blue-9 before:bg-n-blue-9'
|
|
||||||
: 'after:bg-n-weak before:bg-n-weak'
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
|
<!-- Circle -->
|
||||||
<div
|
<div
|
||||||
class="rounded-2xl flex-shrink-0 size-8 flex items-center justify-center left-2 outline outline-2 leading-4 z-10 top-5 bg-n-background"
|
class="rounded-2xl flex-shrink-0 size-8 border-2 border-n-slate-3 flex items-center justify-center left-2 leading-4 z-10 top-5 transition-all duration-300 ease-in-out"
|
||||||
:class="
|
:class="{
|
||||||
isActive(item) || isOver(item) ? 'outline-n-blue-9' : 'outline-n-weak'
|
'bg-n-slate-3': step.isActive || step.isOver,
|
||||||
"
|
'bg-n-background': !step.isActive && !step.isOver,
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="text-xs font-bold"
|
v-if="!step.isOver"
|
||||||
:class="
|
:key="'num-' + step.index"
|
||||||
isActive(item) || isOver(item)
|
class="text-xs font-bold transition-colors duration-300"
|
||||||
? 'text-n-blue-11'
|
:class="step.isActive ? 'text-n-blue-11' : 'text-n-slate-11'"
|
||||||
: 'text-n-slate-11'
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
{{ index + 1 }}
|
{{ step.index + 1 }}
|
||||||
</span>
|
</span>
|
||||||
|
<Icon
|
||||||
|
v-else
|
||||||
|
:key="'check-' + step.index"
|
||||||
|
icon="i-lucide-check"
|
||||||
|
class="text-n-slate-11 size-4"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
<div class="flex flex-col items-start gap-1.5 pb-10 pt-1">
|
<div class="flex flex-col items-start gap-1.5 pb-10 pt-1">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<h3
|
<h3
|
||||||
class="text-sm font-medium overflow-hidden whitespace-nowrap mt-0.5 text-ellipsis leading-tight"
|
class="text-sm font-medium overflow-hidden whitespace-nowrap mt-0.5 text-ellipsis leading-tight"
|
||||||
:class="
|
:class="step.isActive ? 'text-n-blue-11' : 'text-n-slate-12'"
|
||||||
isActive(item) || isOver(item)
|
|
||||||
? 'text-n-blue-11'
|
|
||||||
: 'text-n-slate-12'
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
{{ item.title }}
|
{{ step.title }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<p class="m-0 mt-1.5 text-sm text-n-slate-11">
|
<p class="m-0 mt-1.5 text-sm text-n-slate-11">
|
||||||
{{ item.body }}
|
{{ step.body }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user