Skip to content

Commit

Permalink
Merge branch 'develop' into feature/DES-778-add-form-error-list
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/react/src/index.ts
  • Loading branch information
VincentSmedinga committed Jun 7, 2024
2 parents 28fe764 + 1f4c09a commit 51b0507
Show file tree
Hide file tree
Showing 37 changed files with 829 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages/css": "0.8.0",
"packages/react": "0.8.0",
"proprietary/assets": "0.2.0",
"packages/css": "0.9.0",
"packages/react": "0.9.0",
"proprietary/assets": "0.2.1",
"proprietary/react-icons": "0.1.12",
"proprietary/tokens": "0.8.0"
"proprietary/tokens": "0.9.0"
}
36 changes: 36 additions & 0 deletions packages/css/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,42 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.0](https://github.com/Amsterdam/design-system/compare/design-system-css-v0.8.0...design-system-css-v0.9.0) (2024-06-05)


### ⚠ BREAKING CHANGES

* Disallow directional style rules ([#1245](https://github.com/Amsterdam/design-system/issues/1245))
* Use invalid prop for most inputs ([#1240](https://github.com/Amsterdam/design-system/issues/1240))
* Add invalid prop to Field Set and update Field and Field Set docs ([#1237](https://github.com/Amsterdam/design-system/issues/1237))
* Allow additional background colours for Badge and remove dark blue option ([#1236](https://github.com/Amsterdam/design-system/issues/1236))
* Rename Breadcrumb Item to Link ([#1232](https://github.com/Amsterdam/design-system/issues/1232))
* Use logical properties for Search Field, Select, Text Area and Text Input ([#1226](https://github.com/Amsterdam/design-system/issues/1226))
* Flatten token names for default text size and line height ([#1221](https://github.com/Amsterdam/design-system/issues/1221))

### Features

* Add Error Message ([#1247](https://github.com/Amsterdam/design-system/issues/1247)) ([1dec2ea](https://github.com/Amsterdam/design-system/commit/1dec2ead41fba24e4128c2e1d60b72a7ccb29a92))
* Add Field component ([#1228](https://github.com/Amsterdam/design-system/issues/1228)) ([66832aa](https://github.com/Amsterdam/design-system/commit/66832aaf14a209915b60498acecf90cecff27c23))
* Add invalid prop to Field Set and update Field and Field Set docs ([#1237](https://github.com/Amsterdam/design-system/issues/1237)) ([d7316e8](https://github.com/Amsterdam/design-system/commit/d7316e81cd424f79f9bd655265d1c9b41296fecf))
* Allow additional background colours for Badge and remove dark blue option ([#1236](https://github.com/Amsterdam/design-system/issues/1236)) ([eec669a](https://github.com/Amsterdam/design-system/commit/eec669ad79353fc205e12a35aa7d0a8297c72e41))
* Allow installing only the React or CSS package ([#1206](https://github.com/Amsterdam/design-system/issues/1206)) ([963860d](https://github.com/Amsterdam/design-system/commit/963860d916d54ce3a0b191eb51a83cf3023ab88b))
* Allow small text for ordered lists ([#1219](https://github.com/Amsterdam/design-system/issues/1219)) ([0e77bd6](https://github.com/Amsterdam/design-system/commit/0e77bd60d8f395417c3c736d8e51a3ca3729ece5))
* Allow small text for unordered lists ([#1217](https://github.com/Amsterdam/design-system/issues/1217)) ([5012851](https://github.com/Amsterdam/design-system/commit/5012851492e50e50e2a651250622740e517fd22f))
* File Input ([#1218](https://github.com/Amsterdam/design-system/issues/1218)) ([7b6ba98](https://github.com/Amsterdam/design-system/commit/7b6ba98530caaefafedada5b89a175ef0b1a8784))
* Rename Breadcrumb Item to Link ([#1232](https://github.com/Amsterdam/design-system/issues/1232)) ([6cf2e5e](https://github.com/Amsterdam/design-system/commit/6cf2e5e51217900a24d739c4569c13237b9fb4ab))
* Start-align Dialog buttons and place the primary button first ([#1143](https://github.com/Amsterdam/design-system/issues/1143)) ([fd668c1](https://github.com/Amsterdam/design-system/commit/fd668c15c5fce9cf28b66b811d2463ada7165f7f))
* Use invalid prop for most inputs ([#1240](https://github.com/Amsterdam/design-system/issues/1240)) ([9477186](https://github.com/Amsterdam/design-system/commit/9477186b8432d6d20991e93d92c64a4357d6f391))
* Use logical properties for Search Field, Select, Text Area and Text Input ([#1226](https://github.com/Amsterdam/design-system/issues/1226)) ([4471c7a](https://github.com/Amsterdam/design-system/commit/4471c7a154e9f1f31dd92298f932f4bbc134dbf9))


### Bug Fixes

* Disallow directional style rules ([#1245](https://github.com/Amsterdam/design-system/issues/1245)) ([8ab6f81](https://github.com/Amsterdam/design-system/commit/8ab6f81d4cbcdb75b7acb986a145d49ccd1895c8))
* Fix issues with inputs on iOS ([#1241](https://github.com/Amsterdam/design-system/issues/1241)) ([dcd2f6e](https://github.com/Amsterdam/design-system/commit/dcd2f6e609699a5db6ee026d9d3024e13aff06c9))
* Flatten token names for default text size and line height ([#1221](https://github.com/Amsterdam/design-system/issues/1221)) ([6eeaeb4](https://github.com/Amsterdam/design-system/commit/6eeaeb41fae90a2d455b4e41da3ff3a4561dcbe4))
* Reset the lower placeholder opacity set by Firefox ([#1239](https://github.com/Amsterdam/design-system/issues/1239)) ([d2b371e](https://github.com/Amsterdam/design-system/commit/d2b371e02c385b2ee8371c9ca0c85ea5c0e706aa))

## [0.8.0](https://github.com/Amsterdam/design-system/compare/design-system-css-v0.7.1...design-system-css-v0.8.0) (2024-04-22)


Expand Down
2 changes: 1 addition & 1 deletion packages/css/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.8.0",
"version": "0.9.0",
"author": "Community for NL Design System",
"description": "CSS files for components for the City of Amsterdam based on the NL Design System architecture",
"license": "EUPL-1.2",
Expand Down
11 changes: 11 additions & 0 deletions packages/css/src/components/error-message/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- @license CC0-1.0 -->

# Error Message

Show an error message when there is a form field validation error.
In the error message explain what went wrong and how to fix it.

For guidance and examples on using error messages in a form,
refer to the [Field](/docs/components-forms-field--docs) and [Field Set](/docs/components-forms-field-set--docs) documentation.

Read the documentation by [NL Design System](https://www.nldesignsystem.nl/richtlijnen/formulieren/foutmeldingen) and [Gov.uk](https://design-system.service.gov.uk/components/error-message/) for more information on the contents of error messages and when to show them.
22 changes: 22 additions & 0 deletions packages/css/src/components/error-message/error-message.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @license EUPL-1.2+
* Copyright Gemeente Amsterdam
*/

@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
margin-block: 0;
}

.ams-error-message {
color: var(--ams-error-message-color);
font-family: var(--ams-error-message-font-family);
font-size: var(--ams-error-message-font-size);
font-weight: var(--ams-error-message-font-weight);
line-height: var(--ams-error-message-line-height);

@include text-rendering;
@include reset;
}
2 changes: 2 additions & 0 deletions packages/css/src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

/* Append here */
@import "./table-of-contents/table-of-contents";
@import "./error-message/error-message";
@import "./file-input/file-input";
@import "./field/field";
@import "./select/select";
Expand Down
6 changes: 6 additions & 0 deletions packages/css/src/components/table-of-contents/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- @license CC0-1.0 -->

# Table of Contents

A list of links corresponding to the content sections on the page.
It helps users to easily navigate to different sections on the same page.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @license EUPL-1.2+
* Copyright Gemeente Amsterdam
*/

@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
margin-block: 0;
padding-inline: 0;
}

.ams-table-of-contents {
display: flex;
flex-direction: column;
font-family: var(--ams-table-of-contents-font-family);
font-size: var(--ams-table-of-contents-font-size);
font-weight: var(--ams-table-of-contents-font-weight);
gap: var(--ams-table-of-contents-gap);
line-height: var(--ams-table-of-contents-line-height);
}

.ams-table-of-contents__list {
display: flex;
flex-direction: column;
gap: var(--ams-table-of-contents-list-gap);
list-style: none;

@include text-rendering;
@include reset;

.ams-table-of-contents__list {
padding-block-start: var(--ams-table-of-contents-list-list-padding-block-start);
padding-inline-start: var(--ams-table-of-contents-list-list-padding-inline-start);
}
}

.ams-table-of-contents__link {
color: var(--ams-table-of-contents-link-color);
outline-offset: var(--ams-table-of-contents-link-outline-offset);
text-decoration-line: var(--ams-table-of-contents-link-text-decoration-line);
text-decoration-thickness: var(--ams-table-of-contents-link-text-decoration-thickness);
text-underline-offset: var(--ams-table-of-contents-link-text-underline-offset);

&:hover {
color: var(--ams-table-of-contents-link-hover-color);
text-decoration-line: var(--ams-table-of-contents-link-hover-text-decoration-line);
}
}
28 changes: 28 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.0](https://github.com/Amsterdam/design-system/compare/design-system-react-v0.8.0...design-system-react-v0.9.0) (2024-06-05)


### ⚠ BREAKING CHANGES

* Change Accordion `section` boolean prop to `sectionAs` enum ([#1244](https://github.com/Amsterdam/design-system/issues/1244))
* Use invalid prop for most inputs ([#1240](https://github.com/Amsterdam/design-system/issues/1240))
* Add invalid prop to Field Set and update Field and Field Set docs ([#1237](https://github.com/Amsterdam/design-system/issues/1237))
* Allow additional background colours for Badge and remove dark blue option ([#1236](https://github.com/Amsterdam/design-system/issues/1236))
* Rename Breadcrumb Item to Link ([#1232](https://github.com/Amsterdam/design-system/issues/1232))

### Features

* Add Error Message ([#1247](https://github.com/Amsterdam/design-system/issues/1247)) ([1dec2ea](https://github.com/Amsterdam/design-system/commit/1dec2ead41fba24e4128c2e1d60b72a7ccb29a92))
* Add Field component ([#1228](https://github.com/Amsterdam/design-system/issues/1228)) ([66832aa](https://github.com/Amsterdam/design-system/commit/66832aaf14a209915b60498acecf90cecff27c23))
* Add invalid prop to Field Set and update Field and Field Set docs ([#1237](https://github.com/Amsterdam/design-system/issues/1237)) ([d7316e8](https://github.com/Amsterdam/design-system/commit/d7316e81cd424f79f9bd655265d1c9b41296fecf))
* Allow additional background colours for Badge and remove dark blue option ([#1236](https://github.com/Amsterdam/design-system/issues/1236)) ([eec669a](https://github.com/Amsterdam/design-system/commit/eec669ad79353fc205e12a35aa7d0a8297c72e41))
* Allow installing only the React or CSS package ([#1206](https://github.com/Amsterdam/design-system/issues/1206)) ([963860d](https://github.com/Amsterdam/design-system/commit/963860d916d54ce3a0b191eb51a83cf3023ab88b))
* Allow overriding button labels in Alert, Dialog, Pagination, and Search Field ([#1220](https://github.com/Amsterdam/design-system/issues/1220)) ([c88e569](https://github.com/Amsterdam/design-system/commit/c88e569acd2dd56b37b24ad57e21fc47254d0aaf))
* Allow small text for ordered lists ([#1219](https://github.com/Amsterdam/design-system/issues/1219)) ([0e77bd6](https://github.com/Amsterdam/design-system/commit/0e77bd60d8f395417c3c736d8e51a3ca3729ece5))
* Allow small text for unordered lists ([#1217](https://github.com/Amsterdam/design-system/issues/1217)) ([5012851](https://github.com/Amsterdam/design-system/commit/5012851492e50e50e2a651250622740e517fd22f))
* Change Accordion `section` boolean prop to `sectionAs` enum ([#1244](https://github.com/Amsterdam/design-system/issues/1244)) ([fef3fb1](https://github.com/Amsterdam/design-system/commit/fef3fb1b4d3cb53d2f9d6478225621423d97ad03))
* File Input ([#1218](https://github.com/Amsterdam/design-system/issues/1218)) ([7b6ba98](https://github.com/Amsterdam/design-system/commit/7b6ba98530caaefafedada5b89a175ef0b1a8784))
* **internal:** Indicate beta status for some components, patterns, and assets ([#1242](https://github.com/Amsterdam/design-system/issues/1242)) ([358f40a](https://github.com/Amsterdam/design-system/commit/358f40a9159eb6da3bf5ca053044143491dda12b))
* Rename Breadcrumb Item to Link ([#1232](https://github.com/Amsterdam/design-system/issues/1232)) ([6cf2e5e](https://github.com/Amsterdam/design-system/commit/6cf2e5e51217900a24d739c4569c13237b9fb4ab))
* Set dir auto by default for text input form fields ([#1238](https://github.com/Amsterdam/design-system/issues/1238)) ([b588d10](https://github.com/Amsterdam/design-system/commit/b588d104095365bcadff4f34f7db53e247afc873))
* Use invalid prop for most inputs ([#1240](https://github.com/Amsterdam/design-system/issues/1240)) ([9477186](https://github.com/Amsterdam/design-system/commit/9477186b8432d6d20991e93d92c64a4357d6f391))

## [0.8.0](https://github.com/Amsterdam/design-system/compare/design-system-react-v0.7.1...design-system-react-v0.8.0) (2024-04-22)


Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.8.0",
"version": "0.9.0",
"author": "Community for NL Design System",
"description": "React component library bundle for the City of Amsterdam based on the NL Design System architecture",
"license": "EUPL-1.2",
Expand Down
51 changes: 51 additions & 0 deletions packages/react/src/ErrorMessage/ErrorMessage.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { render, screen } from '@testing-library/react'
import { createRef } from 'react'
import { ErrorMessage } from './ErrorMessage'
import '@testing-library/jest-dom'

describe('Error message', () => {
it('renders', () => {
render(<ErrorMessage />)
const component = screen.getByRole('paragraph')

expect(component).toBeInTheDocument()
expect(component).toBeVisible()
})

it('renders a design system BEM class name', () => {
render(<ErrorMessage />)
const component = screen.getByRole('paragraph')

expect(component).toHaveClass('ams-error-message')
})

it('renders an additional class name', () => {
render(<ErrorMessage className="extra" />)
const component = screen.getByRole('paragraph')

expect(component).toHaveClass('ams-error-message extra')
})

it('renders a Dutch prefix by default', () => {
render(<ErrorMessage />)
const component = screen.getByText('Invoerfout', { exact: false })

expect(component).toBeInTheDocument()
})

it('renders a custom prefix', () => {
render(<ErrorMessage prefix="Error" />)
const component = screen.getByText('Error', { exact: false })

expect(component).toBeInTheDocument()
})

it('supports ForwardRef in React', () => {
const ref = createRef<HTMLParagraphElement>()

render(<ErrorMessage ref={ref} />)
const component = screen.getByRole('paragraph')

expect(ref.current).toBe(component)
})
})
31 changes: 31 additions & 0 deletions packages/react/src/ErrorMessage/ErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license EUPL-1.2+
* Copyright Gemeente Amsterdam
*/

import clsx from 'clsx'
import { forwardRef } from 'react'
import type { ForwardedRef, HTMLAttributes, PropsWithChildren } from 'react'
import { VisuallyHidden } from '../VisuallyHidden'

export type ErrorMessageProps = {
/** An accessible phrase that screen readers announce before the error message. Should translate to something like ‘input error’. */
prefix?: string
} & PropsWithChildren<HTMLAttributes<HTMLParagraphElement>>

export const ErrorMessage = forwardRef(
(
{ children, className, prefix = 'Invoerfout', ...restProps }: ErrorMessageProps,
ref: ForwardedRef<HTMLParagraphElement>,
) => (
<p {...restProps} ref={ref} className={clsx('ams-error-message', className)}>
<VisuallyHidden>
{prefix}
{': '}
</VisuallyHidden>
{children}
</p>
),
)

ErrorMessage.displayName = 'ErrorMessage'
5 changes: 5 additions & 0 deletions packages/react/src/ErrorMessage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- @license CC0-1.0 -->

# React Error Message component

[Error Message documentation](../../../css/src/components/error-message/README.md)
2 changes: 2 additions & 0 deletions packages/react/src/ErrorMessage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ErrorMessage } from './ErrorMessage'
export type { ErrorMessageProps } from './ErrorMessage'
5 changes: 5 additions & 0 deletions packages/react/src/TableOfContents/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- @license CC0-1.0 -->

# React Table of Contents component

[Table of Contents documentation](../../../css/src/components/table-of-contents/README.md)
57 changes: 57 additions & 0 deletions packages/react/src/TableOfContents/TableOfContents.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { render, screen } from '@testing-library/react'
import { createRef } from 'react'
import { TableOfContents } from './TableOfContents'
import '@testing-library/jest-dom'

describe('Table of contents', () => {
it('renders', () => {
const { container } = render(<TableOfContents />)
const component = container.querySelector(':only-child')

expect(component).toBeInTheDocument()
expect(component).toBeVisible()
})

it('renders its children', () => {
render(
<TableOfContents>
<TableOfContents.List />
</TableOfContents>,
)

const testChild = screen.getByRole('list')

expect(testChild).toBeTruthy()
})

it('renders a heading', () => {
render(<TableOfContents heading="Test heading" />)

const heading = screen.getByRole('heading')

expect(heading).toBeInTheDocument()
expect(heading).toHaveTextContent('Test heading')
})

it('renders a design system BEM class name', () => {
const { container } = render(<TableOfContents />)
const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-table-of-contents')
})

it('renders an additional class name', () => {
const { container } = render(<TableOfContents className="extra" />)
const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-table-of-contents extra')
})

it('supports ForwardRef in React', () => {
const ref = createRef<HTMLElement>()
const { container } = render(<TableOfContents ref={ref} />)
const component = container.querySelector(':only-child')

expect(ref.current).toBe(component)
})
})
Loading

0 comments on commit 51b0507

Please sign in to comment.