Remove hardcoded media query breakpoints from the JavaScript for the header and tabs components #3764
Closed
2 tasks done
Labels
Milestone
What
We have hardcoded the default desktop and tablet breakpoints into the JavaScript for both the header and tabs components:
govuk-frontend/packages/govuk-frontend/src/govuk/components/header/header.mjs
Lines 57 to 58 in a4ae219
govuk-frontend/packages/govuk-frontend/src/govuk/components/tabs/tabs.mjs
Lines 63 to 64 in a4ae219
Find another way to link the JavaScript behaviour to the styles applied at different breakpoints without needing to hardcode them.
Why
Having the breakpoints hardcoded is likely cause issues if users override the default breakpoints.
There's also a risk that they may get out of sync if we ever make changes to the default breakpoints.
Further details
Once we've switched to loading our JavaScript using
script type="module"
1 we might be able to expose the breakpoint as a CSS variable in the CSS for each component (or on the document root) and read it out usingwindow.getComputedStyle().getPropertyValue
.Who needs to work on this
Developers
Who needs to review this
Developers
Done when
Footnotes
because all browsers that support
script type="module"
also support CSS variables ↩The text was updated successfully, but these errors were encountered: