@nationalarchives/frontend 0.1.65 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/.eslintrc.js +1 -1
- package/config/.htmlvalidate.json +12 -5
- package/config/stylelint.config.js +1 -0
- package/nationalarchives/all.css +1 -1
- package/nationalarchives/all.css.map +1 -1
- package/nationalarchives/all.js +1 -1
- package/nationalarchives/all.js.map +1 -1
- package/nationalarchives/all.mjs +0 -18
- package/nationalarchives/components/_forms.scss +9 -0
- package/nationalarchives/components/_index.scss +2 -35
- package/nationalarchives/components/_presentation.scss +23 -0
- package/nationalarchives/components/accordion/accordion.css.map +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
- package/nationalarchives/components/button/button.css +1 -1
- package/nationalarchives/components/button/button.css.map +1 -1
- package/nationalarchives/components/button/button.scss +9 -9
- package/nationalarchives/components/card/card.css +1 -1
- package/nationalarchives/components/card/card.css.map +1 -1
- package/nationalarchives/components/checkboxes/checkboxes.css +1 -1
- package/nationalarchives/components/checkboxes/checkboxes.css.map +1 -1
- package/nationalarchives/components/checkboxes/checkboxes.njk +1 -1
- package/nationalarchives/components/checkboxes/checkboxes.scss +1 -1
- package/nationalarchives/components/checkboxes/macro-options.json +6 -0
- package/nationalarchives/components/compound-filters/compound-filters.css.map +1 -1
- package/nationalarchives/components/date-input/date-input.css +1 -1
- package/nationalarchives/components/date-input/date-input.css.map +1 -1
- package/nationalarchives/components/date-input/date-input.scss +2 -2
- package/nationalarchives/components/date-input/fixtures.json +5 -5
- package/nationalarchives/components/date-input/template.njk +1 -1
- package/nationalarchives/components/date-search/date-search.css +1 -1
- package/nationalarchives/components/date-search/date-search.css.map +1 -1
- package/nationalarchives/components/date-search/date-search.scss +2 -2
- package/nationalarchives/components/details/details.css.map +1 -1
- package/nationalarchives/components/error-summary/error-summary.css +1 -1
- package/nationalarchives/components/error-summary/error-summary.css.map +1 -1
- package/nationalarchives/components/error-summary/error-summary.js +1 -1
- package/nationalarchives/components/error-summary/error-summary.js.map +1 -1
- package/nationalarchives/components/error-summary/error-summary.mjs +1 -1
- package/nationalarchives/components/error-summary/error-summary.scss +3 -4
- package/nationalarchives/components/files-list/_index.scss +1 -0
- package/nationalarchives/components/files-list/files-list.css +1 -0
- package/nationalarchives/components/files-list/files-list.css.map +1 -0
- package/nationalarchives/components/{files/files.scss → files-list/files-list.scss} +2 -1
- package/nationalarchives/components/files-list/fixtures.json +71 -0
- package/nationalarchives/components/files-list/macro.njk +3 -0
- package/nationalarchives/components/files-list/template.njk +33 -0
- package/nationalarchives/components/footer/footer.css.map +1 -1
- package/nationalarchives/components/gallery/fixtures.json +1 -1
- package/nationalarchives/components/gallery/gallery.css +1 -1
- package/nationalarchives/components/gallery/gallery.css.map +1 -1
- package/nationalarchives/components/gallery/gallery.scss +5 -6
- package/nationalarchives/components/gallery/template.njk +11 -7
- package/nationalarchives/components/global-header/global-header.css.map +1 -1
- package/nationalarchives/components/header/header.css.map +1 -1
- package/nationalarchives/components/hero/hero.css +1 -1
- package/nationalarchives/components/hero/hero.css.map +1 -1
- package/nationalarchives/components/hero/hero.scss +0 -24
- package/nationalarchives/components/index-grid/index-grid.css +1 -1
- package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
- package/nationalarchives/components/index-grid/index-grid.scss +1 -1
- package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
- package/nationalarchives/components/picture/picture.css.map +1 -1
- package/nationalarchives/components/quick-filters/quick-filters.css +1 -1
- package/nationalarchives/components/quick-filters/quick-filters.css.map +1 -1
- package/nationalarchives/components/radios/radios.css +1 -1
- package/nationalarchives/components/radios/radios.css.map +1 -1
- package/nationalarchives/components/radios/radios.scss +1 -1
- package/nationalarchives/components/records-list/_index.scss +1 -0
- package/nationalarchives/components/records-list/fixtures.json +42 -0
- package/nationalarchives/components/records-list/macro.njk +3 -0
- package/nationalarchives/components/records-list/records-list.css +1 -0
- package/nationalarchives/components/records-list/records-list.css.map +1 -0
- package/nationalarchives/components/{featured-records/featured-records.scss → records-list/records-list.scss} +1 -1
- package/nationalarchives/components/records-list/template.njk +21 -0
- package/nationalarchives/components/search-field/search-field.css +1 -1
- package/nationalarchives/components/search-field/search-field.css.map +1 -1
- package/nationalarchives/components/search-field/search-field.scss +1 -1
- package/nationalarchives/components/select/select.css +1 -1
- package/nationalarchives/components/select/select.css.map +1 -1
- package/nationalarchives/components/select/select.scss +2 -2
- package/nationalarchives/components/sidebar/fixtures.json +12 -2
- package/nationalarchives/components/sidebar/sidebar.css +1 -1
- package/nationalarchives/components/sidebar/sidebar.css.map +1 -1
- package/nationalarchives/components/sidebar/template.njk +9 -0
- package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
- package/nationalarchives/components/tabs/tabs.css.map +1 -1
- package/nationalarchives/components/text-input/text-input.css +1 -1
- package/nationalarchives/components/text-input/text-input.css.map +1 -1
- package/nationalarchives/components/text-input/text-input.scss +2 -2
- package/nationalarchives/components/textarea/textarea.css +1 -1
- package/nationalarchives/components/textarea/textarea.css.map +1 -1
- package/nationalarchives/components/textarea/textarea.scss +2 -2
- package/nationalarchives/components/warning/warning.css +1 -1
- package/nationalarchives/components/warning/warning.css.map +1 -1
- package/nationalarchives/components/warning/warning.scss +1 -0
- package/nationalarchives/global-header-package.css +1 -1
- package/nationalarchives/global-header-package.css.map +1 -1
- package/nationalarchives/global-header-package.scss +1 -1
- package/nationalarchives/print.css +1 -1
- package/nationalarchives/print.css.map +1 -1
- package/nationalarchives/prototype-kit.css +1 -1
- package/nationalarchives/prototype-kit.css.map +1 -1
- package/nationalarchives/tools/_colour.scss +25 -50
- package/nationalarchives/utilities/_columns.scss +1 -1
- package/nationalarchives/utilities/_index.scss +1 -0
- package/nationalarchives/utilities/_reset.scss +2 -8
- package/nationalarchives/utilities/{_colour.scss → colour/_index.scss} +2 -2
- package/nationalarchives/utilities/{_forms.scss → forms/_index.scss} +6 -6
- package/nationalarchives/utilities/grid/macro.njk +3 -0
- package/nationalarchives/utilities/{_lists.scss → lists/_index.scss} +16 -7
- package/nationalarchives/utilities/{_overrides.scss → overrides/_index.scss} +2 -2
- package/nationalarchives/utilities/{_tables.scss → tables/_index.scss} +5 -5
- package/nationalarchives/utilities/{_typography.scss → typography/_index.scss} +5 -5
- package/nationalarchives/variables/_colour.scss +12 -5
- package/package.json +1 -1
- package/nationalarchives/components/accordion/accordion.stories.js +0 -432
- package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +0 -128
- package/nationalarchives/components/button/button-group.stories.js +0 -114
- package/nationalarchives/components/button/button.stories.js +0 -207
- package/nationalarchives/components/card/card.stories.js +0 -402
- package/nationalarchives/components/checkboxes/checkboxes.stories.js +0 -241
- package/nationalarchives/components/compound-filters/compound-filters.stories.js +0 -61
- package/nationalarchives/components/cookie-banner/cookie-banner.stories.js +0 -250
- package/nationalarchives/components/date-input/date-input.stories.js +0 -119
- package/nationalarchives/components/date-search/date-search.stories.js +0 -124
- package/nationalarchives/components/details/details.stories.js +0 -33
- package/nationalarchives/components/error-summary/error-summary.stories.js +0 -59
- package/nationalarchives/components/featured-records/_index.scss +0 -1
- package/nationalarchives/components/featured-records/featured-records.css +0 -1
- package/nationalarchives/components/featured-records/featured-records.css.map +0 -1
- package/nationalarchives/components/featured-records/featured-records.stories.js +0 -50
- package/nationalarchives/components/featured-records/fixtures.json +0 -42
- package/nationalarchives/components/featured-records/macro.njk +0 -3
- package/nationalarchives/components/featured-records/template.njk +0 -21
- package/nationalarchives/components/files/_index.scss +0 -1
- package/nationalarchives/components/files/files.css +0 -1
- package/nationalarchives/components/files/files.css.map +0 -1
- package/nationalarchives/components/files/files.stories.js +0 -59
- package/nationalarchives/components/files/fixtures.json +0 -71
- package/nationalarchives/components/files/macro.njk +0 -3
- package/nationalarchives/components/files/template.njk +0 -33
- package/nationalarchives/components/footer/footer.stories.js +0 -241
- package/nationalarchives/components/gallery/gallery.stories.js +0 -87
- package/nationalarchives/components/global-header/global-header.stories.js +0 -364
- package/nationalarchives/components/grid/_index.scss +0 -1
- package/nationalarchives/components/grid/grid.css +0 -1
- package/nationalarchives/components/grid/grid.css.map +0 -1
- package/nationalarchives/components/grid/grid.stories.js +0 -279
- package/nationalarchives/components/grid/macro.njk +0 -3
- package/nationalarchives/components/header/header.stories.js +0 -239
- package/nationalarchives/components/hero/hero.stories.js +0 -326
- package/nationalarchives/components/index-grid/index-grid.stories.js +0 -128
- package/nationalarchives/components/pagination/pagination.stories.js +0 -532
- package/nationalarchives/components/phase-banner/phase-banner.stories.js +0 -39
- package/nationalarchives/components/picture/picture.stories.js +0 -75
- package/nationalarchives/components/quick-filters/quick-filters.stories.js +0 -76
- package/nationalarchives/components/radios/radios.stories.js +0 -244
- package/nationalarchives/components/search-field/search-field.stories.js +0 -88
- package/nationalarchives/components/search-filters/_index.scss +0 -1
- package/nationalarchives/components/search-filters/fixtures.json +0 -16
- package/nationalarchives/components/search-filters/macro-options.json +0 -39
- package/nationalarchives/components/search-filters/macro.njk +0 -3
- package/nationalarchives/components/search-filters/search-filters.css +0 -1
- package/nationalarchives/components/search-filters/search-filters.css.map +0 -1
- package/nationalarchives/components/search-filters/search-filters.js +0 -2
- package/nationalarchives/components/search-filters/search-filters.js.map +0 -1
- package/nationalarchives/components/search-filters/search-filters.mjs +0 -67
- package/nationalarchives/components/search-filters/search-filters.scss +0 -198
- package/nationalarchives/components/search-filters/search-filters.stories.js +0 -207
- package/nationalarchives/components/search-filters/template.njk +0 -108
- package/nationalarchives/components/select/select.stories.js +0 -197
- package/nationalarchives/components/sensitive-image/_index.scss +0 -1
- package/nationalarchives/components/sensitive-image/fixtures.json +0 -51
- package/nationalarchives/components/sensitive-image/macro-options.json +0 -58
- package/nationalarchives/components/sensitive-image/macro.njk +0 -3
- package/nationalarchives/components/sensitive-image/sensitive-image.css +0 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.css.map +0 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.js +0 -2
- package/nationalarchives/components/sensitive-image/sensitive-image.js.map +0 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.mjs +0 -23
- package/nationalarchives/components/sensitive-image/sensitive-image.scss +0 -85
- package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +0 -86
- package/nationalarchives/components/sensitive-image/template.njk +0 -11
- package/nationalarchives/components/sidebar/sidebar.stories.js +0 -227
- package/nationalarchives/components/skip-link/skip-link.stories.js +0 -76
- package/nationalarchives/components/tabs/tabs.stories.js +0 -300
- package/nationalarchives/components/text-input/text-input.stories.js +0 -188
- package/nationalarchives/components/textarea/textarea.stories.js +0 -130
- package/nationalarchives/components/warning/warning.stories.js +0 -39
- package/nationalarchives/stories/intro.mdx +0 -13
- package/nationalarchives/stories/utilities/colour-schemes/colour-combinations.stories.js +0 -293
- package/nationalarchives/stories/utilities/colour-schemes/colour-themes.stories.js +0 -1513
- package/nationalarchives/stories/utilities/forms/forms.mdx +0 -117
- package/nationalarchives/stories/utilities/lists/lists.stories.js +0 -212
- package/nationalarchives/stories/utilities/overrides/overrides.stories.js +0 -42
- package/nationalarchives/stories/utilities/tables/tables.stories.js +0 -47
- package/nationalarchives/stories/utilities/typography/heading-groups.stories.js +0 -94
- package/nationalarchives/stories/utilities/typography/headings.stories.js +0 -33
- package/nationalarchives/stories/utilities/typography/typography.stories.js +0 -91
- package/nationalarchives/components/{files → files-list}/macro-options.json +0 -0
- package/nationalarchives/components/{featured-records → records-list}/macro-options.json +0 -0
- package/nationalarchives/{components/grid/grid.scss → utilities/grid/_index.scss} +1 -1
- /package/nationalarchives/{components → utilities}/grid/fixtures.json +0 -0
- /package/nationalarchives/{components → utilities}/grid/macro-options.json +0 -0
- /package/nationalarchives/{components → utilities}/grid/template.njk +0 -0
@@ -1,76 +0,0 @@
|
|
1
|
-
import SkipLink from "./template.njk";
|
2
|
-
import macroOptions from "./macro-options.json";
|
3
|
-
import { within, userEvent, expect } from "@storybook/test";
|
4
|
-
|
5
|
-
const argTypes = {
|
6
|
-
text: { control: "text" },
|
7
|
-
href: { control: "text" },
|
8
|
-
classes: { control: "text" },
|
9
|
-
attributes: { control: "object" },
|
10
|
-
};
|
11
|
-
|
12
|
-
Object.keys(argTypes).forEach((argType) => {
|
13
|
-
argTypes[argType].description = macroOptions.find(
|
14
|
-
(option) => option.name === argType,
|
15
|
-
)?.description;
|
16
|
-
});
|
17
|
-
|
18
|
-
export default {
|
19
|
-
title: "Components/Skip link",
|
20
|
-
argTypes,
|
21
|
-
};
|
22
|
-
|
23
|
-
const Template = ({ text, href, classes, attributes }) =>
|
24
|
-
`<p>To view the skip link component tab to this example, or click inside this example and press tab.</p>
|
25
|
-
${SkipLink({
|
26
|
-
params: { text, href, classes, attributes },
|
27
|
-
})}
|
28
|
-
<main class="tna-main" id="main-content">
|
29
|
-
<h1>Main content</h1>
|
30
|
-
</main>`;
|
31
|
-
|
32
|
-
export const Standard = Template.bind({});
|
33
|
-
Standard.args = {
|
34
|
-
classes: "tna-skip-link--demo",
|
35
|
-
};
|
36
|
-
|
37
|
-
export const Test = Template.bind({});
|
38
|
-
Test.parameters = {
|
39
|
-
chromatic: { disableSnapshot: true },
|
40
|
-
};
|
41
|
-
Test.args = {
|
42
|
-
text: "Skip to main content",
|
43
|
-
href: "main-content",
|
44
|
-
classes: "tna-skip-link--demo",
|
45
|
-
};
|
46
|
-
Test.play = async ({ args, canvasElement }) => {
|
47
|
-
const canvas = within(canvasElement);
|
48
|
-
|
49
|
-
const $skipLink = canvas.getByText(args.text);
|
50
|
-
const $linkedElement = document.getElementById(args.href);
|
51
|
-
|
52
|
-
await expect($skipLink.getBoundingClientRect().width).toBe(1);
|
53
|
-
await expect($skipLink.getBoundingClientRect().height).toBe(1);
|
54
|
-
await expect($skipLink.getBoundingClientRect().x).toBeLessThanOrEqual(-1);
|
55
|
-
await expect($skipLink).not.toHaveFocus();
|
56
|
-
await expect($linkedElement).not.toHaveFocus();
|
57
|
-
await expect($linkedElement).not.toHaveAttribute("tabindex");
|
58
|
-
|
59
|
-
await userEvent.keyboard("[Tab]");
|
60
|
-
await expect($skipLink).toHaveFocus();
|
61
|
-
await expect($skipLink.getBoundingClientRect().width).toBeGreaterThan(1);
|
62
|
-
await expect($skipLink.getBoundingClientRect().height).toBeGreaterThan(1);
|
63
|
-
await expect($skipLink.getBoundingClientRect().x).toBeGreaterThanOrEqual(0);
|
64
|
-
|
65
|
-
await userEvent.click($skipLink);
|
66
|
-
await expect($skipLink.getBoundingClientRect().width).toBe(1);
|
67
|
-
await expect($skipLink.getBoundingClientRect().height).toBe(1);
|
68
|
-
await expect($skipLink.getBoundingClientRect().x).toBeLessThanOrEqual(-1);
|
69
|
-
await expect($skipLink).not.toHaveFocus();
|
70
|
-
await expect($linkedElement).toHaveAttribute("tabindex");
|
71
|
-
await expect($linkedElement).toHaveFocus();
|
72
|
-
|
73
|
-
await userEvent.keyboard("[Tab]");
|
74
|
-
await expect($linkedElement).not.toHaveFocus();
|
75
|
-
await expect($linkedElement).not.toHaveAttribute("tabindex");
|
76
|
-
};
|
@@ -1,300 +0,0 @@
|
|
1
|
-
import Tabs from "./template.njk";
|
2
|
-
import macroOptions from "./macro-options.json";
|
3
|
-
import { within, userEvent, expect } from "@storybook/test";
|
4
|
-
|
5
|
-
const argTypes = {
|
6
|
-
items: { control: "object" },
|
7
|
-
sticky: { control: "boolean" },
|
8
|
-
classes: { control: "text" },
|
9
|
-
attributes: { control: "object" },
|
10
|
-
};
|
11
|
-
|
12
|
-
Object.keys(argTypes).forEach((argType) => {
|
13
|
-
argTypes[argType].description = macroOptions.find(
|
14
|
-
(option) => option.name === argType,
|
15
|
-
)?.description;
|
16
|
-
});
|
17
|
-
|
18
|
-
export default {
|
19
|
-
title: "Components/Tabs",
|
20
|
-
argTypes,
|
21
|
-
};
|
22
|
-
|
23
|
-
const Template = ({ items, sticky, classes, attributes }) =>
|
24
|
-
Tabs({
|
25
|
-
params: {
|
26
|
-
items,
|
27
|
-
sticky,
|
28
|
-
classes,
|
29
|
-
attributes,
|
30
|
-
},
|
31
|
-
});
|
32
|
-
|
33
|
-
export const Standard = Template.bind({});
|
34
|
-
Standard.args = {
|
35
|
-
items: [
|
36
|
-
{
|
37
|
-
id: "unique-id-a",
|
38
|
-
title: "Alpha section",
|
39
|
-
body: '<h2 class="tna-heading-l">Alpha title</h2><p>Lorem ipsum</p>',
|
40
|
-
},
|
41
|
-
{
|
42
|
-
id: "unique-id-b",
|
43
|
-
title: "Beta section",
|
44
|
-
body: '<h2 class="tna-heading-l">Beta title</h2><p>Lorem ipsum</p>',
|
45
|
-
},
|
46
|
-
{
|
47
|
-
id: "unique-id-c",
|
48
|
-
title: "Gamma section",
|
49
|
-
body: '<h2 class="tna-heading-l">Gamma title</h2><p>Lorem ipsum</p>',
|
50
|
-
},
|
51
|
-
],
|
52
|
-
classes: "tna-tabs--demo",
|
53
|
-
};
|
54
|
-
|
55
|
-
export const Test = Template.bind({});
|
56
|
-
Test.parameters = {
|
57
|
-
chromatic: { disableSnapshot: true },
|
58
|
-
};
|
59
|
-
Test.args = {
|
60
|
-
items: [
|
61
|
-
{
|
62
|
-
id: "unique-id-a",
|
63
|
-
title: "Alpha section",
|
64
|
-
body: '<h2 class="tna-heading-l">Alpha title</h2><p>Lorem ipsum</p>',
|
65
|
-
},
|
66
|
-
{
|
67
|
-
id: "unique-id-b",
|
68
|
-
title: "Beta section",
|
69
|
-
body: '<h2 class="tna-heading-l">Beta title</h2><p>Lorem ipsum</p>',
|
70
|
-
},
|
71
|
-
{
|
72
|
-
id: "unique-id-c",
|
73
|
-
title: "Gamma section",
|
74
|
-
body: '<h2 class="tna-heading-l">Gamma title</h2><p>Lorem ipsum</p>',
|
75
|
-
},
|
76
|
-
],
|
77
|
-
classes: "tna-tabs--demo",
|
78
|
-
};
|
79
|
-
Test.play = async ({ args, canvasElement, step }) => {
|
80
|
-
await new Promise((r) => setTimeout(r, 100));
|
81
|
-
|
82
|
-
const canvas = within(canvasElement);
|
83
|
-
|
84
|
-
const tablist = canvas.getByRole("tablist");
|
85
|
-
const [buttonA, buttonB, buttonC] = args.items.map((item) =>
|
86
|
-
canvas.getByText(item.title),
|
87
|
-
);
|
88
|
-
const [sectionA, sectionB, sectionC] = args.items.map((item) =>
|
89
|
-
canvasElement.querySelector(`#${item.id}`),
|
90
|
-
);
|
91
|
-
|
92
|
-
const expectButtonToBeCurrent = async (button) => {
|
93
|
-
await expect(button).toHaveAttribute("tabindex", "0");
|
94
|
-
await expect(button).toHaveAttribute("aria-selected", "true");
|
95
|
-
await expect(button).toHaveFocus();
|
96
|
-
};
|
97
|
-
|
98
|
-
const expectButtonNotToBeCurrent = async (button) => {
|
99
|
-
await expect(button).toHaveAttribute("tabindex", "-1");
|
100
|
-
await expect(button).toHaveAttribute("aria-selected", "false");
|
101
|
-
};
|
102
|
-
|
103
|
-
const expectSectionToBeCurrent = async (section) => {
|
104
|
-
await expect(section).toBeVisible();
|
105
|
-
await expect(section).toHaveAttribute("tabindex", "0");
|
106
|
-
};
|
107
|
-
|
108
|
-
const expectSectionNotToBeCurrent = async (section) => {
|
109
|
-
await expect(section).not.toBeVisible();
|
110
|
-
await expect(section).toHaveAttribute("tabindex", "-1");
|
111
|
-
};
|
112
|
-
|
113
|
-
const expectButtonAndSectionAToBeCurrent = async () => {
|
114
|
-
await step("Test tab buttons", async () => {
|
115
|
-
await expectButtonToBeCurrent(buttonA);
|
116
|
-
await expectButtonNotToBeCurrent(buttonB);
|
117
|
-
await expectButtonNotToBeCurrent(buttonC);
|
118
|
-
});
|
119
|
-
|
120
|
-
await step("Test tab sections", async () => {
|
121
|
-
await expectSectionToBeCurrent(sectionA);
|
122
|
-
await expectSectionNotToBeCurrent(sectionB);
|
123
|
-
await expectSectionNotToBeCurrent(sectionC);
|
124
|
-
});
|
125
|
-
};
|
126
|
-
|
127
|
-
const expectButtonAndSectionBToBeCurrent = async () => {
|
128
|
-
await step("Test tab buttons", async () => {
|
129
|
-
await expectButtonNotToBeCurrent(buttonA);
|
130
|
-
await expectButtonToBeCurrent(buttonB);
|
131
|
-
await expectButtonNotToBeCurrent(buttonC);
|
132
|
-
});
|
133
|
-
|
134
|
-
await step("Test tab sections", async () => {
|
135
|
-
await expectSectionNotToBeCurrent(sectionA);
|
136
|
-
await expectSectionToBeCurrent(sectionB);
|
137
|
-
await expectSectionNotToBeCurrent(sectionC);
|
138
|
-
});
|
139
|
-
};
|
140
|
-
|
141
|
-
const expectButtonAndSectionCToBeCurrent = async () => {
|
142
|
-
await step("Test tab buttons", async () => {
|
143
|
-
await expectButtonNotToBeCurrent(buttonA);
|
144
|
-
await expectButtonNotToBeCurrent(buttonB);
|
145
|
-
await expectButtonToBeCurrent(buttonC);
|
146
|
-
});
|
147
|
-
|
148
|
-
await step("Test tab sections", async () => {
|
149
|
-
await expectSectionNotToBeCurrent(sectionA);
|
150
|
-
await expectSectionNotToBeCurrent(sectionB);
|
151
|
-
await expectSectionToBeCurrent(sectionC);
|
152
|
-
});
|
153
|
-
};
|
154
|
-
|
155
|
-
await step("Initial load", async () => {
|
156
|
-
await step("Test tablist", async () => {
|
157
|
-
await expect(tablist).toBeDefined();
|
158
|
-
await expect(tablist).toBeVisible();
|
159
|
-
});
|
160
|
-
|
161
|
-
await step("Test tab buttons", async () => {
|
162
|
-
await step("First tab button", async () => {
|
163
|
-
await expect(buttonA).toBeVisible();
|
164
|
-
await expect(buttonA).toHaveAttribute("id", `${args.items[0].id}-tab`);
|
165
|
-
await expect(buttonA).toHaveAttribute("role", "tab");
|
166
|
-
await expect(buttonA).toHaveAttribute("tabindex", "0");
|
167
|
-
await expect(buttonA).toHaveAttribute("aria-selected", "true");
|
168
|
-
await expect(buttonA).toHaveAttribute(
|
169
|
-
"aria-controls",
|
170
|
-
args.items[0].id,
|
171
|
-
);
|
172
|
-
});
|
173
|
-
|
174
|
-
await step("Second tab button", async () => {
|
175
|
-
await expect(buttonB).toBeVisible();
|
176
|
-
await expect(buttonB).toHaveAttribute("id", `${args.items[1].id}-tab`);
|
177
|
-
await expect(buttonB).toHaveAttribute("role", "tab");
|
178
|
-
await expect(buttonB).toHaveAttribute("tabindex", "-1");
|
179
|
-
await expect(buttonB).toHaveAttribute("aria-selected", "false");
|
180
|
-
await expect(buttonB).toHaveAttribute(
|
181
|
-
"aria-controls",
|
182
|
-
args.items[1].id,
|
183
|
-
);
|
184
|
-
});
|
185
|
-
|
186
|
-
await step("Third tab button", async () => {
|
187
|
-
await expect(buttonC).toBeVisible();
|
188
|
-
await expect(buttonC).toHaveAttribute("id", `${args.items[2].id}-tab`);
|
189
|
-
await expect(buttonC).toHaveAttribute("role", "tab");
|
190
|
-
await expect(buttonC).toHaveAttribute("tabindex", "-1");
|
191
|
-
await expect(buttonC).toHaveAttribute("aria-selected", "false");
|
192
|
-
await expect(buttonC).toHaveAttribute(
|
193
|
-
"aria-controls",
|
194
|
-
args.items[2].id,
|
195
|
-
);
|
196
|
-
});
|
197
|
-
});
|
198
|
-
|
199
|
-
await step("Test tab sections", async () => {
|
200
|
-
await expect(sectionA).toBeVisible();
|
201
|
-
await expect(sectionA).toHaveAttribute("id", args.items[0].id);
|
202
|
-
await expect(sectionA).toHaveAttribute("role", "tabpanel");
|
203
|
-
await expect(sectionA).toHaveAttribute(
|
204
|
-
"aria-labelledby",
|
205
|
-
`${args.items[0].id}-tab`,
|
206
|
-
);
|
207
|
-
await expect(sectionA).toHaveAttribute("tabindex", "0");
|
208
|
-
|
209
|
-
await expect(sectionB).not.toBeVisible();
|
210
|
-
await expect(sectionB).toHaveAttribute("id", args.items[1].id);
|
211
|
-
await expect(sectionB).toHaveAttribute("role", "tabpanel");
|
212
|
-
await expect(sectionB).toHaveAttribute(
|
213
|
-
"aria-labelledby",
|
214
|
-
`${args.items[1].id}-tab`,
|
215
|
-
);
|
216
|
-
await expect(sectionB).toHaveAttribute("tabindex", "0");
|
217
|
-
|
218
|
-
await expect(sectionC).not.toBeVisible();
|
219
|
-
await expect(sectionC).toHaveAttribute("id", args.items[2].id);
|
220
|
-
await expect(sectionC).toHaveAttribute("role", "tabpanel");
|
221
|
-
await expect(sectionC).toHaveAttribute(
|
222
|
-
"aria-labelledby",
|
223
|
-
`${args.items[2].id}-tab`,
|
224
|
-
);
|
225
|
-
await expect(sectionC).toHaveAttribute("tabindex", "0");
|
226
|
-
});
|
227
|
-
});
|
228
|
-
|
229
|
-
await userEvent.click(buttonA);
|
230
|
-
|
231
|
-
await step("First tab (already selected)", async () => {
|
232
|
-
await userEvent.click(buttonA);
|
233
|
-
await expectButtonAndSectionAToBeCurrent();
|
234
|
-
});
|
235
|
-
|
236
|
-
await step("Second tab", async () => {
|
237
|
-
await userEvent.click(buttonB);
|
238
|
-
await expectButtonAndSectionBToBeCurrent();
|
239
|
-
});
|
240
|
-
|
241
|
-
await step("Third tab", async () => {
|
242
|
-
await userEvent.click(buttonC);
|
243
|
-
await expectButtonAndSectionCToBeCurrent();
|
244
|
-
});
|
245
|
-
|
246
|
-
await step("First tab", async () => {
|
247
|
-
await userEvent.click(buttonA);
|
248
|
-
await expectButtonAndSectionAToBeCurrent();
|
249
|
-
});
|
250
|
-
|
251
|
-
await step("Keyboard interaciton", async () => {
|
252
|
-
await step("Left/right", async () => {
|
253
|
-
await userEvent.click(buttonA);
|
254
|
-
await expectButtonAndSectionAToBeCurrent();
|
255
|
-
|
256
|
-
await userEvent.keyboard("[ArrowRight]");
|
257
|
-
await expectButtonAndSectionBToBeCurrent();
|
258
|
-
|
259
|
-
await userEvent.keyboard("[ArrowRight]");
|
260
|
-
await expectButtonAndSectionCToBeCurrent();
|
261
|
-
|
262
|
-
await userEvent.keyboard("[ArrowRight]");
|
263
|
-
await expectButtonAndSectionAToBeCurrent();
|
264
|
-
|
265
|
-
await userEvent.keyboard("[ArrowRight]");
|
266
|
-
await expectButtonAndSectionBToBeCurrent();
|
267
|
-
|
268
|
-
await userEvent.keyboard("[ArrowLeft]");
|
269
|
-
await expectButtonAndSectionAToBeCurrent();
|
270
|
-
|
271
|
-
await userEvent.keyboard("[ArrowLeft]");
|
272
|
-
await expectButtonAndSectionCToBeCurrent();
|
273
|
-
|
274
|
-
await userEvent.keyboard("[ArrowLeft]");
|
275
|
-
await expectButtonAndSectionBToBeCurrent();
|
276
|
-
|
277
|
-
await userEvent.keyboard("[ArrowLeft]");
|
278
|
-
await expectButtonAndSectionAToBeCurrent();
|
279
|
-
});
|
280
|
-
|
281
|
-
await step("Home/end", async () => {
|
282
|
-
await userEvent.click(buttonA);
|
283
|
-
await expectButtonAndSectionAToBeCurrent();
|
284
|
-
|
285
|
-
await userEvent.keyboard("[Home]");
|
286
|
-
await expectButtonAndSectionAToBeCurrent();
|
287
|
-
|
288
|
-
await userEvent.keyboard("[End]");
|
289
|
-
await expectButtonAndSectionCToBeCurrent();
|
290
|
-
|
291
|
-
await userEvent.keyboard("[End]");
|
292
|
-
await expectButtonAndSectionCToBeCurrent();
|
293
|
-
|
294
|
-
await userEvent.keyboard("[Home]");
|
295
|
-
await expectButtonAndSectionAToBeCurrent();
|
296
|
-
});
|
297
|
-
|
298
|
-
buttonA.blur();
|
299
|
-
});
|
300
|
-
};
|
@@ -1,188 +0,0 @@
|
|
1
|
-
import TextInput from "./template.njk";
|
2
|
-
import macroOptions from "./macro-options.json";
|
3
|
-
|
4
|
-
const argTypes = {
|
5
|
-
label: { control: "text" },
|
6
|
-
headingLevel: { control: { type: "number", min: 1, max: 6 } },
|
7
|
-
headingSize: {
|
8
|
-
control: "inline-radio",
|
9
|
-
options: ["xs", "s", "m", "l", "xl"],
|
10
|
-
},
|
11
|
-
id: { control: "text" },
|
12
|
-
name: { control: "text" },
|
13
|
-
hint: { control: "text" },
|
14
|
-
value: { control: "text" },
|
15
|
-
error: { control: "object" },
|
16
|
-
spellcheck: { control: "boolean" },
|
17
|
-
inputmode: {
|
18
|
-
control: "select",
|
19
|
-
options: ["text", "decimal", "numeric", "tel", "search", "email", "url"],
|
20
|
-
},
|
21
|
-
autofill: {
|
22
|
-
control: "select",
|
23
|
-
options: [
|
24
|
-
"name",
|
25
|
-
"honorific-prefix",
|
26
|
-
"given-name",
|
27
|
-
"additional-name",
|
28
|
-
"family-name",
|
29
|
-
"honorific-suffix",
|
30
|
-
"nickname",
|
31
|
-
"username",
|
32
|
-
"new-password",
|
33
|
-
"current-password",
|
34
|
-
"one-time-code",
|
35
|
-
"organization-title",
|
36
|
-
"organization",
|
37
|
-
"street-address",
|
38
|
-
"address-line1",
|
39
|
-
"address-line2",
|
40
|
-
"address-line3",
|
41
|
-
"address-level4",
|
42
|
-
"address-level3",
|
43
|
-
"address-level2",
|
44
|
-
"address-level1",
|
45
|
-
"country",
|
46
|
-
"country-name",
|
47
|
-
"postal-code",
|
48
|
-
"cc-name",
|
49
|
-
"cc-given-name",
|
50
|
-
"cc-additional-name",
|
51
|
-
"cc-family-name",
|
52
|
-
"cc-number",
|
53
|
-
"cc-exp",
|
54
|
-
"cc-exp-month",
|
55
|
-
"cc-exp-year",
|
56
|
-
"cc-csc",
|
57
|
-
"cc-type",
|
58
|
-
"transaction-currency",
|
59
|
-
"transaction-amount",
|
60
|
-
"language",
|
61
|
-
"bday",
|
62
|
-
"bday-day",
|
63
|
-
"bday-month",
|
64
|
-
"bday-year",
|
65
|
-
"sex",
|
66
|
-
"url",
|
67
|
-
"photo",
|
68
|
-
"email",
|
69
|
-
],
|
70
|
-
},
|
71
|
-
size: { control: "inline-radio", options: ["xs", "s", "m", "l", "xl"] },
|
72
|
-
maxLength: { control: "number" },
|
73
|
-
inline: { control: "boolean" },
|
74
|
-
formGroupClasses: { control: "text" },
|
75
|
-
formGroupAttributes: { control: "object" },
|
76
|
-
classes: { control: "text" },
|
77
|
-
attributes: { control: "object" },
|
78
|
-
};
|
79
|
-
|
80
|
-
Object.keys(argTypes).forEach((argType) => {
|
81
|
-
argTypes[argType].description = macroOptions.find(
|
82
|
-
(option) => option.name === argType,
|
83
|
-
)?.description;
|
84
|
-
});
|
85
|
-
|
86
|
-
export default {
|
87
|
-
title: "Components/Text input",
|
88
|
-
argTypes,
|
89
|
-
};
|
90
|
-
|
91
|
-
const Template = ({
|
92
|
-
label,
|
93
|
-
headingLevel,
|
94
|
-
headingSize,
|
95
|
-
id,
|
96
|
-
name,
|
97
|
-
hint,
|
98
|
-
value,
|
99
|
-
error,
|
100
|
-
spellcheck,
|
101
|
-
inputmode,
|
102
|
-
autofill,
|
103
|
-
size,
|
104
|
-
maxLength,
|
105
|
-
inline,
|
106
|
-
formGroupClasses,
|
107
|
-
formGroupAttributes,
|
108
|
-
classes,
|
109
|
-
attributes,
|
110
|
-
}) =>
|
111
|
-
TextInput({
|
112
|
-
params: {
|
113
|
-
label,
|
114
|
-
headingLevel,
|
115
|
-
headingSize,
|
116
|
-
id,
|
117
|
-
name,
|
118
|
-
hint,
|
119
|
-
value,
|
120
|
-
error,
|
121
|
-
spellcheck,
|
122
|
-
inputmode,
|
123
|
-
autofill,
|
124
|
-
size,
|
125
|
-
maxLength,
|
126
|
-
inline,
|
127
|
-
formGroupClasses,
|
128
|
-
formGroupAttributes,
|
129
|
-
classes,
|
130
|
-
attributes,
|
131
|
-
},
|
132
|
-
});
|
133
|
-
|
134
|
-
export const Standard = Template.bind({});
|
135
|
-
Standard.args = {
|
136
|
-
label: "Enter your first name",
|
137
|
-
headingLevel: 4,
|
138
|
-
headingSize: "m",
|
139
|
-
id: "firstname1",
|
140
|
-
name: "firstname1",
|
141
|
-
classes: "tna-text-input--demo",
|
142
|
-
};
|
143
|
-
|
144
|
-
export const Predefined = Template.bind({});
|
145
|
-
Predefined.args = {
|
146
|
-
label: "Edit your first name",
|
147
|
-
headingLevel: 4,
|
148
|
-
headingSize: "m",
|
149
|
-
id: "firstname2",
|
150
|
-
name: "firstname2",
|
151
|
-
value: "John",
|
152
|
-
classes: "tna-text-input--demo",
|
153
|
-
};
|
154
|
-
|
155
|
-
export const WithHint = Template.bind({});
|
156
|
-
WithHint.args = {
|
157
|
-
label: "Enter your first name",
|
158
|
-
headingLevel: 4,
|
159
|
-
headingSize: "m",
|
160
|
-
id: "firstname3",
|
161
|
-
name: "firstname3",
|
162
|
-
hint: "What people call you by",
|
163
|
-
classes: "tna-text-input--demo",
|
164
|
-
};
|
165
|
-
|
166
|
-
export const Error = Template.bind({});
|
167
|
-
Error.args = {
|
168
|
-
label: "Enter your first name",
|
169
|
-
headingLevel: 4,
|
170
|
-
headingSize: "m",
|
171
|
-
id: "firstname4",
|
172
|
-
name: "firstname4",
|
173
|
-
error: {
|
174
|
-
text: "Enter a name",
|
175
|
-
},
|
176
|
-
classes: "tna-text-input--demo",
|
177
|
-
};
|
178
|
-
|
179
|
-
export const Inline = Template.bind({});
|
180
|
-
Inline.args = {
|
181
|
-
label: "Enter your first name",
|
182
|
-
headingLevel: 4,
|
183
|
-
headingSize: "xs",
|
184
|
-
id: "firstname5",
|
185
|
-
name: "firstname5",
|
186
|
-
inline: true,
|
187
|
-
classes: "tna-text-input--demo",
|
188
|
-
};
|
@@ -1,130 +0,0 @@
|
|
1
|
-
import Textarea from "./template.njk";
|
2
|
-
import macroOptions from "./macro-options.json";
|
3
|
-
|
4
|
-
const argTypes = {
|
5
|
-
label: { control: "text" },
|
6
|
-
headingLevel: { control: { type: "number", min: 1, max: 6 } },
|
7
|
-
headingSize: {
|
8
|
-
control: "inline-radio",
|
9
|
-
options: ["xs", "s", "m", "l", "xl"],
|
10
|
-
},
|
11
|
-
id: { control: "text" },
|
12
|
-
name: { control: "text" },
|
13
|
-
hint: { control: "text" },
|
14
|
-
value: { control: "text" },
|
15
|
-
error: { control: "object" },
|
16
|
-
spellcheck: { control: "boolean" },
|
17
|
-
size: { control: "inline-radio", options: ["m", "l", "xl"] },
|
18
|
-
rows: { control: "number" },
|
19
|
-
inline: { control: "boolean" },
|
20
|
-
formGroupClasses: { control: "text" },
|
21
|
-
formGroupAttributes: { control: "object" },
|
22
|
-
classes: { control: "text" },
|
23
|
-
attributes: { control: "object" },
|
24
|
-
};
|
25
|
-
|
26
|
-
Object.keys(argTypes).forEach((argType) => {
|
27
|
-
argTypes[argType].description = macroOptions.find(
|
28
|
-
(option) => option.name === argType,
|
29
|
-
)?.description;
|
30
|
-
});
|
31
|
-
|
32
|
-
export default {
|
33
|
-
title: "Components/Textarea",
|
34
|
-
argTypes,
|
35
|
-
};
|
36
|
-
|
37
|
-
const Template = ({
|
38
|
-
label,
|
39
|
-
headingLevel,
|
40
|
-
headingSize,
|
41
|
-
id,
|
42
|
-
name,
|
43
|
-
hint,
|
44
|
-
value,
|
45
|
-
error,
|
46
|
-
spellcheck,
|
47
|
-
size,
|
48
|
-
rows,
|
49
|
-
inline,
|
50
|
-
formGroupClasses,
|
51
|
-
formGroupAttributes,
|
52
|
-
classes,
|
53
|
-
attributes,
|
54
|
-
}) =>
|
55
|
-
Textarea({
|
56
|
-
params: {
|
57
|
-
label,
|
58
|
-
headingLevel,
|
59
|
-
headingSize,
|
60
|
-
id,
|
61
|
-
name,
|
62
|
-
hint,
|
63
|
-
value,
|
64
|
-
error,
|
65
|
-
spellcheck,
|
66
|
-
size,
|
67
|
-
rows,
|
68
|
-
inline,
|
69
|
-
formGroupClasses,
|
70
|
-
formGroupAttributes,
|
71
|
-
classes,
|
72
|
-
attributes,
|
73
|
-
},
|
74
|
-
});
|
75
|
-
|
76
|
-
export const Standard = Template.bind({});
|
77
|
-
Standard.args = {
|
78
|
-
label: "Enter your feedback",
|
79
|
-
headingLevel: 4,
|
80
|
-
headingSize: "m",
|
81
|
-
id: "feedback1",
|
82
|
-
name: "feedback1",
|
83
|
-
classes: "tna-textarea--demo",
|
84
|
-
};
|
85
|
-
|
86
|
-
export const Predefined = Template.bind({});
|
87
|
-
Predefined.args = {
|
88
|
-
label: "Edit your feedback",
|
89
|
-
headingLevel: 4,
|
90
|
-
headingSize: "m",
|
91
|
-
id: "feedback2",
|
92
|
-
name: "feedback2",
|
93
|
-
value: "I like this 👍🏼",
|
94
|
-
classes: "tna-textarea--demo",
|
95
|
-
};
|
96
|
-
|
97
|
-
export const WithHint = Template.bind({});
|
98
|
-
WithHint.args = {
|
99
|
-
label: "Enter your feedback",
|
100
|
-
headingLevel: 4,
|
101
|
-
headingSize: "m",
|
102
|
-
id: "feedback3",
|
103
|
-
name: "feedback3",
|
104
|
-
hint: "What did you think?",
|
105
|
-
classes: "tna-textarea--demo",
|
106
|
-
};
|
107
|
-
|
108
|
-
export const Error = Template.bind({});
|
109
|
-
Error.args = {
|
110
|
-
label: "Enter your feedback",
|
111
|
-
headingLevel: 4,
|
112
|
-
headingSize: "m",
|
113
|
-
id: "feedback4",
|
114
|
-
name: "feedback4",
|
115
|
-
error: {
|
116
|
-
text: "Enter some feedback",
|
117
|
-
},
|
118
|
-
classes: "tna-textarea--demo",
|
119
|
-
};
|
120
|
-
|
121
|
-
export const Inline = Template.bind({});
|
122
|
-
Inline.args = {
|
123
|
-
label: "Enter your feedback",
|
124
|
-
headingLevel: 4,
|
125
|
-
headingSize: "xs",
|
126
|
-
id: "feedback5",
|
127
|
-
name: "feedback5",
|
128
|
-
inline: true,
|
129
|
-
classes: "tna-textarea--demo",
|
130
|
-
};
|