-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/DES-488-hero-image
- Loading branch information
Showing
41 changed files
with
994 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,6 @@ | |
"sass": "1.69.5" | ||
}, | ||
"dependencies": { | ||
"@utrecht/components": "2.0.0" | ||
"@utrecht/components": "3.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Header | ||
|
||
A Header offers a container to display a City of Amsterdam logo, subsite title and page menu. | ||
|
||
## Guidelines | ||
|
||
- Use the Header when the site is hosted on amsterdam.nl or one of its subdomains. | ||
- The page menu can contain a maximum of 5 items, including menu and search. | ||
- When you have a long subsite title, use no or as little page menu items as possible. | ||
|
||
## References | ||
|
||
- A Header is a [landmark](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_landmark_roles) and can be use to group navigation elements. | ||
- [WCAG 3.2.3](https://wcag.com/designers/3-2-3-consistent-navigation/) Consistent Navigation: Navigation menus that appear on multiple pages are consistent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright (c) 2023 Gemeente Amsterdam | ||
*/ | ||
|
||
@import "../../common/breakpoint"; | ||
|
||
.amsterdam-header { | ||
align-items: center; | ||
display: flex; | ||
flex-wrap: wrap; | ||
padding-block: 1rem; | ||
row-gap: 1.5rem; | ||
|
||
@media screen and (min-width: $amsterdam-breakpoint-wide) { | ||
column-gap: var(--amsterdam-header-column-gap); | ||
flex-wrap: nowrap; | ||
} | ||
} | ||
|
||
.amsterdam-header__logo { | ||
flex: none; | ||
outline-offset: var(--amsterdam-link-outline-offset); | ||
} | ||
|
||
.amsterdam-header__links { | ||
display: none; | ||
|
||
@media screen and (min-width: $amsterdam-breakpoint-medium) { | ||
display: block; | ||
flex: 10 0 auto; | ||
} | ||
|
||
@media screen and (min-width: $amsterdam-breakpoint-wide) { | ||
order: 3; | ||
} | ||
} | ||
|
||
.amsterdam-header__menu { | ||
flex: 1; | ||
padding-inline-start: var(--amsterdam-page-menu-column-gap); | ||
text-align: end; | ||
|
||
@media screen and (min-width: $amsterdam-breakpoint-wide) { | ||
order: 4; | ||
padding-inline-start: 0; | ||
} | ||
} | ||
|
||
.amsterdam-header__title { | ||
flex: 1 1 100%; | ||
|
||
@media screen and (min-width: $amsterdam-breakpoint-wide) { | ||
min-width: 0; | ||
order: 2; | ||
|
||
.amsterdam-header__title-heading { | ||
display: block; | ||
line-height: 1; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
width: 100%; | ||
} | ||
} | ||
} | ||
|
||
// Temporary, will move to megamenu (and/or iconButton) | ||
.amsterdam-header__menu-button { | ||
background-color: transparent; | ||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path fill='%23004699' fill-rule='evenodd' d='M0 3.238h32V7.81H0V3.238zm0 10.476h32v4.572H0v-4.572zM0 24.19h32v4.572H0V24.19z'/></svg>"); | ||
background-position: center right; | ||
background-repeat: no-repeat; | ||
background-size: 19px 19px; | ||
border: 0; | ||
color: var(--amsterdam-page-menu-item-color); | ||
font-family: var(--amsterdam-page-menu-item-font-family); | ||
font-size: var(--amsterdam-page-menu-item-spacious-font-size); | ||
font-weight: var(--amsterdam-page-menu-item-font-weight); | ||
line-height: var(--amsterdam-page-menu-item-spacious-line-height); | ||
margin-block: 0; | ||
padding-inline: 0 30px; | ||
text-align: center; | ||
touch-action: manipulation; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*/ | ||
|
||
.amsterdam-logo { | ||
display: block; | ||
height: var(--amsterdam-logo-height); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { createRef } from 'react' | ||
import { Header, HeaderProps } from './Header' | ||
import '@testing-library/jest-dom' | ||
|
||
describe('Header', () => { | ||
const defaultProps: HeaderProps = { | ||
logoLink: '/', | ||
} | ||
|
||
it('renders', () => { | ||
render(<Header {...defaultProps} />) | ||
|
||
const component = screen.getByRole('banner') | ||
|
||
expect(component).toBeInTheDocument() | ||
expect(component).toBeVisible() | ||
}) | ||
|
||
it('renders a design system BEM class name', () => { | ||
render(<Header {...defaultProps} />) | ||
|
||
const component = screen.getByRole('banner') | ||
|
||
expect(component).toHaveClass('amsterdam-header') | ||
}) | ||
|
||
it('renders an additional class name', () => { | ||
render(<Header {...defaultProps} className="extra" />) | ||
|
||
const component = screen.getByRole('banner') | ||
|
||
expect(component).toHaveClass('extra') | ||
expect(component).toHaveClass('amsterdam-header') | ||
}) | ||
|
||
it('supports ForwardRef in React', () => { | ||
const ref = createRef<HTMLElement>() | ||
|
||
render(<Header {...defaultProps} ref={ref} />) | ||
|
||
const component = screen.getByRole('banner') | ||
|
||
expect(ref.current).toBe(component) | ||
}) | ||
|
||
it('renders with a logo link', () => { | ||
render(<Header {...defaultProps} logoLink="/home" />) | ||
|
||
const logoLink = screen.getByRole('link') | ||
|
||
expect(logoLink).toHaveAttribute('href', '/home') | ||
}) | ||
|
||
it('renders with a logo link title', () => { | ||
render(<Header {...defaultProps} logoLinkTitle="Go to homepage" />) | ||
|
||
const logoLinkTitle = screen.getByRole('link', { name: 'Go to homepage' }) | ||
|
||
expect(logoLinkTitle).toHaveTextContent('Go to homepage') | ||
}) | ||
|
||
it('renders with links', () => { | ||
const { container } = render(<Header {...defaultProps} links={<div>Menu Content</div>} />) | ||
|
||
const menu = container.querySelector('.amsterdam-header__links') | ||
|
||
expect(menu).toBeInTheDocument() | ||
expect(menu).toHaveTextContent('Menu Content') | ||
}) | ||
|
||
it('renders with menu button', () => { | ||
render(<Header {...defaultProps} menu={<button>Menu Button</button>} />) | ||
|
||
const menu = screen.getByRole('button') | ||
|
||
expect(menu).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright (c) 2023 Gemeente Amsterdam | ||
*/ | ||
|
||
import clsx from 'clsx' | ||
import { ForwardedRef, forwardRef, HTMLAttributes, ReactNode } from 'react' | ||
import { Heading } from '../Heading' | ||
import { Logo } from '../Logo' | ||
import type { LogoBrand } from '../Logo' | ||
import { VisuallyHidden } from '../VisuallyHidden' | ||
|
||
export interface HeaderProps extends HTMLAttributes<HTMLElement> { | ||
logoBrand?: LogoBrand | ||
logoLink?: string | ||
logoLinkTitle?: string | ||
title?: string | ||
links?: ReactNode | ||
menu?: ReactNode | ||
} | ||
|
||
export const Header = forwardRef( | ||
( | ||
{ | ||
className, | ||
logoBrand = 'amsterdam', | ||
logoLink = '/', | ||
logoLinkTitle = 'Ga naar de homepage', | ||
title, | ||
links, | ||
menu, | ||
...restProps | ||
}: HeaderProps, | ||
ref: ForwardedRef<HTMLElement>, | ||
) => { | ||
return ( | ||
<> | ||
<header {...restProps} ref={ref} className={clsx('amsterdam-header', className)}> | ||
<a href={logoLink} className="amsterdam-header__logo"> | ||
<VisuallyHidden>{logoLinkTitle}</VisuallyHidden> | ||
<Logo brand={logoBrand} /> | ||
</a> | ||
{links && <div className="amsterdam-header__links">{links}</div>} | ||
{menu && <div className="amsterdam-header__menu">{menu}</div>} | ||
{title && ( | ||
<div className="amsterdam-header__title"> | ||
<Heading level={1} size="level-3" className="amsterdam-header__title-heading"> | ||
{title} | ||
</Heading> | ||
</div> | ||
)} | ||
</header> | ||
</> | ||
) | ||
}, | ||
) | ||
|
||
Header.displayName = 'Header' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# React Header component | ||
|
||
[Header documentation](../../../css/src/header/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Header } from './Header' | ||
export type { HeaderProps } from './Header' |
Oops, something went wrong.