Skip to content

Commit 78afaf0

Browse files
committed
chore: remove JSRequired component using useHead instead
1 parent 21b551d commit 78afaf0

File tree

4 files changed

+53
-25
lines changed

4 files changed

+53
-25
lines changed

app/assets/main.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,44 @@ html:has(dialog:modal) {
338338
overflow: hidden;
339339
scrollbar-gutter: stable;
340340
}
341+
342+
/* No-JS Alert Styles */
343+
.noscript-alert {
344+
position: absolute;
345+
top: 58px;
346+
left: 0;
347+
width: 100%;
348+
349+
padding: 0.5rem 1rem;
350+
351+
/* Square and no side borders */
352+
border-radius: 0;
353+
border-top: 0;
354+
border-left: 0;
355+
border-right: 0;
356+
border-bottom: 1px solid #f87171;
357+
358+
font-size: 0.875rem;
359+
line-height: 1.25rem;
360+
text-align: center;
361+
z-index: 40;
362+
363+
/* Default (Dark) */
364+
background-color: rgba(127, 29, 29, 0.2); /* red-900/20 */
365+
color: #fecaca; /* red-200 */
366+
}
367+
368+
@media (min-width: 768px) {
369+
.noscript-alert {
370+
padding: 0.75rem 1rem;
371+
font-size: 1rem;
372+
line-height: 1.5rem;
373+
}
374+
}
375+
376+
/* Light theme override */
377+
:root[data-theme='light'] .noscript-alert {
378+
border-color: #b91c1c; /* red-700 */
379+
background-color: #fef2f2; /* red-50 */
380+
color: #991b1b; /* red-800 */
381+
}

app/components/JSRequired.vue

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/pages/compare.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ useSeoMeta({
111111
? $t('compare.packages.meta_description', { packages: packages.value.join(', ') })
112112
: $t('compare.packages.meta_description_empty'),
113113
})
114+
115+
useHead({
116+
noscript: [
117+
{
118+
key: 'js-required',
119+
innerHTML: `<div class="noscript-alert" role="alert">
120+
${$t('js_required')}
121+
</div>`,
122+
tagPosition: 'bodyOpen',
123+
},
124+
],
125+
})
114126
</script>
115127

116128
<template>
@@ -136,8 +148,6 @@ useSeoMeta({
136148
</p>
137149
</header>
138150

139-
<JSRequired />
140-
141151
<!-- Package selector -->
142152
<section class="mb-8" aria-labelledby="packages-heading">
143153
<h2 id="packages-heading" class="text-xs text-fg-subtle uppercase tracking-wider mb-3">

test/nuxt/a11y.spec.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ import {
140140
HeaderConnectorModal,
141141
HeaderSearchBox,
142142
InputBase,
143-
JSRequired,
144143
LicenseDisplay,
145144
LoadingSpinner,
146145
PackageProvenanceSection,
@@ -2482,14 +2481,6 @@ describe('component accessibility audits', () => {
24822481
expect(results.violations).toEqual([])
24832482
})
24842483
})
2485-
2486-
describe('JSRequired', () => {
2487-
it('should have no accessibility violations', async () => {
2488-
const component = await mountSuspended(JSRequired)
2489-
const results = await runAxe(component)
2490-
expect(results.violations).toEqual([])
2491-
})
2492-
})
24932484
})
24942485

24952486
function applyTheme(colorMode: string, bgTheme: string | null) {
@@ -2613,10 +2604,6 @@ describe('background theme accessibility', () => {
26132604
name: 'PackageList',
26142605
mount: () => mountSuspended(PackageList, { props: { results: [packageResult] } }),
26152606
},
2616-
{
2617-
name: 'JSRequired',
2618-
mount: () => mountSuspended(JSRequired),
2619-
},
26202607
]
26212608

26222609
/**

0 commit comments

Comments
 (0)