258 lines
7.2 KiB
Vue
258 lines
7.2 KiB
Vue
<template>
|
|
<div
|
|
class="historical-milestones-slider-part position-relative"
|
|
ref="historicalMilestoneSlider"
|
|
>
|
|
<!-- Historical Milestone Details -->
|
|
<div class="historical-milestone-details">
|
|
<!-- Text part of the milestone -->
|
|
<img
|
|
v-if="currentHistoricalMilestone.picture"
|
|
class="position-absolute picture"
|
|
:src="String(currentHistoricalMilestone.picture)"
|
|
:title="String(currentHistoricalMilestone.picture_title)"
|
|
:alt="String(currentHistoricalMilestone.picture_alt)"
|
|
>
|
|
<div class="z-3 position-relative text-primary text-center historical-milestone-content">
|
|
<div class="row justify-content-end">
|
|
<div class="col-12 col-lg-7">
|
|
<p class="year fw-bold text-quad mb-5">
|
|
{{ currentHistoricalMilestone.year }}
|
|
</p>
|
|
</div>
|
|
<div class="col-12 col-lg-4 text-lg-start d-flex flex-column justify-content-end">
|
|
<div class="slide-content mx-auto mx-lg-0 p-lg-0 w-fit rounded p-3">
|
|
<p class="fw-bold fs-5">
|
|
{{ currentHistoricalMilestone.title }}
|
|
</p>
|
|
<p v-if="currentHistoricalMilestone.text">
|
|
{{ currentHistoricalMilestone.text }}
|
|
</p>
|
|
</div>
|
|
<a
|
|
v-if="currentHistoricalMilestone.button_status"
|
|
class="btn btn-quad rounded-5 mt-3 text-white"
|
|
:href="String(currentHistoricalMilestone.button_url)"
|
|
:target="currentHistoricalMilestone.button_new_tab ? `_blank` : ``"
|
|
>{{ currentHistoricalMilestone.button_label }}</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Historical Milestone Years Slider -->
|
|
<div
|
|
class="swiper swiper-historical-milestone w-75"
|
|
id="historical-milestone-slider"
|
|
>
|
|
<div
|
|
class="swiper-wrapper py-3"
|
|
ref="historicalMilestoneSliderWrapper"
|
|
>
|
|
<div
|
|
class="swiper-slide w-fit"
|
|
v-for="(historicalMilestone, eventIndex) in historicalMilestoneModels"
|
|
:key="eventIndex"
|
|
:id="`historical-milestone-${eventIndex}`"
|
|
tabindex="0"
|
|
>
|
|
<div :class="historicalMilestone === currentHistoricalMilestone ? `tilde-quad` : `tilde-white`" />
|
|
<p :class="`position-relative ${historicalMilestone === currentHistoricalMilestone ? 'text-quad fw-bold' : 'text-secondary'}`">
|
|
{{ historicalMilestone.year }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import Swiper from "swiper";
|
|
import { Keyboard } from "swiper/modules";
|
|
import { defineComponent } from "vue";
|
|
import route from "../../modules/route";
|
|
|
|
export default defineComponent({
|
|
name: "HistoricalMilestonesSliderComponent",
|
|
mixins: [route],
|
|
data(): {
|
|
historicalMilestoneModels: LaravelModelList;
|
|
staticHistoricalMilestoneModels: LaravelModelList;
|
|
currentHistoricalMilestone: LaravelModel;
|
|
slider: HTMLElement;
|
|
swiper: Swiper|null;
|
|
swiperPics: Swiper|null;
|
|
swiperAutoplay: boolean;
|
|
} {
|
|
return {
|
|
historicalMilestoneModels: [],
|
|
staticHistoricalMilestoneModels: [],
|
|
currentHistoricalMilestone: {
|
|
id: 0
|
|
},
|
|
slider: document.createElement("div"),
|
|
swiper: null,
|
|
swiperPics: null,
|
|
swiperAutoplay: true,
|
|
};
|
|
},
|
|
computed: {},
|
|
mounted() {
|
|
const json = String(this.$attrs.json ?? "{}"),
|
|
data = JSON.parse(json);
|
|
|
|
this.historicalMilestoneModels = data.historicalMilestoneModels;
|
|
this.staticHistoricalMilestoneModels = [...this.historicalMilestoneModels.values()];
|
|
this.currentHistoricalMilestone = this.historicalMilestoneModels[0];
|
|
this.slider = this.$refs.historicalMilestoneSlider as HTMLElement;
|
|
|
|
this.$nextTick(() => {
|
|
this.initSwiper();
|
|
});
|
|
|
|
},
|
|
methods: {
|
|
/** Init ranges slider */
|
|
initSwiper() {
|
|
this.swiper = new Swiper(".swiper-historical-milestone", {
|
|
modules: [Keyboard],
|
|
grabCursor: true,
|
|
slidesPerView: "auto",
|
|
spaceBetween: 60,
|
|
centeredSlides: true,
|
|
slideToClickedSlide: true,
|
|
keyboard: {
|
|
enabled: true,
|
|
},
|
|
on: {
|
|
slideChangeTransitionEnd: () => {
|
|
this.getCurrentMilestone();
|
|
}
|
|
},
|
|
breakpoints: {
|
|
992: {
|
|
centeredSlides: false,
|
|
watchOverflow: false,
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/** Get the current milestone */
|
|
getCurrentMilestone() {
|
|
let currentSlide = this.slider.querySelector(".swiper-slide-active") as HTMLElement;
|
|
if (!currentSlide) {
|
|
return;
|
|
}
|
|
let milestoneId = parseInt(String(currentSlide.id).replace("historical-milestone-", ""));
|
|
this.currentHistoricalMilestone = this.historicalMilestoneModels[milestoneId];
|
|
this.$nextTick(() => {
|
|
this.swiperPics?.updateSlides();
|
|
this.swiperPics?.slideTo(0);
|
|
this.swiperPics?.autoplay.start();
|
|
});
|
|
},
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
// Bootstrap reimport to use breakpoints
|
|
@import "bootstrap/scss/functions";
|
|
@import "bootstrap/scss/variables";
|
|
@import "bootstrap/scss/mixins";
|
|
@import "../../../sass/fo/utilities/variables";
|
|
|
|
.historical-milestones-slider-part {
|
|
|
|
.swiper-wrapper:before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 35%;
|
|
left: 1rem;
|
|
border-top: 1px solid black;
|
|
background: black;
|
|
width: 99999%;
|
|
transform: translateY(-50%);
|
|
}
|
|
|
|
.picture {
|
|
transform: rotate(-15deg);
|
|
max-height: 70%;
|
|
z-index: 0;
|
|
top: 3rem;
|
|
left: -3rem;
|
|
|
|
@include media-breakpoint-up(lg) {
|
|
left: 0rem;
|
|
}
|
|
}
|
|
|
|
.year {
|
|
font-size: 6rem;
|
|
|
|
@include media-breakpoint-up(lg) {
|
|
font-size: 18rem;
|
|
}
|
|
}
|
|
|
|
.slide-content {
|
|
background-color: #ffffff80;
|
|
}
|
|
// Year slider
|
|
.swiper-historical-milestone {
|
|
@include media-breakpoint-up(lg) {
|
|
width: calc(100% - 12rem) !important;
|
|
margin-left: 12rem;
|
|
clip-path: polygon(0% 0%,90% 0%,90% 100%,0% 100%);
|
|
}
|
|
@include media-breakpoint-up(xl) {
|
|
// width: calc(100% - 4rem) !important;
|
|
// margin-left: 4rem;
|
|
// clip-path: polygon(44% 0%,99% 0%,99% 99%,44% 100%);
|
|
}
|
|
@include media-breakpoint-up(xxl) {
|
|
// width: 100% !important;
|
|
// margin-left: 0rem;
|
|
// clip-path: polygon(44.5% 0%, 99% 0%, 99% 99%, 44.5% 100.00%);
|
|
}
|
|
|
|
.swiper-slide-active {
|
|
p {
|
|
color: #{$color-quad} !important;
|
|
}
|
|
|
|
&::after {
|
|
position: absolute;
|
|
bottom: .1rem;
|
|
left: 50%;
|
|
display: block;
|
|
width: 60%;
|
|
// height: 1rem;
|
|
// background-image: url('@/images/global/underline-yellow.svg');
|
|
background-position: center;
|
|
background-repeat: no-repeat;
|
|
background-size: 100%;
|
|
content: "";
|
|
transform: translateX(-50%);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Historical milestone details
|
|
.historical-milestone-details {
|
|
@include media-breakpoint-up(lg) {
|
|
margin-top: 4rem;
|
|
}
|
|
|
|
.historical-milestone-details-text {
|
|
@include media-breakpoint-up(md) {
|
|
padding-left: 8rem;
|
|
padding-right: 8rem;
|
|
}
|
|
@include media-breakpoint-up(lg) {
|
|
padding-left: 0;
|
|
padding-right: 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|