From 94c2d1e8aca07af75f553b3924c158b30cc5f446 Mon Sep 17 00:00:00 2001 From: Lukas Blaser <141234680+b1aserlu@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:27:55 +0200 Subject: [PATCH 01/16] feat(documentation-v7): migrate textarea stories (#1783) --- .../components/textarea/textarea.docs.mdx | 76 +++++ .../components/textarea/textarea.stories.ts | 266 ++++++++++++++++++ 2 files changed, 342 insertions(+) create mode 100644 packages/documentation-v7/src/stories/components/textarea/textarea.docs.mdx create mode 100644 packages/documentation-v7/src/stories/components/textarea/textarea.stories.ts diff --git a/packages/documentation-v7/src/stories/components/textarea/textarea.docs.mdx b/packages/documentation-v7/src/stories/components/textarea/textarea.docs.mdx new file mode 100644 index 0000000000..93786e4869 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/textarea/textarea.docs.mdx @@ -0,0 +1,76 @@ +import { Meta, Canvas, Controls } from '@storybook/blocks'; +import * as TextareaStories from './textarea.stories'; + + + +# Textarea + +
+ Customize the native <textarea> with CSS that changes the element’s initial + appearance. +
+ +Custom textarea elements need only the class `.form-control` to trigger the custom styles. + + +
+ +
+ +## SCSS Imports + +To import all styles from the design-system-styles package: + +```scss +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```scss +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/forms.scss'; + +// required if you use floating-labels +@use '@swisspost/design-system-styles/components/floating-label.scss'; + +// required if you use validation feedbacks +@use '@swisspost/design-system-styles/components/form-feedback.scss'; +``` + +## Concrete Examples of Application + +The following examples show the different characteristics of the component. These can differ in the type of visualization, the HTML structure, as well as when, how and why they are displayed. + +### Floating Label + +Wrap a pair of ` + `; + if (args.floatingLabel) { + return html` +
${[control, label, ...contextuals].filter(el => el !== null)}
+ `; + } else + return html` + ${[label, control, ...contextuals].filter(el => el !== null)} + `; +} + +export const Default: Story = {}; + +export const FloatingLabel: Story = { + parameters: { + controls: { + exclude: ['Hidden Label', 'Size', 'Rows', 'Helper Text', 'Disabled', 'Validation'], + }, + }, + args: { + floatingLabel: true, + hint: '', + }, +}; + +export const Size: Story = { + parameters: { + controls: { + exclude: [ + 'Label', + 'Floating Label', + 'Hidden Label', + 'Rows', + 'Helper Text', + 'Disabled', + 'Validation', + ], + }, + }, + args: { + size: 'form-control-sm', + hint: '', + }, +}; + +export const Validation: Story = { + parameters: { + controls: { + exclude: [ + 'Label', + 'Floating Label', + 'Hidden Label', + 'Size', + 'Rows', + 'Helper Text', + 'Disabled', + ], + }, + }, + args: { + validation: 'is-invalid', + hint: '', + }, +}; From 8121f10d5d9dc51ae443b95fb2e48caa84811803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Sch=C3=BCrch?= Date: Tue, 15 Aug 2023 13:47:15 +0200 Subject: [PATCH 02/16] chore(documentation-v7): update story file extension from tsx to ts (#1802) --- .../components/badge/{badge.stories.tsx => badge.stories.ts} | 0 .../card/{card.snapshot.stories.tsx => card.snapshot.stories.ts} | 0 .../stories/components/card/{card.stories.tsx => card.stories.ts} | 0 .../checkbox/{checkbox.stories.tsx => checkbox.stories.ts} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename packages/documentation-v7/src/stories/components/badge/{badge.stories.tsx => badge.stories.ts} (100%) rename packages/documentation-v7/src/stories/components/card/{card.snapshot.stories.tsx => card.snapshot.stories.ts} (100%) rename packages/documentation-v7/src/stories/components/card/{card.stories.tsx => card.stories.ts} (100%) rename packages/documentation-v7/src/stories/components/checkbox/{checkbox.stories.tsx => checkbox.stories.ts} (100%) diff --git a/packages/documentation-v7/src/stories/components/badge/badge.stories.tsx b/packages/documentation-v7/src/stories/components/badge/badge.stories.ts similarity index 100% rename from packages/documentation-v7/src/stories/components/badge/badge.stories.tsx rename to packages/documentation-v7/src/stories/components/badge/badge.stories.ts diff --git a/packages/documentation-v7/src/stories/components/card/card.snapshot.stories.tsx b/packages/documentation-v7/src/stories/components/card/card.snapshot.stories.ts similarity index 100% rename from packages/documentation-v7/src/stories/components/card/card.snapshot.stories.tsx rename to packages/documentation-v7/src/stories/components/card/card.snapshot.stories.ts diff --git a/packages/documentation-v7/src/stories/components/card/card.stories.tsx b/packages/documentation-v7/src/stories/components/card/card.stories.ts similarity index 100% rename from packages/documentation-v7/src/stories/components/card/card.stories.tsx rename to packages/documentation-v7/src/stories/components/card/card.stories.ts diff --git a/packages/documentation-v7/src/stories/components/checkbox/checkbox.stories.tsx b/packages/documentation-v7/src/stories/components/checkbox/checkbox.stories.ts similarity index 100% rename from packages/documentation-v7/src/stories/components/checkbox/checkbox.stories.tsx rename to packages/documentation-v7/src/stories/components/checkbox/checkbox.stories.ts From b4eea666ca12304abe90b5e53b4bbbf03e52309a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Sch=C3=BCrch?= Date: Wed, 16 Aug 2023 08:32:38 +0200 Subject: [PATCH 03/16] feat(documentation-v7): add breakpoint docs page (#1781) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alizé Debray <33580481+alizedebray@users.noreply.github.com> --- .changeset/quick-parrots-cover.md | 5 ++ .../layout/breakpoints/breakpoints.blocks.tsx | 28 ++++++ .../layout/breakpoints/breakpoints.docs.mdx | 86 +++++++++++++++++++ .../breakpoints/breakpoints.module.scss | 33 +++++++ .../stories/foundation/layout/layout.docs.mdx | 12 ++- .../layout/breakpoints/breakpoints.blocks.tsx | 29 +++++++ .../breakpoints/breakpoints.module.scss | 33 +++++++ .../breakpoints/breakpoints.stories.mdx | 86 +++++++++++++++++++ .../foundation/layout/layout.stories.mdx | 21 +++-- 9 files changed, 315 insertions(+), 18 deletions(-) create mode 100644 .changeset/quick-parrots-cover.md create mode 100644 packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx create mode 100644 packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx create mode 100644 packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.module.scss create mode 100644 packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx create mode 100644 packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.module.scss create mode 100644 packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.stories.mdx diff --git a/.changeset/quick-parrots-cover.md b/.changeset/quick-parrots-cover.md new file mode 100644 index 0000000000..245370e46e --- /dev/null +++ b/.changeset/quick-parrots-cover.md @@ -0,0 +1,5 @@ +--- +'@swisspost/design-system-documentation': minor +--- + +Added a foundation breakpoints docs page. diff --git a/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx new file mode 100644 index 0000000000..fbfe4c6a16 --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx @@ -0,0 +1,28 @@ +import { forEach } from '../../../../utils/react'; +import { parse } from '../../../../utils/sass-export'; +import scss from './breakpoints.module.scss'; + +export const SCSS_VARIABLES = parse(scss); + +export const BreakpointTable = (props: { name: string; value: string }) => ( + + + + + + + + + + {forEach(SCSS_VARIABLES.breakpoint, (data: { key: number; value: any }) => { + return ( + + + + + + ); + })} + +
BreakpointClass infixDimensions
{data.value.name}{data.value.dimensions}
+); diff --git a/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx new file mode 100644 index 0000000000..80f3f15657 --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx @@ -0,0 +1,86 @@ +import { Meta, Story } from '@storybook/blocks'; +import { BADGE } from '../../../../../.storybook/constants'; +import { BreakpointTable, SCSS_VARIABLES } from './breakpoints.blocks'; + + + +# Breakpoints + +
+ Breakpoints are widths that determine how the responsive layout behaves across device or viewport + sizes. +
+ +## Available breakpoints + +The Swiss Post Design System includes {Object.keys(SCSS_VARIABLES.breakpoint).length} breakpoints, sometimes referred to as grid tiers, for building responsively. These breakpoints can be customized if you’re using our source Sass files. + + + +You’ll find these breakpoints in a Sass map in our styles core. + +```scss +@use '@swisspost/design-system-styles/core' as post; + +@each $key, $value in post.$grid-breakpoints { + ... +} +``` + +## Mixins + +There are several mixins available to use in your own Sass to help with building responsive layouts. + +### Min-width + +We primarily use the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components. + +```scss +// No media query necessary for xs breakpoint as it's effectively @media (min-width: 0) { ... } +.custom-class { + display: none; +} + +@include post.media-breakpoint-up(lg) { + .custom-class { + display: block; + } +} +``` + +### Max-width + +We occasionally use media queries that go in the other direction. + +```scss +// No media query necessary for xs breakpoint as it's effectively @media (max-width: 0) { ... } +@include post.media-breakpoint-down(lg) { + .custom-class { + display: none; + } +} +``` + +### Single breakpoint + +There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum breakpoint widths. + +```scss +@include post.media-breakpoint-only(xs) { + .custom-class { + display: block; + } +} +``` + +### Between breakpoints + +Similarly, media queries may span multiple breakpoint widths. + +```scss +@include post.media-breakpoint-between(sm, lg) { + .custom-class { + display: block; + } +} +``` diff --git a/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.module.scss b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.module.scss new file mode 100644 index 0000000000..250760c880 --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.module.scss @@ -0,0 +1,33 @@ +@use 'sass:list'; +@use 'sass:map'; +@use '@swisspost/design-system-styles/core' as post; + +$breakpointNames: ( + xs: Extra small, + sm: Small, + rg: Regular, + md: Medium, + lg: Large, + xl: Extra large, + xxl: Extra extra large, +); + +:export { + @each $breakpoint, $value in post.$grid-breakpoints { + $i: list.index(post.$grid-breakpoints, $breakpoint $value); + $name: map.get($breakpointNames, $breakpoint) or $breakpoint; + + breakpoint_#{$breakpoint}_name: $name; + + @if $i == 1 { + $keys: map.keys(post.$grid-breakpoints); + $nextValue: map.get(post.$grid-breakpoints, list.nth($keys, $i + 1)); + + breakpoint_#{$breakpoint}_infix: none; + breakpoint_#{$breakpoint}_dimensions: #{'<' + $nextValue}; + } @else { + breakpoint_#{$breakpoint}_infix: #{'' + $breakpoint + ''}; + breakpoint_#{$breakpoint}_dimensions: #{'≥' + $value}; + } + } +} diff --git a/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx b/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx index 12e8d31986..14772f6661 100644 --- a/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx +++ b/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx @@ -1,19 +1,17 @@ import { Meta } from '@storybook/blocks'; import { BADGE } from '../../../../.storybook/constants'; - + # Layout

TODO:

- Breakpoints, Containers, Grid, Columns +Breakpoints, Containers, Grid, Columns - Document differences and link over to bootstrap for the rest +Document differences and link over to bootstrap for the rest + +Refer to the Figma Design as well: Figma - Refer to the Figma Design as well: Figma
diff --git a/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx b/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx new file mode 100644 index 0000000000..b1ba7e060b --- /dev/null +++ b/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.blocks.tsx @@ -0,0 +1,29 @@ +import { forEach } from '../../../../utils/react'; +import { parse } from '../../../../utils/sass-export'; +import scss from './breakpoints.module.scss'; + +export const SCSS_VARIABLES = parse(scss); +export const BreakpointCount = () => {Object.keys(SCSS_VARIABLES.breakpoint).length}; + +export const BreakpointTable = (props: { name: string; value: string }) => ( + + + + + + + + + + {forEach(SCSS_VARIABLES.breakpoint, (data: { key: number; value: any }) => { + return ( + + + + + + ); + })} + +
BreakpointClass infixDimensions
{data.value.name}{data.value.dimensions}
+); diff --git a/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.module.scss b/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.module.scss new file mode 100644 index 0000000000..250760c880 --- /dev/null +++ b/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.module.scss @@ -0,0 +1,33 @@ +@use 'sass:list'; +@use 'sass:map'; +@use '@swisspost/design-system-styles/core' as post; + +$breakpointNames: ( + xs: Extra small, + sm: Small, + rg: Regular, + md: Medium, + lg: Large, + xl: Extra large, + xxl: Extra extra large, +); + +:export { + @each $breakpoint, $value in post.$grid-breakpoints { + $i: list.index(post.$grid-breakpoints, $breakpoint $value); + $name: map.get($breakpointNames, $breakpoint) or $breakpoint; + + breakpoint_#{$breakpoint}_name: $name; + + @if $i == 1 { + $keys: map.keys(post.$grid-breakpoints); + $nextValue: map.get(post.$grid-breakpoints, list.nth($keys, $i + 1)); + + breakpoint_#{$breakpoint}_infix: none; + breakpoint_#{$breakpoint}_dimensions: #{'<' + $nextValue}; + } @else { + breakpoint_#{$breakpoint}_infix: #{'' + $breakpoint + ''}; + breakpoint_#{$breakpoint}_dimensions: #{'≥' + $value}; + } + } +} diff --git a/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.stories.mdx b/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.stories.mdx new file mode 100644 index 0000000000..4527b671d6 --- /dev/null +++ b/packages/documentation/src/stories/foundation/layout/breakpoints/breakpoints.stories.mdx @@ -0,0 +1,86 @@ +import { Meta, Canvas } from '@storybook/addon-docs'; +import { BADGE } from '@geometricpanda/storybook-addon-badges'; +import { BreakpointTable, SCSS_VARIABLES, BreakpointCount } from './breakpoints.blocks'; + + + +# Breakpoints + +
+ Breakpoints are widths that determine how the responsive layout behaves across device or viewport + sizes. +
+ +## Available breakpoints + +The SwissPost Design-System includes breakpoints, sometimes referred to as grid tiers, for building responsively. These breakpoints can be customized if you’re using our source Sass files. + + + +You’ll find these breakpoints in a Sass map in our styles core. + +```css dark +@use '@swisspost/design-system-styles/core' as post; + +@each $key, $value in post.$grid-breakpoints { + ...; +} +``` + +## Mixins + +There are several mixins available to use in your own Sass to help with building responsive layouts. + +### Min-width + +We primarily use the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components. + +```css dark +// No media query necessary for xs breakpoint as it's effectively @media (min-width: 0) { ... } +.custom-class { + display: none; +} + +@include post.media-breakpoint-up(lg) { + .custom-class { + display: block; + } +} +``` + +### Max-width + +We occasionally use media queries that go in the other direction. + +```css dark +// No media query necessary for xs breakpoint as it's effectively @media (max-width: 0) { ... } +@include post.media-breakpoint-down(lg) { + .custom-class { + display: none; + } +} +``` + +### Single breakpoint + +There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum breakpoint widths. + +```css dark +@include post.media-breakpoint-only(xs) { + .custom-class { + display: block; + } +} +``` + +### Between breakpoints + +Similarly, media queries may span multiple breakpoint widths. + +```css dark +@include post.media-breakpoint-between(sm, lg) { + .custom-class { + display: block; + } +} +``` diff --git a/packages/documentation/src/stories/foundation/layout/layout.stories.mdx b/packages/documentation/src/stories/foundation/layout/layout.stories.mdx index 78548d6ebd..3c7f509250 100644 --- a/packages/documentation/src/stories/foundation/layout/layout.stories.mdx +++ b/packages/documentation/src/stories/foundation/layout/layout.stories.mdx @@ -1,7 +1,7 @@ import { Meta } from '@storybook/addon-docs';

TODO:

-

- Breakpoints, Containers, Grid, Columns -
- Document differences and link over to bootstrap for the rest -
- Refer to the Figma Design as well: - - Figma - -

+ +

+ Breakpoints, Containers, Grid, Columns +

+ +Document differences and link over to bootstrap for the rest + +Refer to the Figma Design as well: Figma + From 3a00ae525e349dfb41926ad357df2a72af96b548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20F=C3=BCrhoff?= <12294151+imagoiq@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:13:03 +0200 Subject: [PATCH 04/16] fix(documentation,documentation-v7): Self anchor link to not be redirected (#1794) Co-authored-by: Philipp Gfeller <1659006+gfellerph@users.noreply.github.com> --- .../src/stories/getting-started/components.docs.mdx | 6 ++++-- .../src/stories/getting-started/styles.docs.mdx | 6 ++++-- .../src/stories/icons/getting-started.docs.mdx | 8 +++++--- .../stories/intranet-header/intranet-header.docs.mdx | 10 ++++++---- .../src/stories/components/card/card.docs.mdx | 4 ++-- .../src/stories/getting-started/components.stories.mdx | 6 ++++-- .../src/stories/getting-started/styles.stories.mdx | 6 ++++-- .../src/stories/icons/getting-started.stories.mdx | 10 ++++++---- .../internet-header/getting-started.stories.mdx | 10 ++++++---- .../intranet-header/getting-started.stories.mdx | 10 ++++++---- 10 files changed, 47 insertions(+), 29 deletions(-) diff --git a/packages/documentation-v7/src/stories/getting-started/components.docs.mdx b/packages/documentation-v7/src/stories/getting-started/components.docs.mdx index cd421a857c..4656331e49 100644 --- a/packages/documentation-v7/src/stories/getting-started/components.docs.mdx +++ b/packages/documentation-v7/src/stories/getting-started/components.docs.mdx @@ -12,8 +12,10 @@ import { BADGE } from '../../../.storybook/constants'; A set of standard web components for easy integration with every framework or no framework at all. -- [Installation](#installation) -- [Usage](#usage) + ## Installation diff --git a/packages/documentation-v7/src/stories/getting-started/styles.docs.mdx b/packages/documentation-v7/src/stories/getting-started/styles.docs.mdx index da88545cd2..a3adcfe2c9 100644 --- a/packages/documentation-v7/src/stories/getting-started/styles.docs.mdx +++ b/packages/documentation-v7/src/stories/getting-started/styles.docs.mdx @@ -12,8 +12,10 @@ import { BADGE } from '../../../.storybook/constants'; The styling package, including theming for [Bootstrap](https://getbootstrap.com/) and [ng-bootstrap](https://ng-bootstrap.github.io/#/home) components. -- [Installation](#installation) -- [Usage](#usage) + ## Installation diff --git a/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx b/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx index 47995f3bec..c7edf79130 100644 --- a/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx +++ b/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx @@ -10,9 +10,11 @@ import { BADGE } from '../../../.storybook/constants'; The comprehensive collection of Swiss Post icons. -- [Installation](#installation) -- [Configuration](#configuration) -- [CDN approach](#cdn-approach) + ## Installation diff --git a/packages/documentation-v7/src/stories/intranet-header/intranet-header.docs.mdx b/packages/documentation-v7/src/stories/intranet-header/intranet-header.docs.mdx index 1c3e7e127c..d327d97471 100644 --- a/packages/documentation-v7/src/stories/intranet-header/intranet-header.docs.mdx +++ b/packages/documentation-v7/src/stories/intranet-header/intranet-header.docs.mdx @@ -1,4 +1,4 @@ -import { Meta, ArgTypes } from '@storybook/blocks'; +import { ArgTypes, Meta } from '@storybook/blocks'; import * as IntranetHeaderStories from './intranet-header.stories'; @@ -13,9 +13,11 @@ import * as IntranetHeaderStories from './intranet-header.stories'; The Header Angular component for internal usage. -- [Installation](#installation) -- [Configuration](#configuration) -- [Examples](#examples) + ## Installation diff --git a/packages/documentation/src/stories/components/card/card.docs.mdx b/packages/documentation/src/stories/components/card/card.docs.mdx index 67821649d8..f2aff5a867 100644 --- a/packages/documentation/src/stories/components/card/card.docs.mdx +++ b/packages/documentation/src/stories/components/card/card.docs.mdx @@ -1,4 +1,4 @@ -import { Meta, Canvas, Story, Source, ArgsTable } from '@storybook/addon-docs'; +import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs'; @@ -12,7 +12,7 @@ A card is a flexible and extensible content container.
Built with flexbox, they offer easy alignment and mix well with other components. Cards have no fixed width to start, so they’ll naturally fill the full width of its parent element.
-Use our [sizing examples](#sizing) to customize the size of a card. +Use our sizing examples to customize the size of a card. Last but not least, our card component is based on the bootstrap card component.
Please also have a look at their documentation if you want to get more details or see even more examples. diff --git a/packages/documentation/src/stories/getting-started/components.stories.mdx b/packages/documentation/src/stories/getting-started/components.stories.mdx index 5737f51c70..ff9d676e18 100644 --- a/packages/documentation/src/stories/getting-started/components.stories.mdx +++ b/packages/documentation/src/stories/getting-started/components.stories.mdx @@ -20,8 +20,10 @@ import { BADGE } from '@geometricpanda/storybook-addon-badges'; A set of standard web components for easy integration with every framework or no framework at all. -- [Installation](#installation) -- [Usage](#usage) + ## Installation diff --git a/packages/documentation/src/stories/getting-started/styles.stories.mdx b/packages/documentation/src/stories/getting-started/styles.stories.mdx index 35042c59b4..b5ccb89e4d 100644 --- a/packages/documentation/src/stories/getting-started/styles.stories.mdx +++ b/packages/documentation/src/stories/getting-started/styles.stories.mdx @@ -20,8 +20,10 @@ import { BADGE } from '@geometricpanda/storybook-addon-badges'; The styling package, including theming for [Bootstrap](https://getbootstrap.com/) and [ng-bootstrap](https://ng-bootstrap.github.io/#/home) components. -- [Installation](#installation) -- [Usage](#usage) + ## Installation diff --git a/packages/documentation/src/stories/icons/getting-started.stories.mdx b/packages/documentation/src/stories/icons/getting-started.stories.mdx index 519a2800cf..16d94f3e4a 100644 --- a/packages/documentation/src/stories/icons/getting-started.stories.mdx +++ b/packages/documentation/src/stories/icons/getting-started.stories.mdx @@ -1,4 +1,4 @@ -import { Meta, Source } from '@storybook/addon-docs'; +import { Meta } from '@storybook/addon-docs'; import LinkTo from '@storybook/addon-links/react'; import { BADGE } from '@geometricpanda/storybook-addon-badges'; @@ -21,9 +21,11 @@ import { BADGE } from '@geometricpanda/storybook-addon-badges'; The comprehensive collection of Swiss Post icons. -- [Installation](#installation) -- [Configuration](#configuration) -- [CDN approach](#cdn-approach) + ## Installation diff --git a/packages/documentation/src/stories/internet-header/getting-started.stories.mdx b/packages/documentation/src/stories/internet-header/getting-started.stories.mdx index 5c12e0c8c1..b63882db93 100644 --- a/packages/documentation/src/stories/internet-header/getting-started.stories.mdx +++ b/packages/documentation/src/stories/internet-header/getting-started.stories.mdx @@ -1,4 +1,4 @@ -import { Meta, Story } from '@storybook/addon-docs'; +import { Meta } from '@storybook/addon-docs'; import { BADGE } from '@geometricpanda/storybook-addon-badges'; @@ -9,9 +9,11 @@ import { BADGE } from '@geometricpanda/storybook-addon-badges'; The header for client-facing applications. -- [Installation](#installation) -- [Configuration](#configuration) -- [Help](#help) + ## Installation diff --git a/packages/documentation/src/stories/intranet-header/getting-started.stories.mdx b/packages/documentation/src/stories/intranet-header/getting-started.stories.mdx index 0293d94e6b..fe91b3502a 100644 --- a/packages/documentation/src/stories/intranet-header/getting-started.stories.mdx +++ b/packages/documentation/src/stories/intranet-header/getting-started.stories.mdx @@ -1,4 +1,4 @@ -import { Meta, Story, ArgsTable } from '@storybook/addon-docs'; +import { Meta, ArgsTable } from '@storybook/addon-docs'; import { BADGE } from '@geometricpanda/storybook-addon-badges'; +
  • Installation
  • +
  • Usage
  • +
  • Examples
  • +

    The Intranet Header is an Angular component and as such only works with Angular projects. From 0f684606fd1717ae760163f0ed449bab49e381b9 Mon Sep 17 00:00:00 2001 From: Lukas Blaser <141234680+b1aserlu@users.noreply.github.com> Date: Wed, 16 Aug 2023 16:27:55 +0200 Subject: [PATCH 05/16] feat(documentation-v7): migrate table component stories (#1803) --- .../stories/components/table/table.docs.mdx | 39 +++ .../stories/components/table/table.stories.ts | 224 ++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 packages/documentation-v7/src/stories/components/table/table.docs.mdx create mode 100644 packages/documentation-v7/src/stories/components/table/table.stories.ts diff --git a/packages/documentation-v7/src/stories/components/table/table.docs.mdx b/packages/documentation-v7/src/stories/components/table/table.docs.mdx new file mode 100644 index 0000000000..19b54489d8 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/table/table.docs.mdx @@ -0,0 +1,39 @@ +import { Meta, Canvas, Controls } from '@storybook/blocks'; +import * as TableStories from './table.stories'; + + + +# Table + +

    + Customize the native <table> element with CSS that changes the element’s + initial appearance. +
    + + +
    + +
    + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```scss +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```scss +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/table.scss'; +``` + +## Usage examples + +### Table with buttons + +When buttons are placed in a table, be sure to use `alignment: middle`, respectively `` to nicely align the content and the buttons. + + diff --git a/packages/documentation-v7/src/stories/components/table/table.stories.ts b/packages/documentation-v7/src/stories/components/table/table.stories.ts new file mode 100644 index 0000000000..a27e60447b --- /dev/null +++ b/packages/documentation-v7/src/stories/components/table/table.stories.ts @@ -0,0 +1,224 @@ +import type { Args, Meta, StoryObj } from '@storybook/web-components'; +import { html } from 'lit'; +import { mapClasses } from '../../../utils'; + +const meta: Meta = { + title: 'Components/Table', + render: renderTable, + parameters: {}, + args: { + variant: [], + borderStyle: 'null', + caption: 'List of users', + captionPlacement: 'bottom', + alignment: 'align-top', + content: null, + }, + argTypes: { + content: { + name: 'Content', + description: 'Hidden helper arg for dynamically switching the table body', + table: { + disable: true, + }, + }, + caption: { + name: 'Caption', + description: 'A description of the table, very useful for screen reader users.', + control: { + type: 'text', + }, + table: { + category: 'Caption', + }, + }, + captionPlacement: { + name: 'Caption Placement', + description: + 'Choose where to place the description of the table. If a visual description is not necessary, it can also be hidden visually and still be of value for screen reader users.', + control: { + type: 'select', + labels: { + bottom: 'Bottom (default)', + top: 'Top', + hidden: 'Visually hidden', + }, + }, + options: ['bottom', 'top', 'hidden'], + table: { + category: 'Caption', + }, + }, + borderStyle: { + name: 'Border style', + description: 'Border style', + control: { + type: 'radio', + labels: { + 'null': 'Default (underlined)', + 'table-bordered': 'Bordered', + 'table-borderless': 'Borderless', + }, + }, + options: ['null', 'table-bordered', 'table-borderless'], + table: { + category: 'General', + }, + }, + variant: { + name: 'Variants', + description: 'Stylistic table variants.', + control: { + type: 'check', + labels: { + 'table-sm': 'Small', + 'table-striped': 'Striped', + 'table-hover': 'Hover enabled', + }, + }, + options: ['table-sm', 'table-striped', 'table-hover'], + table: { + category: 'General', + }, + }, + alignment: { + name: 'Alignment', + description: + 'Vertical alignment options for cell content. Alignment classes can also be set for individual rows or cells.', + control: { + type: 'select', + labels: { + 'align-top': 'Top (default)', + 'align-middle': 'Middle', + 'align-bottom': 'Bottom', + }, + }, + options: ['align-top', 'align-middle', 'align-bottom'], + table: { + category: 'General', + }, + }, + }, +}; + +export default meta; + +type Story = StoryObj; + +function renderTable(args: Args) { + const cationTop = args.captionPlacement === 'top' ? 'caption-top' : 'null'; + const variants = args.variant.join(' '); + return html` + + + + + + + + + + + + ${args.content} +
    + ${args.caption} +
    #FirstLastHandle
    + `; +} + +export const Default: Story = { + args: { + content: html` + + 1 + Mark + Otto + @mdo + + + 2 + Jacob + Thornton + @fat + + + 3 + Larry + the Bird + @twitter + + + 4 + Someone + + else +
    + entirely + + @twitter + + `, + }, +}; + +export const TableWithButtons: Story = { + args: { + alignment: 'align-middle', + content: html` + + 1 + Mark + Otto + + + + + + + 2 + Jacob + Thornton + + + + + + + 3 + Larry + the Bird + + + + + + `, + }, +}; From bbc2a678cb796a3b1eff3fb344337dd0056f948c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9=20Debray?= <33580481+alizedebray@users.noreply.github.com> Date: Thu, 17 Aug 2023 08:35:23 +0200 Subject: [PATCH 06/16] fix(styles): missing calendar icon with named icon (#1806) --- .changeset/long-pumpkins-repeat.md | 5 +++++ .changeset/serious-toes-speak.md | 5 +++++ .../datepicker-demo-page/datepicker-demo-page.component.html | 5 +++++ .../datepicker-simple/datepicker-simple-lg.component.html | 2 +- .../datepicker-simple/datepicker-simple.component.html | 2 +- .../datepicker-validation-lg.component.html | 2 +- .../datepicker-validation.component.html | 2 +- packages/demo/src/styles.scss | 4 ---- packages/styles/src/components/datepicker.scss | 5 +++++ 9 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 .changeset/long-pumpkins-repeat.md create mode 100644 .changeset/serious-toes-speak.md diff --git a/.changeset/long-pumpkins-repeat.md b/.changeset/long-pumpkins-repeat.md new file mode 100644 index 0000000000..7b6260fae3 --- /dev/null +++ b/.changeset/long-pumpkins-repeat.md @@ -0,0 +1,5 @@ +--- +'@swisspost/design-system-styles': patch +--- + +Fixed the `.pi-calendar` class not showing an icon in the datepicker. diff --git a/.changeset/serious-toes-speak.md b/.changeset/serious-toes-speak.md new file mode 100644 index 0000000000..dee998ab73 --- /dev/null +++ b/.changeset/serious-toes-speak.md @@ -0,0 +1,5 @@ +--- +'@swisspost/design-system-demo': patch +--- + +Deprecated the `.pi-calendar` class in favor of the `.pi-3203` class to display the calendar icon in the datepicker. diff --git a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-demo-page/datepicker-demo-page.component.html b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-demo-page/datepicker-demo-page.component.html index 781d329906..2fee675f06 100644 --- a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-demo-page/datepicker-demo-page.component.html +++ b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-demo-page/datepicker-demo-page.component.html @@ -3,6 +3,11 @@

    Datepicker

    +
    +

    The .pi-calendar class previously used to display the calendar icon in the datepicker button + has been deprecated in favor of the .pi-3203 class which shows the same icon.

    +
    +

    Choose a language:

    diff --git a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple-lg.component.html b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple-lg.component.html index 4a91f42fe1..97f7cd24b6 100644 --- a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple-lg.component.html +++ b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple-lg.component.html @@ -10,6 +10,6 @@ type="text"/> diff --git a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple.component.html b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple.component.html index 0b82924c53..1ae82672d8 100644 --- a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple.component.html +++ b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-simple/datepicker-simple.component.html @@ -11,6 +11,6 @@ placeholder="yyyy-mm-dd" type="text"> diff --git a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation-lg.component.html b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation-lg.component.html index 28b2274400..0c8d092297 100644 --- a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation-lg.component.html +++ b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation-lg.component.html @@ -14,7 +14,7 @@

    Valid feedback

    diff --git a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation.component.html b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation.component.html index 0932c5e449..c8fac6c868 100644 --- a/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation.component.html +++ b/packages/demo/src/app/ng-bootstrap/components/datepicker/datepicker-validation/datepicker-validation.component.html @@ -14,7 +14,7 @@ type="text">

    Valid feedback

    diff --git a/packages/demo/src/styles.scss b/packages/demo/src/styles.scss index 27fd5c606c..ea77d270ed 100644 --- a/packages/demo/src/styles.scss +++ b/packages/demo/src/styles.scss @@ -52,10 +52,6 @@ body { @include post.pi(2104, 'white'); } -.pi-calendar { - @include post.pi(3203); -} - .code-sample { margin-top: 35px; text-align: center; diff --git a/packages/styles/src/components/datepicker.scss b/packages/styles/src/components/datepicker.scss index 7d8ffb7c94..55602aba62 100644 --- a/packages/styles/src/components/datepicker.scss +++ b/packages/styles/src/components/datepicker.scss @@ -5,6 +5,7 @@ @use './../variables/components/datepicker'; @use './../variables/components/forms'; @use './../variables/commons'; +@use './../mixins/icons' as icons-mx; ngb-datepicker { // Conversion for compatibility @@ -131,7 +132,9 @@ span.ngb-dp-navigation-chevron { width: forms.$input-height-inner; background: transparent; + .pi-3203, .pi-calendar { + @include icons-mx.pi(3203); width: datepicker.$ngb-dp-icon-size; height: datepicker.$ngb-dp-icon-size; transform: none; @@ -142,6 +145,7 @@ span.ngb-dp-navigation-chevron { height: forms.$input-height-inner-sm; width: forms.$input-height-inner-sm; + .pi-3203, .pi-calendar { width: datepicker.$ngb-dp-icon-size-sm; height: datepicker.$ngb-dp-icon-size-sm; @@ -158,6 +162,7 @@ span.ngb-dp-navigation-chevron { height: forms.$input-height-inner-lg; width: forms.$input-height-inner-lg; + .pi-3203, .pi-calendar { width: datepicker.$ngb-dp-icon-size-lg; height: datepicker.$ngb-dp-icon-size-lg; From 9a959bc810e8ef28496fe6b254dc67f997a5fa51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9=20Debray?= <33580481+alizedebray@users.noreply.github.com> Date: Thu, 17 Aug 2023 08:41:04 +0200 Subject: [PATCH 07/16] chore(documentation-v7): add stories for all doc pages (#1788) Co-authored-by: Philipp Gfeller <1659006+gfellerph@users.noreply.github.com> --- packages/documentation-v7/.storybook/preview.ts | 2 +- .../components/input-group/input-group.docs.mdx | 9 ++++----- .../components/input-group/input-group.stories.ts | 15 +++++++++++++++ .../accessibility/accessibility.docs.mdx | 7 ++----- .../accessibility/accessibility.stories.ts | 15 +++++++++++++++ .../src/stories/foundation/color/color.docs.mdx | 4 ++-- .../src/stories/foundation/color/color.stories.ts | 15 +++++++++++++++ .../layout/breakpoints/breakpoints.docs.mdx | 6 +++--- .../layout/breakpoints/breakpoints.stories.ts | 15 +++++++++++++++ .../src/stories/foundation/layout/layout.docs.mdx | 4 ++-- .../stories/foundation/layout/layout.stories.ts | 15 +++++++++++++++ .../foundation/typography/typography.docs.mdx | 7 ++----- .../foundation/typography/typography.stories.ts | 15 +++++++++++++++ .../{ => components}/components.docs.mdx | 7 ++----- .../components/components.stories.ts | 15 +++++++++++++++ .../getting-started/{ => styles}/styles.docs.mdx | 7 ++----- .../getting-started/styles/styles.stories.ts | 15 +++++++++++++++ .../src/stories/icons/getting-started.docs.mdx | 4 ++-- .../src/stories/icons/getting-started.stories.ts | 15 +++++++++++++++ .../misc/{ => changelog}/changelog.docs.mdx | 4 ++-- .../migration-guide.docs.mdx | 4 ++-- .../migration-guide/migration-guide.stories.ts | 15 +++++++++++++++ .../misc/{ => versions}/versions.blocks.tsx | 2 +- .../stories/misc/{ => versions}/versions.docs.mdx | 4 ++-- .../src/stories/misc/versions/versions.stories.ts | 15 +++++++++++++++ .../src/stories/templates/forms/forms.docs.mdx | 4 ++-- .../src/stories/templates/forms/forms.stories.ts | 15 +++++++++++++++ .../src/stories/utilities/common/common.docs.mdx | 7 ++----- .../stories/utilities/common/common.stories.ts | 15 +++++++++++++++ .../src/stories/utilities/sizing/sizing.docs.mdx | 7 ++----- .../stories/utilities/sizing/sizing.stories.ts | 15 +++++++++++++++ .../stories/utilities/spacing/spacing.docs.mdx | 7 ++----- .../stories/utilities/spacing/spacing.stories.ts | 15 +++++++++++++++ 33 files changed, 262 insertions(+), 59 deletions(-) create mode 100644 packages/documentation-v7/src/stories/components/input-group/input-group.stories.ts create mode 100644 packages/documentation-v7/src/stories/foundation/accessibility/accessibility.stories.ts create mode 100644 packages/documentation-v7/src/stories/foundation/color/color.stories.ts create mode 100644 packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.stories.ts create mode 100644 packages/documentation-v7/src/stories/foundation/layout/layout.stories.ts create mode 100644 packages/documentation-v7/src/stories/foundation/typography/typography.stories.ts rename packages/documentation-v7/src/stories/getting-started/{ => components}/components.docs.mdx (88%) create mode 100644 packages/documentation-v7/src/stories/getting-started/components/components.stories.ts rename packages/documentation-v7/src/stories/getting-started/{ => styles}/styles.docs.mdx (92%) create mode 100644 packages/documentation-v7/src/stories/getting-started/styles/styles.stories.ts create mode 100644 packages/documentation-v7/src/stories/icons/getting-started.stories.ts rename packages/documentation-v7/src/stories/misc/{ => changelog}/changelog.docs.mdx (51%) rename packages/documentation-v7/src/stories/misc/{ => migration-guide}/migration-guide.docs.mdx (69%) create mode 100644 packages/documentation-v7/src/stories/misc/migration-guide/migration-guide.stories.ts rename packages/documentation-v7/src/stories/misc/{ => versions}/versions.blocks.tsx (97%) rename packages/documentation-v7/src/stories/misc/{ => versions}/versions.docs.mdx (71%) create mode 100644 packages/documentation-v7/src/stories/misc/versions/versions.stories.ts create mode 100644 packages/documentation-v7/src/stories/templates/forms/forms.stories.ts create mode 100644 packages/documentation-v7/src/stories/utilities/common/common.stories.ts create mode 100644 packages/documentation-v7/src/stories/utilities/sizing/sizing.stories.ts create mode 100644 packages/documentation-v7/src/stories/utilities/spacing/spacing.stories.ts diff --git a/packages/documentation-v7/.storybook/preview.ts b/packages/documentation-v7/.storybook/preview.ts index d42be1d4fd..9eb4868e07 100644 --- a/packages/documentation-v7/.storybook/preview.ts +++ b/packages/documentation-v7/.storybook/preview.ts @@ -42,7 +42,7 @@ const preview: Preview = { 'Templates', 'Utilities', 'Misc', - ['Migration Guide', 'ChangeLog', 'Versions'], + ['Migration Guide', 'Changelog', 'Versions'], 'Snapshots', ], }, diff --git a/packages/documentation-v7/src/stories/components/input-group/input-group.docs.mdx b/packages/documentation-v7/src/stories/components/input-group/input-group.docs.mdx index ebef6a12a4..35b0e92ee3 100644 --- a/packages/documentation-v7/src/stories/components/input-group/input-group.docs.mdx +++ b/packages/documentation-v7/src/stories/components/input-group/input-group.docs.mdx @@ -1,10 +1,9 @@ -import { Meta, Canvas, Controls } from '@storybook/blocks'; +import { Meta } from '@storybook/blocks'; +import * as InputGroupStories from './input-group.stories'; -import { BADGE } from '../../../../.storybook/constants'; + - - -# Input-Group +# Input Group

    TODO:

    diff --git a/packages/documentation-v7/src/stories/components/input-group/input-group.stories.ts b/packages/documentation-v7/src/stories/components/input-group/input-group.stories.ts new file mode 100644 index 0000000000..b7d4b6dea9 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/input-group/input-group.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Components/Input Group', + parameters: { + badges: [BADGE.TODO], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/foundation/accessibility/accessibility.docs.mdx b/packages/documentation-v7/src/stories/foundation/accessibility/accessibility.docs.mdx index b16a1af242..2c497d39fa 100644 --- a/packages/documentation-v7/src/stories/foundation/accessibility/accessibility.docs.mdx +++ b/packages/documentation-v7/src/stories/foundation/accessibility/accessibility.docs.mdx @@ -1,10 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../../.storybook/constants'; +import * as AccessibilityStories from './accessibility.stories'; - + # Accessibility diff --git a/packages/documentation-v7/src/stories/foundation/accessibility/accessibility.stories.ts b/packages/documentation-v7/src/stories/foundation/accessibility/accessibility.stories.ts new file mode 100644 index 0000000000..edde30f568 --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/accessibility/accessibility.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Foundations/Accessibility', + parameters: { + badges: [BADGE.TODO], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/foundation/color/color.docs.mdx b/packages/documentation-v7/src/stories/foundation/color/color.docs.mdx index 6495c5a0a2..ba779620d9 100644 --- a/packages/documentation-v7/src/stories/foundation/color/color.docs.mdx +++ b/packages/documentation-v7/src/stories/foundation/color/color.docs.mdx @@ -1,11 +1,11 @@ import { Meta } from '@storybook/blocks'; import LinkTo from '@storybook/addon-links/react'; -import { BADGE } from '../../../../.storybook/constants'; import { forEach } from '../../../utils/react'; +import * as ColorStories from './color.stories'; import { ColorSwatch, SCSS_VARIABLES } from './color.blocks'; import './color.styles.scss'; - + # Color diff --git a/packages/documentation-v7/src/stories/foundation/color/color.stories.ts b/packages/documentation-v7/src/stories/foundation/color/color.stories.ts new file mode 100644 index 0000000000..a0a4cb44a6 --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/color/color.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Foundations/Color', + parameters: { + badges: [BADGE.BETA, BADGE.NEEDS_REVISION], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx index 80f3f15657..305a31f393 100644 --- a/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx +++ b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.docs.mdx @@ -1,8 +1,8 @@ -import { Meta, Story } from '@storybook/blocks'; -import { BADGE } from '../../../../../.storybook/constants'; +import { Meta } from '@storybook/blocks'; import { BreakpointTable, SCSS_VARIABLES } from './breakpoints.blocks'; +import * as BreakpointStories from './breakpoints.stories'; - + # Breakpoints diff --git a/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.stories.ts b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.stories.ts new file mode 100644 index 0000000000..8aa74e4e5d --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/layout/breakpoints/breakpoints.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Foundations/Layout/Breakpoints', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx b/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx index 14772f6661..9b7fe06fa4 100644 --- a/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx +++ b/packages/documentation-v7/src/stories/foundation/layout/layout.docs.mdx @@ -1,7 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../../.storybook/constants'; +import * as LayoutStories from './layout.stories'; - + # Layout diff --git a/packages/documentation-v7/src/stories/foundation/layout/layout.stories.ts b/packages/documentation-v7/src/stories/foundation/layout/layout.stories.ts new file mode 100644 index 0000000000..9a2772e835 --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/layout/layout.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Foundations/Layout/TODOS', + parameters: { + badges: [BADGE.TODO], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/foundation/typography/typography.docs.mdx b/packages/documentation-v7/src/stories/foundation/typography/typography.docs.mdx index 8f5f218e4e..7a1b0ea272 100644 --- a/packages/documentation-v7/src/stories/foundation/typography/typography.docs.mdx +++ b/packages/documentation-v7/src/stories/foundation/typography/typography.docs.mdx @@ -1,6 +1,6 @@ import { Meta } from '@storybook/blocks'; import LinkTo from '@storybook/addon-links/react'; -import { BADGE } from '../../../../.storybook/constants'; +import * as TypographyStories from './typography.stories'; import { FontFaceWrapper, FontFace, @@ -14,10 +14,7 @@ import { } from './typography.blocks'; import './typography.styles.scss'; - + # Typography diff --git a/packages/documentation-v7/src/stories/foundation/typography/typography.stories.ts b/packages/documentation-v7/src/stories/foundation/typography/typography.stories.ts new file mode 100644 index 0000000000..9c9c77a13b --- /dev/null +++ b/packages/documentation-v7/src/stories/foundation/typography/typography.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Foundations/Typography', + parameters: { + badges: [BADGE.BETA, BADGE.NEEDS_REVISION], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/getting-started/components.docs.mdx b/packages/documentation-v7/src/stories/getting-started/components/components.docs.mdx similarity index 88% rename from packages/documentation-v7/src/stories/getting-started/components.docs.mdx rename to packages/documentation-v7/src/stories/getting-started/components/components.docs.mdx index 4656331e49..70ff0f8534 100644 --- a/packages/documentation-v7/src/stories/getting-started/components.docs.mdx +++ b/packages/documentation-v7/src/stories/getting-started/components/components.docs.mdx @@ -1,10 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../.storybook/constants'; +import * as GettingStartedStories from './components.stories'; - + # @swisspost/design-system-components diff --git a/packages/documentation-v7/src/stories/getting-started/components/components.stories.ts b/packages/documentation-v7/src/stories/getting-started/components/components.stories.ts new file mode 100644 index 0000000000..cacee53bdd --- /dev/null +++ b/packages/documentation-v7/src/stories/getting-started/components/components.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Getting Started/Components', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/getting-started/styles.docs.mdx b/packages/documentation-v7/src/stories/getting-started/styles/styles.docs.mdx similarity index 92% rename from packages/documentation-v7/src/stories/getting-started/styles.docs.mdx rename to packages/documentation-v7/src/stories/getting-started/styles/styles.docs.mdx index a3adcfe2c9..1d1e0c28f5 100644 --- a/packages/documentation-v7/src/stories/getting-started/styles.docs.mdx +++ b/packages/documentation-v7/src/stories/getting-started/styles/styles.docs.mdx @@ -1,10 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../.storybook/constants'; +import * as GettingStartedStories from './styles.stories'; - + # @swisspost/design-system-styles diff --git a/packages/documentation-v7/src/stories/getting-started/styles/styles.stories.ts b/packages/documentation-v7/src/stories/getting-started/styles/styles.stories.ts new file mode 100644 index 0000000000..27b5d70775 --- /dev/null +++ b/packages/documentation-v7/src/stories/getting-started/styles/styles.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Getting Started/Styles', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx b/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx index c7edf79130..c9c1338311 100644 --- a/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx +++ b/packages/documentation-v7/src/stories/icons/getting-started.docs.mdx @@ -1,8 +1,8 @@ import { Meta } from '@storybook/blocks'; import LinkTo from '@storybook/addon-links/react'; -import { BADGE } from '../../../.storybook/constants'; +import * as GettingStartedStories from './getting-started.stories'; - + # @swisspost/design-system-icons diff --git a/packages/documentation-v7/src/stories/icons/getting-started.stories.ts b/packages/documentation-v7/src/stories/icons/getting-started.stories.ts new file mode 100644 index 0000000000..fae506833f --- /dev/null +++ b/packages/documentation-v7/src/stories/icons/getting-started.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../.storybook/constants'; + +const meta: Meta = { + title: 'Icons/Getting started', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/misc/changelog.docs.mdx b/packages/documentation-v7/src/stories/misc/changelog/changelog.docs.mdx similarity index 51% rename from packages/documentation-v7/src/stories/misc/changelog.docs.mdx rename to packages/documentation-v7/src/stories/misc/changelog/changelog.docs.mdx index 1c35b4b1c9..f6a49b5ef8 100644 --- a/packages/documentation-v7/src/stories/misc/changelog.docs.mdx +++ b/packages/documentation-v7/src/stories/misc/changelog/changelog.docs.mdx @@ -1,8 +1,8 @@ import { Markdown, Meta } from '@storybook/blocks'; -import changelog from '../../../../styles/CHANGELOG.md?raw'; +import changelog from '../../../../../styles/CHANGELOG.md?raw'; {changelog} diff --git a/packages/documentation-v7/src/stories/misc/migration-guide.docs.mdx b/packages/documentation-v7/src/stories/misc/migration-guide/migration-guide.docs.mdx similarity index 69% rename from packages/documentation-v7/src/stories/misc/migration-guide.docs.mdx rename to packages/documentation-v7/src/stories/misc/migration-guide/migration-guide.docs.mdx index 56c956f56c..efc1708f90 100644 --- a/packages/documentation-v7/src/stories/misc/migration-guide.docs.mdx +++ b/packages/documentation-v7/src/stories/misc/migration-guide/migration-guide.docs.mdx @@ -1,7 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../.storybook/constants'; +import * as MigrationGuideStories from './migration-guide.stories'; - +
    + # Versions diff --git a/packages/documentation-v7/src/stories/misc/versions/versions.stories.ts b/packages/documentation-v7/src/stories/misc/versions/versions.stories.ts new file mode 100644 index 0000000000..8c363ab619 --- /dev/null +++ b/packages/documentation-v7/src/stories/misc/versions/versions.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Misc/Versions', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/templates/forms/forms.docs.mdx b/packages/documentation-v7/src/stories/templates/forms/forms.docs.mdx index 2b8555ec43..5d132bee99 100644 --- a/packages/documentation-v7/src/stories/templates/forms/forms.docs.mdx +++ b/packages/documentation-v7/src/stories/templates/forms/forms.docs.mdx @@ -1,7 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../../.storybook/constants'; +import * as FormTemplateStories from './forms.stories'; - + # Forms diff --git a/packages/documentation-v7/src/stories/templates/forms/forms.stories.ts b/packages/documentation-v7/src/stories/templates/forms/forms.stories.ts new file mode 100644 index 0000000000..86b4cff338 --- /dev/null +++ b/packages/documentation-v7/src/stories/templates/forms/forms.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Templates/Forms', + parameters: { + badges: [BADGE.TODO], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/utilities/common/common.docs.mdx b/packages/documentation-v7/src/stories/utilities/common/common.docs.mdx index 9e61e9897e..4e2944fd25 100644 --- a/packages/documentation-v7/src/stories/utilities/common/common.docs.mdx +++ b/packages/documentation-v7/src/stories/utilities/common/common.docs.mdx @@ -1,10 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../../.storybook/constants'; +import * as CommonStories from './common.stories'; - + # Common Utilities & Helper diff --git a/packages/documentation-v7/src/stories/utilities/common/common.stories.ts b/packages/documentation-v7/src/stories/utilities/common/common.stories.ts new file mode 100644 index 0000000000..921f593fff --- /dev/null +++ b/packages/documentation-v7/src/stories/utilities/common/common.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Utilities/Common', + parameters: { + badges: [BADGE.TODO], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/utilities/sizing/sizing.docs.mdx b/packages/documentation-v7/src/stories/utilities/sizing/sizing.docs.mdx index b0521f78c1..e8d8957d2f 100644 --- a/packages/documentation-v7/src/stories/utilities/sizing/sizing.docs.mdx +++ b/packages/documentation-v7/src/stories/utilities/sizing/sizing.docs.mdx @@ -1,10 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../../.storybook/constants'; +import * as SizingStories from './sizing.stories'; - + # Sizing diff --git a/packages/documentation-v7/src/stories/utilities/sizing/sizing.stories.ts b/packages/documentation-v7/src/stories/utilities/sizing/sizing.stories.ts new file mode 100644 index 0000000000..6042d3bb33 --- /dev/null +++ b/packages/documentation-v7/src/stories/utilities/sizing/sizing.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Utilities/Sizing', + parameters: { + badges: [BADGE.TODO], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; diff --git a/packages/documentation-v7/src/stories/utilities/spacing/spacing.docs.mdx b/packages/documentation-v7/src/stories/utilities/spacing/spacing.docs.mdx index 1a954654ec..2a9a436b78 100644 --- a/packages/documentation-v7/src/stories/utilities/spacing/spacing.docs.mdx +++ b/packages/documentation-v7/src/stories/utilities/spacing/spacing.docs.mdx @@ -1,10 +1,7 @@ import { Meta } from '@storybook/blocks'; -import { BADGE } from '../../../../.storybook/constants'; +import * as SpacingStories from './spacing.stories'; - + # Spacing diff --git a/packages/documentation-v7/src/stories/utilities/spacing/spacing.stories.ts b/packages/documentation-v7/src/stories/utilities/spacing/spacing.stories.ts new file mode 100644 index 0000000000..aff9081581 --- /dev/null +++ b/packages/documentation-v7/src/stories/utilities/spacing/spacing.stories.ts @@ -0,0 +1,15 @@ +import { Meta, StoryObj } from '@storybook/web-components'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Utilities/Spacing', + parameters: { + badges: [BADGE.TODO], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; From b21d78b778ecfbbdfe49e2f7011169dd9f087f65 Mon Sep 17 00:00:00 2001 From: Lukas Blaser <141234680+b1aserlu@users.noreply.github.com> Date: Thu, 17 Aug 2023 09:07:04 +0200 Subject: [PATCH 08/16] feat(documentation-v7): migrate button-group component (#1813) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alizé Debray <33580481+alizedebray@users.noreply.github.com> Co-authored-by: Loïc Fürhoff <12294151+imagoiq@users.noreply.github.com> --- .../button-group/button-group.docs.mdx | 51 ++++ .../button-group/button-group.stories.ts | 247 ++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 packages/documentation-v7/src/stories/components/button-group/button-group.docs.mdx create mode 100644 packages/documentation-v7/src/stories/components/button-group/button-group.stories.ts diff --git a/packages/documentation-v7/src/stories/components/button-group/button-group.docs.mdx b/packages/documentation-v7/src/stories/components/button-group/button-group.docs.mdx new file mode 100644 index 0000000000..fce158e002 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/button-group/button-group.docs.mdx @@ -0,0 +1,51 @@ +import { Canvas, Controls, Meta } from '@storybook/blocks'; +import * as ButtonGroupStories from './button-group.stories'; + + + +# Button Group + +
    + Group a series of buttons together on a single line. +
    + + +
    + +
    + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```scss +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```scss +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/badge.scss'; +``` + +## Concrete Examples of Application + +The following examples show the different characteristics of the component. These can differ in the type of visualization, the html structure, as well as when, how and why they are displayed. + +### Sizing + +You can change the size of buttons belonging to a group using button-sizing classes: `.btn-sm`, `.btn-rg` and `.btn-lg`. +Just be sure to apply the same class to all buttons contained in the group. + + + +### Checkbox & Radio + +Any HTML element that can be styled as a button can potentially be used in a button group. +It is also possible to use checkable inputs: + +- Checkboxes: this allows all buttons in the group to be selected or deselected individually, +- Radio buttons: in this case all the buttons are linked and only one of them can be selected at a time. + + diff --git a/packages/documentation-v7/src/stories/components/button-group/button-group.stories.ts b/packages/documentation-v7/src/stories/components/button-group/button-group.stories.ts new file mode 100644 index 0000000000..6d46cefbcc --- /dev/null +++ b/packages/documentation-v7/src/stories/components/button-group/button-group.stories.ts @@ -0,0 +1,247 @@ +import type { Args, Meta, StoryContext, StoryObj } from '@storybook/web-components'; +import { html } from 'lit'; +import { useArgs } from '@storybook/preview-api'; +import { BADGE } from '../../../../.storybook/constants'; + +const meta: Meta = { + title: 'Components/Button Group', + render: renderButtonGroup, + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, + args: { + size: 'btn-md', + element: 'button', + label_1: 'Left', + label_2: 'Middle', + label_3: 'Right', + }, + argTypes: { + size: { + name: 'Size', + description: 'Sets the size of the button group.', + control: { + type: 'select', + labels: { + ' btn-sm': 'Small', + ' btn-rg': 'Regular', + ' btn-md': 'Medium', + ' btn-lg': 'Large', + }, + }, + options: [' btn-sm', ' btn-rg', ' btn-md', ' btn-lg'], + table: { + category: 'General', + }, + }, + element: { + name: 'Variant', + description: 'Defined the semantic elements used as button within the group.', + control: { + type: 'radio', + labels: { + button: 'Buttons', + link: 'Links', + checkbox: 'Checkboxes', + radio: 'Radio Buttons', + }, + }, + options: ['button', 'link', 'checkbox', 'radio'], + table: { + category: 'General', + }, + }, + label_1: { + name: 'First Label', + description: 'Defines the label of the first button.', + control: { + type: 'text', + }, + table: { + category: 'Content', + }, + }, + label_2: { + name: 'Second Label', + description: 'Defines the label of the second button.', + control: { + type: 'text', + }, + table: { + category: 'Content', + }, + }, + label_3: { + name: 'Third Label', + description: 'Defines the label of the third button.', + control: { + type: 'text', + }, + table: { + category: 'Content', + }, + }, + checked: { + name: 'Checked Button', + description: 'Defined which button is checked in a radio button group.', + if: { + arg: 'element', + eq: 'radio', + }, + control: { + type: 'inline-radio', + labels: { + 1: 'First', + 2: 'Second', + 3: 'Third', + }, + }, + options: [1, 2, 3], + table: { + category: 'Value', + }, + }, + selected: { + name: 'Selected Button', + description: 'Defined which button is selected in a checkbox group.', + if: { + arg: 'element', + eq: 'checkbox', + }, + control: { + type: 'inline-check', + labels: { + 1: 'First', + 2: 'Second', + 3: 'Third', + }, + }, + options: [1, 2, 3], + table: { + category: 'Value', + }, + }, + }, + decorators: [ + story => + html` +
    { + const target = e.target as HTMLElement; + if (target.tagName === 'A' || target.tagName === 'BUTTON') e.preventDefault(); + }} + > + ${story()} +
    + `, + ], +}; + +export default meta; + +type Story = StoryObj; + +function createButtonTemplate(args: Args, context: StoryContext, index: number) { + const [_, updateArgs] = useArgs(); + const position = index + 1; + const id = `btngroup${context.name}_${position}`; + const label = args[`label_${position}`]; + + switch (args.element) { + case 'checkbox': { + const isSelected = args.selected?.includes(position) ?? false; + return html` + { + let isChecked = []; + if ((e.target as HTMLInputElement).checked === true) { + if (args.selected) { + isChecked = Array.from(new Set(args.selected.concat(position))); + } else { + isChecked = [position]; + } + } else { + isChecked = args.selected.filter((p: number) => p !== position); + } + updateArgs({ selected: isChecked }); + }} + /> + + `; + } + case 'radio': { + const isChecked = position === args.checked; + return html` + { + updateArgs({ checked: position }); + }} + /> + + `; + } + case 'link': + return html` + ${label} + `; + case 'button': + default: + return html` + + `; + } +} + +function renderButtonGroup(args: Args, context: StoryContext) { + return html` +
    + ${Array.from({ length: 3 }).map((_, i) => createButtonTemplate(args, context, i))} +
    + `; +} + +export const Default: Story = {}; + +export const Sizing: Story = { + parameters: { + controls: { + exclude: [ + 'Variant', + 'First Label', + 'Second Label', + 'Third Label', + 'Checked Button', + 'Selected Button', + ], + }, + }, + args: { + size: ' btn-sm', + }, +}; + +export const Checks: Story = { + parameters: { + controls: { + exclude: ['Size', 'First Label', 'Second Label', 'Third Label'], + }, + }, + args: { + element: 'checkbox', + selected: [1, 3], + checked: 2, + }, +}; From 51fea651a4648d5c32fe625c273c5d11664b0fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Sch=C3=BCrch?= Date: Thu, 17 Aug 2023 11:01:10 +0200 Subject: [PATCH 09/16] fix(documentation-v7): overwrite hcm styles for .innerZoomElementWrapper border-color (#1810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Loïc Fürhoff <12294151+imagoiq@users.noreply.github.com> --- packages/documentation-v7/.storybook/styles/preview.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/documentation-v7/.storybook/styles/preview.scss b/packages/documentation-v7/.storybook/styles/preview.scss index b9833d7170..812bbd111a 100644 --- a/packages/documentation-v7/.storybook/styles/preview.scss +++ b/packages/documentation-v7/.storybook/styles/preview.scss @@ -148,4 +148,12 @@ } } } + + @include post.high-contrast-mode() { + .innerZoomElementWrapper { + > * { + border-color: Canvas !important; + } + } + } } From eef429a659839850298fc49ebfc121a8d4354703 Mon Sep 17 00:00:00 2001 From: David Ritter <141235163+davidritter-dotcom@users.noreply.github.com> Date: Thu, 17 Aug 2023 11:01:32 +0200 Subject: [PATCH 10/16] feat(documentation-v7): migrate the switch component (#1800) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Loïc Fürhoff <12294151+imagoiq@users.noreply.github.com> Co-authored-by: Oliver Schürch Co-authored-by: Philipp Gfeller <1659006+gfellerph@users.noreply.github.com> --- .../stories/components/switch/switch.docs.mdx | 55 +++++ .../components/switch/switch.stories.ts | 227 ++++++++++++++++++ 2 files changed, 282 insertions(+) create mode 100644 packages/documentation-v7/src/stories/components/switch/switch.docs.mdx create mode 100644 packages/documentation-v7/src/stories/components/switch/switch.stories.ts diff --git a/packages/documentation-v7/src/stories/components/switch/switch.docs.mdx b/packages/documentation-v7/src/stories/components/switch/switch.docs.mdx new file mode 100644 index 0000000000..da53f79512 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/switch/switch.docs.mdx @@ -0,0 +1,55 @@ +import { Meta, Canvas, Controls } from '@storybook/blocks'; +import * as switchStories from './switch.stories'; + + + +# Switch + +
    + A switch has the markup of a custom <input type="checkbox"/> but uses the{' '} + .form-switch class to render a toggle switch. +
    + +Consider using `role="switch"` to more accurately convey the nature of the control to assistive technologies that support this role. In older assistive technologies, it will simply be announced as a regular `checkbox` as a fallback. Switches also support the `disabled` attribute. + + +
    + +
    + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```scss +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```scss +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/form-check.scss'; + +// required if you use validation feedbacks +@use '@swisspost/design-system-styles/components/form-feedback.scss'; +``` + +## Concrete Examples of Application + +The following examples show the different characteristics of the component. These can differ in the type of visualization, the HTML structure, as well as when, how and why they are displayed. + +### Multiline Labels + +Long labels can be used seamlessly and are automatically wrapped at the end of the line. +You can also include inline elements into the label, such as ``, ``, etc.
    +However, make sure to always place multiline labels after the `checkbox`. + + + +### Validation + +Simply add the classes `.is-valid` or `.is-invalid` to the `switch` element to show it in the expected state.
    +When the component has been validated, don't forget to add a `

    ...

    ` or `

    ...

    ` element after the `switch` element to explain what went wrong. This enables the user to correct the mistake. + + diff --git a/packages/documentation-v7/src/stories/components/switch/switch.stories.ts b/packages/documentation-v7/src/stories/components/switch/switch.stories.ts new file mode 100644 index 0000000000..b5ea58b469 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/switch/switch.stories.ts @@ -0,0 +1,227 @@ +import { useArgs } from '@storybook/preview-api'; +import type { Args, Meta, StoryContext, StoryObj } from '@storybook/web-components'; +import { html, nothing } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { BADGE } from '../../../../.storybook/constants'; +import { mapClasses } from '../../../utils'; + +const meta: Meta = { + title: 'Components/Switch', + render: renderSwitch, + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, + args: { + labelPosition: 'both', + labelBefore: 'Off', + labelAfter: 'On', + hiddenLabel: false, + checked: false, + disabled: false, + validation: 'null', + }, + argTypes: { + labelPosition: { + name: 'Label Position', + description: 'The position of the component label.', + control: { + type: 'radio', + label: { + both: 'Both', + before: 'Before', + after: 'After', + }, + }, + options: ['both', 'before', 'after'], + table: { + category: 'General', + }, + }, + labelBefore: { + name: 'Label (before)', + description: 'Describes the content/topic of the component.', + if: { + arg: 'labelPosition', + neq: 'after', + }, + control: { + type: 'text', + }, + table: { + category: 'General', + }, + }, + labelAfter: { + name: 'Label (after)', + description: 'Describes the content/topic of the component.', + if: { + arg: 'labelPosition', + neq: 'before', + }, + control: { + type: 'text', + }, + table: { + category: 'General', + }, + }, + hiddenLabel: { + name: 'Hidden Label', + description: + 'Renders the component with or without a visible label.There are accessibility concerns with hidden labels.
    Please read our
    label accessibility guide.', + control: { + type: 'boolean', + }, + table: { + category: 'General', + }, + }, + checked: { + name: 'Checked', + description: 'When set to `true`, places the component in the checked state.', + control: { + type: 'boolean', + }, + table: { + category: 'States', + }, + }, + disabled: { + name: 'Disabled', + description: + 'When set to `true`, disables the component\'s functionality and places it in a disabled state.There are accessibility concerns with the disabled state.
    Please read our disabled state accessibility guide.
    ', + control: { + type: 'boolean', + }, + table: { + category: 'States', + }, + }, + validation: { + name: 'Validation', + description: "Controls the display of the component's validation state.", + control: { + type: 'radio', + labels: { + 'null': 'Default', + 'is-valid': 'Valid', + 'is-invalid': 'Invalid', + }, + }, + options: ['null', 'is-valid', 'is-invalid'], + table: { + category: 'States', + }, + }, + }, + decorators: [ + story => + html` +
    ${story()}
    + `, + ], +}; + +export default meta; + +const VALIDATION_STATE_MAP: Record = { + 'null': undefined, + 'is-valid': false, + 'is-invalid': true, +}; + +function renderSwitch(args: Args, context: StoryContext) { + const [_, updateArgs] = useArgs(); + + const switchClasses = mapClasses({ + 'form-check-input': true, + [args.validation]: args.validation !== 'null', + }); + + const useAriaLabel = args.hiddenLabel; + const ariaLabel = args.checked ? args.labelAfter : args.labelBefore; + const useLabelBefore = !useAriaLabel && ['before', 'both'].includes(args.labelPosition); + const useLabelAfter = !useAriaLabel && ['after', 'both'].includes(args.labelPosition); + + const labelBefore = useLabelBefore + ? html` + + ` + : null; + + const labelAfter = useLabelAfter + ? html` + + ` + : null; + + const validationText = args.validation === 'is-valid' ? 'Ggranda sukceso!' : 'Eraro okazis!'; + const validationFeedback = + args.validation !== 'null' + ? html` +

    + ${validationText} +

    + ` + : null; + + return html` +
    + updateArgs({ checked: !args.checked })} + /> + ${labelBefore} ${labelAfter} ${args.validation !== 'null' ? validationFeedback : nothing} +
    + `; +} + +type Story = StoryObj; + +export const Default: Story = {}; + +export const MultilineLabels: Story = { + parameters: { + controls: { + exclude: [ + 'Label Position', + 'Label (before)', + 'Hidden Label', + 'Checked', + 'Disabled', + 'Validation', + ], + }, + }, + args: { + labelPosition: 'after', + labelAfter: + 'Longa etikedo kiu plej versajne ne taugas sur unu linio kaj tial devas esti envolvita. Kaj nur por esti sur la sekura flanko, ni simple aldonu unu plian tre sencelan frazon ci tie. Vi neniam scias...', + }, +}; + +export const Validation: Story = { + parameters: { + controls: { + exclude: [ + 'Label Position', + 'Label (before)', + 'Label (after)', + 'Hidden Label', + 'Checked', + 'Disabled', + ], + }, + }, + args: { + validation: 'is-invalid', + }, +}; From 5218715391d9bb90053fb76907538f224a00b664 Mon Sep 17 00:00:00 2001 From: David Ritter <141235163+davidritter-dotcom@users.noreply.github.com> Date: Thu, 17 Aug 2023 11:01:56 +0200 Subject: [PATCH 11/16] feat(documentation-v7): migrate topic-teaser (#1763) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Oliver Schürch Co-authored-by: Alizé Debray <33580481+alizedebray@users.noreply.github.com> --- .../topic-teaser/topic-teaser.docs.mdx | 33 +++ .../topic-teaser/topic-teaser.stories.ts | 189 ++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.docs.mdx create mode 100644 packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.stories.ts diff --git a/packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.docs.mdx b/packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.docs.mdx new file mode 100644 index 0000000000..f9bd1d79cb --- /dev/null +++ b/packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.docs.mdx @@ -0,0 +1,33 @@ +import { Meta, Canvas, Controls } from '@storybook/blocks'; +import * as TopicTeaserStories from './topic-teaser.stories'; + + + +# Topic Teaser + +
    + Topic Teaser provides a flexible and responsive content container with options to align the image, + adding topic content and links as well as contextual background colors. +
    + +If you use multiple topic teasers on one page, each topic teaser must have a different background. + + +
    + +
    + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```scss +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```scss +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/topic-teaser.scss'; +``` diff --git a/packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.stories.ts b/packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.stories.ts new file mode 100644 index 0000000000..127280968d --- /dev/null +++ b/packages/documentation-v7/src/stories/components/topic-teaser/topic-teaser.stories.ts @@ -0,0 +1,189 @@ +import type { Args, Meta, StoryObj } from '@storybook/web-components'; +import { html, TemplateResult } from 'lit'; +import { BADGE } from '../../../../.storybook/constants'; +import { mapClasses } from '../../../utils'; + +const meta: Meta = { + title: 'Components/Topic Teaser', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, + args: { + title: 'Loremipsum', + subtitle: 'Vero siteos et accusam iretea et justo', + linkCount: 5, + alignment: 'null', + backgroundColor: 'bg-nightblue', + }, + argTypes: { + title: { + name: 'Title', + description: 'The text to include in the component title.', + control: { + type: 'text', + }, + table: { + category: 'General', + }, + }, + subtitle: { + name: 'Subtitle', + description: 'The text to include in the component subtitle.', + control: { + type: 'text', + }, + table: { + category: 'General', + }, + }, + linkCount: { + name: 'Amount of links', + description: 'The amount of the renderd links.', + control: { + type: 'number', + min: 1, + max: 10, + }, + table: { + category: 'General', + }, + }, + alignment: { + name: 'Image alignment', + description: 'The alignment of the image.', + control: { + type: 'radio', + labels: { + 'topic-teaser-reverse': 'Image left', + 'null': 'Image right', + }, + }, + options: ['topic-teaser-reverse', 'null'], + table: { + category: 'General', + }, + }, + backgroundColor: { + name: 'Background Color', + description: 'The color the component uses as background.', + control: { + type: 'select', + labels: { + 'bg-light': 'Light', + 'bg-dark': 'Dark', + 'bg-nightblue': 'Nightblue', + 'bg-nightblue-bright': 'Nightblue (bright)', + 'bg-petrol': 'Petrol', + 'bg-petrol-bright': 'Petrol (bright)', + 'bg-coral': 'Coral', + 'bg-coral-bright': 'Coral (bright)', + 'bg-olive': 'Olive', + 'bg-olive-bright': 'Olive (bright)', + 'bg-purple': 'Purple', + 'bg-purple-bright': 'Purple (bright)', + 'bg-aubergine': 'Aubergine', + 'bg-aubergine-bright': 'Aubergine (bright)', + }, + }, + options: [ + 'bg-light', + 'bg-dark', + 'bg-nightblue', + 'bg-nightblue-bright', + 'bg-petrol', + 'bg-petrol-bright', + 'bg-coral', + 'bg-coral-bright', + 'bg-olive', + 'bg-olive-bright', + 'bg-purple', + 'bg-purple-bright', + 'bg-aubergine', + 'bg-aubergine-bright', + ], + table: { + category: 'General', + }, + }, + }, +}; + +export default meta; + +type Story = StoryObj; + +const linkTexts: string[] = [ + 'At vero eos et accusam et', + 'Dolores et ea rebum', + 'Stet clita kasd gubergren', + 'Sed diam nonumy eirmod', + 'Duo dolores et ea rebum', + 'Magna aliquyam erat', + 'Consetetur sadipscing elitr', + 'Justo duo dolores', + 'Takimata sanctus est', + 'Nonummy nibh euismod', +]; + +export const Default: Story = { + render: (args: Args) => { + const classes = mapClasses({ + 'topic-teaser': true, + 'mb-huge-r': true, + [args.backgroundColor]: args.backgroundColor !== 'null', + [args.alignment]: args.alignment !== 'null', + }); + + const links: TemplateResult[] = linkTexts.slice(0, args.linkCount).map( + text => html` + + `, + ); + + const image = html` +
    + Test teaser image +
    + `; + + const content = html` +
    +

    + ${args.title} + ${args.subtitle} +

    + +
    + `; + + return html` +
    +
    +
    +
    + ${args.alignment === 'null' + ? html` + ${content}${image} + ` + : html` + ${image}${content} + `} +
    +
    +
    +
    + `; + }, +}; From c1dee3be0187eee440d6556b07839ef584f5b3db Mon Sep 17 00:00:00 2001 From: Philipp Gfeller <1659006+gfellerph@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:56:15 +0200 Subject: [PATCH 12/16] feat(styles): add the radio/checkbox card component (#1607) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Loïc Fürhoff <12294151+imagoiq@users.noreply.github.com> Co-authored-by: Oliver Schürch --- .changeset/honest-singers-laugh.md | 6 + packages/components/.eslintrc.json | 33 +-- packages/documentation-v7/.storybook/main.ts | 10 +- packages/documentation-v7/package.json | 1 + .../choice-card/checkbox-card.docs.mdx | 60 +++++ .../choice-card/checkbox-card.stories.ts | 20 ++ .../choice-control.snapshot.stories.ts | 43 ++++ .../components/choice-card/choice-control.ts | 228 ++++++++++++++++++ .../choice-card/radiobutton-card.docs.mdx | 60 +++++ .../choice-card/radiobutton-card.stories.ts | 20 ++ packages/documentation/.storybook/preview.js | 1 + .../snapshots/styles/choice-card.snapshot.ts | 6 + .../checkbox-card.docs.mdx | 36 +++ .../checkbox-card.stories.tsx | 29 +++ .../choice-card-snapshot.stories.mdx | 27 +++ .../choice-control-card/choice-card.tsx | 177 ++++++++++++++ .../radio-button-card.docs.mdx | 36 +++ .../radio-button-card.stories.tsx | 28 +++ packages/styles/src/components/_index.scss | 1 + .../src/components/choice-control-card.scss | 146 +++++++++++ packages/styles/src/variables/_type.scss | 1 + pnpm-lock.yaml | 3 + 22 files changed, 940 insertions(+), 32 deletions(-) create mode 100644 .changeset/honest-singers-laugh.md create mode 100644 packages/documentation-v7/src/stories/components/choice-card/checkbox-card.docs.mdx create mode 100644 packages/documentation-v7/src/stories/components/choice-card/checkbox-card.stories.ts create mode 100644 packages/documentation-v7/src/stories/components/choice-card/choice-control.snapshot.stories.ts create mode 100644 packages/documentation-v7/src/stories/components/choice-card/choice-control.ts create mode 100644 packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.docs.mdx create mode 100644 packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.stories.ts create mode 100644 packages/documentation/cypress/snapshots/styles/choice-card.snapshot.ts create mode 100644 packages/documentation/src/stories/components/choice-control-card/checkbox-card.docs.mdx create mode 100644 packages/documentation/src/stories/components/choice-control-card/checkbox-card.stories.tsx create mode 100644 packages/documentation/src/stories/components/choice-control-card/choice-card-snapshot.stories.mdx create mode 100644 packages/documentation/src/stories/components/choice-control-card/choice-card.tsx create mode 100644 packages/documentation/src/stories/components/choice-control-card/radio-button-card.docs.mdx create mode 100644 packages/documentation/src/stories/components/choice-control-card/radio-button-card.stories.tsx create mode 100644 packages/styles/src/components/choice-control-card.scss diff --git a/.changeset/honest-singers-laugh.md b/.changeset/honest-singers-laugh.md new file mode 100644 index 0000000000..0bdb822077 --- /dev/null +++ b/.changeset/honest-singers-laugh.md @@ -0,0 +1,6 @@ +--- +'@swisspost/design-system-documentation': minor +'@swisspost/design-system-styles': minor +--- + +Added the checkbox and radio-button card pattern. These two components are now available in the styles package diff --git a/packages/components/.eslintrc.json b/packages/components/.eslintrc.json index 43e4496ebf..b3d873ca2d 100644 --- a/packages/components/.eslintrc.json +++ b/packages/components/.eslintrc.json @@ -8,17 +8,14 @@ "plugin:@typescript-eslint/recommended", "plugin:@stencil-community/recommended" ], - "overrides": [ - ], + "overrides": [], "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module", "project": "./tsconfig.eslint.json" }, - "plugins": [ - "@typescript-eslint" - ], + "plugins": ["@typescript-eslint"], "rules": { "indent": [ "error", @@ -27,14 +24,8 @@ "SwitchCase": 1 } ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ], + "quotes": ["error", "single"], + "semi": ["error", "always"], "@typescript-eslint/no-unused-vars": [ "error", { @@ -44,21 +35,9 @@ } ], "@stencil-community/strict-boolean-conditions": "off", - "@stencil-community/required-prefix": [ - "error", - [ - "post" - ] - ], + "@stencil-community/required-prefix": ["error", ["post"]], "@stencil-community/async-methods": "error", - "@stencil-community/ban-prefix": [ - "error", - [ - "stencil", - "stnl", - "st" - ] - ], + "@stencil-community/ban-prefix": ["error", ["stencil", "stnl", "st"]], "@stencil-community/decorators-context": "error", "@stencil-community/decorators-style": [ "error", diff --git a/packages/documentation-v7/.storybook/main.ts b/packages/documentation-v7/.storybook/main.ts index 997465a767..170f6eb849 100644 --- a/packages/documentation-v7/.storybook/main.ts +++ b/packages/documentation-v7/.storybook/main.ts @@ -11,11 +11,6 @@ const config: StorybookConfig = { }, stories: ['../src/stories/**/*.mdx', '../src/stories/**/*.stories.@(ts|tsx)'], addons: [ - '@storybook/addon-links', - '@storybook/addon-designs', - '@storybook/addon-a11y', - '@geometricpanda/storybook-addon-badges', - '@pxtrn/storybook-addon-docs-stencil', { name: '@storybook/addon-essentials', options: { @@ -26,6 +21,11 @@ const config: StorybookConfig = { toolbars: false, }, }, + '@storybook/addon-links', + '@storybook/addon-designs', + '@storybook/addon-a11y', + '@geometricpanda/storybook-addon-badges', + '@pxtrn/storybook-addon-docs-stencil', ], staticDirs: [ { diff --git a/packages/documentation-v7/package.json b/packages/documentation-v7/package.json index 91232a5ad9..97a51accf5 100644 --- a/packages/documentation-v7/package.json +++ b/packages/documentation-v7/package.json @@ -56,6 +56,7 @@ "@types/react-syntax-highlighter": "15.5.7", "cypress": "12.17.3", "lit": "2.8.0", + "lit-html": "2.8.0", "prettier": "2.8.8", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/packages/documentation-v7/src/stories/components/choice-card/checkbox-card.docs.mdx b/packages/documentation-v7/src/stories/components/choice-card/checkbox-card.docs.mdx new file mode 100644 index 0000000000..8ae601f273 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/choice-card/checkbox-card.docs.mdx @@ -0,0 +1,60 @@ +import { Meta, Canvas, Controls } from '@storybook/blocks'; +import * as CheckboxCardStories from './checkbox-card.stories'; + + + +# Checkbox card + +
    + A larger, more consumer oriented, touch friendly variant of the checkbox used for e.g. selecting + services. +
    + +
    +

    Firefox fallback classes

    + Firefox currently does not support + the new CSS :has pseudo-selector + . As a fallback, the following states have to be mirrored on the top level element in the form + of classes: +
      +
    • + checked +
    • +
    • + focused +
    • +
    • + disabled +
    • +
    • + is-invalid +
    • +
    + Check caniuse :has() to check if you still need the fallback. +
    + + +
    + +
    + +## Grouping + +Checkbox cards can be grouped together. Use a `fieldset`/`legend` combination to label the group. If there is an error, link the legend with the error message through the `aria-describedby` attribute on the `legend`, pointing to the `id` of the error message. + + + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```scss +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```scss +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/choice-control-card.scss'; +``` diff --git a/packages/documentation-v7/src/stories/components/choice-card/checkbox-card.stories.ts b/packages/documentation-v7/src/stories/components/choice-card/checkbox-card.stories.ts new file mode 100644 index 0000000000..5ec1e80157 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/choice-card/checkbox-card.stories.ts @@ -0,0 +1,20 @@ +import { BADGE } from '../../../../.storybook/constants'; +import { choiceCardMeta, choiceCardDefault, choiceCardGroup } from './choice-control'; + +export default { + ...choiceCardMeta, + title: 'Components/Checkbox Card', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, +}; + +export const Default = { + render: choiceCardDefault, + args: { ...choiceCardMeta.args, type: 'checkbox' }, +}; + +export const Group = { + render: choiceCardGroup, + args: { ...choiceCardMeta.args, type: 'checkbox' }, +}; diff --git a/packages/documentation-v7/src/stories/components/choice-card/choice-control.snapshot.stories.ts b/packages/documentation-v7/src/stories/components/choice-card/choice-control.snapshot.stories.ts new file mode 100644 index 0000000000..672cbff0b6 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/choice-card/choice-control.snapshot.stories.ts @@ -0,0 +1,43 @@ +import { bombArgs } from '../../../utils/bombArgs'; +import { choiceCardMeta, choiceCardDefault } from './choice-control'; +import { StoryObj } from '@storybook/web-components'; +import { html } from 'lit'; + +export default { + ...choiceCardMeta, + title: 'Hidden/snapshots/components', +}; + +const bombedArgs = bombArgs({ + type: choiceCardMeta.argTypes!.type!.options, + validation: choiceCardMeta.argTypes!.validation!.options, + checked: [false, true], + disabled: [false, true], + label: ['Card check text', 'Really long running choice card text that wraps to two lines'], + showDescription: [false, true], + description: ['A very long running description that is wrapping to two lines'], + showIcon: [false, true], +}) + // Filter out disabled and invalid combinations + .filter(args => !(args.disabled && args.validation === 'is-invalid')); + +export const CheckboxCard: StoryObj = { + render: () => { + return html` +
    + ${['bg-white', 'bg-dark'].map( + bg => html` +
    + ${bombedArgs.map( + args => + html` +
    ${choiceCardDefault(args)}
    + `, + )} +
    + `, + )} +
    + `; + }, +}; diff --git a/packages/documentation-v7/src/stories/components/choice-card/choice-control.ts b/packages/documentation-v7/src/stories/components/choice-card/choice-control.ts new file mode 100644 index 0000000000..39f8b6ce19 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/choice-card/choice-control.ts @@ -0,0 +1,228 @@ +import type { Args, Meta } from '@storybook/web-components'; +import { html } from 'lit/static-html.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { BADGE } from '../../../../.storybook/constants'; +import { nothing } from 'lit'; +import { useArgs } from '@storybook/preview-api'; + +export const choiceCardMeta: Meta = { + parameters: { + badges: [BADGE.NEEDS_REVISION], + controls: { + exclude: ['Type'], + }, + }, + args: { + label: 'Card check text', + type: 'radio', + checked: false, + disabled: false, + focused: false, + validation: 'null', + showDescription: false, + description: 'A small description', + icon: 1000, + showIcon: false, + }, + argTypes: { + label: { + name: 'Label', + type: 'string', + description: 'The main label of the input', + table: { + category: 'General', + }, + }, + type: { + name: 'Type', + control: { + type: 'radio', + labels: { + radio: 'Radio button', + checkbox: 'Checkbox', + }, + }, + options: ['radio', 'checkbox'], + table: { + // Hide it in the controls because there are two pages + disable: true, + }, + }, + checked: { + name: 'Checked', + type: 'boolean', + description: 'When set to `true`, places the component in the checked state.', + table: { + category: 'States', + }, + }, + disabled: { + name: 'Disabled', + description: + 'When set to `true`, disables the component\'s functionality and places it in a disabled state.There are accessibility concerns with the disabled state.
    Please read our disabled state accessibility guide.
    ', + control: { + type: 'boolean', + }, + table: { + category: 'States', + }, + }, + focused: { + name: 'Focused', + description: 'Render the component in a focused state', + control: { type: 'boolean' }, + table: { + category: 'States', + }, + }, + validation: { + name: 'Validation', + description: "Controls the display of the component's validation state.", + control: { + type: 'radio', + labels: { + 'null': 'Default', + 'is-invalid': 'Invalid', + }, + }, + options: ['null', 'is-invalid'], + table: { + category: 'States', + }, + }, + showDescription: { + name: 'Show description', + type: 'boolean', + description: 'Toggles an additional description', + table: { + category: 'Description', + }, + }, + description: { + name: 'Description', + type: 'string', + description: 'A short additional description', + table: { + category: 'Description', + }, + }, + showIcon: { + name: 'Show icon', + type: 'boolean', + description: 'Show or hide icon', + table: { + category: 'Icon', + }, + }, + icon: { + name: 'Icon', + control: { + type: 'select', + }, + options: [1000, 1001, 2000], + table: { + category: 'Icon', + }, + }, + }, +}; + +let id_ct = 1; + +export const choiceCardDefault = (args: Args, name = 'control') => { + const [_, updateArgs] = useArgs(); + + // Conditional classes + const inputClasses = classMap({ + 'form-check-input': true, + 'is-invalid': args.validation === 'is-invalid', + }); + const cardClassMap = classMap({ + 'checked': args.checked, + 'disabled': args.disabled, + 'is-invalid': args.validation === 'is-invalid', + 'checkbox-button-card': args.type === 'checkbox', + 'radio-button-card': args.type === 'radio', + }); + + // Child components + const id = `control-${id_ct++}`; + const description = html` +
    + ${args.description} + `; + const icon = html` + + `; + + // Firefox fallback for the :has selector + const _handleInput = (e: InputEvent) => { + const target = e.target as HTMLInputElement; + updateArgs({ checked: target.checked }); + + // Fix input events not fired on "deselected" radio buttons + target + .closest('fieldset') + ?.querySelectorAll('.radio-button-card') + .forEach(e => e?.classList.remove('checked')); + target.parentElement?.classList.toggle('checked', target.checked); + }; + + // Firefox fallback for the :has selector + const _handleFocus = (e: InputEvent) => { + updateArgs({ focused: true }); + (e.target as HTMLInputElement).parentElement?.classList.add('focused'); + }; + + // Firefox fallback for the :has selector + const _handleBlur = (e: InputEvent) => { + updateArgs({ focused: false }); + (e.target as HTMLInputElement).parentElement?.classList.remove('focused'); + }; + + return html` +
    + + + ${args.showIcon ? icon : nothing} +
    + `; +}; + +export const choiceCardGroup = (args: Args) => { + const loop = ['One', 'Two', 'Three', 'Four', 'Five', 'Six']; + + const col = (label: string) => html` +
    + ${choiceCardDefault({ ...args, label, checked: false, focused: false }, 'group')} +
    + `; + + const error = html` +

    Invalid choice

    + `; + + return html` +
    + + Legend + +
    ${loop.map(n => col(n))}
    + ${args.validation === 'is-invalid' ? error : null} +
    + `; +}; diff --git a/packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.docs.mdx b/packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.docs.mdx new file mode 100644 index 0000000000..4e31c53cd3 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.docs.mdx @@ -0,0 +1,60 @@ +import { Meta, Canvas, Controls } from '@storybook/blocks'; +import * as RadiobuttonCardStories from './radiobutton-card.stories'; + + + +# Radio button card + +
    + A larger, more consumer oriented, touch friendly variant of the radio-button used for e.g. selecting + services. +
    + +
    +

    Firefox fallback classes

    + Firefox currently does not support + the new CSS :has pseudo-selector + . As a fallback, the following states have to be mirrored on the top level element in the form + of classes: +
      +
    • + checked +
    • +
    • + focused +
    • +
    • + disabled +
    • +
    • + is-invalid +
    • +
    + Check caniuse :has() to check if you still need the fallback. +
    + + +
    + +
    + +## Grouping + +Radiobutton cards can be grouped together. Use a `fieldset`/`legend` combination to label the group. If there is an error, link the legend with the error message through the `aria-describedby` attribute on the `legend`, pointing to the `id` of the error message. + + + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```scss +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```scss +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/choice-control-card.scss'; +``` diff --git a/packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.stories.ts b/packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.stories.ts new file mode 100644 index 0000000000..392ddf353c --- /dev/null +++ b/packages/documentation-v7/src/stories/components/choice-card/radiobutton-card.stories.ts @@ -0,0 +1,20 @@ +import { BADGE } from '../../../../.storybook/constants'; +import { choiceCardMeta, choiceCardDefault, choiceCardGroup } from './choice-control'; + +export default { + ...choiceCardMeta, + title: 'Components/Radio Button Card', + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, +}; + +export const Default = { + render: choiceCardDefault, + args: { ...choiceCardMeta.args, type: 'radio' }, +}; + +export const Group = { + render: choiceCardGroup, + args: { ...choiceCardMeta.args, type: 'radio' }, +}; diff --git a/packages/documentation/.storybook/preview.js b/packages/documentation/.storybook/preview.js index e273f272b3..bf5fa8787a 100644 --- a/packages/documentation/.storybook/preview.js +++ b/packages/documentation/.storybook/preview.js @@ -106,6 +106,7 @@ export const parameters = { dt: null, dd: null, a: null, + div: null, }, source: { excludeDecorators: true, diff --git a/packages/documentation/cypress/snapshots/styles/choice-card.snapshot.ts b/packages/documentation/cypress/snapshots/styles/choice-card.snapshot.ts new file mode 100644 index 0000000000..929b4874f1 --- /dev/null +++ b/packages/documentation/cypress/snapshots/styles/choice-card.snapshot.ts @@ -0,0 +1,6 @@ +describe('Choice cards', () => { + it('default', () => { + cy.visit('/iframe.html?id=hidden-choice-card-snapshot-test--page'); + cy.percySnapshot('Choice card', { widths: [320, 1024] }); + }); +}); diff --git a/packages/documentation/src/stories/components/choice-control-card/checkbox-card.docs.mdx b/packages/documentation/src/stories/components/choice-control-card/checkbox-card.docs.mdx new file mode 100644 index 0000000000..37533f54b8 --- /dev/null +++ b/packages/documentation/src/stories/components/choice-control-card/checkbox-card.docs.mdx @@ -0,0 +1,36 @@ +import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'; +import LinkTo from '@storybook/addon-links/react'; + + + +# Checkbox Card + + + + +
    + +
    + +## Grouping checkboxes + +Checkbox cards can be grouped together by wrapping them in a `fieldset/legend` structure. + + + + + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```css dark +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```css dark +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/choice-control-button.scss'; +``` diff --git a/packages/documentation/src/stories/components/choice-control-card/checkbox-card.stories.tsx b/packages/documentation/src/stories/components/choice-control-card/checkbox-card.stories.tsx new file mode 100644 index 0000000000..67ae22324c --- /dev/null +++ b/packages/documentation/src/stories/components/choice-control-card/checkbox-card.stories.tsx @@ -0,0 +1,29 @@ +import { Meta, Story } from '@storybook/react'; +import { choiceCardGroup, choiceCardMeta, ChoiceCardReactiveTemplate } from './choice-card'; +import docsPage from './checkbox-card.docs.mdx'; + +export default Object.assign({}, choiceCardMeta, { + title: 'Components/Checkbox card', + parameters: { ...choiceCardMeta.parameters, docs: { page: docsPage } }, + args: { ...choiceCardMeta.args, type: 'checkbox' }, +}) as Meta; + +export const Default: Story = ChoiceCardReactiveTemplate.bind({}); +Default.args = { + type: 'checkbox', +}; +Default.parameters = { + controls: { + exclude: ['Type'], + }, +}; + +export const Group: Story = choiceCardGroup.bind({}); +Group.args = { + type: 'checkbox', +}; +Group.parameters = { + controls: { + exclude: ['Checked', 'Disabled', 'Type', 'Label'], + }, +}; diff --git a/packages/documentation/src/stories/components/choice-control-card/choice-card-snapshot.stories.mdx b/packages/documentation/src/stories/components/choice-control-card/choice-card-snapshot.stories.mdx new file mode 100644 index 0000000000..eee9f6ad0d --- /dev/null +++ b/packages/documentation/src/stories/components/choice-control-card/choice-card-snapshot.stories.mdx @@ -0,0 +1,27 @@ +import { Meta, Args, Story, Canvas } from '@storybook/addon-docs'; +import { bombArgs } from '../../utilities/bombArgs'; +import { choiceCardMeta, ChoiceCardTemplate } from './choice-card.tsx'; + + + +
    + {['bg-white', 'bg-dark'].map(bg => ( +
    + {bombArgs({ + type: choiceCardMeta.argTypes.type.options, + validation: choiceCardMeta.argTypes.validation.options, + checked: [false, true], + disabled: [false, true], + label: ['Card check text', 'Really long running choice card text that wraps to two lines'], + showDescription: [false, true], + description: ['A very long running description that is wrapping to two lines'], + showIcon: [false, true], + }) + // Filter out disabled and invalid combinations + .filter(args => !(args.disabled && args.validation === 'is-invalid')) + .map(args => ( +
    {ChoiceCardTemplate({ ...args, icon: 1000 })}
    + ))} +
    + ))} +
    diff --git a/packages/documentation/src/stories/components/choice-control-card/choice-card.tsx b/packages/documentation/src/stories/components/choice-control-card/choice-card.tsx new file mode 100644 index 0000000000..6af1294d8d --- /dev/null +++ b/packages/documentation/src/stories/components/choice-control-card/choice-card.tsx @@ -0,0 +1,177 @@ +import { BADGE } from '@geometricpanda/storybook-addon-badges'; +import { Args, Meta } from '@storybook/react'; + +import { useArgs } from '@storybook/client-api'; + +export const choiceCardMeta = { + parameters: { + badges: [BADGE.NEEDS_REVISION], + }, + args: { + label: 'Card check text', + type: 'radio', + checked: false, + disabled: false, + validation: 'null', + showDescription: false, + description: 'A small description', + icon: 1000, + showIcon: false, + }, + argTypes: { + label: { + name: 'Label', + type: 'string', + description: 'The main label of the input', + table: { + category: 'General', + }, + }, + type: { + name: 'Type', + control: { + type: 'radio', + labels: { + radio: 'Radio button', + checkbox: 'Checkbox', + }, + }, + options: ['radio', 'checkbox'], + table: { + category: 'General', + }, + }, + checked: { + name: 'Checked', + type: 'boolean', + description: 'When set to `true`, places the component in the checked state.', + table: { + category: 'States', + }, + }, + disabled: { + name: 'Disabled', + description: + 'When set to `true`, disables the component\'s functionality and places it in a disabled state.There are accessibility concerns with the disabled state.
    Please read our disabled state accessibility guide.
    ', + control: { + type: 'boolean', + }, + table: { + category: 'States', + }, + }, + validation: { + name: 'Validation', + description: "Controls the display of the component's validation state.", + control: { + type: 'radio', + labels: { + 'null': 'Default', + 'is-invalid': 'Invalid', + }, + }, + options: ['null', 'is-invalid'], + table: { + category: 'States', + }, + }, + showDescription: { + name: 'Show description', + type: 'boolean', + description: 'Toggles an additional description', + table: { + category: 'Description', + }, + }, + description: { + name: 'Description', + type: 'string', + description: 'A short additional description', + table: { + category: 'Description', + }, + }, + showIcon: { + name: 'Show icon', + type: 'boolean', + description: 'Show or hide icon', + table: { + category: 'Icon', + }, + }, + icon: { + name: 'Icon', + control: { + type: 'select', + }, + options: [1000, 1001, 2000], + table: { + category: 'Icon', + }, + }, + }, +} as Meta; + +export const ChoiceCardTemplate = (args: Args, onChange?: () => void, id = 'choice-card') => { + const inputClasses = ['form-check-input', args.validation].filter(c => c !== 'null').join(' '); + return ( +
    + {typeof onChange === 'function' ? ( + + ) : ( + + )} + + {args.showIcon && } +
    + ); +}; + +export const ChoiceCardReactiveTemplate = (args: Args) => { + const [_, updateArgs] = useArgs(); + return ChoiceCardTemplate(args, () => updateArgs({ checked: !args.checked })); +}; + +export const choiceCardGroup = (args: Args) => { + const loop = ['One', 'Two', 'Three', 'Four', 'Five', 'Six']; + return ( +
    + Legend +
    + {loop.map(n => ( +
    + {ChoiceCardTemplate({ ...args, label: n }, undefined, `choice-card-${n}`)} +
    + ))} +
    + + {args.validation === 'is-invalid' && ( +

    + Invalid choice +

    + )} +
    + ); +}; diff --git a/packages/documentation/src/stories/components/choice-control-card/radio-button-card.docs.mdx b/packages/documentation/src/stories/components/choice-control-card/radio-button-card.docs.mdx new file mode 100644 index 0000000000..45eab00c3c --- /dev/null +++ b/packages/documentation/src/stories/components/choice-control-card/radio-button-card.docs.mdx @@ -0,0 +1,36 @@ +import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'; +import LinkTo from '@storybook/addon-links/react'; + + + +# Radio button card + + + + +
    + +
    + +## Grouping radio buttons + +Radio button cards can be grouped by wrapping them in a `fieldset/legend` construct. + + + + + +## SCSS Imports + +To import all styles from the design-system-styles package: + +```css dark +@use '@swisspost/design-system-styles/index.scss'; +``` + +To import only the styles required for this component: + +```css dark +@use '@swisspost/design-system-styles/basics.scss'; +@use '@swisspost/design-system-styles/components/choice-control-button.scss'; +``` diff --git a/packages/documentation/src/stories/components/choice-control-card/radio-button-card.stories.tsx b/packages/documentation/src/stories/components/choice-control-card/radio-button-card.stories.tsx new file mode 100644 index 0000000000..5d32168074 --- /dev/null +++ b/packages/documentation/src/stories/components/choice-control-card/radio-button-card.stories.tsx @@ -0,0 +1,28 @@ +import { Story } from '@storybook/react'; +import { choiceCardGroup, choiceCardMeta, ChoiceCardReactiveTemplate } from './choice-card'; +import docsPage from './radio-button-card.docs.mdx'; + +export default Object.assign({}, choiceCardMeta, { + title: 'Components/Radio Button Card', + parameters: { ...choiceCardMeta.parameters, docs: { page: docsPage } }, +}); + +export const Default: Story = ChoiceCardReactiveTemplate.bind({}); +Default.args = { + type: 'radio', +}; +Default.parameters = { + controls: { + exclude: ['Type'], + }, +}; + +export const Group: Story = choiceCardGroup.bind({}); +Group.args = { + type: 'radio', +}; +Group.parameters = { + controls: { + exclude: ['Checked', 'Disabled', 'Type', 'Label'], + }, +}; diff --git a/packages/styles/src/components/_index.scss b/packages/styles/src/components/_index.scss index 623c73b462..cebd4c6353 100644 --- a/packages/styles/src/components/_index.scss +++ b/packages/styles/src/components/_index.scss @@ -9,6 +9,7 @@ @use 'button'; @use 'button-group'; @use 'card'; +@use 'choice-control-card'; @use 'carousel'; @use 'close'; @use 'elevation'; diff --git a/packages/styles/src/components/choice-control-card.scss b/packages/styles/src/components/choice-control-card.scss new file mode 100644 index 0000000000..3b1ad7e518 --- /dev/null +++ b/packages/styles/src/components/choice-control-card.scss @@ -0,0 +1,146 @@ +@use '../variables/color'; +@use '../variables/commons'; +@use '../variables/spacing'; +@use '../mixins/utilities'; + +.radio-button-card, +.checkbox-button-card { + --post-card-select--hover-bg: #{color.$gray-10}; + + position: relative; + display: flex; + gap: 0 spacing.$size-mini; + + width: 100%; + + color: color.$gray-80; + background-color: color.$white; + border: 2px solid color.$gray-60; + border-radius: commons.$border-radius; + padding: spacing.$size-regular; + transition: color 100ms ease-in-out, background-color 100ms ease-in-out, + border-color 100ms ease-in-out; + + // Checked + &:where(:has(input:checked), .checked) { + --post-card-select--hover-bg: #{color.$yellow}; + background-color: color.$yellow; + border-color: color.$gray-60; + + input { + background-color: color.$white !important; + } + } + + // Focus + &:where(:has(input:focus-visible), .focused) { + background-color: var(--post-card-select--hover-bg); + outline: 2px solid color.$black; + outline-offset: 2px; + border-color: color.$black; + + input { + border-color: color.$black; + } + } + + // Hover + &:where(:hover:not(:has(input:disabled)), :hover:not(.disabled)) { + border-color: color.$black; + color: color.$black; + background-color: var(--post-card-select--hover-bg); + + input { + border-color: color.$black; + } + + @include utilities.high-contrast-mode() { + border-color: Highlight; + transition: none; + } + } + + // Disabled + &:has(input:disabled), + &.disabled { + border-color: color.$gray-20; + color: color.$gray-40 !important; + + > * { + cursor: default; + } + } + + &:has(input:disabled:checked), + &.disabled.checked { + background-color: color.$gray-10; + } + + // Error + &:has(input[aria-invalid]), + &:has(input.is-invalid), + &.is-invalid { + color: color.$error; + border-color: color.$error; + + ~ .invalid-feedback { + display: block; + } + } + + &:last-child { + margin-bottom: 0; + } + + > * { + cursor: pointer; + } + + post-icon { + width: 2em; + height: 2em; + margin-left: spacing.$size-mini; + pointer-events: none; + } + + input { + border-color: color.$gray-80; + background-color: color.$white; + transition: border-color 100ms ease-in-out; + grid-column: 1 / 2; + + &:focus { + box-shadow: none !important; + } + } + + .form-check-label { + padding-left: 0; + + &::before { + // This spans up the click area of the label to the whole + // card in order to make it clickable natively. + content: ''; + position: absolute; + inset: -2px; + } + + span { + // Lift spans above the before element to make them selectable + position: relative; + } + } + + input, + .form-check-label { + margin-block: 0.25rem; + } + + // Align input and label if there is an icon + &:has(post-icon) { + input, + .form-check-label { + margin-top: 0.25rem; + } + } +} diff --git a/packages/styles/src/variables/_type.scss b/packages/styles/src/variables/_type.scss index 69842b1254..c7dd2c2015 100644 --- a/packages/styles/src/variables/_type.scss +++ b/packages/styles/src/variables/_type.scss @@ -77,6 +77,7 @@ $font-sizes: ( ); $font-size-map: ( + 12: $font-size-12, 14: $font-size-14, 16: $font-size-16, 18: $font-size-18, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f887fa648..c43d824215 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -687,6 +687,9 @@ importers: lit: specifier: 2.8.0 version: 2.8.0 + lit-html: + specifier: 2.8.0 + version: 2.8.0 prettier: specifier: 2.8.8 version: 2.8.8 From ee91d416e8a611ef19bf96d45878f9bba8738ccb Mon Sep 17 00:00:00 2001 From: David Ritter <141235163+davidritter-dotcom@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:58:21 +0200 Subject: [PATCH 13/16] feat(documentation-v7): migrate snapshot test for collapsible (#1823) --- .../components/collapsible.snapshot.ts | 7 ++++ .../collapsible.snapshot.stories.tsx | 41 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 packages/documentation-v7/cypress/snapshots/components/collapsible.snapshot.ts create mode 100644 packages/documentation-v7/src/stories/components/collapsible/collapsible.snapshot.stories.tsx diff --git a/packages/documentation-v7/cypress/snapshots/components/collapsible.snapshot.ts b/packages/documentation-v7/cypress/snapshots/components/collapsible.snapshot.ts new file mode 100644 index 0000000000..d72ea712f2 --- /dev/null +++ b/packages/documentation-v7/cypress/snapshots/components/collapsible.snapshot.ts @@ -0,0 +1,7 @@ +describe('Collapsible', () => { + it('default', () => { + cy.visit('/iframe.html?id=snapshots--collapsible'); + cy.get('post-collapsible.hydrated').should('be.visible'); + cy.percySnapshot('Collapsible'); + }); +}); diff --git a/packages/documentation-v7/src/stories/components/collapsible/collapsible.snapshot.stories.tsx b/packages/documentation-v7/src/stories/components/collapsible/collapsible.snapshot.stories.tsx new file mode 100644 index 0000000000..0a912aec93 --- /dev/null +++ b/packages/documentation-v7/src/stories/components/collapsible/collapsible.snapshot.stories.tsx @@ -0,0 +1,41 @@ +import { html } from 'lit'; +import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; +import { bombArgs } from '../../../utils/bombArgs'; + +import meta, { Default } from './collapsible.stories'; + +export default { + ...meta, + title: 'Snapshots', +}; + +type Story = StoryObj; + +export const collapsible: Story = { + render: (_args: Args, context: StoryContext) => { + const templateVariants = bombArgs({ + innerHTML: [ + `Titulum

    Contentus momentus vero siteos et accusam iretea et justo.

    `, + `

    Contentus momentus vero siteos et accusam iretea et justo.

    `, + ], + collapsed: [false, true], + headingLevel: [1, 2, 3, 4, 5, 6], + }).map((args: Args) => { + return html` +
    + ${meta.render?.({ ...context.args, ...Default.args, ...args }, context)} +
    + `; + }); + + return html` +
    + ${['white', 'dark'].map( + bg => html` +
    ${templateVariants}
    + `, + )} +
    + `; + }, +}; From e2f335797be3be8bbf78970c5d9ea101c84ce5ff Mon Sep 17 00:00:00 2001 From: Lukas Blaser <141234680+b1aserlu@users.noreply.github.com> Date: Thu, 17 Aug 2023 16:02:22 +0200 Subject: [PATCH 14/16] feat(documentation-v7): add select snapshot test (#1817) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Oliver Schürch --- .../snapshots/components/select.snapshot.ts | 6 + .../select/select.snapshot.stories.ts | 116 ++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 packages/documentation-v7/cypress/snapshots/components/select.snapshot.ts create mode 100644 packages/documentation-v7/src/stories/components/select/select.snapshot.stories.ts diff --git a/packages/documentation-v7/cypress/snapshots/components/select.snapshot.ts b/packages/documentation-v7/cypress/snapshots/components/select.snapshot.ts new file mode 100644 index 0000000000..51939323b1 --- /dev/null +++ b/packages/documentation-v7/cypress/snapshots/components/select.snapshot.ts @@ -0,0 +1,6 @@ +describe('Select', () => { + it('default', () => { + cy.visit('./iframe.html?id=snapshots--select'); + cy.percySnapshot('Selects', { widths: [400] }); + }); +}); diff --git a/packages/documentation-v7/src/stories/components/select/select.snapshot.stories.ts b/packages/documentation-v7/src/stories/components/select/select.snapshot.stories.ts new file mode 100644 index 0000000000..ba4d60022e --- /dev/null +++ b/packages/documentation-v7/src/stories/components/select/select.snapshot.stories.ts @@ -0,0 +1,116 @@ +import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; +import meta, { Default, FloatingLabel } from './select.stories'; +import { html } from 'lit'; +import { bombArgs } from '../../../utils/bombArgs'; + +export default { + ...meta, + title: 'Snapshots', +}; + +type Story = StoryObj; + +export const Select: Story = { + render: (_args: Args, context: StoryContext) => { + //Arguments for Default Version + const bombArgsGeneratedDefault = [ + ...bombArgs({ + label: [ + context.args.label, + 'Label - Lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor', + ], + hint: [''], + }), + ...bombArgs({ + hiddenLabel: [true], + hint: ['Hintus textus', context.args.hint], + }), + ...bombArgs({ + size: context.argTypes.size.options, + disabled: [false, true], + validation: context.argTypes.validation.options, + }), + ] + // remove disabled & validated examples + .filter((args: Args) => !(args.disabled && args.validation !== 'null')); + + //Arguments for Multiple Version + const bombArgsGeneratedMultiple = [ + ...bombArgs({ + multiple: [true], + label: [ + context.args.label, + 'Label - Lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor', + ], + hint: [''], + }), + ...bombArgs({ + multiple: [true], + hiddenLabel: [true], + hint: ['', 'Hintus textus', context.args.hint], + }), + ...bombArgs({ + multiple: [true], + size: context.argTypes.size.options, + disabled: [false, true], + validation: context.argTypes.validation.options, + }), + ] + // remove disabled & validated examples + .filter((args: Args) => !(args.disabled && args.validation !== 'null')); + + return html` +
    + ${['bg-white', 'bg-dark'].map( + bg => + html` +
    +

    Default

    + ${bombArgsGeneratedDefault.map( + (args: Args) => + html` +
    + ${Default.render?.({ ...context.args, ...Default.args, ...args }, context)} +
    + `, + )} +

    Floating Label

    + ${bombArgsGeneratedDefault.map( + (args: Args) => + html` +
    + ${FloatingLabel.render?.( + { ...context.args, ...FloatingLabel.args, ...args }, + context, + )} +
    + `, + )} +

    Multiple - Default

    + ${bombArgsGeneratedMultiple.map( + (args: Args) => + html` +
    + ${Default.render?.({ ...context.args, ...Default.args, ...args }, context)} +
    + `, + )} +

    Multiple - Floating Label

    + ${bombArgsGeneratedMultiple.map( + (args: Args) => + html` +
    + ${FloatingLabel.render?.( + { ...context.args, ...FloatingLabel.args, ...args }, + context, + )} +
    + `, + )} +
    + `, + )} +
    + `; + }, +}; From 442218663dea5523e32435757c4f8bbb6da89880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9=20Debray?= <33580481+alizedebray@users.noreply.github.com> Date: Thu, 17 Aug 2023 16:25:50 +0200 Subject: [PATCH 15/16] chore(documentation-v7): migrate the internet header component stories (#1822) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Philipp Gfeller <1659006+gfellerph@users.noreply.github.com> Co-authored-by: Loïc Fürhoff <12294151+imagoiq@users.noreply.github.com> --- .../helpers/register-web-components.ts | 30 ++- .../documentation-v7/.storybook/preview.ts | 14 +- .../components/internet-header.docs.mdx | 54 ++++ .../components/internet-header.stories.tsx | 241 ++++++++++++++++++ .../components/internet-header.styles.scss | 32 +++ .../internet-header/getting-started.docs.mdx | 113 ++++++++ .../internet-header/migration-guide.docs.mdx | 195 ++++++++++++++ .../post-klp-login-widget.tsx | 2 +- packages/internet-header/stencil.config.ts | 7 + pnpm-lock.yaml | 2 +- 10 files changed, 665 insertions(+), 25 deletions(-) create mode 100644 packages/documentation-v7/src/stories/internet-header/components/internet-header.docs.mdx create mode 100644 packages/documentation-v7/src/stories/internet-header/components/internet-header.stories.tsx create mode 100644 packages/documentation-v7/src/stories/internet-header/components/internet-header.styles.scss create mode 100644 packages/documentation-v7/src/stories/internet-header/getting-started.docs.mdx create mode 100644 packages/documentation-v7/src/stories/internet-header/migration-guide.docs.mdx diff --git a/packages/documentation-v7/.storybook/helpers/register-web-components.ts b/packages/documentation-v7/.storybook/helpers/register-web-components.ts index a09a50def5..c5963a748c 100644 --- a/packages/documentation-v7/.storybook/helpers/register-web-components.ts +++ b/packages/documentation-v7/.storybook/helpers/register-web-components.ts @@ -1,14 +1,22 @@ -import { defineCustomElements, JSX as LocalJSX } from '@swisspost/design-system-components/loader'; -import { HTMLAttributes } from 'react'; +import { defineCustomElements as defineInternetHeader } from '@swisspost/internet-header/loader'; +import { defineCustomElements as definePostComponent } from '@swisspost/design-system-components/loader'; +import { setStencilDocJson } from '@pxtrn/storybook-addon-docs-stencil'; +import { StencilJsonDocs, StencilJsonDocsComponent } from '@pxtrn/storybook-addon-docs-stencil/dist/types'; +import postComponentsDocJson from '@swisspost/design-system-components/dist/docs.json'; +import internetHeaderDocJson from '@swisspost/internet-header/dist/docs.json'; -type StencilToReact = { - [P in keyof T]?: T[P] & Omit, 'className'> & { class?: string }; -}; +defineInternetHeader(window); +definePostComponent(window); -declare global { - export namespace JSX { - interface IntrinsicElements extends StencilToReact {} - } -} +if (postComponentsDocJson && internetHeaderDocJson) { + const jsonDocs: StencilJsonDocs = { + timestamp: postComponentsDocJson.timestamp, + compiler: postComponentsDocJson.compiler, + components: [ + ...postComponentsDocJson.components, + ...internetHeaderDocJson.components + ] as StencilJsonDocsComponent[], + }; -defineCustomElements(window); + setStencilDocJson(jsonDocs); +} diff --git a/packages/documentation-v7/.storybook/preview.ts b/packages/documentation-v7/.storybook/preview.ts index 9eb4868e07..8d05d53869 100644 --- a/packages/documentation-v7/.storybook/preview.ts +++ b/packages/documentation-v7/.storybook/preview.ts @@ -1,11 +1,6 @@ import type { Preview } from '@storybook/web-components'; -import { - extractArgTypes, - extractComponentDescription, - setStencilDocJson, -} from '@pxtrn/storybook-addon-docs-stencil'; -import { StencilJsonDocs } from '@pxtrn/storybook-addon-docs-stencil/dist/types'; +import { extractArgTypes, extractComponentDescription } from '@pxtrn/storybook-addon-docs-stencil'; import { format } from 'prettier'; import DocsLayout from './blocks/layout'; import { badgesConfig, prettierOptions, resetComponents } from './helpers'; @@ -18,10 +13,6 @@ import scss from 'react-syntax-highlighter/dist/esm/languages/prism/scss'; SyntaxHighlighter.registerLanguage('scss', scss); -import docJson from '@swisspost/design-system-components/dist/docs.json'; - -if (docJson) setStencilDocJson(docJson as StencilJsonDocs); - const preview: Preview = { parameters: { options: { @@ -34,7 +25,7 @@ const preview: Preview = { ['Typography', 'Color', 'Layout', 'Elevation', 'Accessibility'], 'Components', 'Internet Header', - ['Getting started', 'Migration Guide', 'Components', ['Header', 'Breadcrumbs', 'Footer']], + ['Getting started', 'Migration Guide', 'Header Component', 'Breadcrumbs Component', 'Footer Component'], 'Intranet Header', ['Getting started'], 'Icons', @@ -55,7 +46,6 @@ const preview: Preview = { }, components: resetComponents, extractArgTypes, - extractComponentDescription, }, actions: { argTypesRegex: '^on[A-Z].*' }, controls: { diff --git a/packages/documentation-v7/src/stories/internet-header/components/internet-header.docs.mdx b/packages/documentation-v7/src/stories/internet-header/components/internet-header.docs.mdx new file mode 100644 index 0000000000..4be69ee0f9 --- /dev/null +++ b/packages/documentation-v7/src/stories/internet-header/components/internet-header.docs.mdx @@ -0,0 +1,54 @@ +import { Canvas, ArgTypes, Meta } from '@storybook/blocks'; +import * as InternetHeaderStories from './internet-header.stories'; + + + +# Header + +
    + Customizable navigation header tailored for Swiss Post customer-facing applications, + ensuring complete accessibility and responsiveness. +
    + +The `` element needs +to be nested directly inside the `` for the sticky scrolling to work. + +If you want to render the header element with Angular, +have a look at [portals](https://medium.com/angular-in-depth/how-do-cdk-portals-work-7c097c14a494). + + + Open Header in New Tab + + + + +
    + +
    + +## Examples + +### Custom Navigation Item + + + +### Custom Online Service Flyout + + + +### Full Width + +By default, on viewports with a width greater than 1440px, header content is padded right and left. +To make the header span the full width of the viewport, set the `full-width` property to `true`. + + + See Fullwidth Header + diff --git a/packages/documentation-v7/src/stories/internet-header/components/internet-header.stories.tsx b/packages/documentation-v7/src/stories/internet-header/components/internet-header.stories.tsx new file mode 100644 index 0000000000..d2b80ec41b --- /dev/null +++ b/packages/documentation-v7/src/stories/internet-header/components/internet-header.stories.tsx @@ -0,0 +1,241 @@ +import { Args, Meta, StoryObj } from '@storybook/web-components'; +import { html } from 'lit'; +import { spread } from '@open-wc/lit-helpers'; +import { BADGE } from '../../../../.storybook/constants'; +import './internet-header.styles.scss'; + +const meta: Meta = { + title: 'Internet Header/Header Component', + component: 'swisspost-internet-header', + render: renderInternetHeader, + parameters: { + layout: 'fullscreen', + actions: { + handles: ['headerLoaded', 'languageChanged'], + }, + badges: [BADGE.STABLE], + controls: { + exclude: ['config-proxy'] + }, + }, + args: { + 'project': 'test' + }, + argTypes: { + activeRoute: { + name: 'active-route', + control: 'text', + }, + customConfig: { + name: 'custom-config', + control: 'object', + }, + language: { + control: 'select', + options: ['de', 'fr', 'it', 'en'], + }, + languageCookieKey: { + name: 'language-cookie-key', + control: 'text', + }, + languageLocalStorageKey: { + name: 'language-local-storage-key', + control: 'text', + }, + languageSwitchOverrides: { + name: 'language-switch-overrides', + control: 'object', + }, + osFlyoutOverrides: { + name: 'os-flyout-overrides', + control: 'object', + }, + stickyness: { + control: 'select', + }, + }, +}; + +export default meta; + +// DECORATORS +function mockPage(story: any) { + return html` +
    + ${story()} +
    + +

    Swiss Post Internet Header

    +

    +

    +
    + +
    + `; +} + +// RENDERER +function renderInternetHeader(args: HTMLSwisspostInternetHeaderElement) { + const attributes = getAttributes(args, arg => arg !== null && arg !== undefined); + return html` + + `; +} + +// STORIES +type Story = StoryObj; + +export const Default: Story = { + decorators: [ mockPage ], + parameters: { + docs: { + story: { + inline: false, + height: '40em', + }, + }, + }, +}; + +export const FullWidth: Story = { + decorators: [ mockPage ], + args: { + fullWidth: true, + }, +}; + +export const CustomNavigation: Story = { + args: { + customConfig: { + de: { + header: { + navMain: [ + { + title: 'Meine Links (custom config)', + text: 'Meine Links', + url: '#', + flyout: [ + { + title: 'Google', + linkList: [ + { url: 'https://maps.google.com', title: 'Google Maps', target: '_blank' }, + { url: 'https://translate.google.com', title: 'Google Translate' }, + ], + }, + ], + }, + ], + }, + }, + fr: { + header: { + navMain: [ + { + title: 'Meine Links (custom config)', + text: 'Meine Links', + url: '#', + flyout: [ + { + title: 'Google', + linkList: [ + { url: 'https://maps.google.com', title: 'Google Maps', target: '_blank' }, + { url: 'https://translate.google.com', title: 'Google Translate' }, + ], + }, + ], + }, + ], + }, + }, + it: { + header: { + navMain: [ + { + title: 'Meine Links (custom config)', + text: 'Meine Links', + url: '#', + flyout: [ + { + title: 'Google', + linkList: [ + { url: 'https://maps.google.com', title: 'Google Maps', target: '_blank' }, + { url: 'https://translate.google.com', title: 'Google Translate' }, + ], + }, + ], + }, + ], + }, + }, + en: { + header: { + navMain: [ + { + title: 'Meine Links (custom config)', + text: 'Meine Links', + url: '#', + flyout: [ + { + title: 'Google', + linkList: [ + { url: 'https://maps.google.com', title: 'Google Maps', target: '_blank' }, + { url: 'https://translate.google.com', title: 'Google Translate' }, + ], + }, + ], + }, + ], + }, + }, + }, + }, +}; + +export const CustomOnlineServiceFlyout: Story = { + args: { + osFlyoutOverrides: { + title: 'Custom OS Flyout', + text: 'Custom OS Flyout', + url: '#', + flyout: [ + { + title: 'A title', + linkList: [ + { + url: '#bla', + title: 'Another link', + }, + ], + }, + { + title: 'Another column', + linkList: [ + { + url: '#foo', + title: 'Foo', + }, + ], + }, + ], + }, + }, +}; + +// TODO: move to utils +const getAttributes = (args: Args, condition?: (arg: any) => boolean): Args => { + const attrs: { [key: string]: any } = {}; + + for (const key in args) { + if (args.hasOwnProperty(key) && condition && condition(args[key])) { + const attrKey = key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); + + // Cast boolean false to string so it's displayed in the docs code block. False values are otherwise omitted + attrs[attrKey] = args[key] === false ? 'false' : args[key]; + if (typeof args[key] === 'object') { + attrs[attrKey] = JSON.stringify(args[key]); + } + } + } + + return attrs; +}; diff --git a/packages/documentation-v7/src/stories/internet-header/components/internet-header.styles.scss b/packages/documentation-v7/src/stories/internet-header/components/internet-header.styles.scss new file mode 100644 index 0000000000..9b64d999be --- /dev/null +++ b/packages/documentation-v7/src/stories/internet-header/components/internet-header.styles.scss @@ -0,0 +1,32 @@ +.docs-story { + > div:first-child { + overflow: hidden; + } + + > div:nth-child(2) { + z-index: 1000; + } +} + +// Used for internet header stories +.fake-content { + position: relative; + min-height: calc(1.6rem * 8); + background: repeating-linear-gradient( + rgb(230, 230, 230), + rgb(230, 230, 230) 1rem, + transparent 1rem, + transparent 1.6rem + ); + + &::after { + content: ''; + background: white; + width: 33%; + height: 1.7rem; + display: block; + position: absolute; + bottom: 0; + right: 0; + } +} diff --git a/packages/documentation-v7/src/stories/internet-header/getting-started.docs.mdx b/packages/documentation-v7/src/stories/internet-header/getting-started.docs.mdx new file mode 100644 index 0000000000..5da7c225be --- /dev/null +++ b/packages/documentation-v7/src/stories/internet-header/getting-started.docs.mdx @@ -0,0 +1,113 @@ +import { Meta } from '@storybook/blocks'; +import { BADGE } from '../../../.storybook/constants'; + + + +# @swisspost/internet-header + +[![npm version](https://badge.fury.io/js/@swisspost%2Finternet-header.svg)](https://badge.fury.io/js/@swisspost%2Finternet-header) + +The header for client-facing applications. + +- [Installation](#installation) +- [Configuration](#configuration) +- [Help](#help) + +## Installation + +### Angular, Vue JS, React (or any other bundler setup) + +All the popular frameworks come with some form of bundler. +This makes it easy to use npm packages like the Internet Header as you can import, +bundle and deliver the header with your own code. + +When working with Angular or any other framework, the easiest installation method is via npm. + +```shell +npm install @swisspost/internet-header +``` + +```typescript +// main.ts / index.js / ... +import { defineCustomElements } from '@swisspost/internet-header'; + +defineCustomElements(); +``` + +```html + + + + ... + +``` + +### Include from a CDN + +If you are not using any loader or don't want to install from npm, +you can load the `internet-header` from your favourite +[CDN](https://en.wikipedia.org/wiki/Content_delivery_network).
    +There are two options available. +Make sure to replace `{version}` with the version you want to use. + +- [jsDelivr](https://www.jsdelivr.com/) +- [unpkg](https://unpkg.com/) + +#### jsDelivr + +```html + + + + + + + +``` + +```javascript +// main.js | main.ts +import { defineCustomElements } from 'https://cdn.jsdelivr.net/npm/@swisspost/internet-header@{version}/loader/index.min.js'; + +defineCustomElements(); +``` + +#### unpkg + +```javascript +// main.js | main.ts +import { defineCustomElements } from 'https://unpkg.com/@swisspost/internet-header@{version}/loader/index.min.js'; + +defineCustomElements(); +``` + +## Configuration + +The Internet Header is built to support the already existing Portal Configuration used for the old Internet Header. + +If you're working on a new project, you probably need a new configuration. Please click the button below. + +Contact Post Portal Team + +Not every Online Service has configurations for all environments. +For example, "TOPOS" only has `int02` configured and cannot use `int01` as value for environment. +If you are not sure what's configured for your project, please reach out to the post-portal team as well. + +For settings on the header itself, see the examples provided in the left menu bar. + +## Help + +If you noticed a bug or need assistance with migrating to the new Internet Header, +please post your enquiry at the [Design System GitHub Discussions](https://github.com/swisspost/design-system/discussions/categories/q-a). diff --git a/packages/documentation-v7/src/stories/internet-header/migration-guide.docs.mdx b/packages/documentation-v7/src/stories/internet-header/migration-guide.docs.mdx new file mode 100644 index 0000000000..59819e4702 --- /dev/null +++ b/packages/documentation-v7/src/stories/internet-header/migration-guide.docs.mdx @@ -0,0 +1,195 @@ +import { Meta } from '@storybook/blocks'; +import { BADGE } from '../../../.storybook/constants'; + + + +# Migration from the old header + +This guide aims to give a broad overview of how a migration can be performed. +Different projects have different levels of integration with the header, +and therefore require more steps to migrate. + +## Architecture + +The "new" +Internet Header Web Component aims +to encapsulate as much as possible whereas the old header had a big influence on the page — +limiting design decisions and flexibility of the markup structure. +The Web Component Header consists of one script and three standard Web Components that can be freely placed on the page. +It's even possible to render those elements with Angular +(or any other framework) to easier pass settings into the component. + +The new header is built +to work with the existing Sitecore configuration +already existing for your project to make the migration as smooth as possible. + +## Support + +If you need support during your migration, +don't hesitate +to contact the [Design System Team](https://github.com/swisspost/design-system/discussions/categories/general) on GitHub. + +## 1. Remove the old header + +In your index.html, you should find three scripts associated with the old header. +One to load static assets, one to configure it and one to load it. + +- You can remove the configuration and the loader scripts, but remember your `serviceid`. +- Try to remove the `staticassets` script to check if you still need it + +```html + + + + + + + + + + + + +
    + +
    + + + + + + + + +``` + +## 2. Fix your app styles + +The old header was responsible for wrapping your main code (here `#os_content`) with custom `
    `s. +The new header does not provide those wrappers. +Instead, every page has control over the main markup structure. +A possible replacement of the above code could be: + +```html + + + + + + + + + +
    + +
    + + +``` + +- Likely you'll need the class `container` around your main content to align it properly in the center. +- For bonus points on semantic markup, use the [`
    ` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main) around the main page content +- Check if you need the `staticasset` stylesheets linked in the header + +If you need to do any other changes, +please make a post to the [Design System Teams Channel](https://teams.microsoft.com/l/channel/19%3ae7fa68fb13eb40b4bf4604edea5f4b3e%40thread.tacv2/%25F0%259F%259A%2591%2520Support?groupId=123c7c9e-052a-40e6-98d3-6cc6d46bad0a&tenantId=3ae7c479-0cf1-47f4-8f84-929f364eff67) +in order to inform the devs to update this guide and provide useful information for other developers. + +## 3. jQuery + +The new Header does not ship jQuery anymore. +While jQuery v3.6 is an internal dependency for the Login Widget, +every project is now responsible for loading and updating jQuery individually. +If you are depending on an older (<3.5) version of jQuery, please update. +There is a long list of [known jQuery vulnerabilities](https://security.snyk.io/package/npm/jquery). + +## 4. Install the new header + +Please refer to the [Internet Header installation instructions](/story/getting-started--page) for an installation guide. + +After installation, you're ready to add the new tags to your markup: + +```html + + + + + + + + + + + + + + +
    + +
    + + + + +``` + +Place the new elements as described (and needed) as shown above. +The breadcrumbs need a `container` wrapper to align themselves with the content of your page, +the header and the footer already provide a container. +If you don't have breadcrumbs, you can just delete the `
    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.tsx b/packages/documentation-v6/src/stories/components/radio/radio.stories.tsx similarity index 100% rename from packages/documentation/src/stories/components/radio/radio.stories.tsx rename to packages/documentation-v6/src/stories/components/radio/radio.stories.tsx diff --git a/packages/documentation-v7/src/stories/components/range/range.docs.mdx b/packages/documentation-v6/src/stories/components/range/range.docs.mdx similarity index 71% rename from packages/documentation-v7/src/stories/components/range/range.docs.mdx rename to packages/documentation-v6/src/stories/components/range/range.docs.mdx index 29ed32c1dd..ef571fd9d0 100644 --- a/packages/documentation-v7/src/stories/components/range/range.docs.mdx +++ b/packages/documentation-v6/src/stories/components/range/range.docs.mdx @@ -1,34 +1,34 @@ -import { Canvas, Controls, Meta } from '@storybook/blocks'; +import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'; -import * as RangeStories from './range.stories'; - - + # Range -
    +

    Use our custom <input type="range" /> for consistent cross-browser styling and built-in customization. -

    +

    Create custom `range` controls with `.form-range`. The track (the background) and thumb (the value) are both styled to appear the same across browsers. - + + +
    - +
    ## SCSS Imports To import all styles from the design-system-styles package: -```scss +```css dark @use '@swisspost/design-system-styles/index.scss'; ``` To import only the styles required for this component: -```scss +```css dark @use '@swisspost/design-system-styles/basics.scss'; @use '@swisspost/design-system-styles/components/form-range.scss'; @@ -45,11 +45,15 @@ The following examples show the different characteristics of the component. Thes Range inputs have implicit values for `min` and `max` (0 and 100 respectively), and snap to integer values by default. You may specify new values for those using the `min`, `max` and `step` attributes. - + + + ### Validation Simply add the classes `.is-valid` or `.is-invalid` to the `range` element to show it in the expected state.
    -When the component has been validated, don't forget to add a `

    ...

    ` or `

    ...

    ` element after the `range` element to explain what went wrong. This enables the user to correct the mistake. +When the component has been validated, don't forget to add a `

    ...

    ` or `

    ...

    ` element after the `range` element to explain what went wrong. This enables the user to correct the mistake. - + + + diff --git a/packages/documentation/src/stories/components/range/range.stories.tsx b/packages/documentation-v6/src/stories/components/range/range.stories.tsx similarity index 100% rename from packages/documentation/src/stories/components/range/range.stories.tsx rename to packages/documentation-v6/src/stories/components/range/range.stories.tsx diff --git a/packages/documentation-v7/src/stories/components/select/select.docs.mdx b/packages/documentation-v6/src/stories/components/select/select.docs.mdx similarity index 83% rename from packages/documentation-v7/src/stories/components/select/select.docs.mdx rename to packages/documentation-v6/src/stories/components/select/select.docs.mdx index ee4602e1e2..d7ff11ae85 100644 --- a/packages/documentation-v7/src/stories/components/select/select.docs.mdx +++ b/packages/documentation-v6/src/stories/components/select/select.docs.mdx @@ -1,33 +1,34 @@ -import { Meta, Canvas, Controls } from '@storybook/blocks'; -import * as SelectStories from './select.stories'; +import { Meta, Canvas, Story, Source, ArgsTable } from '@storybook/addon-docs'; - + # Select -
    +

    Customize the native <select> with CSS that changes the element’s initial appearance. -

    +

    Custom ``’s initial appearance and cannot modify the `
    - + + + ### Validation Simply add the classes `is-valid` or `is-invalid` to the `