Skip to content

Commit

Permalink
Merge branch 'feature/update-tokens' of github.com:gsoft-inc/wl-hoppe…
Browse files Browse the repository at this point in the history
…r into feature/update-tokens
  • Loading branch information
fraincs committed May 14, 2024
2 parents 2e4381f + 0762d59 commit 00b59af
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const config = {
const a11yParameters = getA11yAddonParameters(storyContext.parameters);

// Do not run a11y tests on disabled stories.
if (a11yParameters?.disabled) {
if (a11yParameters?.disable) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const meta = {
},
parameters: {
...hopperParameters({ disabled: true }),
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
}
} satisfies Meta<typeof HopperProvider>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Default: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
args: {
color: "primary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Inherit: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
render: props => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const InheritColor: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
render: args => (
<Inline>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Inherit: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
render: props => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const Default: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
render: props => (
<SlotProvider values={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Default: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
render: props => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const Reverse: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
render: args => (
<Inline>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const Reverse: Story = {

export const Styling: Story = {
parameters: {
...a11yParameters({ disabled: true })
...a11yParameters({ disableContrastCheck: true })
},
render: args => (
<Inline>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const meta = {
viewports: viewports
},
controls: { hideNoControlsWarning: true },
...a11yParameters({ disabled: true })
...a11yParameters({ disable: true })
},
args: {
color: "core_samoyed",
Expand Down
2 changes: 1 addition & 1 deletion packages/tokens/src/stories/tokens.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const meta = {
component: List,
parameters: {
...hopperParameters({ disabled: true }), // the story handle their own color scheme
...a11yParameters({ disabled: true }) // Disable a11y rules as this only displays colors
...a11yParameters({ disable: true }) // Disable a11y rules as this only displays colors
}
} satisfies Meta<typeof List>;

Expand Down
24 changes: 21 additions & 3 deletions tooling/storybook-addon/a11y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,35 @@ export type Rules = NonNullable<Parameters<typeof configureAxe>[1]>["rules"];

export interface A11yAddonParameters {
a11y: {
disabled?: boolean;
disable?: boolean;
config?: {
rules?: Rules;
};
disableContrastCheck?: boolean;
};
}

export function a11yParameters(params: A11yAddonParameters["a11y"]): A11yAddonParameters {
return {
a11y: params
const { disableContrastCheck, ...rest } = params;

const a11yOptions = {
a11y: rest
};

if (disableContrastCheck) {
a11yOptions.a11y.config = {
...a11yOptions.a11y.config,
rules: [
...a11yOptions.a11y.config?.rules ?? [],
{
id: "color-contrast",
enabled: false
}
]
};
}

return a11yOptions;
}

export function getA11yAddonParameters(parameters: SBParameters): A11yAddonParameters["a11y"] | undefined {
Expand Down

0 comments on commit 00b59af

Please sign in to comment.