ldc-showroom/components/layout/AppFooter.vue
2024-01-31 16:59:54 +01:00

152 lines
4.5 KiB
Vue

<template>
<footer
id="footer"
ref="footer"
class="container-fluid flex-grow-0"
:style="`background-color: ${activeBrand?.color} !important`"
>
<div v-if="route.name !== 'index'" class="row">
<div class="col-12 col-md-4 d-flex justify-content-center align-items-center">
<span
class="fw-bold d-block px-5"
:style="{
'color': activeBrand ? getContrastYIQ(activeBrand.color) : 'inherit'
}"
>
{{ t('discover_other_brands') }}
</span>
</div>
<div class="col col-md-8">
<Swiper
class="z-0"
:scrollbar="{
hide: true,
}"
:modules="modules"
:space-between="30"
:breakpoints="{
'300': {
slidesPerView: 2,
spaceBetween: 20,
},
'560': {
slidesPerView: 4,
spaceBetween: 40,
},
}"
>
<SwiperSlide v-for="(brand,brandIndex) of brands" :key="brandIndex">
<NuxtLinkLocale
class="swiper-slide"
:to="`/brands/${brand.slug}`"
data-bs-toggle="tooltip"
:title="`Voir les gammes de la marque ${transField(brand, 'name')}`"
@click.prevent="gotoBrand(brand)"
>
<img
class="img-fluid"
:src="`/data/${brand.picture}`"
:alt="`Marque ${transField(brand, 'name')}`"
:title="`Le logo de la marque ${transField(brand, 'name')}`"
data-bs-toggle="tooltip"
>
</NuxtLinkLocale>
</SwiperSlide>
</Swiper>
</div>
</div>
<div
v-if="versions.isDebug"
class="row"
:style="{
'color': activeBrand ? getContrastYIQ(activeBrand.color) : 'inherit'
}"
>
<div class="col text-center">
<span>{{ appInfo.licence }}</span>&nbsp;-&nbsp;
<span>{{ appInfo.name }}</span>&nbsp;-&nbsp;
<span>{{ appInfo.version }}</span>&nbsp;-&nbsp;
<span class="fw-bold">UWIL</span>
© {{ (new Date()).getFullYear() }}
</div>
</div>
</footer>
</template>
<script lang="ts">
import { Scrollbar } from "swiper/modules";
import { Swiper, SwiperSlide } from "swiper/vue";
import { defineComponent } from "vue";
import { useRoute, type RouteLocationNormalizedLoaded } from "vue-router";
import ToolboxHelper from "~/classes/ToolboxHelper";
import type { appInfo } from "~/electron/main";
import { useAppStore } from "~/stores/useAppStore";
import bsTooltips from "~/vueModules/bsTooltips";
export default defineComponent({
name: "AppFooter",
components: {Swiper, SwiperSlide},
data(): {
locale: string;
versions: typeof window.versions;
appInfo: typeof appInfo;
route: RouteLocationNormalizedLoaded;
brands: Array<TypeBrand>;
activeBrand: TypeBrand|null;
modules: Array<{
name: string;
}>;
} {
return {
locale: "",
route: useRoute(),
versions: window.versions,
appInfo: {
version: "",
name: "",
licence: ""
},
brands: [],
activeBrand: null,
modules: [Scrollbar],
};
},
watch: {
$route(to: RouteLocationNormalizedLoaded) {
if(to.name?.toString().startsWith("index")) {
// * Reset active Brand on main page
useAppStore().setActiveBrand(null);
}
this.activeBrand = useAppStore().activeBrand;
},
},
mounted() {
this.$nextTick(() => bsTooltips.methods.initTooltips());
window.ipcRendererObject.getAppInfo().then((appInfo) => {this.appInfo = appInfo;});
this.brands = useAppStore().data.brands();
this.activeBrand = useAppStore().activeBrand;
const { locale } = useAppStore().getI18n();
this.locale = locale;
},
methods: {
t(text: string, params: Record<string,string> = {}, localeToUse: string|null = null): string {
return ToolboxHelper.trans(text, params, localeToUse);
},
transField(model: Typei18nModel, field: Typei18nFieldList) {
return ToolboxHelper.getTranslatableField(model, field);
},
getContrastYIQ(hexcolor: string): string {
return ToolboxHelper.getContrastYIQ(hexcolor);
},
gotoBrand(brand: TypeBrand) {
useAppStore().setActiveBrand(brand);
navigateTo(useLocaleRoute()({"name": "brands-slug", "params": {"slug": this.transField(brand, "slug")}}));
}
}
});
</script>
<style lang="scss">
@import "swiper/scss";
@import "swiper/scss/scrollbar";
</style>