Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use extendable reusable consent gate partial #386

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions resources/views/components/_consent_gate.antlers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{#
@name Consent gate
@desc An ext
#}}

<!-- /components/_consent_gate.antlers.html -->
{{ _consent_embeds =
(environment == 'local' && seo:trackers_local && seo:embeds) or
(environment == 'staging' && seo:trackers_staging && seo:embeds) or
(environment == 'production' && seo:trackers_production && seo:embeds)
}}
<div
{{ if _consent_embeds }}
x-data
{{ /if }}
class="{{ class }}"
>
<div class="relative aspect-video">
{{ if _consent_embeds }}
<div
x-show="!$store.consentBanner.getConsent() || !$store.consentBanner.getConsentValue('embeds')"
class="absolute z-10 inset-0 p-6 flex justify-center items-center bg-neutral/10 text-neutral/80"
>
<a @click.prevent="$store.consentBanner.revokeConsent()" href="#" class="p-1 -m-1 underline focus:outline-none focus-visible:ring-2 ring-primary">
{{ trans:strings.consent_embeds_disabled }}
</a>
</div>
<template x-if="$store.consentBanner.getConsent() && $store.consentBanner.getConsentValue('embeds')">
{{ slot }}
</template>
{{ else }}
{{ slot }}
{{ /if }}
</div>

{{ slot:append }}
</div>
<!-- End: /components/_consent_gate.antlers.html -->
46 changes: 7 additions & 39 deletions resources/views/components/_video.antlers.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,11 @@
#}}

<!-- /components/_video.antlers.html -->
{{ consent_embeds =
(environment == 'local' && seo:trackers_local && seo:embeds) or
(environment == 'staging' && seo:trackers_staging && seo:embeds) or
(environment == 'production' && seo:trackers_production && seo:embeds)
}}
<div
{{ if consent_embeds }}
x-data
{{ /if }}
class="
not-prose my-8
{{ switch(
(size == 'md') => 'span-md',
(size == 'lg') => 'span-lg',
(size == 'xl') => 'span-xl',
() => 'span-md'
)}}
"
>
<div class="relative aspect-video">
{{ if consent_embeds }}
<div
x-show="!$store.consentBanner.getConsent() || !$store.consentBanner.getConsentValue('embeds')"
class="absolute z-10 inset-0 p-6 flex justify-center items-center bg-neutral/10 text-neutral/80"
>
<a @click.prevent="$store.consentBanner.revokeConsent()" href="#" class="underline">
{{ trans:strings.consent_embeds_disabled }}
</a>
</div>
<template x-if="$store.consentBanner.getConsent() && $store.consentBanner.getConsentValue('embeds')">
<iframe class="absolute top-0 left-0 w-full h-full" width="100%" src="{{ video_url | embed_url }}" height="auto" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</template>
{{ else }}
<iframe class="absolute top-0 left-0 w-full h-full" width="100%" src="{{ video_url | embed_url }}" height="auto" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
{{ /if }}
</div>
{{ partial:components/consent_gate class="not-prose my-8 { switch((size == 'md') => 'span-md', (size == 'lg') => 'span-lg', (size == 'xl') => 'span-xl', () => 'span-md')}" }}
<iframe class="absolute top-0 left-0 w-full h-full" width="100%" src="{{ video_url | embed_url }}" height="auto" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

{{ partial:typography/caption }}
</div>
<!-- End: /components/_video.antlers.html -->
{{ slot:append }}
{{ partial:typography/caption }}
{{ /slot:append }}
{{ /partial:components/consent_gate }}
<!-- End: /components/_video.antlers.html -->
Loading