Repository navigation
Expand file tree
/
Copy pathwork.astro
More file actions
163 lines (148 loc) · 4.13 KB
/
Copy pathwork.astro
File metadata and controls
163 lines (148 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
---
import { Image } from 'astro:assets'
import { WORKS } from '@/scripts/data'
import FileName from '@/components/file-name.astro'
---
<section class="work relative text-white">
<h2 class="sr-only">My Work</h2>
<FileName path="src/components/work.astro" label="work.astro" class="top-4 left-1/2 -translate-x-1/2" />
{WORKS.map(work => (
<article class="group relative h-svh overflow-hidden">
{work.image.src && (
<Image
src={work.image}
width={work.image.width}
alt=""
densities={[1, 2]}
quality="low"
data-speed=".5"
class="size-full object-cover bg-white"
/>
)}
<div class="absolute inset-0 p-5 flex items-center justify-center bg-linear-to-br from-black/30 to-black/90 text-center backdrop-blur-[2px] md:from-black/40 md:to-black/95 md:backdrop-blur-xs">
<div data-speed=".75">
<h3 class="cursor-default text-3xl/tight font-light text-shadow-sm text-shadow-black sm:text-shadow-md sm:text-5xl/tight 2xl:text-7xl/tight">
{work.title}
</h3>
{work.links.length > 0 && (
<ul class="mt-2 flex flex-wrap items-center justify-center sm:mt-5 2xl:mt-6">
{work.links.map(link => (
<li>
<a
href={link.url}
target="_blank"
rel="noopener noreferrer"
class="inline-block p-3 text-shadow-sm text-shadow-black underline-offset-2 hover:underline sm:p-4 sm:text-shadow-md sm:text-2xl 2xl:text-4xl 2xl:underline-offset-4"
>
{link.label || new URL(link.url).hostname}
</a>
</li>
))}
</ul>
)}
</div>
</div>
</article>
))}
</section>
<style is:global>
@media (prefers-reduced-motion: no-preference) {
.work h3 > * {
transition-property: font-weight, font-stretch;
transition-duration: 200ms;
transition-timing-function: ease;
&:has(+ * + * + *:hover) {
font-weight: 400;
font-stretch: 105%;
}
&:has(+ * + *:hover) {
font-weight: 500;
font-stretch: 110%;
}
&:has(+ *:hover) {
font-weight: 700;
font-stretch: 115%;
}
&:hover {
font-weight: 900;
font-stretch: 120%;
+ * {
font-weight: 700;
font-stretch: 115%;
+ * {
font-weight: 500;
font-stretch: 110%;
+ * {
font-weight: 400;
font-stretch: 105%;
}
}
}
}
}
}
</style>
<script>
import { gsap } from 'gsap'
import '@/scripts/gsap'
import { SplitText } from 'gsap/SplitText'
const work = document.querySelector('.work') as HTMLElement
const articles = gsap.utils.toArray<HTMLElement>(work.querySelectorAll('article'))
gsap.matchMedia(work)
.add('(prefers-reduced-motion: no-preference)', function () {
articles.forEach(function (article) {
const splitH = SplitText.create(article.querySelector('h3'), {
type: 'chars',
autoSplit: true,
})
const splitA = SplitText.create(article.getElementsByTagName('a'), {
type: 'chars',
autoSplit: true,
})
gsap.from(splitH.chars, {
autoAlpha: 0,
yPercent: 100,
duration: .3,
stagger: .015,
scrollTrigger: {
trigger: article,
start: 'center bottom',
},
})
gsap.from(splitA.chars, {
autoAlpha: 0,
yPercent: -100,
duration: .25,
delay: .25,
stagger: {
from: 'end',
each: .01,
},
scrollTrigger: {
trigger: article,
start: 'center bottom',
},
})
})
})
.add('(prefers-reduced-motion: reduce)', function () {
articles.forEach(function (article) {
gsap.from(article.querySelector('h3'), {
opacity: 0,
scrollTrigger: {
trigger: article,
start: 'center bottom',
},
})
gsap.from(article.getElementsByTagName('a'), {
opacity: 0,
delay: .25,
stagger: .25,
scrollTrigger: {
trigger: article,
start: 'center bottom',
},
})
})
})
</script>