Skip to content

Commit 4941bc9

Browse files
committed
TreatmentConsultant - Add auto advance
1 parent 52fe4cf commit 4941bc9

2 files changed

Lines changed: 34 additions & 16 deletions

File tree

app/components/03.organisms/treatment-consultant/TreatmentConsultant.vue

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<!-- Header -->
66
<div v-motion :initial="{ opacity: 0, y: 20 }" :enter="{ opacity: 1, y: 0 }" class="colour-finder__header">
77
<EyebrowText text-content="Interactive Tool" font-size="large" />
8-
<p class="colour-finder__label">Interactive Tool</p>
98
<h1 class="colour-finder__title">
109
Find Your
1110
<span class="colour-finder__title-highlight">Perfect Look</span>
@@ -69,7 +68,7 @@
6968
v-for="ht in hairTypes"
7069
:key="ht.id"
7170
:class="['colour-finder__option', { 'colour-finder__option--selected': hairType === ht.id }]"
72-
@click="hairType = ht.id"
71+
@click="selectHairType(ht.id)"
7372
>
7473
<div class="colour-finder__option-pattern">{{ ht.pattern }}</div>
7574
<span class="colour-finder__option-label">{{ ht.label }}</span>
@@ -88,7 +87,7 @@
8887
'colour-finder__option colour-finder__option--colour',
8988
{ 'colour-finder__option--selected': naturalColour === nc.id },
9089
]"
91-
@click="naturalColour = nc.id"
90+
@click="selectNaturalColour(nc.id)"
9291
>
9392
<div class="colour-finder__option-swatch" :style="{ backgroundColor: nc.colour }">
9493
<NuxtImg
@@ -123,7 +122,7 @@
123122
dc.id === 'none' ? 'colour-finder__option--no-change' : 'colour-finder__option--colour',
124123
{ 'colour-finder__option--selected': desiredColour === dc.id },
125124
]"
126-
@click="desiredColour = dc.id"
125+
@click="selectDesiredColour(dc.id)"
127126
>
128127
<template v-if="dc.id === 'none'">
129128
<div class="colour-finder__option-none-icon">
@@ -342,12 +341,13 @@
342341
</Transition>
343342

344343
<!-- Navigation Buttons -->
345-
<div v-if="step < 4" class="colour-finder__navigation">
344+
<div v-if="step < 4 && (step > 0 || !autoAdvance)" class="colour-finder__navigation">
346345
<button v-if="step > 0" class="colour-finder__nav-button colour-finder__nav-button--back" @click="back">
347346
<Icon name="lucide:arrow-left" class="colour-finder__nav-icon" />
348347
Back
349348
</button>
350349
<button
350+
v-if="!autoAdvance"
351351
:disabled="!canProceed"
352352
:class="[
353353
'colour-finder__nav-button colour-finder__nav-button--next',
@@ -367,6 +367,14 @@
367367
<script setup lang="ts">
368368
import { ref, computed } from "vue";
369369
370+
// ─── Props ────────────────────────────────────────────────────────────────────
371+
const props = defineProps({
372+
autoAdvance: {
373+
type: Boolean,
374+
default: false,
375+
},
376+
});
377+
370378
// ─── Types ────────────────────────────────────────────────────────────────────
371379
type HairType = "straight" | "wavy" | "curly" | "coily";
372380
type NaturalColour = "light-blonde" | "dark-blonde" | "light-brown" | "dark-brown" | "red" | "black" | "grey-white";
@@ -444,7 +452,7 @@ const naturalColours: { id: NaturalColour; label: string; colour: string; image:
444452
445453
// 'none' first as requested
446454
const desiredColours: { id: DesiredColour; label: string; colour?: string; image?: string; textDark?: boolean }[] = [
447-
{ id: "none", label: "No Colour Treatment" },
455+
{ id: "none", label: "I don't want a colour change" },
448456
{
449457
id: "blonde",
450458
label: "Blonde",
@@ -479,9 +487,9 @@ const desiredColours: { id: DesiredColour; label: string; colour?: string; image
479487
const treatments: Treatment[] = [
480488
{
481489
id: "none",
482-
label: "No Treatment",
490+
label: "I don't want any treatments",
483491
icon: "lucide:minus-circle",
484-
description: "Skip to results",
492+
description: "Go straight to your results",
485493
notes: [],
486494
},
487495
{
@@ -1151,6 +1159,7 @@ const selectedTreatments = ref<TreatmentId[]>([]);
11511159
function toggleTreatment(id: TreatmentId) {
11521160
if (id === "none") {
11531161
selectedTreatments.value = selectedTreatments.value.includes("none") ? [] : ["none"];
1162+
if (props.autoAdvance) next();
11541163
return;
11551164
}
11561165
const idx = selectedTreatments.value.indexOf(id);
@@ -1159,6 +1168,7 @@ function toggleTreatment(id: TreatmentId) {
11591168
} else {
11601169
selectedTreatments.value = selectedTreatments.value.filter((t) => t !== "none");
11611170
selectedTreatments.value.push(id);
1171+
if (props.autoAdvance) next();
11621172
}
11631173
}
11641174
@@ -1202,6 +1212,21 @@ function reset() {
12021212
selectedTreatments.value = [];
12031213
}
12041214
1215+
function selectHairType(id: HairType) {
1216+
hairType.value = id;
1217+
if (props.autoAdvance) next();
1218+
}
1219+
1220+
function selectNaturalColour(id: NaturalColour) {
1221+
naturalColour.value = id;
1222+
if (props.autoAdvance) next();
1223+
}
1224+
1225+
function selectDesiredColour(id: DesiredColour) {
1226+
desiredColour.value = id;
1227+
if (props.autoAdvance) next();
1228+
}
1229+
12051230
// ─── Summary Items ────────────────────────────────────────────────────────────
12061231
const summaryItems = computed(() => {
12071232
const nc = naturalColours.find((n) => n.id === naturalColour.value);
@@ -1361,7 +1386,6 @@ const suitabilityConfig: Record<Suitability, { icon: string; label: string }> =
13611386
color: var(--_muted-foreground);
13621387
transition: all var(--_transition-duration) ease;
13631388
cursor: pointer;
1364-
13651389
}
13661390
13671391
.colour-finder__progress-button--active {
@@ -1385,7 +1409,6 @@ const suitabilityConfig: Record<Suitability, { icon: string; label: string }> =
13851409
justify-content: center;
13861410
font-weight: 500;
13871411
border-radius: 50%;
1388-
13891412
}
13901413
13911414
.colour-finder__progress-indicator--completed {
@@ -1547,7 +1570,6 @@ const suitabilityConfig: Record<Suitability, { icon: string; label: string }> =
15471570
text-transform: uppercase;
15481571
color: var(--_muted-foreground);
15491572
transition: color var(--_transition-duration) ease;
1550-
15511573
}
15521574
15531575
.colour-finder__option-sublabel {
@@ -1796,7 +1818,6 @@ const suitabilityConfig: Record<Suitability, { icon: string; label: string }> =
17961818
letter-spacing: 0.08em;
17971819
text-transform: uppercase;
17981820
font-weight: 500;
1799-
18001821
}
18011822
18021823
.colour-finder__compat-badge--ok {
@@ -1850,7 +1871,6 @@ const suitabilityConfig: Record<Suitability, { icon: string; label: string }> =
18501871
inline-size: 100%;
18511872
block-size: 100%;
18521873
object-fit: cover;
1853-
18541874
}
18551875
}
18561876
@@ -1907,7 +1927,6 @@ const suitabilityConfig: Record<Suitability, { icon: string; label: string }> =
19071927
border-radius: var(--_border-radius);
19081928
cursor: pointer;
19091929
border: 1px solid transparent;
1910-
19111930
}
19121931
19131932
.colour-finder__button--primary {
@@ -1953,7 +1972,6 @@ const suitabilityConfig: Record<Suitability, { icon: string; label: string }> =
19531972
inline-size: 1rem;
19541973
block-size: 1rem;
19551974
}
1956-
19571975
}
19581976
}
19591977

app/pages/ui/services/treatment-consultant.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</LayoutRow>
88

99
<LayoutRow tag="div" variant="content" :style-class-passthrough="['mbe-20']">
10-
<TreatmentConsultant />
10+
<TreatmentConsultant :auto-advance="true" />
1111
</LayoutRow>
1212
</template>
1313
</NuxtLayout>

0 commit comments

Comments
 (0)