Files
Code-Create/src/pages/home/components/ProductFeature.vue

270 lines
5.0 KiB
Vue
Raw Normal View History

2026-05-15 10:29:21 +08:00
<script setup lang="ts">
import { RouterLink } from 'vue-router'
withDefaults(
defineProps<{
name: string
title: string
backgroundImage: string
backgroundAlt: string
panelImage: string
panelAlt: string
reversed?: boolean
}>(),
{
reversed: false
}
)
</script>
<template>
2026-05-15 16:41:52 +08:00
<section
class="product-feature"
:class="{ 'product-feature-reversed': reversed }"
v-custom-animation.scroll
>
2026-05-15 10:29:21 +08:00
<div class="product-feature-art">
<img
class="product-feature-bg"
:src="backgroundImage"
:alt="backgroundAlt"
loading="lazy"
2026-05-15 11:09:36 +08:00
translate-x-s="-100"
translate-x="100"
2026-05-15 10:29:21 +08:00
/>
2026-05-15 16:41:52 +08:00
<img
class="product-feature-panel"
:src="panelImage"
:alt="panelAlt"
loading="lazy"
translate-y-s="-100"
translate-y="20"
/>
2026-05-15 10:29:21 +08:00
</div>
<div class="product-feature-copy">
<p class="product-feature-name">{{ name }}</p>
<h2 class="product-feature-title">{{ title }}</h2>
2026-05-15 16:41:52 +08:00
<RouterLink
class="product-feature-link"
to="/products"
translate-y-s="100"
translate-y="0"
>
View More
</RouterLink>
2026-05-15 10:29:21 +08:00
</div>
</section>
</template>
<style scoped lang="less">
.product-feature {
display: flex;
align-items: center;
gap: clamp(48px, 5.5vw, 76px);
width: 1440px;
min-width: 0;
min-height: 690px;
margin: 0 auto;
& > div {
width: 50%;
}
}
.product-feature-reversed {
grid-template-columns: minmax(420px, 0.95fr) minmax(0, 1.05fr);
}
.product-feature-reversed .product-feature-art {
order: 2;
justify-self: end;
}
.product-feature-reversed .product-feature-copy {
order: 1;
justify-self: start;
max-width: 510px;
}
.product-feature-art {
position: relative;
width: min(100%, 560px);
min-width: 0;
min-height: 560px;
justify-self: start;
}
.product-feature-bg {
display: block;
width: min(100%, 480px);
max-width: 100%;
height: auto;
user-select: none;
}
.product-feature-panel {
position: absolute;
right: 0;
bottom: 94px;
width: min(72%, 380px);
max-width: 100%;
height: auto;
user-select: none;
}
.product-feature-reversed .product-feature-bg {
width: min(100%, 460px);
margin-left: auto;
}
.product-feature-reversed .product-feature-panel {
right: auto;
left: -88px;
bottom: 70px;
width: min(78%, 430px);
}
.product-feature-copy {
position: relative;
z-index: 1;
max-width: 590px;
min-width: 0;
justify-self: start;
padding-bottom: 18px;
}
.product-feature-name {
margin: 0 0 20px;
color: #6e6e6e;
font-family: Poppins, sans-serif;
font-size: 18px;
font-weight: 700;
line-height: 1;
letter-spacing: 2px;
}
.product-feature-title {
margin: 0 0 28px;
color: #252525;
font-family: Poppins, sans-serif;
font-size: clamp(30px, 2.8vw, 38px);
font-weight: 700;
line-height: 1.16;
letter-spacing: 2px;
text-transform: none;
overflow-wrap: break-word;
}
.product-feature-link {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 152px;
min-height: 48px;
padding: 0 28px;
border-radius: 999px;
color: #ffffff;
background: #a72125;
font-family: Poppins, sans-serif;
font-size: 10px;
font-weight: 700;
line-height: 1;
letter-spacing: 2px;
text-decoration: none;
text-transform: uppercase;
transition:
background-color 0.2s ease,
transform 0.2s ease;
}
.product-feature-link:hover,
.product-feature-link:focus-visible {
background: #8e171b;
transform: translateY(-1px);
}
.product-feature-link:focus-visible {
outline: 2px solid #a72125;
outline-offset: 4px;
}
@media (max-width: 980px) {
.product-feature,
.product-feature-reversed {
grid-template-columns: 1fr;
gap: 24px;
width: min(680px, calc(100% - 40px));
min-height: 0;
padding: 70px 0;
}
.product-feature-reversed .product-feature-art,
.product-feature-reversed .product-feature-copy {
order: initial;
justify-self: start;
}
.product-feature-art {
width: 100%;
max-width: 100%;
min-height: clamp(390px, 82vw, 560px);
justify-self: stretch;
}
.product-feature-copy {
width: 100%;
max-width: 640px;
justify-self: stretch;
padding-bottom: 0;
}
.product-feature-reversed .product-feature-panel {
left: 0;
}
}
@media (max-width: 640px) {
.product-feature,
.product-feature-reversed {
width: calc(100% - 32px);
padding: 52px 0;
}
.product-feature-art {
min-height: clamp(300px, 82vw, 430px);
}
.product-feature-copy,
.product-feature-reversed .product-feature-copy {
width: 100% !important;
max-width: 100% !important;
justify-self: stretch !important;
}
.product-feature-bg {
width: 78%;
}
.product-feature-panel,
.product-feature-reversed .product-feature-panel {
left: auto;
right: 0;
bottom: 42px;
width: 68%;
}
.product-feature-reversed .product-feature-bg {
width: 72%;
}
.product-feature-title {
width: 100%;
max-width: 100%;
font-size: clamp(26px, 7.2vw, 30px);
line-height: 1.2;
letter-spacing: 1.2px;
overflow-wrap: anywhere;
}
}
</style>