Skip to content

Commit

Permalink
Card and cookie banner styles (#67)
Browse files Browse the repository at this point in the history
* Allow plain cookie banner, change boxed for contrast

* Update fixture
  • Loading branch information
ahosgood authored Dec 19, 2023
1 parent 8004ae4 commit d47bd3d
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
### Changed

- The default cookie banner colour is dark on light but can be changed with a `style` attribute or classes such as `tna-cookie-banner--contrast`
- The card style of `boxed` has been changed to `contrast` in line with other components

### Deprecated
### Removed
### Fixed
Expand Down
14 changes: 7 additions & 7 deletions src/nationalarchives/components/card/card.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const argTypes = {
text: { control: "text" },
actions: { control: "object" },
horizontal: { control: "boolean" },
style: { control: "inline-radio", options: ["none", "boxed", "accent"] },
style: { control: "inline-radio", options: ["none", "contrast", "accent"] },
plainSupertitle: { control: "boolean" },
htmlElement: { control: "text" },
classes: { control: "text" },
Expand Down Expand Up @@ -170,8 +170,8 @@ PlainSupertitle.args = {
classes: "tna-card--demo",
};

export const Boxed = Template.bind({});
Boxed.args = {
export const Contrast = Template.bind({});
Contrast.args = {
supertitle: "Card supertitle",
title: "Card title",
headingLevel: 3,
Expand All @@ -184,7 +184,7 @@ Boxed.args = {
imageHeight: 333,
label: "New",
body: "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam vel tincidunt velit, a molestie turpis.</p>",
style: "boxed",
style: "contrast",
htmlElement: "article",
classes: "tna-card--demo",
};
Expand Down Expand Up @@ -234,8 +234,8 @@ Horizontal.args = {
classes: "tna-card--demo",
};

export const HorizontalBoxed = Template.bind({});
HorizontalBoxed.args = {
export const HorizontalContrast = Template.bind({});
HorizontalContrast.args = {
supertitle: "Card supertitle",
title: "Card title",
headingLevel: 3,
Expand All @@ -256,7 +256,7 @@ HorizontalBoxed.args = {
},
],
horizontal: true,
style: "boxed",
style: "contrast",
htmlElement: "article",
classes: "tna-card--demo",
};
Expand Down
4 changes: 2 additions & 2 deletions src/nationalarchives/components/card/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@
"hidden": false
},
{
"name": "with a boxed style",
"name": "with a contrast style",
"options": {
"title": "Card title",
"headingLevel": 3,
"body": "<p>Card body</p>",
"style": "boxed"
"style": "contrast"
},
"html": "<div class=\"tna-card tna-card--contrast\"><div class=\"tna-card__inner\"><h3 class=\" tna-heading-s tna-card__heading\">Card title</h3><div class=\"tna-card__body\"><p>Card body</p></div></div></div>",
"hidden": false
Expand Down
2 changes: 1 addition & 1 deletion src/nationalarchives/components/card/macro-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
"name": "style",
"type": "text",
"required": false,
"description": "The style of card to use which can be either `boxed` for an inverted card or `accent` for a card that matches the page's accent colour."
"description": "The style of card to use which can be either `contrast` for an inverted card or `accent` for a card that matches the page's accent colour."
},
{
"name": "plainSupertitle",
Expand Down
2 changes: 1 addition & 1 deletion src/nationalarchives/components/card/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{%- if params.horizontal -%}
{%- set containerClasses = containerClasses.concat('tna-card--horizontal') -%}
{%- endif -%}
{%- if params.style == "boxed" -%}
{%- if params.style == "contrast" -%}
{%- set containerClasses = containerClasses.concat('tna-card--contrast') -%}
{%- elseif params.style == "accent" -%}
{%- set containerClasses = containerClasses.concat('tna-card--accent') -%}
Expand Down
14 changes: 12 additions & 2 deletions src/nationalarchives/components/cookie-banner/cookie-banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
@use "../grid";

.tna-cookie-banner {
@include colour.contrast;

padding-top: 2rem;
padding-bottom: 2rem;

&--contrast {
@include colour.contrast;
}

&--accent {
@include colour.accent;
}

&--tint {
@include colour.tint;
}

@include media.on-tiny {
padding-top: 1rem;
padding-bottom: 1rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const argTypes = {
cookiesDomain: { control: "text" },
cookiesPath: { control: "text" },
allowInsecure: { control: "boolean" },
style: {
control: "inline-radio",
options: ["none", "contrast", "accent", "tint"],
},
classes: { control: "text" },
attributes: { control: "object" },
};
Expand All @@ -37,6 +41,7 @@ const Template = ({
cookiesDomain,
cookiesPath,
allowInsecure,
style,
classes,
attributes,
}) =>
Expand All @@ -50,6 +55,7 @@ const Template = ({
cookiesDomain,
cookiesPath,
allowInsecure,
style,
classes,
attributes,
},
Expand All @@ -66,6 +72,7 @@ Accept.args = {
serviceName: "My service",
cookiesUrl: "#",
allowInsecure: true,
style: "contrast",
classes: "tna-cookie-banner--demo",
};
Accept.play = async ({ canvasElement }) => {
Expand Down Expand Up @@ -106,6 +113,7 @@ export const Reject = Template.bind({});
Reject.args = {
serviceName: "My service",
cookiesUrl: "#",
style: "contrast",
classes: "tna-cookie-banner--demo",
};
Reject.play = async ({ canvasElement }) => {
Expand Down Expand Up @@ -143,6 +151,7 @@ CustomPolicies.args = {
serviceName: "My service",
cookiesUrl: "#",
policies: "custom",
style: "contrast",
classes: "tna-cookie-banner--demo",
};
CustomPolicies.parameters = {
Expand Down Expand Up @@ -178,6 +187,7 @@ Existing.args = {
serviceName: "My service",
cookiesUrl: "#",
allowInsecure: true,
style: "contrast",
classes: "tna-cookie-banner--demo",
};
Existing.decorators = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"required": false,
"description": ""
},
{
"name": "style",
"type": "text",
"required": false,
"description": "The style of banner to use which can be either `contrast` for an inverted style, `accent` for a banner that matches the page's accent colour or `tint` for a subtle, tinted banner."
},
{
"name": "classes",
"type": "string",
Expand Down
7 changes: 7 additions & 0 deletions src/nationalarchives/components/cookie-banner/template.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{% from "nationalarchives/components/button/macro.njk" import tnaButton %}

{%- set containerClasses = [params.classes] if params.classes else [] -%}
{%- if params.style == "contrast" -%}
{%- set containerClasses = containerClasses.concat('tna-cookie-banner--contrast') -%}
{%- elseif params.style == "accent" -%}
{%- set containerClasses = containerClasses.concat('tna-cookie-banner--accent') -%}
{%- elseif params.style == "tint" -%}
{%- set containerClasses = containerClasses.concat('tna-cookie-banner--tint') -%}
{%- endif -%}
<section class="tna-cookie-banner {{ containerClasses | join(' ') }}" data-module="tna-cookie-banner" role="region" data-policies="{{ params.policies if params.policies }}" data-preferenceskey="{{ params.preferencesSetKey if params.preferencesSetKey }}" data-policieskey="{{ params.policiesKey if params.policiesKey }}" data-domain="{{ params.cookiesDomain if params.cookiesDomain }}" data-path="{{ params.cookiesPath if params.cookiesPath }}" data-insecure="{{ true if params.allowInsecure else 'false' }}" aria-label="Cookies on {{ params.serviceName }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %} hidden>
<div class="tna-container">
<div class="tna-column tna-column--full tna-cookie-banner__message tna-cookie-banner__message--prompt">
Expand Down
5 changes: 5 additions & 0 deletions src/nationalarchives/components/picture/picture.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
max-height: none;
height: auto;
}

&__caption {
margin-right: 0;
margin-left: 0;
}
}

@include colour.on-high-contrast-and-forced-colours {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ const Template = ({ theme, accent }) => {
${Card({
params: {
...cardDefaultOptions,
style: "boxed",
style: "contrast",
classes: "tna-!--margin-bottom-m",
},
})}
Expand Down Expand Up @@ -505,7 +505,7 @@ const Template = ({ theme, accent }) => {
params: {
...cardDefaultOptions,
horizontal: true,
style: "boxed",
style: "contrast",
classes: "tna-!--margin-bottom-m",
},
})}
Expand Down

0 comments on commit d47bd3d

Please sign in to comment.