@amsterdam/design-system-react 0.15.0 → 0.16.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/README.md +1 -1
- package/dist/Accordion/Accordion.js +4 -1
- package/dist/Accordion/Accordion.test.js +19 -3
- package/dist/Accordion/AccordionSection.test.js +1 -1
- package/dist/ActionGroup/ActionGroup.test.js +1 -1
- package/dist/Alert/Alert.test.js +1 -1
- package/dist/Avatar/Avatar.test.js +1 -1
- package/dist/Badge/Badge.test.js +1 -1
- package/dist/Blockquote/Blockquote.test.js +3 -4
- package/dist/Breadcrumb/Breadcrumb.test.js +1 -1
- package/dist/Breadcrumb/BreadcrumbLink.test.js +1 -1
- package/dist/Breakout/Breakout.test.js +11 -19
- package/dist/Breakout/BreakoutCell.d.ts +3 -1
- package/dist/Breakout/BreakoutCell.js +1 -0
- package/dist/Breakout/BreakoutCell.test.js +20 -16
- package/dist/Button/Button.test.js +8 -1
- package/dist/Card/Card.d.ts +10 -0
- package/dist/Card/Card.js +8 -1
- package/dist/Card/Card.test.js +1 -1
- package/dist/Card/CardHeading.d.ts +11 -0
- package/dist/Card/CardHeading.js +10 -0
- package/dist/Card/CardHeading.test.js +34 -0
- package/dist/Card/CardHeadingGroup.test.js +1 -1
- package/dist/Card/CardImage.d.ts +7 -0
- package/dist/Card/CardImage.js +10 -0
- package/dist/{Footer/FooterSpotlight.test.js → Card/CardImage.test.js} +9 -9
- package/dist/Card/CardLink.test.js +1 -1
- package/dist/CharacterCount/CharacterCount.test.js +1 -1
- package/dist/Checkbox/Checkbox.test.js +2 -3
- package/dist/Column/Column.d.ts +4 -3
- package/dist/Column/Column.js +2 -1
- package/dist/Column/Column.test.js +10 -12
- package/dist/DateInput/DateInput.test.js +1 -1
- package/dist/DescriptionList/DescriptionList.test.js +1 -1
- package/dist/DescriptionList/DescriptionListDescription.test.js +1 -1
- package/dist/DescriptionList/DescriptionListSection.test.js +1 -1
- package/dist/DescriptionList/DescriptionListTerm.test.js +1 -1
- package/dist/Dialog/Dialog.test.js +1 -1
- package/dist/ErrorMessage/ErrorMessage.test.js +1 -1
- package/dist/Field/Field.test.js +1 -1
- package/dist/FieldSet/FieldSet.test.js +1 -1
- package/dist/Figure/Figure.test.js +1 -1
- package/dist/Figure/FigureCaption.test.js +1 -1
- package/dist/FileInput/FileInput.test.js +1 -1
- package/dist/FileList/FileList.test.js +1 -1
- package/dist/FileList/FileListItem.test.js +1 -1
- package/dist/Grid/Grid.d.ts +8 -5
- package/dist/Grid/Grid.js +2 -0
- package/dist/Grid/Grid.test.js +13 -29
- package/dist/Grid/GridCell.test.js +2 -8
- package/dist/Grid/paddingClasses.d.ts +2 -2
- package/dist/Heading/Heading.test.js +17 -11
- package/dist/Hint/Hint.test.js +1 -1
- package/dist/Icon/Icon.d.ts +1 -1
- package/dist/Icon/Icon.test.js +3 -4
- package/dist/IconButton/IconButton.js +1 -1
- package/dist/IconButton/IconButton.test.js +1 -1
- package/dist/Image/Image.d.ts +4 -8
- package/dist/Image/Image.test.js +1 -1
- package/dist/ImageSlider/ImageSlider.test.js +1 -1
- package/dist/ImageSlider/ImageSliderItem.test.js +1 -1
- package/dist/ImageSlider/ImageSliderScroller.test.js +1 -1
- package/dist/ImageSlider/ImageSliderThumbnails.js +1 -1
- package/dist/ImageSlider/ImageSliderThumbnails.test.js +1 -1
- package/dist/InvalidFormAlert/InvalidFormAlert.test.js +1 -1
- package/dist/Label/Label.test.js +3 -4
- package/dist/Link/Link.d.ts +0 -6
- package/dist/Link/Link.js +1 -1
- package/dist/Link/Link.test.js +22 -29
- package/dist/LinkList/LinkList.test.js +1 -1
- package/dist/LinkList/LinkListLink.test.js +1 -1
- package/dist/Logo/Logo.test.js +2 -3
- package/dist/Mark/Mark.test.js +1 -1
- package/dist/OrderedList/OrderedList.test.js +1 -1
- package/dist/OrderedList/OrderedListItem.test.js +1 -1
- package/dist/Overlap/Overlap.test.js +1 -1
- package/dist/{Footer/FooterSpotlight.d.ts → Page/Page.d.ts} +2 -2
- package/dist/Page/Page.js +9 -0
- package/dist/{MegaMenu/MegaMenu.test.js → Page/Page.test.js} +9 -9
- package/dist/Page/index.d.ts +2 -0
- package/dist/Page/index.js +1 -0
- package/dist/{Footer/Footer.d.ts → PageFooter/PageFooter.d.ts} +2 -2
- package/dist/PageFooter/PageFooter.js +17 -0
- package/dist/{Footer/Footer.test.js → PageFooter/PageFooter.test.js} +9 -9
- package/dist/{Footer/FooterMenu.d.ts → PageFooter/PageFooterMenu.d.ts} +2 -2
- package/dist/PageFooter/PageFooterMenu.js +9 -0
- package/dist/{Footer/FooterMenu.test.js → PageFooter/PageFooterMenu.test.js} +9 -9
- package/dist/{Footer/FooterMenuLink.d.ts → PageFooter/PageFooterMenuLink.d.ts} +2 -2
- package/dist/PageFooter/PageFooterMenuLink.js +9 -0
- package/dist/{Footer/FooterMenuLink.test.js → PageFooter/PageFooterMenuLink.test.js} +9 -9
- package/dist/PageFooter/PageFooterSpotlight.d.ts +9 -0
- package/dist/PageFooter/PageFooterSpotlight.js +9 -0
- package/dist/{MegaMenu/MegaMenuListCategory.test.js → PageFooter/PageFooterSpotlight.test.js} +9 -9
- package/dist/PageFooter/index.d.ts +5 -0
- package/dist/PageFooter/index.js +1 -0
- package/dist/{Header/Header.d.ts → PageHeader/PageHeader.d.ts} +4 -4
- package/dist/PageHeader/PageHeader.js +31 -0
- package/dist/{Header/Header.test.js → PageHeader/PageHeader.test.js} +37 -38
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.d.ts +2 -0
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.js +6 -0
- package/dist/{Header/HeaderGridCellNarrowWindowOnly.test.js → PageHeader/PageHeaderGridCellNarrowWindowOnly.test.js} +10 -10
- package/dist/PageHeader/PageHeaderMenuIcon.d.ts +2 -0
- package/dist/PageHeader/PageHeaderMenuIcon.js +2 -0
- package/dist/{Header/HeaderMenuLink.d.ts → PageHeader/PageHeaderMenuLink.d.ts} +2 -2
- package/dist/PageHeader/PageHeaderMenuLink.js +5 -0
- package/dist/{Header/HeaderMenuLink.test.js → PageHeader/PageHeaderMenuLink.test.js} +13 -13
- package/dist/PageHeader/index.d.ts +3 -0
- package/dist/PageHeader/index.js +1 -0
- package/dist/PageHeading/PageHeading.test.js +2 -3
- package/dist/Pagination/Pagination.test.js +1 -1
- package/dist/Paragraph/Paragraph.test.js +1 -1
- package/dist/PasswordInput/PasswordInput.test.js +1 -1
- package/dist/Radio/Radio.test.js +1 -1
- package/dist/Row/Row.d.ts +4 -3
- package/dist/Row/Row.js +2 -1
- package/dist/Row/Row.test.js +10 -12
- package/dist/SearchField/SearchField.d.ts +2 -0
- package/dist/SearchField/SearchField.test.js +2 -3
- package/dist/SearchField/SearchFieldInput.test.js +2 -3
- package/dist/Select/Select.test.js +1 -1
- package/dist/Select/SelectOption.test.js +1 -1
- package/dist/Select/SelectOptionGroup.test.js +1 -1
- package/dist/SkipLink/SkipLink.test.js +1 -1
- package/dist/Spotlight/Spotlight.d.ts +4 -2
- package/dist/Spotlight/Spotlight.js +1 -0
- package/dist/Spotlight/Spotlight.test.js +11 -9
- package/dist/StandaloneLink/StandaloneLink.d.ts +17 -0
- package/dist/StandaloneLink/StandaloneLink.js +10 -0
- package/dist/StandaloneLink/StandaloneLink.test.js +40 -0
- package/dist/StandaloneLink/index.d.ts +2 -0
- package/dist/StandaloneLink/index.js +1 -0
- package/dist/Switch/Switch.test.js +1 -1
- package/dist/Table/Table.test.js +1 -1
- package/dist/Table/TableBody.test.js +1 -1
- package/dist/Table/TableCaption.test.js +1 -1
- package/dist/Table/TableCell.test.js +1 -1
- package/dist/Table/TableFooter.test.js +1 -1
- package/dist/Table/TableHeader.test.js +1 -1
- package/dist/Table/TableHeaderCell.test.js +1 -1
- package/dist/Table/TableRow.test.js +1 -1
- package/dist/TableOfContents/TableOfContents.test.js +1 -1
- package/dist/TableOfContents/TableOfContentsLink.test.js +1 -1
- package/dist/TableOfContents/TableOfContentsList.test.js +1 -1
- package/dist/Tabs/Tabs.d.ts +6 -6
- package/dist/Tabs/Tabs.js +4 -5
- package/dist/Tabs/Tabs.test.js +21 -6
- package/dist/Tabs/TabsButton.d.ts +4 -4
- package/dist/Tabs/TabsButton.js +4 -4
- package/dist/Tabs/TabsButton.test.js +10 -10
- package/dist/Tabs/TabsContext.d.ts +2 -7
- package/dist/Tabs/TabsContext.js +0 -1
- package/dist/Tabs/TabsList.js +1 -1
- package/dist/Tabs/TabsList.test.js +1 -1
- package/dist/Tabs/TabsPanel.d.ts +4 -4
- package/dist/Tabs/TabsPanel.js +4 -4
- package/dist/Tabs/TabsPanel.test.js +10 -12
- package/dist/TextArea/TextArea.test.js +1 -1
- package/dist/TextInput/TextInput.test.js +2 -3
- package/dist/TimeInput/TimeInput.test.js +1 -1
- package/dist/UnorderedList/UnorderedList.test.js +1 -1
- package/dist/UnorderedList/UnorderedListItem.test.js +1 -1
- package/dist/common/accessibility.d.ts +9 -1
- package/dist/index.cjs.js +1000 -1057
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +164 -194
- package/dist/index.esm.js +998 -1053
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/dist/Footer/Footer.js +0 -17
- package/dist/Footer/FooterMenu.js +0 -9
- package/dist/Footer/FooterMenuLink.js +0 -9
- package/dist/Footer/FooterSpotlight.js +0 -9
- package/dist/Footer/index.d.ts +0 -5
- package/dist/Footer/index.js +0 -1
- package/dist/Header/Header.js +0 -31
- package/dist/Header/HeaderGridCellNarrowWindowOnly.d.ts +0 -2
- package/dist/Header/HeaderGridCellNarrowWindowOnly.js +0 -6
- package/dist/Header/HeaderMenuIcon.d.ts +0 -2
- package/dist/Header/HeaderMenuIcon.js +0 -2
- package/dist/Header/HeaderMenuLink.js +0 -5
- package/dist/Header/index.d.ts +0 -3
- package/dist/Header/index.js +0 -1
- package/dist/MegaMenu/MegaMenu.d.ts +0 -14
- package/dist/MegaMenu/MegaMenu.js +0 -12
- package/dist/MegaMenu/MegaMenuListCategory.d.ts +0 -9
- package/dist/MegaMenu/MegaMenuListCategory.js +0 -9
- package/dist/MegaMenu/index.d.ts +0 -3
- package/dist/MegaMenu/index.js +0 -1
- package/dist/PageMenu/PageMenu.d.ts +0 -25
- package/dist/PageMenu/PageMenu.js +0 -12
- package/dist/PageMenu/PageMenu.test.js +0 -45
- package/dist/PageMenu/PageMenuLink.d.ts +0 -13
- package/dist/PageMenu/PageMenuLink.js +0 -10
- package/dist/PageMenu/PageMenuLink.test.js +0 -40
- package/dist/PageMenu/index.d.ts +0 -3
- package/dist/PageMenu/index.js +0 -1
- package/dist/Screen/Screen.d.ts +0 -21
- package/dist/Screen/Screen.js +0 -9
- package/dist/Screen/Screen.test.d.ts +0 -1
- package/dist/Screen/Screen.test.js +0 -40
- package/dist/Screen/index.d.ts +0 -2
- package/dist/Screen/index.js +0 -1
- package/dist/TopTaskLink/TopTaskLink.d.ts +0 -17
- package/dist/TopTaskLink/TopTaskLink.js +0 -9
- package/dist/TopTaskLink/TopTaskLink.test.d.ts +0 -1
- package/dist/TopTaskLink/TopTaskLink.test.js +0 -42
- package/dist/TopTaskLink/index.d.ts +0 -1
- package/dist/TopTaskLink/index.js +0 -1
- /package/dist/{Footer/Footer.test.d.ts → Card/CardHeading.test.d.ts} +0 -0
- /package/dist/{Footer/FooterMenu.test.d.ts → Card/CardImage.test.d.ts} +0 -0
- /package/dist/{Footer/FooterMenuLink.test.d.ts → Page/Page.test.d.ts} +0 -0
- /package/dist/{Footer/FooterSpotlight.test.d.ts → PageFooter/PageFooter.test.d.ts} +0 -0
- /package/dist/{Header/HeaderGridCellNarrowWindowOnly.test.d.ts → PageFooter/PageFooterMenu.test.d.ts} +0 -0
- /package/dist/{Header/HeaderMenuLink.test.d.ts → PageFooter/PageFooterMenuLink.test.d.ts} +0 -0
- /package/dist/{MegaMenu/MegaMenu.test.d.ts → PageFooter/PageFooterSpotlight.test.d.ts} +0 -0
- /package/dist/{Header/Header.test.d.ts → PageHeader/PageHeader.test.d.ts} +0 -0
- /package/dist/{MegaMenu/MegaMenuListCategory.test.d.ts → PageHeader/PageHeaderGridCellNarrowWindowOnly.test.d.ts} +0 -0
- /package/dist/{PageMenu/PageMenu.test.d.ts → PageHeader/PageHeaderMenuLink.test.d.ts} +0 -0
- /package/dist/{Header → PageHeader}/matchMedia.mock.d.ts +0 -0
- /package/dist/{Header → PageHeader}/matchMedia.mock.js +0 -0
- /package/dist/{PageMenu/PageMenuLink.test.d.ts → StandaloneLink/StandaloneLink.test.d.ts} +0 -0
|
@@ -2,82 +2,81 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { createRef } from 'react';
|
|
5
|
-
import './matchMedia.mock'; // Must be imported before
|
|
6
|
-
import {
|
|
5
|
+
import './matchMedia.mock'; // Must be imported before PageHeader
|
|
6
|
+
import { PageHeader } from './PageHeader';
|
|
7
7
|
import '@testing-library/jest-dom';
|
|
8
|
-
describe('Header', () => {
|
|
8
|
+
describe('Page Header', () => {
|
|
9
9
|
it('renders', () => {
|
|
10
|
-
render(_jsx(
|
|
10
|
+
render(_jsx(PageHeader, {}));
|
|
11
11
|
const component = screen.getByRole('banner');
|
|
12
12
|
expect(component).toBeInTheDocument();
|
|
13
13
|
expect(component).toBeVisible();
|
|
14
14
|
});
|
|
15
15
|
it('renders a design system BEM class name', () => {
|
|
16
|
-
render(_jsx(
|
|
16
|
+
render(_jsx(PageHeader, {}));
|
|
17
17
|
const component = screen.getByRole('banner');
|
|
18
|
-
expect(component).toHaveClass('ams-header');
|
|
18
|
+
expect(component).toHaveClass('ams-page-header');
|
|
19
19
|
});
|
|
20
|
-
it('renders an
|
|
21
|
-
render(_jsx(
|
|
20
|
+
it('renders an extra class name', () => {
|
|
21
|
+
render(_jsx(PageHeader, { className: "extra" }));
|
|
22
22
|
const component = screen.getByRole('banner');
|
|
23
|
-
expect(component).toHaveClass('extra');
|
|
24
|
-
expect(component).toHaveClass('ams-header');
|
|
23
|
+
expect(component).toHaveClass('ams-page-header extra');
|
|
25
24
|
});
|
|
26
25
|
it('supports ForwardRef in React', () => {
|
|
27
26
|
const ref = createRef();
|
|
28
|
-
render(_jsx(
|
|
27
|
+
render(_jsx(PageHeader, { ref: ref }));
|
|
29
28
|
const component = screen.getByRole('banner');
|
|
30
29
|
expect(ref.current).toBe(component);
|
|
31
30
|
});
|
|
32
31
|
it('renders a logo link', () => {
|
|
33
|
-
render(_jsx(
|
|
32
|
+
render(_jsx(PageHeader, {}));
|
|
34
33
|
const component = screen.getByRole('link');
|
|
35
|
-
expect(component).toHaveClass('ams-header__logo-link');
|
|
34
|
+
expect(component).toHaveClass('ams-page-header__logo-link');
|
|
36
35
|
});
|
|
37
36
|
it('renders a different brand logo', () => {
|
|
38
|
-
const { container } = render(_jsx(
|
|
37
|
+
const { container } = render(_jsx(PageHeader, { logoBrand: "ggd-amsterdam" }));
|
|
39
38
|
const component = container.querySelector('.ams-logo__text-secondary');
|
|
40
39
|
expect(component).toBeInTheDocument();
|
|
41
40
|
});
|
|
42
41
|
it('renders a custom logo link', () => {
|
|
43
|
-
render(_jsx(
|
|
42
|
+
render(_jsx(PageHeader, { logoLink: "/home" }));
|
|
44
43
|
const logoLink = screen.getByRole('link');
|
|
45
44
|
expect(logoLink).toHaveAttribute('href', '/home');
|
|
46
45
|
});
|
|
47
46
|
it('renders a custom logo link title', () => {
|
|
48
|
-
render(_jsx(
|
|
47
|
+
render(_jsx(PageHeader, { logoLinkTitle: "Go to homepage" }));
|
|
49
48
|
const logoLinkTitle = screen.getByRole('link', { name: 'Go to homepage' });
|
|
50
49
|
expect(logoLinkTitle).toBeInTheDocument();
|
|
51
50
|
});
|
|
52
51
|
it('renders an application name', () => {
|
|
53
|
-
render(_jsx(
|
|
52
|
+
render(_jsx(PageHeader, { brandName: "Application name" }));
|
|
54
53
|
const brandName = screen.getByText('Application name');
|
|
55
54
|
expect(brandName).toBeInTheDocument();
|
|
56
55
|
});
|
|
57
56
|
it('renders the correct class for the responsive logo', () => {
|
|
58
|
-
const { container } = render(_jsx(
|
|
59
|
-
const logoContainer = container.querySelector('.ams-header__logo-container');
|
|
57
|
+
const { container } = render(_jsx(PageHeader, { brandName: "Application name" }));
|
|
58
|
+
const logoContainer = container.querySelector('.ams-page-header__logo-container');
|
|
60
59
|
expect(logoContainer).toBeInTheDocument();
|
|
61
60
|
});
|
|
62
61
|
it('renders a nav section', () => {
|
|
63
|
-
render(_jsx(
|
|
62
|
+
render(_jsx(PageHeader, { children: "Test" }));
|
|
64
63
|
const component = screen.getByRole('navigation');
|
|
65
|
-
expect(component).toHaveClass('ams-header__navigation');
|
|
64
|
+
expect(component).toHaveClass('ams-page-header__navigation');
|
|
66
65
|
});
|
|
67
66
|
it('renders a nav section with a custom label', () => {
|
|
68
|
-
render(_jsx(
|
|
67
|
+
render(_jsx(PageHeader, { navigationLabel: "Custom Navigation", children: "Test" }));
|
|
69
68
|
const component = screen.getByRole('navigation', { name: 'Custom Navigation' });
|
|
70
69
|
expect(component).toBeInTheDocument();
|
|
71
70
|
});
|
|
72
71
|
it('renders a menu', () => {
|
|
73
|
-
render(_jsx(
|
|
72
|
+
render(_jsx(PageHeader, { menuItems: _jsx(PageHeader.MenuLink, { children: "Menu Item" }) }));
|
|
74
73
|
const component = screen.getByRole('list');
|
|
75
|
-
expect(component).toHaveClass('ams-header__menu');
|
|
74
|
+
expect(component).toHaveClass('ams-page-header__menu');
|
|
76
75
|
});
|
|
77
76
|
it('renders menu items', () => {
|
|
78
|
-
render(_jsx(
|
|
79
|
-
_jsx(
|
|
80
|
-
_jsx(
|
|
77
|
+
render(_jsx(PageHeader, { menuItems: [
|
|
78
|
+
_jsx(PageHeader.MenuLink, { href: "/", children: "Menu Item 1" }, 1),
|
|
79
|
+
_jsx(PageHeader.MenuLink, { href: "/", children: "Menu Item 2" }, 2),
|
|
81
80
|
] }));
|
|
82
81
|
const item1 = screen.getByRole('link', { name: 'Menu Item 1' });
|
|
83
82
|
const item2 = screen.getByRole('link', { name: 'Menu Item 2' });
|
|
@@ -85,35 +84,35 @@ describe('Header', () => {
|
|
|
85
84
|
expect(item2).toBeInTheDocument();
|
|
86
85
|
});
|
|
87
86
|
it('renders a menu button', () => {
|
|
88
|
-
render(_jsx(
|
|
87
|
+
render(_jsx(PageHeader, { children: "Test" }));
|
|
89
88
|
const component = screen.getByRole('button', { name: 'Menu' });
|
|
90
|
-
expect(component).toHaveClass('ams-header__mega-menu-button');
|
|
89
|
+
expect(component).toHaveClass('ams-page-header__mega-menu-button');
|
|
91
90
|
});
|
|
92
91
|
it('renders a menu button icon', () => {
|
|
93
|
-
const { container } = render(_jsx(
|
|
94
|
-
const component = container.querySelector('.ams-header__menu-icon');
|
|
92
|
+
const { container } = render(_jsx(PageHeader, { children: "Test" }));
|
|
93
|
+
const component = container.querySelector('.ams-page-header__menu-icon');
|
|
95
94
|
expect(component).toBeInTheDocument();
|
|
96
95
|
});
|
|
97
96
|
it('renders a custom menu button text', () => {
|
|
98
|
-
render(_jsx(
|
|
97
|
+
render(_jsx(PageHeader, { menuButtonText: "Custom button text", children: "Test" }));
|
|
99
98
|
const component = screen.getByRole('button', { name: 'Custom button text' });
|
|
100
99
|
expect(component).toBeInTheDocument();
|
|
101
100
|
});
|
|
102
101
|
it('renders the correct class when noMenuButtonOnWideWindow is true', () => {
|
|
103
|
-
render(_jsx(
|
|
102
|
+
render(_jsx(PageHeader, { noMenuButtonOnWideWindow: true, children: "Test" }));
|
|
104
103
|
const component = screen.getByRole('listitem');
|
|
105
|
-
expect(component).toHaveClass('ams-header__mega-menu-button-item--hide-on-wide-window');
|
|
104
|
+
expect(component).toHaveClass('ams-page-header__mega-menu-button-item--hide-on-wide-window');
|
|
106
105
|
});
|
|
107
106
|
it('opens and closes the mega menu', async () => {
|
|
108
107
|
const user = userEvent.setup();
|
|
109
|
-
const { container } = render(_jsx(
|
|
110
|
-
const closedMegaMenu = container.querySelector('.ams-header__mega-menu--closed');
|
|
108
|
+
const { container } = render(_jsx(PageHeader, { children: "Test" }));
|
|
109
|
+
const closedMegaMenu = container.querySelector('.ams-page-header__mega-menu--closed');
|
|
111
110
|
expect(closedMegaMenu).toBeInTheDocument();
|
|
112
111
|
const menuButton = screen.getByRole('button', { name: 'Menu' });
|
|
113
112
|
await user.click(menuButton);
|
|
114
|
-
const openMegaMenu = container.querySelector('.ams-header__mega-menu');
|
|
113
|
+
const openMegaMenu = container.querySelector('.ams-page-header__mega-menu');
|
|
115
114
|
expect(openMegaMenu).toBeInTheDocument();
|
|
116
|
-
expect(openMegaMenu).not.toHaveClass('ams-header__mega-menu--closed');
|
|
115
|
+
expect(openMegaMenu).not.toHaveClass('ams-page-header__mega-menu--closed');
|
|
117
116
|
});
|
|
118
117
|
it.skip('it closes the mega menu when it is open and the screen width passes the breakpoint', () => {
|
|
119
118
|
// TODO: Add this test
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { Grid } from '../Grid';
|
|
5
|
+
export const PageHeaderGridCellNarrowWindowOnly = forwardRef(({ children, className, ...restProps }, ref) => (_jsx(Grid.Cell, { ...restProps, className: clsx('ams-page-header__grid-cell-narrow-window-only', className), ref: ref, children: children })));
|
|
6
|
+
PageHeaderGridCellNarrowWindowOnly.displayName = 'PageHeader.GridCellNarrowWindowOnly';
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { createRef } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { PageHeaderGridCellNarrowWindowOnly } from './PageHeaderGridCellNarrowWindowOnly';
|
|
5
5
|
import '@testing-library/jest-dom';
|
|
6
|
-
describe('Header
|
|
6
|
+
describe('Page Header Grid Cell Narrow Window Only', () => {
|
|
7
7
|
it('renders', () => {
|
|
8
|
-
const { container } = render(_jsx(
|
|
8
|
+
const { container } = render(_jsx(PageHeaderGridCellNarrowWindowOnly, {}));
|
|
9
9
|
const component = container.querySelector(':only-child');
|
|
10
10
|
expect(component).toBeInTheDocument();
|
|
11
11
|
expect(component).toBeVisible();
|
|
12
12
|
});
|
|
13
13
|
it('renders a Grid.Cell', () => {
|
|
14
|
-
const { container } = render(_jsx(
|
|
14
|
+
const { container } = render(_jsx(PageHeaderGridCellNarrowWindowOnly, {}));
|
|
15
15
|
const component = container.querySelector(':only-child');
|
|
16
16
|
expect(component).toHaveClass('ams-grid__cell');
|
|
17
17
|
});
|
|
18
18
|
it('renders a design system BEM class name', () => {
|
|
19
|
-
const { container } = render(_jsx(
|
|
19
|
+
const { container } = render(_jsx(PageHeaderGridCellNarrowWindowOnly, {}));
|
|
20
20
|
const component = container.querySelector(':only-child');
|
|
21
|
-
expect(component).toHaveClass('ams-header__grid-cell-narrow-window-only');
|
|
21
|
+
expect(component).toHaveClass('ams-page-header__grid-cell-narrow-window-only');
|
|
22
22
|
});
|
|
23
|
-
it('renders an
|
|
24
|
-
const { container } = render(_jsx(
|
|
23
|
+
it('renders an extra class name', () => {
|
|
24
|
+
const { container } = render(_jsx(PageHeaderGridCellNarrowWindowOnly, { className: "extra" }));
|
|
25
25
|
const component = container.querySelector(':only-child');
|
|
26
|
-
expect(component).toHaveClass('ams-header__grid-cell-narrow-window-only extra');
|
|
26
|
+
expect(component).toHaveClass('ams-page-header__grid-cell-narrow-window-only extra');
|
|
27
27
|
});
|
|
28
28
|
it('supports ForwardRef in React', () => {
|
|
29
29
|
const ref = createRef();
|
|
30
|
-
const { container } = render(_jsx(
|
|
30
|
+
const { container } = render(_jsx(PageHeaderGridCellNarrowWindowOnly, { ref: ref }));
|
|
31
31
|
const component = container.querySelector(':only-child');
|
|
32
32
|
expect(ref.current).toBe(component);
|
|
33
33
|
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const PageHeaderMenuIcon = (props) => (_jsxs("svg", { "aria-hidden": "true", focusable: "false", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...props, children: [_jsx("line", { className: "ams-page-header__menu-icon-top", x1: "0", x2: "100%", y1: "50%", y2: "50%" }), _jsx("line", { className: "ams-page-header__menu-icon-middle", x1: "0", x2: "100%", y1: "50%", y2: "50%" }), _jsx("line", { className: "ams-page-header__menu-icon-bottom", x1: "0", x2: "100%", y1: "50%", y2: "50%" })] }));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, PropsWithChildren } from 'react';
|
|
2
|
-
export type
|
|
2
|
+
export type PageHeaderMenuLinkProps = {
|
|
3
3
|
fixed?: boolean;
|
|
4
4
|
} & PropsWithChildren<AnchorHTMLAttributes<HTMLAnchorElement>>;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const PageHeaderMenuLink: import("react").ForwardRefExoticComponent<{
|
|
6
6
|
fixed?: boolean;
|
|
7
7
|
} & AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
8
8
|
children?: import("react").ReactNode | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
export const PageHeaderMenuLink = forwardRef(({ children, className, fixed, ...restProps }, ref) => (_jsx("li", { className: clsx('ams-page-header__menu-item', fixed && 'ams-page-header__menu-item--fixed'), children: _jsx("a", { ...restProps, className: clsx('ams-page-header__menu-link', className), ref: ref, children: children }) })));
|
|
5
|
+
PageHeaderMenuLink.displayName = 'PageHeader.MenuLink';
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { createRef } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { PageHeaderMenuLink } from './PageHeaderMenuLink';
|
|
5
5
|
import '@testing-library/jest-dom';
|
|
6
|
-
describe('Header
|
|
6
|
+
describe('Page Header Menu Link', () => {
|
|
7
7
|
it('renders', () => {
|
|
8
|
-
render(_jsx(
|
|
8
|
+
render(_jsx(PageHeaderMenuLink, { href: "/" }));
|
|
9
9
|
const component = screen.getByRole('listitem');
|
|
10
10
|
expect(component).toBeInTheDocument();
|
|
11
11
|
expect(component).toBeVisible();
|
|
12
12
|
});
|
|
13
13
|
it('renders a design system BEM class name', () => {
|
|
14
|
-
render(_jsx(
|
|
14
|
+
render(_jsx(PageHeaderMenuLink, { href: "/" }));
|
|
15
15
|
const item = screen.getByRole('listitem');
|
|
16
|
-
expect(item).toHaveClass('ams-header__menu-item');
|
|
16
|
+
expect(item).toHaveClass('ams-page-header__menu-item');
|
|
17
17
|
const link = screen.getByRole('link');
|
|
18
|
-
expect(link).toHaveClass('ams-header__menu-link');
|
|
18
|
+
expect(link).toHaveClass('ams-page-header__menu-link');
|
|
19
19
|
});
|
|
20
|
-
it('renders an
|
|
21
|
-
render(_jsx(
|
|
20
|
+
it('renders an extra class name', () => {
|
|
21
|
+
render(_jsx(PageHeaderMenuLink, { className: "extra", href: "/" }));
|
|
22
22
|
const component = screen.getByRole('link');
|
|
23
|
-
expect(component).toHaveClass('ams-header__menu-link extra');
|
|
23
|
+
expect(component).toHaveClass('ams-page-header__menu-link extra');
|
|
24
24
|
});
|
|
25
25
|
it('renders the href attribute', () => {
|
|
26
|
-
render(_jsx(
|
|
26
|
+
render(_jsx(PageHeaderMenuLink, { href: "/" }));
|
|
27
27
|
const component = screen.getByRole('link');
|
|
28
28
|
expect(component).toHaveAttribute('href', '/');
|
|
29
29
|
});
|
|
30
30
|
it('renders the ‘fixed’ prop classname', () => {
|
|
31
|
-
render(_jsx(
|
|
31
|
+
render(_jsx(PageHeaderMenuLink, { fixed: true, href: "/" }));
|
|
32
32
|
const component = screen.getByRole('listitem');
|
|
33
|
-
expect(component).toHaveClass('ams-header__menu-item--fixed');
|
|
33
|
+
expect(component).toHaveClass('ams-page-header__menu-item--fixed');
|
|
34
34
|
});
|
|
35
35
|
it('supports ForwardRef in React', () => {
|
|
36
36
|
const ref = createRef();
|
|
37
|
-
render(_jsx(
|
|
37
|
+
render(_jsx(PageHeaderMenuLink, { href: "/", ref: ref }));
|
|
38
38
|
const component = screen.getByRole('link');
|
|
39
39
|
expect(ref.current).toBe(component);
|
|
40
40
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PageHeader } from './PageHeader';
|
|
@@ -17,11 +17,10 @@ describe('Page heading', () => {
|
|
|
17
17
|
const component = container.querySelector(':only-child');
|
|
18
18
|
expect(component).toHaveClass('ams-page-heading');
|
|
19
19
|
});
|
|
20
|
-
it('renders an
|
|
20
|
+
it('renders an extra class name', () => {
|
|
21
21
|
const { container } = render(_jsx(PageHeading, { className: "extra" }));
|
|
22
22
|
const component = container.querySelector(':only-child');
|
|
23
|
-
expect(component).toHaveClass('extra');
|
|
24
|
-
expect(component).toHaveClass('ams-page-heading');
|
|
23
|
+
expect(component).toHaveClass('ams-page-heading extra');
|
|
25
24
|
});
|
|
26
25
|
it('renders the class name for inverse color', () => {
|
|
27
26
|
render(_jsx(PageHeading, { color: "inverse", children: "Titel" }));
|
|
@@ -16,7 +16,7 @@ describe('Pagination', () => {
|
|
|
16
16
|
const component = screen.getByRole('navigation', { name: 'Paginering' });
|
|
17
17
|
expect(component).toHaveClass('ams-pagination');
|
|
18
18
|
});
|
|
19
|
-
it('
|
|
19
|
+
it('renders an extra class name', () => {
|
|
20
20
|
render(_jsx(Pagination, { className: "extra", linkTemplate: linkTemplate, totalPages: 10 }));
|
|
21
21
|
const component = screen.getByRole('navigation', { name: 'Paginering' });
|
|
22
22
|
expect(component).toHaveClass('ams-pagination extra');
|
|
@@ -43,7 +43,7 @@ describe('Paragraph', () => {
|
|
|
43
43
|
const paragraph = screen.getByText('Paragraph');
|
|
44
44
|
expect(paragraph).toHaveClass('ams-paragraph--inverse');
|
|
45
45
|
});
|
|
46
|
-
it('renders an
|
|
46
|
+
it('renders an extra class name', () => {
|
|
47
47
|
const { container } = render(_jsx(Paragraph, { className: "intro" }));
|
|
48
48
|
const paragraph = container.querySelector(':only-child');
|
|
49
49
|
expect(paragraph).toHaveClass('intro');
|
|
@@ -17,7 +17,7 @@ describe('Password input', () => {
|
|
|
17
17
|
const component = container.querySelector(':only-child');
|
|
18
18
|
expect(component).toHaveClass('ams-password-input');
|
|
19
19
|
});
|
|
20
|
-
it('renders an
|
|
20
|
+
it('renders an extra class name', () => {
|
|
21
21
|
const { container } = render(_jsx(PasswordInput, { className: "extra" }));
|
|
22
22
|
const component = container.querySelector(':only-child');
|
|
23
23
|
expect(component).toHaveClass('ams-password-input extra');
|
package/dist/Radio/Radio.test.js
CHANGED
|
@@ -30,7 +30,7 @@ describe('Radio', () => {
|
|
|
30
30
|
expect(circle).toBeInTheDocument();
|
|
31
31
|
expect(indicator).toBeInTheDocument();
|
|
32
32
|
});
|
|
33
|
-
it('renders an
|
|
33
|
+
it('renders an extra class name', () => {
|
|
34
34
|
const { container } = render(_jsx(Radio, { className: "extra" }));
|
|
35
35
|
const wrapper = container.querySelector(':only-child');
|
|
36
36
|
expect(wrapper).toHaveClass('ams-radio extra');
|
package/dist/Row/Row.d.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
6
|
import type { CrossAlign, MainAlign } from '../common/types';
|
|
7
|
-
export declare const
|
|
8
|
-
type
|
|
9
|
-
|
|
7
|
+
export declare const rowTags: readonly ["article", "div", "section"];
|
|
8
|
+
type RowTag = (typeof rowTags)[number];
|
|
9
|
+
export declare const rowGapSizes: readonly ["none", "x-small", "small", "large", "x-large"];
|
|
10
|
+
type RowGap = (typeof rowGapSizes)[number];
|
|
10
11
|
export type RowProps = {
|
|
11
12
|
/**
|
|
12
13
|
* The horizontal alignment of the items in the row.
|
package/dist/Row/Row.js
CHANGED
|
@@ -5,6 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
|
-
export const
|
|
8
|
+
export const rowTags = ['article', 'div', 'section'];
|
|
9
|
+
export const rowGapSizes = ['none', 'x-small', 'small', 'large', 'x-large'];
|
|
9
10
|
export const Row = forwardRef(({ align, alignVertical, as: Tag = 'div', children, className, gap, wrap, ...restProps }, ref) => (_jsx(Tag, { ...restProps, className: clsx('ams-row', align && `ams-row--align-${align}`, alignVertical && `ams-row--align-vertical-${alignVertical}`, gap && `ams-row--gap-${gap}`, wrap && 'ams-row--wrap', className), ref: ref, children: children })));
|
|
10
11
|
Row.displayName = 'Row';
|
package/dist/Row/Row.test.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { createRef } from 'react';
|
|
4
|
-
import { Row,
|
|
4
|
+
import { Row, rowGapSizes, rowTags } from './Row';
|
|
5
|
+
import { ariaRoleForTag } from '../common/accessibility';
|
|
5
6
|
import { crossAlignOptions, mainAlignOptions } from '../common/types';
|
|
6
7
|
import '@testing-library/jest-dom';
|
|
7
8
|
describe('Row', () => {
|
|
@@ -16,12 +17,12 @@ describe('Row', () => {
|
|
|
16
17
|
const component = container.querySelector(':only-child');
|
|
17
18
|
expect(component).toHaveClass('ams-row');
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
+
rowGapSizes.map((gap) => it(`renders with ‘${gap}’ gap`, () => {
|
|
20
21
|
const { container } = render(_jsx(Row, { gap: gap }));
|
|
21
22
|
const component = container.querySelector(':only-child');
|
|
22
23
|
expect(component).toHaveClass(`ams-row--gap-${gap}`);
|
|
23
24
|
}));
|
|
24
|
-
it('renders an
|
|
25
|
+
it('renders an extra class name', () => {
|
|
25
26
|
const { container } = render(_jsx(Row, { className: "extra" }));
|
|
26
27
|
const component = container.querySelector(':only-child');
|
|
27
28
|
expect(component).toHaveClass('ams-row extra');
|
|
@@ -31,15 +32,12 @@ describe('Row', () => {
|
|
|
31
32
|
const component = container.querySelector(':only-child');
|
|
32
33
|
expect(component).toHaveClass('ams-row--wrap');
|
|
33
34
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const { container } = render(_jsx(Row, { as: "section" }));
|
|
41
|
-
const component = container.querySelector('section');
|
|
42
|
-
expect(component).toBeInTheDocument();
|
|
35
|
+
rowTags.forEach((tag) => {
|
|
36
|
+
it(`renders with a custom ${tag} tag`, () => {
|
|
37
|
+
const { container } = render(_jsx(Row, { "aria-label": tag === 'section' ? 'Accessible name' : undefined, as: tag }));
|
|
38
|
+
const component = tag === 'div' ? container.querySelector(tag) : screen.getByRole(ariaRoleForTag[tag]);
|
|
39
|
+
expect(component).toBeInTheDocument();
|
|
40
|
+
});
|
|
43
41
|
});
|
|
44
42
|
it('supports ForwardRef in React', () => {
|
|
45
43
|
const ref = createRef();
|
|
@@ -58,6 +58,8 @@ export declare const SearchField: import("react").ForwardRefExoticComponent<HTML
|
|
|
58
58
|
unselectable?: "on" | "off" | undefined | undefined;
|
|
59
59
|
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
60
60
|
is?: string | undefined | undefined;
|
|
61
|
+
exportparts?: string | undefined | undefined;
|
|
62
|
+
part?: string | undefined | undefined;
|
|
61
63
|
"aria-activedescendant"?: string | undefined | undefined;
|
|
62
64
|
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
63
65
|
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
@@ -32,11 +32,10 @@ describe('Search field', () => {
|
|
|
32
32
|
const component = screen.getByRole('search');
|
|
33
33
|
expect(component).toHaveClass('ams-search-field');
|
|
34
34
|
});
|
|
35
|
-
it('renders an
|
|
35
|
+
it('renders an extra class name', () => {
|
|
36
36
|
render(_jsx(SearchField, { className: "extra" }));
|
|
37
37
|
const component = screen.getByRole('search');
|
|
38
|
-
expect(component).toHaveClass('extra');
|
|
39
|
-
expect(component).toHaveClass('ams-search-field');
|
|
38
|
+
expect(component).toHaveClass('ams-search-field extra');
|
|
40
39
|
});
|
|
41
40
|
it('supports ForwardRef in React', () => {
|
|
42
41
|
const ref = createRef();
|
|
@@ -16,11 +16,10 @@ describe('Search field input', () => {
|
|
|
16
16
|
const component = screen.getByRole('searchbox', { name: 'Zoeken' });
|
|
17
17
|
expect(component).toHaveClass('ams-search-field__input');
|
|
18
18
|
});
|
|
19
|
-
it('renders an
|
|
19
|
+
it('renders an extra class name', () => {
|
|
20
20
|
render(_jsx(SearchFieldInput, { className: "extra" }));
|
|
21
21
|
const component = screen.getByRole('searchbox', { name: 'Zoeken' });
|
|
22
|
-
expect(component).toHaveClass('extra');
|
|
23
|
-
expect(component).toHaveClass('ams-search-field__input');
|
|
22
|
+
expect(component).toHaveClass('ams-search-field__input extra');
|
|
24
23
|
});
|
|
25
24
|
it('supports a custom label', () => {
|
|
26
25
|
render(_jsx(SearchFieldInput, { label: "Test label" }));
|
|
@@ -15,7 +15,7 @@ describe('Select', () => {
|
|
|
15
15
|
const component = screen.getByRole('combobox');
|
|
16
16
|
expect(component).toHaveClass('ams-select');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
render(_jsx(Select, { className: "extra" }));
|
|
20
20
|
const component = screen.getByRole('combobox');
|
|
21
21
|
expect(component).toHaveClass('ams-select extra');
|
|
@@ -22,7 +22,7 @@ describe('Select option', () => {
|
|
|
22
22
|
const component = screen.getByRole('option');
|
|
23
23
|
expect(component).toHaveClass('ams-select__option');
|
|
24
24
|
});
|
|
25
|
-
it('renders an
|
|
25
|
+
it('renders an extra class name', () => {
|
|
26
26
|
render(_jsx(Select.Option, { className: "extra" }));
|
|
27
27
|
const component = screen.getByRole('option');
|
|
28
28
|
expect(component).toHaveClass('ams-select__option extra');
|
|
@@ -22,7 +22,7 @@ describe('Select option group', () => {
|
|
|
22
22
|
const component = screen.getByRole('group');
|
|
23
23
|
expect(component).toHaveClass('ams-select__group');
|
|
24
24
|
});
|
|
25
|
-
it('renders an
|
|
25
|
+
it('renders an extra class name', () => {
|
|
26
26
|
render(_jsx(Select.Group, { className: "extra" }));
|
|
27
27
|
const component = screen.getByRole('group');
|
|
28
28
|
expect(component).toHaveClass('ams-select__group extra');
|
|
@@ -15,7 +15,7 @@ describe('Skip link', () => {
|
|
|
15
15
|
const component = screen.getByRole('link');
|
|
16
16
|
expect(component).toHaveClass('ams-skip-link');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
render(_jsx(SkipLink, { className: "extra", href: "/" }));
|
|
20
20
|
const component = screen.getByRole('link');
|
|
21
21
|
expect(component).toHaveClass('ams-skip-link extra');
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
* Copyright Gemeente Amsterdam
|
|
4
4
|
*/
|
|
5
5
|
import { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
|
+
export declare const spotlightTags: readonly ["article", "aside", "div", "footer", "section"];
|
|
7
|
+
type SpotlightTag = (typeof spotlightTags)[number];
|
|
6
8
|
export declare const spotlightColors: readonly ["azure", "green", "lime", "magenta", "orange", "yellow"];
|
|
7
9
|
type SpotlightColor = (typeof spotlightColors)[number];
|
|
8
10
|
export type SpotlightProps = {
|
|
9
11
|
/** The HTML element to use. */
|
|
10
|
-
as?:
|
|
12
|
+
as?: SpotlightTag;
|
|
11
13
|
/** The background colour. */
|
|
12
14
|
color?: SpotlightColor;
|
|
13
15
|
} & PropsWithChildren<HTMLAttributes<HTMLElement>>;
|
|
14
16
|
export declare const Spotlight: import("react").ForwardRefExoticComponent<{
|
|
15
17
|
/** The HTML element to use. */
|
|
16
|
-
as?:
|
|
18
|
+
as?: SpotlightTag;
|
|
17
19
|
/** The background colour. */
|
|
18
20
|
color?: SpotlightColor;
|
|
19
21
|
} & HTMLAttributes<HTMLElement> & {
|
|
@@ -5,6 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
|
+
export const spotlightTags = ['article', 'aside', 'div', 'footer', 'section'];
|
|
8
9
|
export const spotlightColors = ['azure', 'green', 'lime', 'magenta', 'orange', 'yellow'];
|
|
9
10
|
export const Spotlight = forwardRef(({ as: Tag = 'div', children, className, color, ...restProps }, ref) => (_jsx(Tag, { ...restProps, className: clsx('ams-spotlight', color && `ams-spotlight--${color}`, className), ref: ref, children: children })));
|
|
10
11
|
Spotlight.displayName = 'Spotlight';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { createRef } from 'react';
|
|
4
|
-
import { Spotlight, spotlightColors } from './Spotlight';
|
|
4
|
+
import { Spotlight, spotlightColors, spotlightTags } from './Spotlight';
|
|
5
|
+
import { ariaRoleForTag } from '../common/accessibility';
|
|
5
6
|
import '@testing-library/jest-dom';
|
|
6
7
|
describe('Spotlight', () => {
|
|
7
8
|
it('renders', () => {
|
|
@@ -15,11 +16,17 @@ describe('Spotlight', () => {
|
|
|
15
16
|
const component = container.querySelector(':only-child');
|
|
16
17
|
expect(component).toHaveClass('ams-spotlight');
|
|
17
18
|
});
|
|
18
|
-
it('renders an
|
|
19
|
+
it('renders an extra class name', () => {
|
|
19
20
|
const { container } = render(_jsx(Spotlight, { className: "extra" }));
|
|
20
21
|
const component = container.querySelector(':only-child');
|
|
21
|
-
expect(component).toHaveClass('extra');
|
|
22
|
-
|
|
22
|
+
expect(component).toHaveClass('ams-spotlight extra');
|
|
23
|
+
});
|
|
24
|
+
spotlightTags.forEach((tag) => {
|
|
25
|
+
it(`renders with a custom ${tag} tag`, () => {
|
|
26
|
+
const { container } = render(_jsx(Spotlight, { "aria-label": tag === 'section' ? 'Accessible name' : undefined, as: tag }));
|
|
27
|
+
const component = tag === 'div' ? container.querySelector(tag) : screen.getByRole(ariaRoleForTag[tag]);
|
|
28
|
+
expect(component).toBeInTheDocument();
|
|
29
|
+
});
|
|
23
30
|
});
|
|
24
31
|
it('supports ForwardRef in React', () => {
|
|
25
32
|
const ref = createRef();
|
|
@@ -32,9 +39,4 @@ describe('Spotlight', () => {
|
|
|
32
39
|
const component = container.querySelector(':only-child');
|
|
33
40
|
expect(component).toHaveClass(`ams-spotlight--${color}`);
|
|
34
41
|
}));
|
|
35
|
-
it('renders a custom tag', () => {
|
|
36
|
-
render(_jsx(Spotlight, { as: "article" }));
|
|
37
|
-
const cell = screen.getByRole('article');
|
|
38
|
-
expect(cell).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
42
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license EUPL-1.2+
|
|
3
|
+
* Copyright Gemeente Amsterdam
|
|
4
|
+
*/
|
|
5
|
+
import type { AnchorHTMLAttributes } from 'react';
|
|
6
|
+
export type StandaloneLinkProps = {
|
|
7
|
+
/** Changes the text colour for readability on a light or dark background. */
|
|
8
|
+
color?: 'contrast' | 'inverse';
|
|
9
|
+
/** Adds an icon to the link, showing it before the link text. */
|
|
10
|
+
icon?: Function;
|
|
11
|
+
} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'placeholder'>;
|
|
12
|
+
export declare const StandaloneLink: import("react").ForwardRefExoticComponent<{
|
|
13
|
+
/** Changes the text colour for readability on a light or dark background. */
|
|
14
|
+
color?: "contrast" | "inverse";
|
|
15
|
+
/** Adds an icon to the link, showing it before the link text. */
|
|
16
|
+
icon?: Function;
|
|
17
|
+
} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "placeholder"> & import("react").RefAttributes<HTMLAnchorElement>>;
|