Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed contrast problems for disabled elements #1921

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions lib/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ const config: StorybookConfig = {
name: "@storybook/react-vite",
options: {},
},
features: { buildStoriesJson: true },
};
export default config;
12 changes: 10 additions & 2 deletions lib/src/chip/Chip.accessibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import React from "react";
import { render } from "@testing-library/react";
import { axe } from "../../test/accessibility/axe-helper.js";
import DxcChip from "./Chip.tsx";
import { disabledRules as rules } from "../../test/accessibility/rules/specific/chip/disabledRules.js";

const disabledRules = {
rules: rules.reduce((rulesObj, rule) => {
rulesObj[rule] = { enabled: false };
return rulesObj;
}, {}),
};

const iconSVG = (
<svg
Expand Down Expand Up @@ -29,14 +37,14 @@ c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.11
describe("Chip component accessibility tests", () => {
it("Should not have basic accessibility issues", async () => {
const { container } = render(<DxcChip margin="small" prefixIcon={iconSVG} suffixIcon={iconSVG} label="Chip" />);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for disabled mode", async () => {
const { container } = render(
<DxcChip margin="small" prefixIcon={iconSVG} suffixIcon={iconSVG} label="Chip" disabled />
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
});
12 changes: 12 additions & 0 deletions lib/src/chip/Chip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ import DxcChip from "./Chip";
import Title from "../../.storybook/components/Title";
import ExampleContainer from "../../.storybook/components/ExampleContainer";
import { HalstackProvider } from "../HalstackContext";
import preview from "../../.storybook/preview";
import { disabledRules } from "../../test/accessibility/rules/specific/chip/disabledRules";

export default {
title: "Chip",
component: DxcChip,
parameters: {
a11y: {
config: {
rules: [
...disabledRules.map((ruleId) => ({ id: ruleId, reviewOnFail: true })),
...preview?.parameters?.a11y?.config?.rules,
],
},
},
},
};

const iconSVG = (
Expand Down
6 changes: 3 additions & 3 deletions lib/src/common/variables.ts
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have yet to validate some of these changes with the Design team.

Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const componentTokens = {
pickerHoverFontColor: CoreTokens.color_black,
pickerActiveBackgroundColor: CoreTokens.color_purple_800,
pickerActiveFontColor: CoreTokens.color_white,
pickerNonCurrentMonthFontColor: CoreTokens.color_grey_500,
pickerNonCurrentMonthFontColor: CoreTokens.color_grey_700,
pickerCurrentDateBorderColor: CoreTokens.color_purple_300,
pickerCurrentDateFontColor: CoreTokens.color_black,
pickerCurrentYearFontColor: CoreTokens.color_purple_700,
Expand Down Expand Up @@ -905,8 +905,8 @@ export const componentTokens = {
selectedUnderlineColor: CoreTokens.color_purple_700,
selectedUnderlineThickness: "2px",
unselectedBackgroundColor: CoreTokens.color_white,
unselectedFontColor: CoreTokens.color_grey_700,
unselectedIconColor: CoreTokens.color_grey_700,
unselectedFontColor: CoreTokens.color_grey_800,
unselectedIconColor: CoreTokens.color_grey_800,
disabledFontColor: CoreTokens.color_grey_500,
disabledIconColor: CoreTokens.color_grey_500,
disabledFontStyle: CoreTokens.type_normal,
Expand Down
16 changes: 12 additions & 4 deletions lib/src/file-input/FileInput.accessibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import React from "react";
import { render } from "@testing-library/react";
import { axe } from "../../test/accessibility/axe-helper.js";
import DxcFileInput from "./FileInput.tsx";
import { disabledRules as rules } from "../../test/accessibility/rules/specific/file-input/disabledRules.js";

const disabledRules = {
rules: rules.reduce((rulesObj, rule) => {
rulesObj[rule] = { enabled: false };
return rulesObj;
}, {}),
};

const picPreview = "https://cdn.mos.cms.futurecdn.net/CAZ6JXi6huSuN4QGE627NR.jpg";

Expand Down Expand Up @@ -61,7 +69,7 @@ describe("FileInput component accessibility tests", () => {
showPreview
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for disabled mode", async () => {
Expand All @@ -80,7 +88,7 @@ describe("FileInput component accessibility tests", () => {
disabled
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for file mode", async () => {
Expand All @@ -99,7 +107,7 @@ describe("FileInput component accessibility tests", () => {
showPreview
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for filedrop mode", async () => {
Expand All @@ -118,7 +126,7 @@ describe("FileInput component accessibility tests", () => {
showPreview
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
});
12 changes: 12 additions & 0 deletions lib/src/file-input/FileInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ import Title from "../../.storybook/components/Title";
import ExampleContainer from "../../.storybook/components/ExampleContainer";
import FileItem from "./FileItem";
import { HalstackProvider } from "../HalstackContext";
import { disabledRules } from "../../test/accessibility/rules/specific/file-input/disabledRules";
import preview from "../../.storybook/preview";

export default {
title: "File Input",
component: DxcFileInput,
parameters: {
a11y: {
config: {
rules: [
...disabledRules.map((ruleId) => ({ id: ruleId, reviewOnFail: true })),
...preview?.parameters?.a11y?.config?.rules,
],
},
},
},
};

const picPreview = "https://cdn.mos.cms.futurecdn.net/CAZ6JXi6huSuN4QGE627NR.jpg";
Expand Down
24 changes: 4 additions & 20 deletions lib/src/footer/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,15 @@ export const Chromatic = () => (
</ExampleContainer>
<ExampleContainer>
<Title title="With children, copyright, bottom links and social links" theme="light" level={4} />
<DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}>
<div>
<a href="https://www.linkedin.com/company/dxctechnology">Linkedin</a>
</div>
</DxcFooter>
<DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}></DxcFooter>
</ExampleContainer>
<ExampleContainer>
<Title title="With children, copyright, bottom links and social links from material" theme="light" level={4} />
<DxcFooter copyright="Copyright" socialLinks={socialMaterialIcons} bottomLinks={bottom}>
<div>
<a href="https://www.linkedin.com/company/dxctechnology">Linkedin</a>
</div>
</DxcFooter>
<DxcFooter copyright="Copyright" socialLinks={socialMaterialIcons} bottomLinks={bottom}></DxcFooter>
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-focus">
<Title title="Focused bottom and social links" theme="light" level={4} />
<DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}>
<div>
<a href="https://www.linkedin.com/company/dxctechnology">Linkedin</a>
</div>
</DxcFooter>
<DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}></DxcFooter>
</ExampleContainer>
<ExampleContainer>
<Title title="Reduced" theme="light" level={4} />
Expand Down Expand Up @@ -197,11 +185,7 @@ export const Chromatic = () => (
<Title title="Opinionated theme" theme="light" level={2} />
<ExampleContainer>
<HalstackProvider theme={opinionatedTheme}>
<DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}>
<div>
<a href="https://www.linkedin.com/company/dxctechnology">Linkedin</a>
</div>
</DxcFooter>
<DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}></DxcFooter>
</HalstackProvider>
</ExampleContainer>
</>
Expand Down
20 changes: 14 additions & 6 deletions lib/src/number-input/NumberInput.accessibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import React from "react";
import { render } from "@testing-library/react";
import { axe } from "../../test/accessibility/axe-helper.js";
import DxcNumberInput from "./NumberInput.tsx";
import { disabledRules as rules } from "../../test/accessibility/rules/specific/number-input/disabledRules.js";

const disabledRules = {
rules: rules.reduce((rulesObj, rule) => {
rulesObj[rule] = { enabled: false };
return rulesObj;
}, {}),
};

// Mocking DOMRect for Radix Primitive Popover
global.globalThis = global;
Expand Down Expand Up @@ -32,7 +40,7 @@ describe("Number input component accessibility tests", () => {
step={1}
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for optional mode", async () => {
Expand All @@ -53,7 +61,7 @@ describe("Number input component accessibility tests", () => {
optional
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for error mode", async () => {
Expand All @@ -74,7 +82,7 @@ describe("Number input component accessibility tests", () => {
step={1}
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for disabled mode", async () => {
Expand All @@ -95,7 +103,7 @@ describe("Number input component accessibility tests", () => {
disabled
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for read-only mode", async () => {
Expand All @@ -116,7 +124,7 @@ describe("Number input component accessibility tests", () => {
readOnly
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for autocomplete mode", async () => {
Expand All @@ -137,7 +145,7 @@ describe("Number input component accessibility tests", () => {
autocomplete="on"
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
});
30 changes: 14 additions & 16 deletions lib/src/number-input/NumberInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ import React from "react";
import Title from "../../.storybook/components/Title";
import ExampleContainer from "../../.storybook/components/ExampleContainer";
import DxcNumberInput from "./NumberInput";
import { disabledRules } from "../../test/accessibility/rules/specific/number-input/disabledRules";
import preview from "../../.storybook/preview";

export default {
title: "Number Input",
component: DxcNumberInput,
parameters: {
a11y: {
config: {
rules: [
...disabledRules.map((ruleId) => ({ id: ruleId, reviewOnFail: true })),
...preview?.parameters?.a11y?.config?.rules,
],
},
},
},
};

export const Chromatic = () => (
Expand All @@ -32,25 +44,11 @@ export const Chromatic = () => (
</ExampleContainer>
<ExampleContainer>
<Title title="Read only" theme="light" level={4} />
<DxcNumberInput
label="Example label"
helperText="Help message"
readOnly
optional
prefix="€"
defaultValue="33"
/>
<DxcNumberInput label="Example label" helperText="Help message" readOnly optional prefix="€" defaultValue="33" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-hover">
<Title title="Hovered read only" theme="light" level={4} />
<DxcNumberInput
label="Example label"
helperText="Help message"
readOnly
optional
prefix="€"
defaultValue="1"
/>
<DxcNumberInput label="Example label" helperText="Help message" readOnly optional prefix="€" defaultValue="1" />
</ExampleContainer>
<ExampleContainer pseudoState="pseudo-active">
<Title title="Active read only" theme="light" level={4} />
Expand Down
13 changes: 11 additions & 2 deletions lib/src/radio-group/RadioGroup.accessibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ const options = [
{ label: "Option 09", value: "9" },
];

import { disabledRules as rules } from "../../test/accessibility/rules/specific/radio-group/disabledRules.js";

const disabledRules = {
rules: rules.reduce((rulesObj, rule) => {
rulesObj[rule] = { enabled: false };
return rulesObj;
}, {}),
};

describe("Radio Group component accessibility tests", () => {
it("Should not have basic accessibility issues", async () => {
const { container } = render(
Expand All @@ -30,7 +39,7 @@ describe("Radio Group component accessibility tests", () => {
optional
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
it("Should not have basic accessibility issues for read-only mode", async () => {
Expand All @@ -47,7 +56,7 @@ describe("Radio Group component accessibility tests", () => {
readOnly
/>
);
const results = await axe(container);
const results = await axe(container, disabledRules);
expect(results).toHaveNoViolations();
});
});
12 changes: 12 additions & 0 deletions lib/src/radio-group/RadioGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ import ExampleContainer from "../../.storybook/components/ExampleContainer";
import Title from "../../.storybook/components/Title";
import DxcRadioGroup from "./RadioGroup";
import { HalstackProvider } from "../HalstackContext";
import { disabledRules } from "../../test/accessibility/rules/specific/radio-group/disabledRules";
import preview from "../../.storybook/preview";

export default {
title: "Radio Group",
component: DxcRadioGroup,
parameters: {
a11y: {
config: {
rules: [
...disabledRules.map((ruleId) => ({ id: ruleId, reviewOnFail: true })),
...preview?.parameters?.a11y?.config?.rules,
],
},
},
},
};

const single_option = [{ label: "Option A", value: "A" }];
Expand Down
2 changes: 1 addition & 1 deletion lib/src/slider/Slider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useMemo, useContext } from "react";
import React, { useState, useMemo } from "react";
import styled, { ThemeProvider } from "styled-components";
import DxcTextInput from "../text-input/TextInput";
import { spaces } from "../common/variables";
Expand Down
Loading