ldc-showroom/components/NavigationMenu.vue
2024-01-17 09:38:51 +01:00

119 lines
3.3 KiB
Vue

<template>
<div class="container">
<div class="row py-4">
<div class="col arrow pe-3 d-flex align-items-center justify-content-end">
<button
class="rounded-pill btn btn-primary px-4 py-1"
:disabled="previousRange === null"
:title="`Voir les produits de la gamme ${previousRange?.name}`"
data-bs-toggle="tooltip"
@click="gotoRange(previousRange)"
>
<FontAwesomeIcon :icon="['fas', 'arrow-left']" />
</button>
</div>
<div class="col home text-center px-3">
<button
class="rounded-pill btn btn-primary px-4 py-1"
title="Voir les gammes"
data-bs-toggle="tooltip"
@click="gotoBrand(activeBrand)"
>
<FontAwesomeIcon :icon="['fas', 'house']" />
</button>
</div>
<div class="col arrow ps-3 d-flex align-items-center justify-content-start">
<button
class="rounded-pill btn btn-primary px-4 py-1"
:disabled="nextRange === null"
:title="`Voir les produits de la gamme ${nextRange?.name}`"
data-bs-toggle="tooltip"
@click="gotoRange(nextRange)"
>
<FontAwesomeIcon :icon="['fas', 'arrow-right']" />
</button>
</div>
</div>
</div>
</template>
<script lang="ts">
// eslint-disable-next-line import/named
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { defineComponent } from "vue";
export default defineComponent({
name: "NavigationMenu",
components: { FontAwesomeIcon },
data(): {
brands: Array<TypeRange>;
nextRange: TypeRange | null;
previousRange: TypeRange | null;
activeRange: TypeRange | null;
activeBrand: TypeBrand | null;
} {
return {
brands: [],
nextRange: null,
previousRange: null,
activeRange: null,
activeBrand: null,
};
},
watch: {
$route() {
this.refreshData();
},
},
mounted() {
this.refreshData();
},
methods: {
refreshData() {
this.activeBrand = useAppStore().activeBrand;
this.activeRange = useAppStore().activeRange;
this.nextRange = useAppStore().getNextRange();
this.previousRange = useAppStore().getPreviousRange();
},
gotoBrand(activeBrand: TypeBrand|null) {
if(!activeBrand) {
return;
}
useAppStore().setActiveRange(null);
navigateTo(useLocaleRoute()({"name": "brands-slug", "params": {"slug": activeBrand.slug}}));
},
gotoRange(range: TypeRange|null) {
if(!range) {
return;
}
useAppStore().setActiveRange(range);
navigateTo(useLocaleRoute()({"name": "ranges-slug", "params": {"slug": range.slug}}));
}
}
});
</script>
<style lang="scss" scoped>
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/vendor/rfs";
.arrow > button {
@include media-breakpoint-up(md) {
@include rfs(1.5rem, font-size);
}
@include media-breakpoint-up(xxl) {
@include rfs(4rem, font-size);
}
}
.home > button {
@include media-breakpoint-up(md) {
@include rfs(2rem, font-size);
}
@include media-breakpoint-up(xxl) {
@include rfs(4rem, font-size);
}
}
</style>