From 0b6d0a08b97d786510ebb3f9a395924a9dbe8ff8 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Wed, 3 Apr 2024 09:32:38 +0100 Subject: [PATCH] Variable scopes and colours (#112) * Allow border width change, fix variable scopes * Improve markup of warning component * Fix column margin removal classes * Update card fixtures * Update button macro options * Alter CSS variables, switch high contrast to media query only * Add missing IDs to form elements --- .storybook/storybook.scss | 22 ++++- CHANGELOG.md | 18 ++++ .../components/button/button.scss | 12 ++- .../components/button/macro-options.json | 24 ++--- .../components/card/fixtures.json | 24 +++++ .../components/checkboxes/checkboxes.njk | 2 +- .../components/checkboxes/fixtures.json | 12 +-- .../components/date-input/fixtures.json | 10 +- .../components/date-input/template.njk | 2 +- .../error-summary/error-summary.scss | 2 +- .../featured-records/featured-records.scss | 5 +- .../global-header/global-header.scss | 1 - .../components/header/header.scss | 5 +- .../components/hero/hero.scss | 2 +- .../components/radios/fixtures.json | 12 +-- .../components/radios/radios.njk | 2 +- .../components/skip-link/skip-link.scss | 10 +- .../components/tabs/tabs.scss | 30 +++--- .../components/warning/fixtures.json | 2 +- .../components/warning/template.njk | 6 +- .../global-header-package.scss | 2 +- src/nationalarchives/tools/_colour.scss | 92 +++++++++++-------- src/nationalarchives/tools/_grid.scss | 6 +- src/nationalarchives/utilities/_colour.scss | 53 +++++------ src/nationalarchives/utilities/_reset.scss | 4 + src/nationalarchives/variables/_borders.scss | 1 + src/nationalarchives/variables/_colour.scss | 8 +- src/nationalarchives/variables/_index.scss | 1 + tasks/test-package.js | 1 + 29 files changed, 223 insertions(+), 148 deletions(-) create mode 100644 src/nationalarchives/variables/_borders.scss diff --git a/.storybook/storybook.scss b/.storybook/storybook.scss index 93c9adad..55ea25bc 100644 --- a/.storybook/storybook.scss +++ b/.storybook/storybook.scss @@ -64,12 +64,26 @@ .sb-story.sb-unstyled { @include colour.colour-css-vars; - @include colour.colour-background("page-background"); + @include colour.colour-background("background"); } -.tna-template--padded { - > .tna-template__body { - padding: 16px; +.tna-template { + &--high-contrast-theme { + @include colour.colour-css-vars-high-contrast; + + * { + background-image: none !important; + } + + &.tna-template--dark-theme { + @include colour.colour-css-vars-high-contrast-dark; + } + } + + &--padded { + > .tna-template__body { + padding: 16px; + } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bade86c..3f0bef7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/nationalarchives/tna-frontend/compare/v0.1.50...HEAD) ### Added + +- "Thick" and button border widths are customisable + ### Changed + +- Improved markup of warning component +- `--page-background` is now `--background` + ### Deprecated + +- Deprecated support for the `tna-template--high-contrast-theme` class - high contrast themes can be used by setting a preference for higher contrast in the operating system +- `colour-font()` no longer has the ability to define the default palette + ### Removed + +- Fallbacks for custom CSS properties are defined in the `var()` function rather than in a separate property - this removes any colouring support for browsers without custom CSS properties + ### Fixed + +- Fixed column margin removal classes +- Added missing IDs to some form elements so they can be linked top from the error summary + ### Security ## [0.1.50](https://github.com/nationalarchives/tna-frontend/compare/v0.1.49...v0.1.50) - 2024-03-28 diff --git a/src/nationalarchives/components/button/button.scss b/src/nationalarchives/components/button/button.scss index 005e9702..23a94526 100644 --- a/src/nationalarchives/components/button/button.scss +++ b/src/nationalarchives/components/button/button.scss @@ -5,6 +5,8 @@ @use "../../tools/typography"; @use "button-group"; +$button-border-width: 4px !default; + .tna-button { padding: spacing.space(0.25) spacing.space(1); @@ -22,7 +24,7 @@ @include colour.colour-background("button-background"); - @include colour.colour-border("button-background", 4px); + @include colour.colour-border("button-background", $button-border-width); cursor: pointer; @@ -144,7 +146,7 @@ &:not(.tna-button--plain):hover { @include colour.colour-font("font-dark"); - @include colour.colour-background("page-background"); + @include colour.colour-background("background"); } } @@ -157,9 +159,9 @@ .tna-background-accent &--accent { @include colour.plain; - @include colour.colour-background("page-background"); + @include colour.colour-background("background"); - @include colour.colour-border("page-background"); + @include colour.colour-border("background"); &, &:link, @@ -168,7 +170,7 @@ } &:hover { - @include colour.colour-font("page-background"); + @include colour.colour-font("background"); @include colour.colour-background("font-dark"); } diff --git a/src/nationalarchives/components/button/macro-options.json b/src/nationalarchives/components/button/macro-options.json index 9df9f6a0..6d3a1bff 100644 --- a/src/nationalarchives/components/button/macro-options.json +++ b/src/nationalarchives/components/button/macro-options.json @@ -3,73 +3,73 @@ "name": "text", "type": "string", "required": true, - "description": "" + "description": "The text of the button." }, { "name": "href", "type": "string", "required": false, - "description": "" + "description": "A URL to use as a link for the button." }, { "name": "title", "type": "string", "required": false, - "description": "" + "description": "A title attribute for the button." }, { "name": "icon", "type": "string", "required": false, - "description": "" + "description": "The name of a Font Awesome icon, without the prefixed `fa-`." }, { "name": "accent", "type": "boolean", "required": false, - "description": "" + "description": "If true, set the colour of the button to the page's accent colour." }, { "name": "small", "type": "boolean", "required": false, - "description": "" + "description": "If true, make the button smaller." }, { "name": "plain", "type": "boolean", "required": false, - "description": "" + "description": "If true, remove the background colour of the button and make it look more like a link." }, { "name": "iconOnly", "type": "boolean", "required": false, - "description": "" + "description": "If true, don't show the text of the button." }, { "name": "iconOnlyOnMobile", "type": "boolean", "required": false, - "description": "" + "description": "If true, show both the text and icon on larger devices but only show the icon on smaller devices." }, { "name": "rightAlignIcon", "type": "boolean", "required": false, - "description": "" + "description": "If true, align the icon to the right hand side of the button." }, { "name": "buttonElement", "type": "boolean", "required": false, - "description": "" + "description": "If true, use a `