Skip to content

Commit 4759ef4

Browse files
committed
chore: clean up spotlight
1 parent 1c438cb commit 4759ef4

File tree

2 files changed

+34
-56
lines changed

2 files changed

+34
-56
lines changed

apps/website/src/sections/Spotlight.astro

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
import { Image } from "astro:assets";
33
import UzhLogo from "../assets/logos/uzh-logo.svg";
4-
import videoUrl from "../assets/videos/quassel.mp4";
4+
import Video from "../assets/videos/quassel.mp4";
55
import Poster from "../assets/videos/poster.png";
6-
import PlayButton from "../assets/videos/play-button.svg";
6+
import PlayButtonSymbol from "../assets/videos/play-button-symbol.svg";
77
---
88

99
<style>
@@ -12,14 +12,17 @@ import PlayButton from "../assets/videos/play-button.svg";
1212
flex-direction: column;
1313
align-items: center;
1414
background: radial-gradient(50% 50% at 50% 50%, var(--color-primary) 60%, transparent 100%);
15+
font-size: var(--font-size-lg);
1516
}
1617

1718
h1 {
1819
font-size: var(--font-size-xxxl);
1920
}
2021

21-
p {
22+
h2 {
2223
font-size: var(--font-size-lg);
24+
font-weight: var(--font-weight-medium);
25+
align-self: center;
2326
}
2427

2528
.intro {
@@ -29,7 +32,7 @@ import PlayButton from "../assets/videos/play-button.svg";
2932
max-width: 37rem;
3033
}
3134

32-
.quassel-video {
35+
.video-wrapper {
3336
display: flex;
3437
align-items: center;
3538
justify-content: center;
@@ -54,28 +57,23 @@ import PlayButton from "../assets/videos/play-button.svg";
5457
}
5558

5659
.play-button {
57-
background: none;
5860
position: absolute;
59-
border: none;
6061
cursor: pointer;
6162
top: 50%;
6263
left: 50%;
63-
transform: translate(-50%, -50%);
64-
visibility: visible;
64+
translate: -50% -50%;
65+
transform-origin: center center;
66+
width: clamp(3rem, 10vw, 6rem);
6567
}
6668

67-
.play-button-invisible {
69+
.play-button.hidden {
6870
visibility: hidden;
6971
}
7072

71-
.play-button :hover {
73+
.play-button:hover {
7274
transform: scale(1.1);
7375
}
7476

75-
.play-button img {
76-
width: clamp(3rem, 10vw, 6rem);
77-
}
78-
7977
.used-by {
8078
margin-top: var(--spacing-xl);
8179
display: flex;
@@ -87,12 +85,6 @@ import PlayButton from "../assets/videos/play-button.svg";
8785
}
8886
}
8987

90-
.used-by h2 {
91-
font-size: var(--font-size-lg);
92-
font-weight: var(--font-weight-medium);
93-
align-self: center;
94-
}
95-
9688
.used-by img {
9789
max-height: 4rem;
9890
}
@@ -105,38 +97,26 @@ import PlayButton from "../assets/videos/play-button.svg";
10597
<script>
10698
document.addEventListener("DOMContentLoaded", () => {
10799
const video = document.querySelector("video") as HTMLVideoElement;
108-
const playButton = document.getElementsByClassName("play-button")[0] as HTMLButtonElement;
109-
let isUserPause = false;
110-
111-
video.removeAttribute("controls");
112-
video.classList.add("video-not-interactive");
113-
114-
playButton.addEventListener("click", () => {
115-
video.play();
116-
playButton.classList.add("play-button-invisible");
117-
video.classList.remove("video-not-interactive");
118-
video.setAttribute("controls", "true");
119-
isUserPause = true;
120-
});
121-
122-
video.addEventListener("pause", () => {
123-
if (isUserPause == true) {
124-
playButton.classList.remove("play-button-invisible");
125-
video.classList.add("video-not-interactive");
126-
video.removeAttribute("controls");
127-
}
128-
});
129-
130-
video.addEventListener("click", (e) => {
131-
const target = e.target as HTMLVideoElement;
132-
if (target === video && video.hasAttribute("controls")) {
133-
isUserPause = true;
100+
const playButton = document.querySelector(".play-button") as HTMLButtonElement;
101+
let wasSeeking = false;
102+
103+
const togglePlayButton = () => {
104+
if (!video.seeking && !wasSeeking) {
105+
playButton.classList.toggle("hidden");
106+
if (video.getAttribute("controls")) {
107+
video.removeAttribute("controls");
108+
} else {
109+
video.setAttribute("controls", "true");
110+
}
111+
} else {
112+
wasSeeking = !wasSeeking;
134113
}
135-
});
114+
};
136115

137-
video.addEventListener("seeking", () => {
138-
isUserPause = false;
139-
});
116+
playButton.addEventListener("click", () => video.play());
117+
video.addEventListener("play", togglePlayButton);
118+
video.addEventListener("pause", togglePlayButton);
119+
video.addEventListener("click", togglePlayButton);
140120
});
141121
</script>
142122

@@ -145,13 +125,11 @@ import PlayButton from "../assets/videos/play-button.svg";
145125
<h1>Gather language exposure data</h1>
146126
<p>Efficient documenting <strong>children's</strong> language exposure by carer, language and time.</p>
147127
</div>
148-
<div class="quassel-video">
149-
<video controls poster={Poster.src} muted playsinline>
150-
<source src={videoUrl} type="video/mp4" />
128+
<div class="video-wrapper">
129+
<video poster={Poster.src} muted playsinline>
130+
<source src={Video} type="video/mp4" />
151131
</video>
152-
<button class="play-button">
153-
<Image src={PlayButton} alt="Play button" />
154-
</button>
132+
<Image class="play-button" src={PlayButtonSymbol} alt="Play button symbol" />
155133
</div>
156134
<div class="used-by">
157135
<h2>Used by</h2>

0 commit comments

Comments
 (0)