diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99b12173..96808d70 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- "Thick" and button border widths are both customisable
- The colour of a card label can be changed
- Accent colours can be set on blocks with `tna-accent-pink`, `tna-accent-orange`, `tna-accent-yellow`, `tna-accent-blue` and `tna-accent-green`
+- Hero components can now have a "shifted" style option and can have contrasting, tinted and accent backgrounds
### Changed
@@ -26,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### 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
+- Hero components no longer have `heading`, `body` or `text` properties - these have been replaced with a `content` property
### Fixed
diff --git a/src/nationalarchives/components/hero/fixtures.json b/src/nationalarchives/components/hero/fixtures.json
index 799cf855..622aa5d6 100644
--- a/src/nationalarchives/components/hero/fixtures.json
+++ b/src/nationalarchives/components/hero/fixtures.json
@@ -4,70 +4,108 @@
{
"name": "minimal",
"options": {
- "heading": "Title",
"imageSrc": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg",
"imageAlt": "The National Archives office",
"imageWidth": 499,
"imageHeight": 333
},
- "html": "
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", "imageSrc": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", "imageAlt": "The National Archives office", "imageWidth": 499, "imageHeight": 333 }, - "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", "imageSrc": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", "imageAlt": "The National Archives office", "imageWidth": 499, - "imageHeight": 333 + "imageHeight": 333, + "style": "accent" }, - "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", "imageSrc": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", "imageAlt": "The National Archives office", "imageWidth": 499, "imageHeight": 333, - "imageCaption": "An interesting photo by a famous photographer ©2023" + "style": "contrast" }, - "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", + "imageSrc": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", + "imageAlt": "The National Archives office", + "imageWidth": 499, + "imageHeight": 333, + "style": "tint" + }, + "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", + "imageSrc": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", + "imageAlt": "The National Archives office", + "imageWidth": 499, + "imageHeight": 333, + "shifted": true + }, + "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", + "imageSrc": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", + "imageAlt": "The National Archives office", + "imageWidth": 499, + "imageHeight": 333, + "style": "accent", + "shifted": true + }, + "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", + content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`, imageSrc: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", imageAlt: "The National Archives office", imageWidth: 499, imageHeight: 333, imageCaption: "An interesting photo by a famous photographer ©2023", - classes: "tna-hero--demo", }; Standard.play = async ({ args, canvasElement, step }) => { @@ -78,13 +79,13 @@ Standard.play = async ({ args, canvasElement, step }) => { const canvas = within(canvasElement); const image = canvas.getByAltText(args.imageAlt); - const title = canvas.getByText(args.heading); + const content = canvasElement.querySelector(".tna-hero__content"); const summary = canvasElement.querySelector(".tna-hero__details-summary"); const information = canvas.getByText(args.imageCaption); await step("Initial load", async () => { await expect(image).toBeVisible(); - await expect(title).toBeVisible(); + await expect(content).toBeVisible(); await expect(summary).toBeVisible(); await expect(information).not.toBeVisible(); }); @@ -100,15 +101,93 @@ Standard.play = async ({ args, canvasElement, step }) => { }); }; -export const HeadingOnly = Template.bind({}); -HeadingOnly.args = { - heading: "Title", +export const LargeContent = Template.bind({}); +LargeContent.parameters = { + chromatic: { disableSnapshot: true }, +}; +LargeContent.args = { + content: ` +Focus on
+Switchboard LGBT+ Helpline is one of the oldest telephone help services for lesbian, gay, bisexual, transgender and queer people in the UK. Despite high demand for its support, prejudice and laws meant Switchboard’s journey to register as a charity was not easy.
`, + imageSrc: + "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", + imageAlt: "The National Archives office", + imageWidth: 499, + imageHeight: 333, + imageCaption: "An interesting photo by a famous photographer ©2023", + style: "accent", +}; + +export const Accent = Template.bind({}); +Accent.parameters = { + chromatic: { disableSnapshot: true }, +}; +Accent.args = { + content: ` +Supertitle
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`, + imageSrc: + "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", + imageAlt: "The National Archives office", + imageWidth: 499, + imageHeight: 333, + imageCaption: "An interesting photo by a famous photographer ©2023", + style: "accent", +}; + +export const Contrast = Template.bind({}); +Contrast.parameters = { + chromatic: { disableSnapshot: true }, +}; +Contrast.args = { + content: ` +Supertitle
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`, imageSrc: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", imageAlt: "The National Archives office", imageWidth: 499, imageHeight: 333, - classes: "tna-hero--demo", + imageCaption: "An interesting photo by a famous photographer ©2023", + style: "contrast", +}; + +export const Tint = Template.bind({}); +Tint.parameters = { + chromatic: { disableSnapshot: true }, +}; +Tint.args = { + content: ` +Supertitle
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`, + imageSrc: + "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", + imageAlt: "The National Archives office", + imageWidth: 499, + imageHeight: 333, + imageCaption: "An interesting photo by a famous photographer ©2023", + style: "tint", +}; + +export const Shifted = Template.bind({}); +Shifted.args = { + content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`, + imageSrc: + "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", + imageAlt: "The National Archives office", + imageWidth: 499, + imageHeight: 333, + imageCaption: "An interesting photo by a famous photographer ©2023", + style: "accent", + shifted: true, }; export const CaptionWithNoHeading = Template.bind({}); @@ -122,7 +201,6 @@ CaptionWithNoHeading.args = { imageWidth: 499, imageHeight: 333, imageCaption: "An interesting photo by a famous photographer ©2023", - classes: "tna-hero--demo", }; export const Sources = Template.bind({}); @@ -130,8 +208,7 @@ Sources.parameters = { chromatic: { disableSnapshot: true }, }; Sources.args = { - heading: "Title", - body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", + content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`, imageSrc: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", imageAlt: "The National Archives office", @@ -146,7 +223,6 @@ Sources.args = { height: 404, }, ], - classes: "tna-hero--demo", }; export const Mobile = Template.bind({}); @@ -159,13 +235,11 @@ Mobile.parameters = { }, }; Mobile.args = { - heading: "Title", - body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", + content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`, imageSrc: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", imageAlt: "The National Archives office", imageWidth: 499, imageHeight: 333, imageCaption: "An interesting photo by a famous photographer ©2023", - classes: "tna-hero--demo", }; diff --git a/src/nationalarchives/components/hero/macro-options.json b/src/nationalarchives/components/hero/macro-options.json index 206053c0..df9c3238 100644 --- a/src/nationalarchives/components/hero/macro-options.json +++ b/src/nationalarchives/components/hero/macro-options.json @@ -1,18 +1,6 @@ [ { - "name": "heading", - "type": "string", - "required": false, - "description": "" - }, - { - "name": "body", - "type": "string", - "required": false, - "description": "" - }, - { - "name": "text", + "name": "content", "type": "string", "required": false, "description": "" @@ -91,6 +79,18 @@ "required": false, "description": "" }, + { + "name": "style", + "type": "string", + "required": false, + "description": "The style of hero to use. This can be `contrast`, `tint` or `accent`." + }, + { + "name": "shifted", + "type": "boolean", + "required": false, + "description": "" + }, { "name": "classes", "type": "string", diff --git a/src/nationalarchives/components/hero/template.njk b/src/nationalarchives/components/hero/template.njk index 89d92401..db6e3edf 100644 --- a/src/nationalarchives/components/hero/template.njk +++ b/src/nationalarchives/components/hero/template.njk @@ -1,10 +1,20 @@ {%- set containerClasses = [params.classes] if params.classes else [] -%} -<{{ 'header' if params.heading else 'div' }} class="tna-hero {{ containerClasses | join(' ') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> +{%- if params.style == "contrast" -%} + {%- set containerClasses = containerClasses.concat('tna-hero--contrast') -%} +{%- elseif params.style == "tint" -%} + {%- set containerClasses = containerClasses.concat('tna-hero--tint') -%} +{%- elseif params.style == "accent" -%} + {%- set containerClasses = containerClasses.concat('tna-hero--accent') -%} +{%- endif -%} +{%- if params.shifted -%} + {%- set containerClasses = containerClasses.concat('tna-hero--shifted') -%} +{%- endif -%} +<{{ 'header' if params.content else 'div' }} class="tna-hero {{ containerClasses | join(' ') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> -{{ 'header' if params.heading else 'div' }}> +{{ 'header' if params.content else 'div' }}> diff --git a/src/nationalarchives/components/search-filters/search-filters.scss b/src/nationalarchives/components/search-filters/search-filters.scss index c7609baa..7c3de9f9 100644 --- a/src/nationalarchives/components/search-filters/search-filters.scss +++ b/src/nationalarchives/components/search-filters/search-filters.scss @@ -108,7 +108,7 @@ &__item { padding: spacing.space(0.75); - @include colour.colour-background("background-tint"); + @include colour.tint; @include colour.colour-border("keyline", 1px); border-width: 0 1px 1px; diff --git a/src/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js b/src/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js index a64fd267..21bacaf7 100644 --- a/src/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js +++ b/src/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js @@ -202,7 +202,6 @@ const Template = ({ theme, accent }) => { imageWidth: 499, imageHeight: 333, imageCaption: "An interesting photo by a famous photographer ©2023", - classes: "tna-hero--demo", }, })}