Skip to content

Commit f40e625

Browse files
committed
Add labels to Consent page switches
1 parent bd89ec9 commit f40e625

3 files changed

Lines changed: 110 additions & 47 deletions

File tree

src/components/Pages/Consent/index.astro

Lines changed: 108 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ const { content } = Astro.props
9292
</p>
9393
<div class="px-6 pb-2">
9494
<div class="mb-6">
95-
<h1
95+
<h2
9696
id="consent-preferences__title"
9797
class="text-3xl md:text-4xl font-bold text-primary-offset mb-2"
9898
>
9999
{content.header.title}
100-
</h1>
100+
</h2>
101101
<p class="text-content text-md leading-relaxed">{content.header.description}</p>
102102
</div>
103103

@@ -144,56 +144,98 @@ const { content } = Astro.props
144144
<div class="bg-page-offset rounded-xl p-6">
145145
<div class="flex items-center justify-between mb-1">
146146
<div>
147-
<h3 class="text-xl font-semibold text-primary-offset">{content.analytics.heading}</h3>
147+
<h3
148+
id="consent-preferences__analytics-title"
149+
class="text-xl font-semibold text-primary-offset"
150+
>
151+
{content.analytics.heading}
152+
</h3>
148153
</div>
149154
<label
150-
class="relative inline-flex items-center cursor-pointer"
155+
class="inline-flex items-center gap-2 cursor-pointer"
151156
data-consent-toggle="analytics-cookies"
152157
>
153-
<input
154-
type="checkbox"
155-
id="analytics-cookies"
156-
class="sr-only peer"
157-
role="switch"
158-
aria-labelledby="consent-preferences__analytics-title"
159-
aria-describedby="consent-preferences__analytics-desc"
160-
checked
161-
/>
162-
<div
163-
class="w-11 h-6 bg-content rounded-full peer peer-focus-visible:outline-2 peer-focus-visible:outline-spotlight peer-focus-visible:outline-offset-2 peer-focus-visible:rounded-none peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
158+
<span
159+
aria-hidden="true"
160+
class="w-8 shrink-0 text-center text-[10px] font-bold uppercase tracking-wide text-content transition-colors"
164161
>
165-
</div>
162+
Off
163+
</span>
164+
<span class="relative shrink-0 w-11 h-6">
165+
<input
166+
type="checkbox"
167+
id="analytics-cookies"
168+
class="peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer opacity-0"
169+
role="switch"
170+
aria-labelledby="consent-preferences__analytics-title"
171+
aria-describedby="consent-preferences__analytics-desc"
172+
checked
173+
/>
174+
<div
175+
class="relative h-6 w-11 rounded-full bg-content peer-focus-visible:outline-2 peer-focus-visible:outline-spotlight peer-focus-visible:outline-offset-2 peer-focus-visible:rounded-none peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
176+
>
177+
</div>
178+
</span>
179+
<span
180+
aria-hidden="true"
181+
class="w-8 shrink-0 text-center text-[10px] font-bold uppercase tracking-wide text-note-offset transition-colors"
182+
>
183+
On
184+
</span>
166185
</label>
167186
</div>
168-
<p class="text-sm text-note-offset mb-3">{content.analytics.subheading}</p>
187+
<p id="consent-preferences__analytics-desc" class="text-sm text-note-offset mb-3">
188+
{content.analytics.subheading}
189+
</p>
169190
<p class="text-content text-md leading-relaxed">{content.analytics.description}</p>
170191
</div>
171192

172193
{/* Functional */}
173194
<div class="bg-page-offset rounded-xl p-6">
174195
<div class="flex items-center justify-between mb-1">
175196
<div>
176-
<h3 class="text-xl font-semibold text-primary-offset">{content.functional.heading}</h3>
197+
<h3
198+
id="consent-preferences__functional-title"
199+
class="text-xl font-semibold text-primary-offset"
200+
>
201+
{content.functional.heading}
202+
</h3>
177203
</div>
178204
<label
179-
class="relative inline-flex items-center cursor-pointer"
205+
class="inline-flex items-center gap-2 cursor-pointer"
180206
data-consent-toggle="functional-cookies"
181207
>
182-
<input
183-
type="checkbox"
184-
id="functional-cookies"
185-
class="sr-only peer"
186-
role="switch"
187-
aria-labelledby="consent-preferences__functional-title"
188-
aria-describedby="consent-preferences__functional-desc"
189-
/>
190-
<div
191-
class="w-11 h-6 bg-content rounded-full peer peer-focus-visible:outline-2 peer-focus-visible:outline-spotlight peer-focus-visible:outline-offset-2 peer-focus-visible:rounded-none peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
208+
<span
209+
aria-hidden="true"
210+
class="w-8 shrink-0 text-center text-[10px] font-bold uppercase tracking-wide text-content transition-colors"
192211
>
193-
</div>
212+
Off
213+
</span>
214+
<span class="relative shrink-0 w-11 h-6">
215+
<input
216+
type="checkbox"
217+
id="functional-cookies"
218+
class="peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer opacity-0"
219+
role="switch"
220+
aria-labelledby="consent-preferences__functional-title"
221+
aria-describedby="consent-preferences__functional-desc"
222+
/>
223+
<div
224+
class="relative h-6 w-11 rounded-full bg-content peer-focus-visible:outline-2 peer-focus-visible:outline-spotlight peer-focus-visible:outline-offset-2 peer-focus-visible:rounded-none peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
225+
>
226+
</div>
227+
</span>
228+
<span
229+
aria-hidden="true"
230+
class="w-8 shrink-0 text-center text-[10px] font-bold uppercase tracking-wide text-note-offset transition-colors"
231+
>
232+
On
233+
</span>
194234
</label>
195235
</div>
196-
<p class="text-sm text-note-offset mb-3">{content.functional.subheading}</p>
236+
<p id="consent-preferences__functional-desc" class="text-sm text-note-offset mb-3">
237+
{content.functional.subheading}
238+
</p>
197239
<p class="text-content text-md leading-relaxed">{content.functional.description}</p>
198240
<div class="bg-content-inverse-active rounded-lg p-4 mt-4 -mx-1">
199241
<p class="text-sm text-secondary leading-relaxed" set:html={content.functional.trailer}></p>
@@ -204,27 +246,48 @@ const { content } = Astro.props
204246
<div class="bg-page-offset rounded-xl p-6">
205247
<div class="flex items-center justify-between mb-1">
206248
<div>
207-
<h3 class="text-xl font-semibold text-primary-offset">{content.marketing.heading}</h3>
249+
<h3
250+
id="consent-preferences__marketing-title"
251+
class="text-xl font-semibold text-primary-offset"
252+
>
253+
{content.marketing.heading}
254+
</h3>
208255
</div>
209256
<label
210-
class="relative inline-flex items-center cursor-pointer"
257+
class="inline-flex items-center gap-2 cursor-pointer"
211258
data-consent-toggle="marketing-cookies"
212259
>
213-
<input
214-
type="checkbox"
215-
id="marketing-cookies"
216-
class="sr-only peer"
217-
role="switch"
218-
aria-labelledby="consent-preferences__marketing-title"
219-
aria-describedby="consent-preferences__marketing-desc"
220-
/>
221-
<div
222-
class="w-11 h-6 bg-content rounded-full peer peer-focus-visible:outline-2 peer-focus-visible:outline-spotlight peer-focus-visible:outline-offset-2 peer-focus-visible:rounded-none peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
260+
<span
261+
aria-hidden="true"
262+
class="w-8 shrink-0 text-center text-[10px] font-bold uppercase tracking-wide text-content transition-colors"
223263
>
224-
</div>
264+
Off
265+
</span>
266+
<span class="relative shrink-0 w-11 h-6">
267+
<input
268+
type="checkbox"
269+
id="marketing-cookies"
270+
class="peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer opacity-0"
271+
role="switch"
272+
aria-labelledby="consent-preferences__marketing-title"
273+
aria-describedby="consent-preferences__marketing-desc"
274+
/>
275+
<div
276+
class="relative h-6 w-11 rounded-full bg-content peer-focus-visible:outline-2 peer-focus-visible:outline-spotlight peer-focus-visible:outline-offset-2 peer-focus-visible:rounded-none peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
277+
>
278+
</div>
279+
</span>
280+
<span
281+
aria-hidden="true"
282+
class="w-8 shrink-0 text-center text-[10px] font-bold uppercase tracking-wide text-note-offset transition-colors"
283+
>
284+
On
285+
</span>
225286
</label>
226287
</div>
227-
<p class="text-sm text-note-offset mb-3">{content.marketing.subheading}</p>
288+
<p id="consent-preferences__marketing-desc" class="text-sm text-note-offset mb-3">
289+
{content.marketing.subheading}
290+
</p>
228291
<p class="text-content text-md leading-relaxed">{content.marketing.description}</p>
229292
</div>
230293
</div>

test/e2e/specs/11-accessibility/aria-screen-readers.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('ARIA and Screen Readers', () => {
229229
* an issue if a heading element (<h1> through <h6>) is empty or hidden from assistive
230230
* technologies.
231231
*/
232-
test.only('@ready page has exactly one h1', async ({ page: playwrightPage }) => {
232+
test('@ready page has exactly one h1', async ({ page: playwrightPage }) => {
233233
const page = await BasePage.init(playwrightPage)
234234
await runAcrossPages(page, 'check h1 count', async (url) => {
235235
await page.goto(url)

test/e2e/specs/11-accessibility/axe.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cat.text-alternatives: Rules for ensuring that text alternatives are provided fo
2424
*/
2525

2626
describe('WCAG Compliance', () => {
27-
test.only('run axe accessibility audit on homepage with default theme', async ({ page: playwrightPage }) => {
27+
test.only('run axe accessibility audit with default theme', async ({ page: playwrightPage }) => {
2828
const page = await BasePage.init(playwrightPage)
2929
await runAcrossPages(page, 'check forms', async (url) => {
3030
await page.goto(url)

0 commit comments

Comments
 (0)