126 lines
2.7 KiB
Vue
126 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
|
|
const { t } = useI18n();
|
|
|
|
const statsRef = ref<HTMLElement | null>(null);
|
|
let observer: IntersectionObserver | null = null;
|
|
|
|
const stats = computed(() => [
|
|
{
|
|
value: "8+",
|
|
label: t("stats.projectsCompleted"),
|
|
},
|
|
{
|
|
value: "6+",
|
|
label: t("stats.projectsOnline"),
|
|
},
|
|
{
|
|
value: "5+",
|
|
label: t("stats.websites"),
|
|
},
|
|
{
|
|
value: "3+",
|
|
label: t("stats.backendApis"),
|
|
},
|
|
]);
|
|
|
|
onMounted(() => {
|
|
if (!statsRef.value) return;
|
|
|
|
observer = new IntersectionObserver(
|
|
(entries) => {
|
|
entries.forEach((entry) => {
|
|
entry.target.classList.toggle(
|
|
"is-visible",
|
|
entry.isIntersecting,
|
|
);
|
|
});
|
|
},
|
|
{
|
|
threshold: 0.15,
|
|
rootMargin: "0px 0px -40px 0px",
|
|
},
|
|
);
|
|
|
|
statsRef.value
|
|
.querySelectorAll("[data-reveal]")
|
|
.forEach((element) => observer?.observe(element));
|
|
});
|
|
|
|
onBeforeUnmount(() => {
|
|
observer?.disconnect();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<section
|
|
ref="statsRef"
|
|
class="relative overflow-hidden py-14 sm:py-18 lg:py-24"
|
|
>
|
|
<div class="mx-auto w-full max-w-7xl px-5 sm:px-8 lg:px-10">
|
|
<div
|
|
class="grid grid-cols-2 gap-3 sm:gap-5 lg:grid-cols-4 lg:gap-6"
|
|
>
|
|
<div
|
|
v-for="(item, index) in stats"
|
|
:key="item.label"
|
|
data-reveal
|
|
class="reveal group rounded-2xl border p-4 text-center transition-[transform,background-color,border-color] duration-300 hover:-translate-y-1 sm:rounded-3xl sm:p-6 md:p-8"
|
|
:style="{
|
|
'--delay': `${index * 90}ms`,
|
|
backgroundColor: 'var(--surface)',
|
|
borderColor: 'var(--border)',
|
|
}"
|
|
>
|
|
<h3
|
|
class="text-3xl font-bold tracking-[-0.04em] text-(--primary) sm:text-4xl md:text-5xl"
|
|
>
|
|
{{ item.value }}
|
|
</h3>
|
|
|
|
<p
|
|
class="mt-2 text-[11px] leading-4 sm:mt-3 sm:text-sm sm:leading-5"
|
|
:style="{
|
|
color: 'var(--text-muted)',
|
|
}"
|
|
>
|
|
{{ item.label }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.reveal {
|
|
opacity: 0;
|
|
transform: translate3d(0, 30px, 0);
|
|
transition:
|
|
opacity 650ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
transform 650ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
transition-delay: var(--delay, 0ms);
|
|
will-change: opacity, transform;
|
|
}
|
|
|
|
.reveal.is-visible {
|
|
opacity: 1;
|
|
transform: translate3d(0, 0, 0);
|
|
}
|
|
|
|
@media (max-width: 639px) {
|
|
.reveal {
|
|
transform: translate3d(0, 22px, 0);
|
|
transition-duration: 580ms;
|
|
}
|
|
}
|
|
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.reveal {
|
|
opacity: 1;
|
|
transform: none;
|
|
transition: none;
|
|
}
|
|
}
|
|
</style> |