diff --git a/CHANGELOG.md b/CHANGELOG.md
index 755f0321..38f05999 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `typography.$base-font-size-px` is now `typography.$relative-1rem-px`
- `xl` and `l` headings are Supria Sans and `m` and `s` are Open Sans
- Card heading size defaults to `s`
+- Markup and styles altered for hero component
### Deprecated
### Removed
diff --git a/src/nationalarchives/components/hero/fixtures.json b/src/nationalarchives/components/hero/fixtures.json
index 30209b29..045c7910 100644
--- a/src/nationalarchives/components/hero/fixtures.json
+++ b/src/nationalarchives/components/hero/fixtures.json
@@ -5,14 +5,93 @@
"name": "minimal",
"options": {
"heading": "Title",
- "image": {
- "src": "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg",
- "alt": "The National Archives office",
- "width": 1996,
- "height": 1331
+ "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 + }, + "html": "Body
", - image: { - src: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", - alt: "The National Archives office", - width: 499, - height: 333, - information: "An interesting photo by a famous photographer ©2023", - }, + 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, + imageCaption: "An interesting photo by a famous photographer ©2023", classes: "tna-hero--demo", }; @@ -53,12 +75,10 @@ Standard.play = async ({ args, canvasElement, step }) => { await new Promise((r) => setTimeout(r, 100)); const canvas = within(canvasElement); - const image = canvas.getByAltText(args.image.alt); + const image = canvas.getByAltText(args.imageAlt); const title = canvas.getByText(args.heading); - const summary = canvasElement.querySelector( - ".tna-hero__image-details-summary", - ); - const information = canvas.getByText(args.image.information); + const summary = canvasElement.querySelector(".tna-hero__details-summary"); + const information = canvas.getByText(args.imageCaption); await step("Initial load", async () => { await expect(image).toBeVisible(); @@ -78,14 +98,45 @@ Standard.play = async ({ args, canvasElement, step }) => { }); }; -export const TitleOnly = Template.bind({}); -TitleOnly.args = { +export const HeadingOnly = Template.bind({}); +HeadingOnly.args = { heading: "Title", - image: { - src: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", - alt: "The National Archives office", - width: 499, - height: 333, + 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", +}; + +export const CaptionWithNoHeading = Template.bind({}); +CaptionWithNoHeading.args = { + 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", +}; + +export const Mobile = Template.bind({}); +Mobile.parameters = { + viewport: { + defaultViewport: "small", }, + chromatic: { + viewports: [customViewports["small"].styles.width.replace(/px$/, "")], + }, +}; +Mobile.args = { + heading: "Title", + 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, + 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 dde777be..5820bf9c 100644 --- a/src/nationalarchives/components/hero/macro-options.json +++ b/src/nationalarchives/components/hero/macro-options.json @@ -2,7 +2,7 @@ { "name": "heading", "type": "string", - "required": true, + "required": false, "description": "" }, { @@ -18,42 +18,34 @@ "description": "" }, { - "name": "image", - "type": "object", + "name": "imageSrc", + "type": "string", + "required": true, + "description": "" + }, + { + "name": "imageAlt", + "type": "string", "required": true, - "description": "", - "params": [ - { - "name": "src", - "type": "string", - "required": true, - "description": "" - }, - { - "name": "alt", - "type": "string", - "required": true, - "description": "" - }, - { - "name": "width", - "type": "number", - "required": true, - "description": "" - }, - { - "name": "height", - "type": "number", - "required": true, - "description": "" - }, - { - "name": "information", - "type": "string", - "required": false, - "description": "" - } - ] + "description": "" + }, + { + "name": "imageWidth", + "type": "number", + "required": true, + "description": "" + }, + { + "name": "imageHeight", + "type": "number", + "required": true, + "description": "" + }, + { + "name": "imageCaption", + "type": "string", + "required": false, + "description": "" }, { "name": "classes", diff --git a/src/nationalarchives/components/hero/template.njk b/src/nationalarchives/components/hero/template.njk index 21d7b12a..bd8367cc 100644 --- a/src/nationalarchives/components/hero/template.njk +++ b/src/nationalarchives/components/hero/template.njk @@ -1,34 +1,36 @@ {%- set containerClasses = [params.classes] if params.classes else [] -%} -{{ params.image.information }}
-Lorem ipsum dolor sit amet, consectetur adipiscing elit.
", - image: { - src: "https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg", - alt: "The National Archives office", - width: 499, - height: 333, - information: "An interesting photo by a famous photographer ©2023", - }, + 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", }, })} @@ -394,7 +395,17 @@ const Template = ({ theme, accent }) => {Lorem ipsum