-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add useLoop hook with play/pause controls
- Loading branch information
Showing
44 changed files
with
663 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
import PlayPause from "./PlayPause.astro"; | ||
--- | ||
|
||
<script> | ||
import { pauseAllLoops, playAllLoops } from "usegl"; | ||
|
||
document.querySelector("[title=Play]").addEventListener("click", (event) => { | ||
if ((event.currentTarget as HTMLElement).ariaChecked === "true") { | ||
playAllLoops(); | ||
} else { | ||
pauseAllLoops(); | ||
} | ||
}); | ||
</script> | ||
|
||
<PlayPause /> | ||
|
||
<style is:global> | ||
button { | ||
position: absolute; | ||
bottom: 0.9rem; | ||
left: 0.9rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<button | ||
type="button" | ||
title="Play" | ||
role="switch" | ||
aria-checked="false" | ||
onclick="this.title=this.title==='Play' ? 'Pause' : 'Play';this.ariaChecked=this.ariaChecked==='false'" | ||
> | ||
<svg class="playsvg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"> | ||
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--> | ||
<path | ||
fill="currentColor" | ||
d="M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80L0 432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z" | ||
> | ||
</path> | ||
</svg> | ||
<svg class="pausesvg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"> | ||
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--> | ||
<path | ||
fill="currentColor" | ||
d="M48 64C21.5 64 0 85.5 0 112L0 400c0 26.5 21.5 48 48 48l32 0c26.5 0 48-21.5 48-48l0-288c0-26.5-21.5-48-48-48L48 64zm192 0c-26.5 0-48 21.5-48 48l0 288c0 26.5 21.5 48 48 48l32 0c26.5 0 48-21.5 48-48l0-288c0-26.5-21.5-48-48-48l-32 0z" | ||
> | ||
</path> | ||
</svg> | ||
</button> | ||
|
||
<style> | ||
button { | ||
display: grid; | ||
grid-template: auto / auto; | ||
place-items: center; | ||
|
||
background: transparent; | ||
border: none; | ||
color: white; | ||
cursor: pointer; | ||
font-size: min(1em, 2svmin); | ||
padding: 1em; | ||
border-radius: 4px; | ||
transition: background-color 100ms; | ||
|
||
&:hover, | ||
&:focus-visible { | ||
background: hsla(0, 0%, 100%, 0.1); | ||
} | ||
|
||
&:active { | ||
background: hsla(0, 0%, 100%, 0.15); | ||
} | ||
|
||
&[aria-checked="true"] { | ||
.playsvg { | ||
display: none; | ||
} | ||
.pausesvg { | ||
display: block; | ||
} | ||
} | ||
|
||
&[aria-checked="false"] { | ||
.playsvg { | ||
display: block; | ||
} | ||
.pausesvg { | ||
display: none; | ||
} | ||
} | ||
} | ||
|
||
svg { | ||
width: 3em; | ||
aspect-ratio: 1; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.