-
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.
Always show video buttons. Consent dialog
- Loading branch information
Showing
12 changed files
with
143 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ConsentDialog } from "@/YoutubePlayer/ConsentDialog.tsx"; | ||
import { createEffect, createSignal, Show } from "solid-js"; | ||
import { SimpleButton } from "@/components/solid/atoms/SimpleButton.tsx"; | ||
import { Portal } from "solid-js/web"; | ||
|
||
const LOCAL_STORAGE_KEY = "manual-test-consent-show-dialog"; | ||
export const ManualTest = () => { | ||
const [consent, setConsent] = createSignal(false); | ||
const [showDialog, setShowDialog] = createSignal(JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY) || "false")); | ||
|
||
createEffect(() => { | ||
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(showDialog())); | ||
}); | ||
|
||
function onConsentChange(value: boolean) { | ||
setShowDialog(false); | ||
setConsent(value); | ||
} | ||
return ( | ||
<div> | ||
<div>Consent: {consent() ? "Yes" : "No"}</div> | ||
<SimpleButton label={"Show consent dialog"} onClick={() => setShowDialog(true)} /> | ||
<Portal> | ||
<Show when={showDialog()}> | ||
<ConsentDialog setResult={onConsentChange} /> | ||
</Show> | ||
</Portal> | ||
</div> | ||
); | ||
}; |
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,64 @@ | ||
import { type Component, onCleanup, onMount } from "solid-js"; | ||
import { SimpleButton } from "@/components/solid/atoms/SimpleButton.tsx"; | ||
import { t } from "@/i18n"; | ||
import { IconYoutubeWhite } from "@/icons"; | ||
|
||
export const ConsentDialog: Component<{ setResult: (value: boolean) => void }> = (props) => { | ||
let animation: Animation; | ||
|
||
function setElement(element: HTMLDivElement | null) { | ||
animation = new Animation( | ||
new KeyframeEffect(element, [{ opacity: 0 }, { opacity: 1 }], { duration: 200, fill: "forwards" }), | ||
document.timeline, | ||
); | ||
} | ||
|
||
onMount(() => { | ||
animation?.play(); | ||
document.body.style.width = "100vw"; | ||
document.body.style.height = "100vh"; | ||
document.body.style.overflow = "hidden"; | ||
}); | ||
|
||
onCleanup(() => { | ||
document.body.style.width = ""; | ||
document.body.style.height = ""; | ||
document.body.style.overflow = ""; | ||
}); | ||
|
||
async function onResult(value: boolean) { | ||
animation?.reverse(); | ||
await animation.finished; | ||
props.setResult(value); | ||
} | ||
|
||
return ( | ||
<div ref={setElement} class={"fixed inset-0 bg-black/25 z-50 opacity-0"}> | ||
<div | ||
class={ | ||
"absolute bg-white p-8 rounded-lg top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 max-w-2xl w-3/4 shadow-xl" | ||
} | ||
> | ||
<h1 class={"text-secondary-dark flex flex-wrap mt-0"}> | ||
<IconYoutubeWhite class={"h-8 pe-2"} /> | ||
{t("video.consent.title")} | ||
</h1> | ||
<p class={"text-secondary-dark"}>{t("video.consent.text")}</p> | ||
<p class="mb-8"> | ||
<a | ||
target="_blank" | ||
href="https://www.youtube.com/howyoutubeworks/our-commitments/protecting-user-data/#privacy-guidelines" | ||
> | ||
{t("video.consent.link-text")} | ||
</a> | ||
</p> | ||
|
||
<div class={"grid grid-cols-1 xl:grid-cols-2 gap-4"}> | ||
<SimpleButton label={t("video.consent.yes")} onClick={() => onResult(true)} /> | ||
<SimpleButton label={t("video.consent.no")} onClick={() => onResult(false)} /> | ||
</div> | ||
<div class={"mt-4 text-secondary"}>{t("video.consent.suffix")}</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,14 @@ | ||
import { render } from "solid-js/web"; | ||
import { ConsentDialog } from "@/YoutubePlayer/ConsentDialog.tsx"; | ||
|
||
export async function askYoutubeConsent(): Promise<boolean> { | ||
const { promise, resolve } = Promise.withResolvers<boolean>(); | ||
const container = document.createElement("div"); | ||
document.body.append(container); | ||
|
||
const cleanup = render(() => <ConsentDialog setResult={resolve} />, container); | ||
const value = await promise; | ||
cleanup(); | ||
container.remove(); | ||
return value; | ||
} |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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