Card title
Card body
diff --git a/CHANGELOG.md b/CHANGELOG.md index c2916c95..cd767058 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 - Added `itemHeadingLevel` to file list component and changed file titles to headings - Ordered and unordered lists can be spaced out with `.tna-ul--spaced` and `.tna-ol--spaced` - The contents of the details element can be [called in Nunjucks](https://mozilla.github.io/nunjucks/templating.html#call) +- Cards can be made entirely clickable using the `fullAreaClick` property ### Changed @@ -23,6 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated ### Removed + +- Cards can no longer have plain supertitles + ### Fixed - Fixed spacing in nested lists diff --git a/src/nationalarchives/components/card/card.scss b/src/nationalarchives/components/card/card.scss index 263b51f9..ef7ce101 100644 --- a/src/nationalarchives/components/card/card.scss +++ b/src/nationalarchives/components/card/card.scss @@ -7,6 +7,8 @@ .tna-card { @include spacing.space-above; + position: relative; + &__inner { display: flex; flex-direction: column; @@ -35,6 +37,16 @@ } } + &--full-click &__heading-link { + &::before { + content: ""; + + position: absolute; + inset: 0; + z-index: 3; + } + } + &__image-container { height: 0; margin-bottom: spacing.space(1); @@ -47,6 +59,7 @@ &__image { position: absolute; inset: 0; + z-index: 1; img { width: 100%; @@ -62,6 +75,7 @@ position: absolute; top: spacing.space(0.5); left: spacing.space(0.5); + z-index: 2; .tna-background-accent &:not(.tna-chip--plain) { @include colour.accent; @@ -135,6 +149,7 @@ position: absolute; inset: 0 50% 0 0; + z-index: 1; } .tna-card__heading, diff --git a/src/nationalarchives/components/card/card.stories.js b/src/nationalarchives/components/card/card.stories.js index 27ecbc6f..9a267e09 100644 --- a/src/nationalarchives/components/card/card.stories.js +++ b/src/nationalarchives/components/card/card.stories.js @@ -26,12 +26,12 @@ const argTypes = { body: { control: "text" }, text: { control: "text" }, actions: { control: "object" }, + fullAreaClick: { control: "boolean" }, horizontal: { control: "boolean" }, style: { control: "inline-radio", options: ["none", "contrast", "tint", "accent"], }, - plainSupertitle: { control: "boolean" }, htmlElement: { control: "text" }, classes: { control: "text" }, attributes: { control: "object" }, @@ -71,9 +71,9 @@ const Template = ({ body, text, actions, + fullAreaClick, horizontal, style, - plainSupertitle, htmlElement, classes, attributes, @@ -100,9 +100,9 @@ const Template = ({ body, text, actions, + fullAreaClick, horizontal, style, - plainSupertitle, htmlElement, classes, attributes, @@ -166,24 +166,6 @@ Meta.args = { classes: "tna-card--demo", }; -export const PlainSupertitle = Template.bind({}); -PlainSupertitle.args = { - supertitle: "Card supertitle", - title: "Card title", - headingLevel: 3, - headingSize: "m", - href: "#", - 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, - body: "
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam vel tincidunt velit, a molestie turpis.
", - htmlElement: "article", - plainSupertitle: true, - classes: "tna-card--demo", -}; - export const Contrast = Template.bind({}); Contrast.args = { supertitle: "Card supertitle", @@ -380,6 +362,25 @@ HorizontalContrastMobile.args = { classes: "tna-card--demo", }; +export const FullClick = Template.bind({}); +FullClick.args = { + supertitle: "Card supertitle", + title: "Card title", + href: "#", + headingLevel: 3, + headingSize: "l", + 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, + label: "New", + body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam vel tincidunt velit, a molestie turpis.
", + fullAreaClick: true, + htmlElement: "article", + classes: "tna-card--demo", +}; + export const Sources = Template.bind({}); Sources.args = { supertitle: "Card supertitle", diff --git a/src/nationalarchives/components/card/fixtures.json b/src/nationalarchives/components/card/fixtures.json index b0ef97da..6f66b0a1 100644 --- a/src/nationalarchives/components/card/fixtures.json +++ b/src/nationalarchives/components/card/fixtures.json @@ -285,6 +285,44 @@ }, "html": "Card body
Card body
", + "fullAreaClick": true + }, + "html": "Card body
Card body
", + "fullAreaClick": true + }, + "html": "Card body
Card body
", + "fullAreaClick": true, + "actions": [ + { + "text": "Card action", + "href": "#" + } + ] + }, + "html": "{{ params.supertitle }}
+{{ params.supertitle }}