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

feat(Header)!: Add responsive version of Amsterdam Logo, remove Heading level 1 #1880

Merged
merged 30 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9924955
Add responsive Header Logo
alimpens Feb 19, 2025
acad285
Add responsiveLogo prop
alimpens Feb 19, 2025
52b406d
Add tests
alimpens Feb 19, 2025
53c47b6
Add docs
alimpens Feb 19, 2025
a7bdb74
Merge branch 'develop' into feat/DES-978-add-responsive-header-logo
alimpens Feb 19, 2025
61e79d6
Use class name of Logo component 1
alimpens Feb 19, 2025
8516cf2
Use class name of Logo component 2
alimpens Feb 19, 2025
b4d30b6
Remove responsiveLogo prop, base show / hide condition on logoBrand a…
alimpens Feb 26, 2025
83d6836
Update tests
alimpens Feb 26, 2025
c7eeec9
Merge branch 'develop' into feat/DES-978-add-responsive-header-logo
alimpens Feb 26, 2025
4b224ea
Add brand name to link
alimpens Feb 28, 2025
6e0d4b8
Use single SVG
alimpens Feb 28, 2025
178eab5
Remove emblem only logo
alimpens Feb 28, 2025
c6c57c6
Remove unnecessary container
alimpens Feb 28, 2025
a2529d7
Fix tests
alimpens Feb 28, 2025
41496cf
Remove unnecessary exclude
alimpens Feb 28, 2025
5e5f235
Merge branch 'develop' of https://github.com/Amsterdam/design-system …
alimpens Feb 28, 2025
385f0bb
Use correct tokens
alimpens Feb 28, 2025
eef1590
Merge branch 'develop' into feat/DES-978-add-responsive-header-logo
alimpens Feb 28, 2025
80c9bdd
Add missing test
alimpens Feb 28, 2025
d4a691c
Merge branch 'feat/DES-978-add-responsive-header-logo' of https://git…
alimpens Feb 28, 2025
5254572
Constrain logo link to fit its content
alimpens Mar 5, 2025
ac76340
Update comments
alimpens Mar 5, 2025
9a774d3
Revert change to display rule
alimpens Mar 5, 2025
a32d6aa
Make sure button inherits font-family
alimpens Mar 7, 2025
1f7ca5e
Merge branch 'develop' of https://github.com/Amsterdam/design-system …
alimpens Mar 7, 2025
ec7f6de
Merge branch 'develop' into feat/DES-978-add-responsive-header-logo
VincentSmedinga Mar 7, 2025
5cddb19
Update comment
alimpens Mar 7, 2025
a45202b
Update comment
alimpens Mar 7, 2025
1a52dda
Merge branch 'develop' into feat/DES-978-add-responsive-header-logo
VincentSmedinga Mar 7, 2025
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
1 change: 1 addition & 0 deletions packages/css/src/components/header/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Includes the name of the application if it is not the general website.
- On narrow windows, links can move from the inline menu to the collapsible one.
- Labels should be short to help the inline menu fit on a single line whenever possible.
- An icon can be added to the end of a link to make its destination easier to guess.
- For websites with a brand name that feature the standard Amsterdam logo, only the emblem is shown on narrow screens.

## References

Expand Down
28 changes: 19 additions & 9 deletions packages/css/src/components/header/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,40 @@
* Display grid is used to let both branding sections overlap.
*/
display: grid;
font-family: var(--ams-header-font-family);
padding-block: var(--ams-header-padding-block);
padding-inline: var(--ams-header-padding-inline);
}

.ams-header__branding {
.ams-header__logo-link {
align-items: center;
align-self: start; // To align the branding section to the top of the header when it wraps
column-gap: var(--ams-header-branding-column-gap);
display: flex;
column-gap: var(--ams-header-logo-link-column-gap);
display: inline-flex;
grid-area: 1 / 1; // To allow this section to overlap with the second branding section
outline-offset: var(--ams-header-logo-link-outline-offset);
text-decoration: none;
}

.ams-header__branding--hidden {
.ams-header__logo-link--hidden {
opacity: 0%;
user-select: none; // The hidden branding section should not be selectable
}

.ams-header__logo-link {
outline-offset: var(--ams-header-logo-link-outline-offset);
.ams-header__logo-container {
flex-shrink: 0;
inline-size: 0.75rem;
overflow: hidden;

@media screen and (min-width: $ams-breakpoint-medium) {
inline-size: auto;
}
}

/* TODO Remove after updating Heading line heights in DES-973. */
.ams-heading.ams-header__brand-name {
.ams-header__brand-name {
color: var(--ams-header-brand-name-color);
font-size: var(--ams-header-brand-name-font-size);
font-weight: var(--ams-header-brand-name-font-weight);
line-height: 1.35;
}

Expand Down Expand Up @@ -83,7 +94,6 @@

@mixin header-menu-action {
color: var(--ams-header-menu-item-color);
font-family: var(--ams-header-menu-item-font-family);
font-size: var(--ams-header-menu-item-font-size);
font-weight: var(--ams-header-menu-item-font-weight);
line-height: var(--ams-header-menu-item-line-height);
Expand Down
23 changes: 10 additions & 13 deletions packages/react/src/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ describe('Header', () => {
expect(ref.current).toBe(component)
})

it('renders a brand section', () => {
const { container } = render(<Header />)

const component = container.querySelector('.ams-header__branding')

expect(component).toBeInTheDocument()
})

it('renders a logo link', () => {
render(<Header />)

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

const heading = screen.getByRole('heading', {
level: 1,
name: 'Application name',
})
const brandName = screen.getByText('Application name')

expect(brandName).toBeInTheDocument()
})

it('renders the correct class for the responsive logo', () => {
const { container } = render(<Header brandName="Application name" />)

const logoContainer = container.querySelector('.ams-header__logo-container')

expect(heading).toBeInTheDocument()
expect(logoContainer).toBeInTheDocument()
})

it('renders a nav section', () => {
Expand Down
38 changes: 19 additions & 19 deletions packages/react/src/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import clsx from 'clsx'
import { forwardRef, useEffect, useState } from 'react'
import type { ForwardedRef, HTMLAttributes, ReactNode } from 'react'
import { Heading } from '../Heading'
import { Icon } from '../Icon'
import { Logo } from '../Logo'
import type { LogoBrand } from '../Logo'
Expand All @@ -15,6 +14,19 @@ import { HeaderMenuIcon } from './HeaderMenuIcon'
import { HeaderMenuLink } from './HeaderMenuLink'
import useIsAfterBreakpoint from '../common/useIsAfterBreakpoint'

const LogoLinkContent = ({ brandName, logoBrand }: { brandName?: string; logoBrand: LogoBrand }) => (
<>
<span className={clsx(logoBrand === 'amsterdam' && Boolean(brandName) && 'ams-header__logo-container')}>
<Logo brand={logoBrand} />
</span>
{brandName && (
<span aria-hidden="true" className="ams-header__brand-name">
{brandName}
</span>
)}
</>
)

export type HeaderProps = {
/** The name of the application. */
brandName?: string
Expand Down Expand Up @@ -64,31 +76,19 @@ const HeaderRoot = forwardRef(

return (
<header {...restProps} className={clsx('ams-header', className)} ref={ref}>
<div className="ams-header__branding">
<a className="ams-header__logo-link" href={logoLink}>
<span className="ams-visually-hidden">{logoLinkTitle}</span>
<Logo brand={logoBrand} />
</a>
{brandName && (
<Heading className="ams-header__brand-name" level={1} size="level-5">
{brandName}
</Heading>
)}
</div>
<a className="ams-header__logo-link" href={logoLink}>
<span className="ams-visually-hidden">{logoLinkTitle}</span>
<LogoLinkContent brandName={brandName} logoBrand={logoBrand} />
</a>
{(children || menuItems) && (
<nav aria-labelledby="primary-navigation" className="ams-header__navigation">
<h2 className="ams-visually-hidden" id="primary-navigation">
{navigationLabel}
</h2>

{/* The branding section is recreated here, to make sure the page menu breaks at the right spot */}
<div aria-hidden className="ams-header__branding ams-header__branding--hidden">
<div className="ams-header__logo-link">
<Logo brand={logoBrand} />
</div>
{brandName && (
<span className="ams-heading ams-heading--level-5 ams-header__brand-name">{brandName}</span>
)}
<div className="ams-header__logo-link ams-header__logo-link--hidden">
<LogoLinkContent brandName={brandName} logoBrand={logoBrand} />
</div>

<ul className="ams-header__menu">
Expand Down
11 changes: 7 additions & 4 deletions proprietary/tokens/src/components/ams/header.tokens.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"ams": {
"header": {
"font-family": { "value": "{ams.typography.font-family}" },
"padding-block": { "value": "{ams.space.grid.sm}" },
"padding-inline": {
"value": "{ams.grid.padding-inline}",
"comment": "Must be the Grid inline padding, to make sure Header and Grid line up"
},
"branding": {
"column-gap": { "value": "{ams.space.md}" },
"row-gap": { "value": "{ams.space.grid.xs}" }
},
"logo-link": {
"column-gap": { "value": "{ams.space.md}" },
"outline-offset": { "value": "{ams.focus.outline-offset}" }
},
"brand-name": {
"color": { "value": "{ams.color.text.default}" },
"font-size": { "value": "{ams.typography.heading.4.font-size}" },
"font-weight": { "value": "{ams.typography.heading.font-weight}" }
},
"mega-menu": {
"button": {
"cursor": { "value": "{ams.cursor.interactive}" },
Expand Down