Files
aigc-home/calliope-web/src/lib/components/refract/Hero.svelte
T

254 lines
5.2 KiB
Svelte

<script lang="ts">
import { onMount } from 'svelte';
let { onStart, onImport }: { onStart: () => void; onImport: () => void } =
$props();
let card: HTMLDivElement;
onMount(() => {
let raf = 0,
x = 0,
v = 0,
target = 0,
time = 0;
const reduced = () =>
window.matchMedia('(prefers-reduced-motion: reduce)').matches ||
document.documentElement.dataset.reduce === '1';
function animate(now: number) {
const dt = Math.min((now - time) / 1000 || 0.016, 0.032);
time = now;
v += ((target - x) * 100 - v * 10) * dt;
x += v * dt;
card.style.transform = `rotate(${10 + x}deg) translateY(${-Math.abs(x)}px)`;
if (Math.abs(v) + Math.abs(target - x) > 0.01)
raf = requestAnimationFrame(animate);
else raf = 0;
}
function go(value: number) {
if (reduced()) return;
target = value;
if (!raf) {
time = performance.now();
raf = requestAnimationFrame(animate);
}
}
const enter = () => go(-5),
leave = () => go(0);
card.addEventListener('pointerenter', enter);
card.addEventListener('pointerleave', leave);
return () => {
cancelAnimationFrame(raf);
card.removeEventListener('pointerenter', enter);
card.removeEventListener('pointerleave', leave);
};
});
</script>
<section class="refract-hero">
<div class="hero-copy">
<div class="eyebrow">● A SPACE FOR THE UNEXPECTED</div>
<h1>让想象,<br /><span>在这里成形。</span></h1>
<p>
从一个念头,到一组画面,再到一段故事。<br
/>你的模型、素材与灵感,都在同一个工作室。
</p>
<div class="hero-buttons">
<button class="a-btn primary" onclick={onStart}>开始创作 →</button><button
class="text-button"
onclick={onImport}>导入已有剧本 ↗</button
>
</div>
</div>
<div class="hero-art">
<img
class="hero-photo"
src="/refract/coast.jpg"
alt="海岸与薄雾构成的灵感画面"
/>
<div class="art-circle"></div>
<span class="hero-star">✳</span>
<div class="art-label">
VISUAL STUDY / 001<br />LIGHT, SPACE &amp; POSSIBILITY
</div>
<div class="hero-card" bind:this={card}>
<img src="/refract/arch.jpg" alt="建筑几何参考" /><span
>FOUND IN THE IN-BETWEEN</span
>
</div>
<div class="art-word">Beyond<br />the ordinary.</div>
</div>
</section>
<style>
.refract-hero {
display: grid;
grid-template-columns: 1fr 1.12fr;
min-height: 322px;
border-radius: 18px;
background:
radial-gradient(ellipse at 0 0, #7850ff1a, transparent 70%), #141419;
border: 1px solid var(--line);
overflow: hidden;
position: relative;
}
.hero-copy {
padding: 35px 40px;
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
z-index: 1;
}
.eyebrow {
color: var(--accent);
font-size: 9px;
letter-spacing: 1.3px;
margin-bottom: 19px;
}
h1 {
font-size: clamp(33px, 3vw, 47px);
line-height: 1.3;
margin: 0 0 15px;
font-weight: 650;
letter-spacing: -1.6px;
}
h1 span {
color: var(--accent);
}
p {
font-size: 12px;
line-height: 1.9;
color: var(--text-3);
margin: 0 0 23px;
}
.hero-buttons {
display: flex;
gap: 20px;
align-items: center;
}
.hero-buttons .a-btn {
height: 41px;
padding: 0 20px;
}
.text-button {
border: 0;
background: none;
color: var(--text-2);
font-size: 11px;
cursor: pointer;
}
.hero-art {
position: relative;
overflow: hidden;
background: #d2dbe4;
min-height: 322px;
isolation: isolate;
}
.hero-photo {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center 70%;
filter: contrast(0.92) saturate(0.7);
}
.art-circle {
position: absolute;
width: 270px;
height: 270px;
border: 1px solid #ffffff88;
border-radius: 50%;
top: 28px;
left: 75px;
z-index: 1;
}
.art-circle:before,
.art-circle:after {
content: '';
position: absolute;
border: 1px solid #ffffff66;
border-radius: 50%;
inset: 26px;
}
.art-circle:after {
inset: 57px;
}
.art-word {
position: absolute;
bottom: 22px;
left: 23px;
z-index: 2;
font-family: Georgia, serif;
font-size: 64px;
color: white;
line-height: 0.8;
font-style: italic;
letter-spacing: -4px;
}
.art-label {
position: absolute;
top: 21px;
right: 22px;
z-index: 2;
color: #fff;
font-size: 9px;
text-align: right;
letter-spacing: 1.4px;
}
.hero-card {
position: absolute;
right: 27px;
top: 60px;
width: 145px;
height: 188px;
border: 5px solid var(--surface);
background: var(--surface);
box-shadow: 0 20px 30px #1b2a3530;
transform: rotate(10deg);
z-index: 3;
}
.hero-card img {
width: 100%;
height: 155px;
object-fit: cover;
}
.hero-card span {
font-family: monospace;
letter-spacing: 0.4px;
font-size: 8px;
display: block;
margin-top: 5px;
text-align: center;
}
.hero-star {
position: absolute;
top: 40px;
left: 57px;
color: var(--lime);
font-size: 65px;
line-height: 1;
z-index: 2;
}
@media (max-width: 1250px) {
.hero-copy {
padding: 28px;
}
.hero-copy h1 {
font-size: 35px;
}
.hero-buttons {
gap: 10px;
}
.hero-card {
width: 125px;
height: 164px;
right: 18px;
}
.hero-card img {
height: 131px;
}
.art-circle {
left: 20px;
}
}
</style>