Skip to content

Commit 9490bd9

Browse files
Merge branch 'develop' into fix-heading-hierarchy-in-docs
2 parents b4d9cc4 + b55b6fb commit 9490bd9

File tree

8 files changed

+71
-63
lines changed

8 files changed

+71
-63
lines changed

packages/css/src/components/header/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Includes the name of the application if it is not the general website.
1818
- On narrow windows, links can move from the inline menu to the collapsible one.
1919
- Labels should be short to help the inline menu fit on a single line whenever possible.
2020
- An icon can be added to the end of a link to make its destination easier to guess.
21+
- For websites with a brand name that feature the standard Amsterdam logo, only the emblem is shown on narrow screens.
2122

2223
## References
2324

packages/css/src/components/header/header.scss

+28-16
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,55 @@
88

99
.ams-header {
1010
/*
11-
* The branding section is created twice: once outside the navigation and once hidden inside it.
12-
* This keeps all navigation in one nav element and lets the menu wrap around the branding section.
13-
* Display grid is used to let both branding sections overlap.
11+
* The logo link section is created twice: once outside the navigation and once hidden inside it.
12+
* This keeps all navigation in one nav element and lets the menu wrap around the logo link section.
13+
* Display grid is used to let both logo link sections overlap.
1414
*/
1515
display: grid;
16+
font-family: var(--ams-header-font-family);
1617
padding-block: var(--ams-header-padding-block);
1718
padding-inline: var(--ams-header-padding-inline);
1819
}
1920

20-
.ams-header__branding {
21+
.ams-header__logo-link {
2122
align-items: center;
22-
align-self: start; // To align the branding section to the top of the header when it wraps
23-
column-gap: var(--ams-header-branding-column-gap);
23+
align-self: start; // To align the logo link section to the top of the header when it wraps
24+
column-gap: var(--ams-header-logo-link-column-gap);
2425
display: flex;
25-
grid-area: 1 / 1; // To allow this section to overlap with the second branding section
26+
grid-area: 1 / 1; // To allow this section to overlap with the second logo link section
27+
inline-size: fit-content;
28+
outline-offset: var(--ams-header-logo-link-outline-offset);
29+
text-decoration: none;
2630
}
2731

28-
.ams-header__branding--hidden {
32+
.ams-header__logo-link--hidden {
2933
opacity: 0%;
30-
user-select: none; // The hidden branding section should not be selectable
34+
user-select: none; // The hidden logo link section should not be selectable
3135
}
3236

33-
.ams-header__logo-link {
34-
outline-offset: var(--ams-header-logo-link-outline-offset);
37+
.ams-header__logo-container {
38+
flex-shrink: 0;
39+
inline-size: 0.75rem;
40+
overflow: hidden;
41+
42+
@media screen and (min-width: $ams-breakpoint-medium) {
43+
inline-size: auto;
44+
}
3545
}
3646

37-
/* TODO Remove after updating Heading line heights in DES-973. */
38-
.ams-heading.ams-header__brand-name {
47+
.ams-header__brand-name {
48+
color: var(--ams-header-brand-name-color);
49+
font-size: var(--ams-header-brand-name-font-size);
50+
font-weight: var(--ams-header-brand-name-font-weight);
3951
line-height: 1.35;
4052
}
4153

4254
.ams-header__navigation {
4355
column-gap: var(--ams-header-navigation-column-gap);
4456
display: flex;
4557
flex-wrap: wrap;
46-
grid-area: 1 / 1; // To allow this section to overlap with the branding section
47-
// This section blocks pointer events initially, so the hidden branding section can't be activated.
58+
grid-area: 1 / 1; // To allow this section to overlap with the logo link section
59+
// This section blocks pointer events initially, so the hidden logo link section can't be activated.
4860
// The menu and collapsible menu set it back to auto, to make sure they can be activated.
4961
pointer-events: none;
5062
row-gap: var(--ams-header-navigation-row-gap);
@@ -83,7 +95,6 @@
8395

8496
@mixin header-menu-action {
8597
color: var(--ams-header-menu-item-color);
86-
font-family: var(--ams-header-menu-item-font-family);
8798
font-size: var(--ams-header-menu-item-font-size);
8899
font-weight: var(--ams-header-menu-item-font-weight);
89100
line-height: var(--ams-header-menu-item-line-height);
@@ -132,6 +143,7 @@
132143
column-gap: var(--ams-header-menu-item-column-gap);
133144
cursor: var(--ams-header-mega-menu-button-cursor);
134145
display: grid;
146+
font-family: inherit;
135147
grid-auto-flow: column;
136148

137149
@include header-menu-action;

packages/react/src/Header/Header.test.tsx

+10-13
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ describe('Header', () => {
4242
expect(ref.current).toBe(component)
4343
})
4444

45-
it('renders a brand section', () => {
46-
const { container } = render(<Header />)
47-
48-
const component = container.querySelector('.ams-header__branding')
49-
50-
expect(component).toBeInTheDocument()
51-
})
52-
5345
it('renders a logo link', () => {
5446
render(<Header />)
5547

@@ -85,12 +77,17 @@ describe('Header', () => {
8577
it('renders an application name', () => {
8678
render(<Header brandName="Application name" />)
8779

88-
const heading = screen.getByRole('heading', {
89-
level: 1,
90-
name: 'Application name',
91-
})
80+
const brandName = screen.getByText('Application name')
81+
82+
expect(brandName).toBeInTheDocument()
83+
})
84+
85+
it('renders the correct class for the responsive logo', () => {
86+
const { container } = render(<Header brandName="Application name" />)
87+
88+
const logoContainer = container.querySelector('.ams-header__logo-container')
9289

93-
expect(heading).toBeInTheDocument()
90+
expect(logoContainer).toBeInTheDocument()
9491
})
9592

9693
it('renders a nav section', () => {

packages/react/src/Header/Header.tsx

+20-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import clsx from 'clsx'
77
import { forwardRef, useEffect, useState } from 'react'
88
import type { ForwardedRef, HTMLAttributes, ReactNode } from 'react'
9-
import { Heading } from '../Heading'
109
import { Icon } from '../Icon'
1110
import { Logo } from '../Logo'
1211
import type { LogoBrand } from '../Logo'
@@ -15,6 +14,19 @@ import { HeaderMenuIcon } from './HeaderMenuIcon'
1514
import { HeaderMenuLink } from './HeaderMenuLink'
1615
import useIsAfterBreakpoint from '../common/useIsAfterBreakpoint'
1716

17+
const LogoLinkContent = ({ brandName, logoBrand }: { brandName?: string; logoBrand: LogoBrand }) => (
18+
<>
19+
<span className={clsx(logoBrand === 'amsterdam' && Boolean(brandName) && 'ams-header__logo-container')}>
20+
<Logo brand={logoBrand} />
21+
</span>
22+
{brandName && (
23+
<span aria-hidden="true" className="ams-header__brand-name">
24+
{brandName}
25+
</span>
26+
)}
27+
</>
28+
)
29+
1830
export type HeaderProps = {
1931
/** The name of the application. */
2032
brandName?: string
@@ -64,29 +76,19 @@ const HeaderRoot = forwardRef(
6476

6577
return (
6678
<header {...restProps} className={clsx('ams-header', className)} ref={ref}>
67-
<div className="ams-header__branding">
68-
<a className="ams-header__logo-link" href={logoLink}>
69-
<span className="ams-visually-hidden">{logoLinkTitle}</span>
70-
<Logo brand={logoBrand} />
71-
</a>
72-
{brandName && (
73-
<Heading className="ams-header__brand-name" level={1} size="level-5">
74-
{brandName}
75-
</Heading>
76-
)}
77-
</div>
79+
<a className="ams-header__logo-link" href={logoLink}>
80+
<span className="ams-visually-hidden">{logoLinkTitle}</span>
81+
<LogoLinkContent brandName={brandName} logoBrand={logoBrand} />
82+
</a>
7883
{(children || menuItems) && (
7984
<nav aria-labelledby="primary-navigation" className="ams-header__navigation">
8085
<h2 className="ams-visually-hidden" id="primary-navigation">
8186
{navigationLabel}
8287
</h2>
8388

84-
{/* The branding section is recreated here, to make sure the page menu breaks at the right spot */}
85-
<div aria-hidden className="ams-header__branding ams-header__branding--hidden">
86-
<div className="ams-header__logo-link">
87-
<Logo brand={logoBrand} />
88-
</div>
89-
{brandName && <span className="ams-heading ams-heading--5 ams-header__brand-name">{brandName}</span>}
89+
{/* The logo link section is recreated here, to make sure the header menu wraps at the right spot */}
90+
<div className="ams-header__logo-link ams-header__logo-link--hidden">
91+
<LogoLinkContent brandName={brandName} logoBrand={logoBrand} />
9092
</div>
9193

9294
<ul className="ams-header__menu">

proprietary/tokens/src/components/ams/header.tokens.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
22
"ams": {
33
"header": {
4+
"font-family": { "value": "{ams.typography.font-family}" },
45
"padding-block": { "value": "{ams.space.grid.sm}" },
56
"padding-inline": {
67
"value": "{ams.grid.padding-inline}",
78
"comment": "Must be the Grid inline padding, to make sure Header and Grid line up"
89
},
9-
"branding": {
10-
"column-gap": { "value": "{ams.space.md}" },
11-
"row-gap": { "value": "{ams.space.grid.xs}" }
12-
},
1310
"logo-link": {
11+
"column-gap": { "value": "{ams.space.md}" },
1412
"outline-offset": { "value": "{ams.focus.outline-offset}" }
1513
},
14+
"brand-name": {
15+
"color": { "value": "{ams.color.text.default}" },
16+
"font-size": { "value": "{ams.typography.heading.4.font-size}" },
17+
"font-weight": { "value": "{ams.typography.heading.font-weight}" }
18+
},
1619
"mega-menu": {
1720
"button": {
1821
"cursor": { "value": "{ams.cursor.interactive}" },

storybook/src/components/Footer/Footer.stories.tsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ export const Default: Story = {
3636
args: {
3737
children: [
3838
<Footer.Spotlight key="footer-spotlight">
39-
<Heading className="ams-visually-hidden" color="inverse" level={1}>
40-
Colofon
41-
</Heading>
4239
<Grid gapVertical="large" paddingVertical="medium">
4340
<Grid.Cell span={4}>
4441
<Heading className="ams-mb--xs" color="inverse" level={2} size="level-4">
@@ -74,7 +71,7 @@ export const Default: Story = {
7471
</LinkList>
7572
</Grid.Cell>
7673
<Grid.Cell span={4} start={{ narrow: 1, medium: 1, wide: 9 }}>
77-
<section className="ams-mb--md">
74+
<div className="ams-mb--md">
7875
<Heading className="ams-mb--xs" color="inverse" level={2} size="level-4">
7976
Nieuwsbrief
8077
</Heading>
@@ -83,8 +80,8 @@ export const Default: Story = {
8380
Inschrijven
8481
</LinkList.Link>
8582
</LinkList>
86-
</section>
87-
<section>
83+
</div>
84+
<div>
8885
<Heading className="ams-mb--xs" color="inverse" level={2} size="level-4">
8986
Volg ons
9087
</Heading>
@@ -95,7 +92,7 @@ export const Default: Story = {
9592
</LinkList.Link>
9693
))}
9794
</LinkList>
98-
</section>
95+
</div>
9996
</Grid.Cell>
10097
</Grid>
10198
</Footer.Spotlight>,
@@ -115,9 +112,6 @@ export const OnderzoekEnStatistiek: Story = {
115112
args: {
116113
children: [
117114
<Footer.Spotlight key="footer-spotlight">
118-
<Heading className="ams-visually-hidden" color="inverse" level={1}>
119-
Colofon
120-
</Heading>
121115
<Grid gapVertical="large" paddingVertical="medium">
122116
<Grid.Cell span={3}>
123117
<Heading className="ams-mb--xs" color="inverse" level={2} size="level-4">

storybook/src/components/Header/Header.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export const WithCustomTexts: Story = {
190190
</Grid.Cell>
191191
</Grid>
192192
),
193-
menuButtonText: 'Hoofdmenu',
193+
menuButtonText: 'Alle onderwerpen',
194194
navigationLabel: 'Navigatie',
195195
},
196196
}

storybook/src/pages/amsterdam/common/AppHeader.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { headerMenuLinks, megaMenuLinks } from './menu'
33

44
export const AppHeader = () => (
55
<Header
6-
menuButtonText="Alle onderwerpen"
76
menuItems={headerMenuLinks.map(({ fixed, href, label, lang }) => (
87
<Header.MenuLink fixed={fixed} href={href ?? '#'} key={label} lang={lang} rel={href ? 'external' : undefined}>
98
{label}

0 commit comments

Comments
 (0)