-
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-287-split-link-components
- Loading branch information
Showing
39 changed files
with
703 additions
and
834 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
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,41 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { createRef } from 'react' | ||
import { BreadcrumbItem } from './BreadcrumbItem' | ||
import '@testing-library/jest-dom' | ||
|
||
describe('BreadcrumbItem', () => { | ||
it('renders', () => { | ||
render(<BreadcrumbItem href="/" />) | ||
const component = screen.getByRole('listitem') | ||
expect(component).toBeInTheDocument() | ||
expect(component).toBeVisible() | ||
}) | ||
|
||
it('renders a design system BEM class name', () => { | ||
render(<BreadcrumbItem href="/" />) | ||
const item = screen.getByRole('listitem') | ||
expect(item).toHaveClass('amsterdam-breadcrumb__item') | ||
|
||
const link = screen.getByRole('link') | ||
expect(link).toHaveClass('amsterdam-breadcrumb__link') | ||
}) | ||
|
||
it('renders an additional class name', () => { | ||
render(<BreadcrumbItem href="/" className="extra" />) | ||
const component = screen.getByRole('listitem') | ||
expect(component).toHaveClass('amsterdam-breadcrumb__item extra') | ||
}) | ||
|
||
it('renders the href attribute', () => { | ||
render(<BreadcrumbItem href="/" />) | ||
const component = screen.getByRole('link') | ||
expect(component).toHaveAttribute('href', '/') | ||
}) | ||
|
||
it('supports ForwardRef in React', () => { | ||
const ref = createRef<HTMLLIElement>() | ||
render(<BreadcrumbItem href="/" ref={ref} />) | ||
const component = screen.getByRole('listitem') | ||
expect(ref.current).toBe(component) | ||
}) | ||
}) |
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,24 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright (c) 2023 Gemeente Amsterdam | ||
*/ | ||
|
||
import { clsx } from 'clsx' | ||
import { forwardRef } from 'react' | ||
import type { ForwardedRef, HTMLAttributes, PropsWithChildren } from 'react' | ||
|
||
export interface BreadcrumbItemProps extends PropsWithChildren<HTMLAttributes<HTMLLIElement>> { | ||
href: string | ||
} | ||
|
||
export const BreadcrumbItem = forwardRef( | ||
({ children, className, href, ...restProps }: BreadcrumbItemProps, ref: ForwardedRef<HTMLLIElement>) => ( | ||
<li {...restProps} className={clsx('amsterdam-breadcrumb__item', className)} ref={ref}> | ||
<a className="amsterdam-breadcrumb__link" href={href}> | ||
{children} | ||
</a> | ||
</li> | ||
), | ||
) | ||
|
||
BreadcrumbItem.displayName = 'BreadcrumbItem' |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { Breadcrumb } from './Breadcrumb' | ||
export type { BreadcrumbProps, BreadcrumbItemProps } from './Breadcrumb' | ||
export type { BreadcrumbProps } from './Breadcrumb' | ||
export type { BreadcrumbItemProps } from './BreadcrumbItem' |
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,48 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { createRef } from 'react' | ||
import { CardHeadingGroup } from './CardHeadingGroup' | ||
import '@testing-library/jest-dom' | ||
|
||
describe('CardHeadingGroup', () => { | ||
it('renders', () => { | ||
const { container } = render(<CardHeadingGroup tagline="test" />) | ||
|
||
const component = container.querySelector(':only-child') | ||
|
||
expect(component).toBeInTheDocument() | ||
expect(component).toBeVisible() | ||
}) | ||
|
||
it('renders a design system BEM class name', () => { | ||
const { container } = render(<CardHeadingGroup tagline="test" />) | ||
|
||
const component = container.querySelector(':only-child') | ||
|
||
expect(component).toHaveClass('amsterdam-card__heading-group') | ||
}) | ||
|
||
it('renders an additional class name', () => { | ||
const { container } = render(<CardHeadingGroup tagline="test" className="extra" />) | ||
|
||
const component = container.querySelector(':only-child') | ||
|
||
expect(component).toHaveClass('amsterdam-card__heading-group extra') | ||
}) | ||
|
||
it('renders a tagline', () => { | ||
render(<CardHeadingGroup tagline="tagline" />) | ||
|
||
const tagline = screen.getByText('tagline') | ||
|
||
expect(tagline).toBeInTheDocument() | ||
}) | ||
|
||
it('supports ForwardRef in React', () => { | ||
const ref = createRef<HTMLElement>() | ||
const { container } = render(<CardHeadingGroup tagline="test" ref={ref} />) | ||
|
||
const component = container.querySelector(':only-child') | ||
|
||
expect(ref.current).toBe(component) | ||
}) | ||
}) |
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,24 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright (c) 2023 Gemeente Amsterdam | ||
*/ | ||
|
||
import clsx from 'clsx' | ||
import { forwardRef } from 'react' | ||
import type { ForwardedRef, HTMLAttributes, PropsWithChildren } from 'react' | ||
import { Paragraph } from '../Paragraph' | ||
|
||
export interface CardHeadingGroupProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> { | ||
tagline: string | ||
} | ||
|
||
export const CardHeadingGroup = forwardRef( | ||
({ children, className, tagline, ...restProps }: CardHeadingGroupProps, ref: ForwardedRef<HTMLElement>) => ( | ||
<hgroup {...restProps} ref={ref} className={clsx('amsterdam-card__heading-group', className)}> | ||
{children} | ||
<Paragraph size="small">{tagline}</Paragraph> | ||
</hgroup> | ||
), | ||
) | ||
|
||
CardHeadingGroup.displayName = 'CardHeadingGroup' |
Oops, something went wrong.