Skip to content

Commit 5f9cd45

Browse files
authored
Merge pull request #412 from openscript-ch/409-fix-video-and-button
409 fix video and button
2 parents 37415ea + d06a6a5 commit 5f9cd45

File tree

7 files changed

+38
-45
lines changed

7 files changed

+38
-45
lines changed

.changeset/five-candles-send.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@quassel/website": minor
3+
---
4+
5+
Update play button class name, video ratio and controls effect

apps/website/public/favicon.png

24.4 KB
Loading
47.4 KB
Loading
2.01 MB
Binary file not shown.

apps/website/src/layouts/Document.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import "@fontsource-variable/montserrat";
99
<meta charset="utf-8" />
1010
<meta name="viewport" content="width=device-width" />
1111
<link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="any" />
12+
<link rel="icon" href="/favicon.png" type="image/png" />
1213
<link rel="icon" href="/favicon-16x16.png" type="image/png" sizes="16x16" />
1314
<link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32" />
1415
<link rel="icon" href="/favicon-48x48.png" type="image/png" sizes="48x48" />

apps/website/src/sections/Spotlight.astro

Lines changed: 32 additions & 45 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;
@@ -53,29 +56,24 @@ import PlayButton from "../assets/videos/play-button.svg";
5356
filter: brightness(0.2);
5457
}
5558

56-
.playButton {
57-
background: none;
59+
.play-button {
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-
.playButton-invisible {
69+
.play-button.hidden {
6870
visibility: hidden;
6971
}
7072

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

75-
.playButton 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,25 +97,22 @@ 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("playButton")[0] as HTMLButtonElement;
109-
let isPlaying = false;
110-
111-
video.classList.add("video-not-interactive");
112-
113-
playButton.addEventListener("click", () => {
114-
video.play();
115-
isPlaying = true;
116-
playButton.classList.add("playButton-invisible");
117-
video.classList.remove("video-not-interactive");
118-
});
119-
120-
video.addEventListener("pause", () => {
121-
if (isPlaying) {
122-
isPlaying = false;
123-
playButton.classList.remove("playButton-invisible");
124-
video.classList.add("video-not-interactive");
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+
video.toggleAttribute("controls");
107+
} else {
108+
wasSeeking = !wasSeeking;
125109
}
126-
});
110+
};
111+
112+
playButton.addEventListener("click", () => video.play());
113+
video.addEventListener("play", togglePlayButton);
114+
video.addEventListener("pause", togglePlayButton);
115+
video.addEventListener("click", togglePlayButton);
127116
});
128117
</script>
129118

@@ -132,13 +121,11 @@ import PlayButton from "../assets/videos/play-button.svg";
132121
<h1>Gather language exposure data</h1>
133122
<p>Efficient documenting <strong>children's</strong> language exposure by carer, language and time.</p>
134123
</div>
135-
<div class="quassel-video">
136-
<video controls poster={Poster.src} muted playsinline>
137-
<source src={videoUrl} type="video/mp4" />
124+
<div class="video-wrapper">
125+
<video poster={Poster.src} muted playsinline>
126+
<source src={Video} type="video/mp4" />
138127
</video>
139-
<button class="playButton">
140-
<Image src={PlayButton} alt="Play button" />
141-
</button>
128+
<Image class="play-button" src={PlayButtonSymbol} alt="Play button symbol" />
142129
</div>
143130
<div class="used-by">
144131
<h2>Used by</h2>

0 commit comments

Comments
 (0)