diff --git a/.changeset/wise-tomatoes-brake.md b/.changeset/wise-tomatoes-brake.md new file mode 100644 index 0000000000..99014097fc --- /dev/null +++ b/.changeset/wise-tomatoes-brake.md @@ -0,0 +1,5 @@ +--- +'@swisspost/design-system-styles': patch +--- + +Updated the styles of the form validation messages to match the new Post design. diff --git a/packages/documentation/cypress/e2e/components/validation.cy.ts b/packages/documentation/cypress/e2e/components/validation.cy.ts new file mode 100644 index 0000000000..2130453f9c --- /dev/null +++ b/packages/documentation/cypress/e2e/components/validation.cy.ts @@ -0,0 +1,13 @@ +describe('Validation', () => { + describe('Accessibility', () => { + beforeEach(() => { + cy.visit('/iframe.html?id=snapshots--validation'); + cy.get('.snapshot', { timeout: 30000 }).should('be.visible'); + cy.injectAxe(); + }); + + it('Has no detectable a11y violations on load for all variants', () => { + cy.checkA11y('#root-inner'); + }); + }); +}); diff --git a/packages/documentation/cypress/snapshots/components/validation.snapshot.ts b/packages/documentation/cypress/snapshots/components/validation.snapshot.ts new file mode 100644 index 0000000000..c99cbb4f5d --- /dev/null +++ b/packages/documentation/cypress/snapshots/components/validation.snapshot.ts @@ -0,0 +1,7 @@ +describe('Validation', () => { + it('default', () => { + cy.visit('/iframe.html?id=snapshots--validation'); + cy.get('.snapshot', { timeout: 30000 }).should('be.visible'); + cy.percySnapshot('Validation', { widths: [1440] }); + }); +}); diff --git a/packages/documentation/src/shared/styles-package-import-individual.sample.ts b/packages/documentation/src/shared/styles-package-import-individual.sample.ts index 036c1ed60a..4a6b33bc82 100644 --- a/packages/documentation/src/shared/styles-package-import-individual.sample.ts +++ b/packages/documentation/src/shared/styles-package-import-individual.sample.ts @@ -6,7 +6,7 @@ interface Props { const requiredLabels: { [key: string]: string } = { 'icons': 'required if you use icons', 'floating-label': 'required if you use floating-labels', - 'form-feedback': 'required if you use validation feedbacks', + 'validation': 'required if you use validation feedbacks', }; export function getComponentStyleImports(props: Props) { diff --git a/packages/documentation/src/shared/styles-package-import.mdx b/packages/documentation/src/shared/styles-package-import.mdx index 02671c8a21..ff87878edf 100644 --- a/packages/documentation/src/shared/styles-package-import.mdx +++ b/packages/documentation/src/shared/styles-package-import.mdx @@ -4,20 +4,17 @@ import { getComponentStyleImports } from './styles-package-import-individual.sam ## Style Imports

- *Make sure the `@swisspost/design-system-styles` package is already present in your project - or follow the [installation guidelines](http://localhost:9000/?path=/docs/e53e2de8-0bbf-4f70-babc-074c5466f700--docs).* + + *Make sure the `@swisspost/design-system-styles` package is already present in your project or + follow the [installation + guidelines](http://localhost:9000/?path=/docs/e53e2de8-0bbf-4f70-babc-074c5466f700--docs).* +

To import all Design System styles: - + To import only the styles required for this component: - + diff --git a/packages/documentation/src/stories/components/card-control/standard-html/card-control.stories.ts b/packages/documentation/src/stories/components/card-control/standard-html/card-control.stories.ts index 62cc57640c..d46664d63c 100644 --- a/packages/documentation/src/stories/components/card-control/standard-html/card-control.stories.ts +++ b/packages/documentation/src/stories/components/card-control/standard-html/card-control.stories.ts @@ -95,7 +95,8 @@ const meta: MetaComponent = { }, validation: { name: 'Validation', - description: "Controls the display of the component's validation state.", + description: + 'Defines the validation state of the card control and controls the display of the corresponding return message.Please read our validation guidelines here. ', control: { type: 'radio', labels: { diff --git a/packages/documentation/src/stories/components/checkbox/checkbox.docs.mdx b/packages/documentation/src/stories/components/checkbox/checkbox.docs.mdx index b41fd25faa..4c113c35d3 100644 --- a/packages/documentation/src/stories/components/checkbox/checkbox.docs.mdx +++ b/packages/documentation/src/stories/components/checkbox/checkbox.docs.mdx @@ -24,7 +24,7 @@ Our checkboxes use custom icons to indicate checked or indeterminate states. - + ## Examples @@ -57,7 +57,8 @@ To show a checkbox group, just wrap your checkboxes in a `fieldset`. Don't forget to add also a `` element. You can visually hide the legend using the `.visually-hidden` class if necessary. - Read more about that topic in our [accessibility docs](/?path=/docs/46da78e8-e83b-4ca1-aaf6-bbc662efef14--docs). +Read more about that topic in our [accessibility docs](/?path=/docs/46da78e8-e83b-4ca1-aaf6-bbc662efef14--docs). + @@ -75,13 +76,3 @@ Read more about that topic in our [accessibility docs](/?path=/docs/46da78e8-e83 - -### Validation - -To provide feedback to your users about the validation state of a checkbox, -simply add a `.is-valid` or a `.is-invalid` classes to it. - -These classes control the display of corresponding feedback messages that should be placed under the input: -`

...

` or `

...

`. - - diff --git a/packages/documentation/src/stories/components/checkbox/checkbox.stories.ts b/packages/documentation/src/stories/components/checkbox/checkbox.stories.ts index 5c30547138..cd34f6c361 100644 --- a/packages/documentation/src/stories/components/checkbox/checkbox.stories.ts +++ b/packages/documentation/src/stories/components/checkbox/checkbox.stories.ts @@ -107,8 +107,7 @@ const meta: MetaComponent = { validation: { name: 'Validation', description: - 'Defines the validation state of the checkbox and controls the display of the corresponding return' + - ' message.', + 'Defines the validation state of the checkbox and controls the display of the corresponding return message. Please read our validation guidelines here. ', control: { type: 'radio', labels: { diff --git a/packages/documentation/src/stories/components/forms/validation/validation.docs.mdx b/packages/documentation/src/stories/components/forms/validation/validation.docs.mdx new file mode 100644 index 0000000000..f6f5d4d265 --- /dev/null +++ b/packages/documentation/src/stories/components/forms/validation/validation.docs.mdx @@ -0,0 +1,75 @@ +import { Canvas, Controls, Meta } from '@storybook/blocks'; +import * as ValidationStories from './validation.stories'; +import StylesPackageImport from '@/shared/styles-package-import.mdx'; + + + +
+# Validation + + +
+ +
+ The Validation component is a reusable component designed to provide consistent validation + feedback across all components that require input validation. +
+ +Validation employs the `:invalid` and `:valid` pseudo-classes to provide styling for ``, ` +

+ Hintus textus elare volare cantare hendrerit in vulputate velit esse molestie consequat, vel + illum dolore eu feugiat nulla facilisis. +

+ ${feedbackTemplate} + `; + }, +}; diff --git a/packages/documentation/src/stories/components/input/input.docs.mdx b/packages/documentation/src/stories/components/input/input.docs.mdx index 53b969055c..032abd32e3 100644 --- a/packages/documentation/src/stories/components/input/input.docs.mdx +++ b/packages/documentation/src/stories/components/input/input.docs.mdx @@ -25,7 +25,7 @@ Custom input elements need only the class `.form-control` to trigger the custom ## Concrete Examples of Application @@ -40,10 +40,3 @@ But note that the `` element must come first, so we can ensure the correc Ensure that `placeholder` attribute is set (even with an empty value) so the label can act as a placeholder when no value is set. - -### Validation - -Simply add the classes `.is-valid` or `.is-invalid` to the `` element to show it in the expected state.
-When the component has been validated, don't forget to add a `

...

` or `

...

` element after the `input` element to explain what went wrong. This enables the user to correct the mistake. - - diff --git a/packages/documentation/src/stories/components/input/input.stories.ts b/packages/documentation/src/stories/components/input/input.stories.ts index 793338534f..f68b161e3b 100644 --- a/packages/documentation/src/stories/components/input/input.stories.ts +++ b/packages/documentation/src/stories/components/input/input.stories.ts @@ -123,7 +123,8 @@ const meta: MetaComponent = { }, validation: { name: 'Validation', - description: 'Controls the validation state appearance of the component.', + description: + 'Defines the validation state of the input and controls the display of the corresponding return message. Please read our validation guidelines here. ', control: { type: 'radio', labels: { diff --git a/packages/documentation/src/stories/components/radio/radio.docs.mdx b/packages/documentation/src/stories/components/radio/radio.docs.mdx index 44744435bb..0bf509aae4 100644 --- a/packages/documentation/src/stories/components/radio/radio.docs.mdx +++ b/packages/documentation/src/stories/components/radio/radio.docs.mdx @@ -25,7 +25,7 @@ Our radios use custom icons to indicate checked states. - + ## Concrete Examples of Application @@ -39,7 +39,8 @@ To show radio button group, just wrap your radios in a `fieldset`. Don't forget to add also a `` element. You can visually hide the legend using the `.visually-hidden` class if necessary. - Read more about that topic in our [accessibility docs](/?path=/docs/46da78e8-e83b-4ca1-aaf6-bbc662efef14--docs). +Read more about that topic in our [accessibility docs](/?path=/docs/46da78e8-e83b-4ca1-aaf6-bbc662efef14--docs). + @@ -52,16 +53,13 @@ To render a radio inline, simply add the class `.form-check-inline` to the `.for Remember to wrap your radio groups in a <fieldset> including a{' '} <legend> tag. This provides a label for your radio group.
- For more information, read our{' '} grouping accessibility guide. + For more information, read our{' '} + + grouping accessibility guide + + . To visually hide the `` element, use the `.visually-hidden` class. - -### Validation - -Simply add the classes `.is-valid` or `.is-invalid` to the `radio` element to show it in the expected state.
-When the component has been validated, don't forget to add a `

...

` or `

...

` element after the `radio` element to explain what went wrong. This enables the user to correct the mistake. - - diff --git a/packages/documentation/src/stories/components/radio/radio.stories.ts b/packages/documentation/src/stories/components/radio/radio.stories.ts index e0cc709c15..6114d90fc4 100644 --- a/packages/documentation/src/stories/components/radio/radio.stories.ts +++ b/packages/documentation/src/stories/components/radio/radio.stories.ts @@ -87,7 +87,8 @@ const meta: MetaComponent = { }, validation: { name: 'Validation', - description: "Controls the display of the component's validation state.", + description: + 'Defines the validation state of the radio button and controls the display of the corresponding return message. Please read our validation guidelines here. ', control: { type: 'radio', labels: { diff --git a/packages/documentation/src/stories/components/select/select.docs.mdx b/packages/documentation/src/stories/components/select/select.docs.mdx index 8a354f06f3..30963bac7a 100644 --- a/packages/documentation/src/stories/components/select/select.docs.mdx +++ b/packages/documentation/src/stories/components/select/select.docs.mdx @@ -23,7 +23,7 @@ Custom `` when there are no value defined or no option selected. - -### Validation - -Simply add the classes `is-valid` or `is-invalid` to the `