From 87b3b7fd9cb0c51fff8ad737271425fd7d9591e2 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Wed, 13 Sep 2023 16:36:55 +0100 Subject: [PATCH] Revert to use single sentence heading in card --- .../components/card/card.stories.js | 36 +++++++++++-- .../components/card/fixtures.json | 28 +++++------ .../components/card/template.njk | 50 +++++++++---------- .../typography/heading-groups.stories.js | 20 +++++++- .../utilities/typography/typography.mdx | 11 ++++ .../utilities/_typography.scss | 50 +++++++++---------- 6 files changed, 127 insertions(+), 68 deletions(-) diff --git a/src/nationalarchives/components/card/card.stories.js b/src/nationalarchives/components/card/card.stories.js index aa05c351..70e3488a 100644 --- a/src/nationalarchives/components/card/card.stories.js +++ b/src/nationalarchives/components/card/card.stories.js @@ -64,7 +64,7 @@ Standard.args = { supertitle: "Card supertitle", title: "Card title", level: 3, - size: "l", + size: "m", }, href: "#", image: { @@ -92,7 +92,7 @@ Boxed.args = { supertitle: "Card supertitle", title: "Card title", level: 3, - size: "l", + size: "m", }, href: "#", image: { @@ -114,7 +114,7 @@ Accent.args = { supertitle: "Card supertitle", title: "Card title", level: 3, - size: "l", + size: "m", }, href: "#", image: { @@ -189,6 +189,36 @@ HorizontalBoxed.args = { classes: "tna-card--demo", }; +export const HorizontalAccent = Template.bind({}); +HorizontalAccent.args = { + heading: { + supertitle: "Card supertitle", + title: "Card title", + level: 3, + size: "l", + }, + 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, + }, + label: "New", + body: "

Card body

", + actions: [ + { + text: "Card action", + href: "#", + title: "Go and do the action", + icon: "calendar", + }, + ], + horizontal: true, + style: "accent", + htmlElement: "article", + classes: "tna-card--demo", +}; + const GridTemplate = ({ heading, href, diff --git a/src/nationalarchives/components/card/fixtures.json b/src/nationalarchives/components/card/fixtures.json index 9af9f8a6..9e7401d5 100644 --- a/src/nationalarchives/components/card/fixtures.json +++ b/src/nationalarchives/components/card/fixtures.json @@ -10,7 +10,7 @@ }, "body": "

Card body

" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -23,7 +23,7 @@ }, "body": "

Card body

" }, - "html": "

Card supertitle

Card title

Card body

", + "html": "

Card supertitleCard title

Card body

", "hidden": false }, { @@ -48,7 +48,7 @@ }, "body": "

Card body

" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -61,7 +61,7 @@ "href": "#", "body": "

Card body

" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -73,7 +73,7 @@ }, "text": "Card body" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -91,7 +91,7 @@ }, "body": "

Card body

" }, - "html": "

Card title

\"A

Card body

", + "html": "

Card title

\"A

Card body

", "hidden": false }, { @@ -110,7 +110,7 @@ "href": "#", "body": "

Card body

" }, - "html": "

Card title

\"A

Card body

", + "html": "

Card title

\"A

Card body

", "hidden": false }, { @@ -129,7 +129,7 @@ } ] }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -142,7 +142,7 @@ "label": "New", "body": "

Card body

" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -155,7 +155,7 @@ "body": "

Card body

", "style": "boxed" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -168,7 +168,7 @@ "body": "

Card body

", "style": "accent" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -181,7 +181,7 @@ "body": "

Card body

", "style": "foobar" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -194,7 +194,7 @@ "body": "

Card body

", "classes": "card__test-class" }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false }, { @@ -209,7 +209,7 @@ "data-testattribute": "foobar" } }, - "html": "

Card title

Card body

", + "html": "

Card title

Card body

", "hidden": false } ] diff --git a/src/nationalarchives/components/card/template.njk b/src/nationalarchives/components/card/template.njk index 704067ff..4a765218 100644 --- a/src/nationalarchives/components/card/template.njk +++ b/src/nationalarchives/components/card/template.njk @@ -11,43 +11,43 @@ <{{ htmlElement }} class="tna-card {{ containerClasses | join(' ') }}" data-module="tna-card" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
{%- if params.heading.supertitle -%} -
-

{{ params.heading.supertitle }}

- - {%- if params.href -%} +
+ + {{ params.heading.supertitle }} + {%- if params.href -%} {{ params.heading.title }} - {%- else -%} + {%- else -%} {{ params.heading.title }} - {%- endif -%} + {%- endif -%}
{%- else -%} - - {%- if params.href -%} + + {%- if params.href -%} {{ params.heading.title }} - {%- else -%} + {%- else -%} {{ params.heading.title }} - {%- endif -%} + {%- endif -%} - {%- endif -%} - {%- if params.image -%} - {%- if params.href -%} - - {%- else -%} -
{%- endif -%} - {{ params.image.alt }} - {%- if params.label -%} - {%- endif -%} - {%- endif -%}
{%- if params.text -%}

{{ params.text }}

diff --git a/src/nationalarchives/stories/utilities/typography/heading-groups.stories.js b/src/nationalarchives/stories/utilities/typography/heading-groups.stories.js index 9afac339..0b3fa2a8 100644 --- a/src/nationalarchives/stories/utilities/typography/heading-groups.stories.js +++ b/src/nationalarchives/stories/utilities/typography/heading-groups.stories.js @@ -3,6 +3,7 @@ const argTypes = { title: { control: "text" }, level: { control: "number", min: 1, max: 6, step: 1 }, size: { control: "radio", options: ["m", "l", "xl"] }, + singleSentence: { control: "boolean" }, }; export default { @@ -15,13 +16,30 @@ const Template = ({ title, level = 3, size = "l", -}) => `
+ singleSentence, +}) => + singleSentence + ? `
+ + ${supertitle} + ${title} + +
` + : `

${supertitle}

${title}
`; export const HeadingGroup = Template.bind({}); HeadingGroup.args = { + supertitle: "The story of", + title: "Alice Hawkins", + singleSentence: true, +}; + +export const HeadingGroupSeparated = Template.bind({}); +HeadingGroupSeparated.args = { supertitle: "Record revealed", title: "The Monteagle Letter", + singleSentence: false, }; diff --git a/src/nationalarchives/stories/utilities/typography/typography.mdx b/src/nationalarchives/stories/utilities/typography/typography.mdx index 0f9812fc..13ffdb0c 100644 --- a/src/nationalarchives/stories/utilities/typography/typography.mdx +++ b/src/nationalarchives/stories/utilities/typography/typography.mdx @@ -14,8 +14,19 @@ We use a set of typefaces... + +## Heading groups + +Although visually identical, there are two types of header groups based on whether the group should be read as a single sentence or not. + +In the first example, the heading will be read by screen readers as `The story of Alice Hawkins.` + +In the second example, the heading will be read as two separate sentences; `Record revealed. The Monteagle Letter.` + + + ## General typography diff --git a/src/nationalarchives/utilities/_typography.scss b/src/nationalarchives/utilities/_typography.scss index d62a58e5..2da3b719 100644 --- a/src/nationalarchives/utilities/_typography.scss +++ b/src/nationalarchives/utilities/_typography.scss @@ -156,6 +156,31 @@ a { } } +%heading { + @include colour.colour-font("font-dark"); + @include typography.heading-font; + + a { + display: inline-block; + + &::after { + padding-left: 0.25rem; + + display: inline-block; + + font-weight: 700; + + content: "\203A"; + } + + &:hover { + &::after { + padding-left: 0.5rem; + } + } + } +} + %heading-xl { @include typography.relative-font-size(64); line-height: 1.2; @@ -194,31 +219,6 @@ a { line-height: 1.6; } -%heading { - @include colour.colour-font("font-dark"); - @include typography.heading-font; - - a { - display: inline-block; - - &::after { - padding-left: 0.25rem; - - display: inline-block; - - font-weight: 700; - - content: "\203A"; - } - - &:hover { - &::after { - padding-left: 0.5rem; - } - } - } -} - .tna-heading { @extend %heading;