Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional phase banners to the top of the header components #170

Merged
merged 5 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- 'README.md'
tags-ignore:
- '**'
pull_request:
types:
- opened
- synchronize

concurrency:
group: tests-${{ github.ref }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added `labelText` option to breadcrumbs to enable custom `aria-label` attributes
- Phase banners can be added at the top of the header and global header components

### Changed
### Deprecated
### Removed

- Remove `accent` option of the phase banner component

### Fixed

- Clicking on a gallery item doesn't break keyboard navigation for the gallery
Expand Down
42 changes: 40 additions & 2 deletions src/nationalarchives/components/global-header/fixtures.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
@use "../../tools/typography";

.tna-global-header {
padding-top: spacing.space(1);

@include colour.contrast;
background: linear-gradient(
0deg,
Expand All @@ -29,6 +27,7 @@
}

&__main {
padding-top: spacing.space(1);
padding-bottom: spacing.space(1.5);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const argTypes = {
collapseOnMedium: { control: "boolean" },
navigationId: { control: "text" },
topNavigationId: { control: "text" },
phaseBanner: { control: "object" },
classes: { control: "text" },
attributes: { control: "object" },
};
Expand All @@ -35,6 +36,7 @@ const Template = ({
collapseOnMedium,
navigationId,
topNavigationId,
phaseBanner,
classes,
attributes,
}) =>
Expand All @@ -46,6 +48,7 @@ const Template = ({
collapseOnMedium,
navigationId,
topNavigationId,
phaseBanner,
classes,
attributes,
},
Expand Down Expand Up @@ -366,3 +369,58 @@ Mobile.play = async ({ args, canvasElement, step }) => {

$navigationToggle.blur();
};

export const WithPhaseBanner = Template.bind({});
WithPhaseBanner.args = {
logo: {
href: "#/",
},
topNavigation: [
{
text: "Search",
href: "https://www.nationalarchives.gov.uk/search/",
icon: "search",
},
{
text: "Shop",
href: "https://shop.nationalarchives.gov.uk/",
icon: "shop",
},
{
text: "Sign in",
href: "#/sign-in",
icon: "user",
},
],
navigation: [
{
text: "Visit",
href: "https://www.nationalarchives.gov.uk/about/visit-us/",
},
{
text: "What’s on",
href: "https://www.nationalarchives.gov.uk/about/visit-us/whats-on/",
},
{
text: "Explore the collection",
href: "https://beta.nationalarchives.gov.uk/explore-the-collection/",
},
{
text: "Help using the archive",
href: "https://www.nationalarchives.gov.uk/help-with-your-research/",
},
{
text: "Education",
href: "https://www.nationalarchives.gov.uk/education/",
},
{
text: "Professional guidance and services",
href: "https://www.nationalarchives.gov.uk/professional-guidance-and-services/",
},
],
phaseBanner: {
phase: "beta",
message: `This is a new service – <a href="#">give us your feedback</a> to help improve it.`,
},
classes: "tna-global-header--demo",
};
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
"required": false,
"description": ""
},
{
"name": "phaseBanner",
"type": "object",
"required": false,
"description": "",
"paramsFrom": "phase-banner"
},
{
"name": "classes",
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions src/nationalarchives/components/global-header/template.njk
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{% from "nationalarchives/components/phase-banner/macro.njk" import tnaPhaseBanner %}

{%- set containerClasses = [params.classes] if params.classes else [] -%}
{%- if params.collapseOnMedium -%}
{%- set containerClasses = containerClasses.concat('tna-global-header--collapse-on-medium') -%}
{%- endif -%}
{%- set classes = containerClasses | join(' ') -%}
<header class="tna-global-header{% if classes %} {{ classes }}{% endif %}" data-module="tna-global-header"{% for attribute, value in params.attributes %} {{ attribute }}{% if value !== '' %}="{{ value }}"{% endif %}{% endfor %}>
{% if params.phaseBanner -%}
{{ tnaPhaseBanner(params.phaseBanner) }}
{% endif -%}
<div class="tna-container tna-global-header__main">
<div class="tna-column tna-column--flex-1 tna-column--order-2">
<span class="tna-global-header__logo-wrapper">
Expand Down
121 changes: 116 additions & 5 deletions src/nationalarchives/components/header/fixtures.json

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions src/nationalarchives/components/header/header.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const argTypes = {
accent: {
control: "boolean",
},
phaseBanner: { control: "object" },
classes: { control: "text" },
attributes: { control: "object" },
};
Expand All @@ -33,6 +34,7 @@ const Template = ({
topNavigation,
navigation,
accent,
phaseBanner,
classes,
attributes,
}) =>
Expand All @@ -42,6 +44,7 @@ const Template = ({
topNavigation,
navigation,
accent,
phaseBanner,
classes,
attributes,
},
Expand Down Expand Up @@ -224,3 +227,42 @@ Mobile.play = async ({ args, canvasElement, step }) => {

$navigationToggle.blur();
};

export const WithPhaseBanner = Template.bind({});
WithPhaseBanner.args = {
logo: {
strapline: "Design System",
href: "#/",
},
topNavigation: [
{
text: "Top item 1",
href: "#/top-1",
},
{
text: "Top item 2",
href: "#/top-2",
icon: "heart",
},
],
navigation: [
{
text: "Alpha",
href: "#/alpha",
selected: true,
},
{
text: "Beta",
href: "#/beta",
},
{
text: "Gamma",
href: "#/gamma",
},
],
phaseBanner: {
phase: "beta",
message: `This is a new service – <a href="#">give us your feedback</a> to help improve it.`,
},
classes: "tna-header--demo",
};
7 changes: 7 additions & 0 deletions src/nationalarchives/components/header/macro-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@
"required": false,
"description": ""
},
{
"name": "phaseBanner",
"type": "object",
"required": false,
"description": "",
"paramsFrom": "phase-banner"
},
{
"name": "classes",
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions src/nationalarchives/components/header/template.njk
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{% from "nationalarchives/components/phase-banner/macro.njk" import tnaPhaseBanner %}

{%- set containerClasses = [params.classes] if params.classes else [] -%}
{%- if params.accent -%}
{%- set containerClasses = containerClasses.concat('tna-background-accent') -%}
{%- endif -%}
{%- set classes = containerClasses | join(' ') -%}
<header class="tna-header{% if classes %} {{ classes }}{% endif %}" data-module="tna-header"{% for attribute, value in params.attributes %} {{ attribute }}{% if value !== '' %}="{{ value }}"{% endif %}{% endfor %}>
{% if params.phaseBanner -%}
{{ tnaPhaseBanner(params.phaseBanner) }}
{% endif -%}
<div class="tna-container tna-header__contents">
<div class="tna-column tna-header__logo-wrapper">
{% if params.logo.href -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
"required": true,
"description": ""
},
{
"name": "accent",
"type": "boolean",
"required": false,
"description": ""
},
{
"name": "classes",
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

@include typography.font-size(16);

border-bottom: 1px transparent solid;

.tna-container {
align-items: center;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const argTypes = {
control: "text",
},
message: { control: "text" },
accent: { control: "boolean" },
classes: { control: "text" },
attributes: { control: "object" },
};
Expand Down
3 changes: 0 additions & 3 deletions src/nationalarchives/components/phase-banner/template.njk
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{%- set containerClasses = [params.classes] if params.classes else [] -%}
{%- if params.accent -%}
{%- set containerClasses = containerClasses.concat('tna-background-accent') -%}
{%- endif -%}
{%- set classes = containerClasses | join(' ') -%}
<div class="tna-phase-banner{% if classes %} {{ classes }}{% endif %}" {%- for attribute, value in params.attributes %} {{ attribute }}{% if value !== '' %}="{{ value }}"{% endif %}{% endfor %}>
<div class="tna-container">
Expand Down