@scottish-government/designsystem-react 0.0.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/.editorconfig +12 -0
- package/.github/workflows/release-package.yml +96 -0
- package/@types/common/ConditionalWrapper.d.ts +6 -0
- package/@types/common/HintText.d.ts +6 -0
- package/@types/common/Icon.d.ts +11 -0
- package/@types/common/ScreenReaderText.d.ts +4 -0
- package/@types/common/WrapperTag.d.ts +5 -0
- package/@types/components/Accordion.d.ts +15 -0
- package/@types/components/AspectBox.d.ts +5 -0
- package/@types/components/BackToTop.d.ts +5 -0
- package/@types/components/Breadcrumbs.d.ts +14 -0
- package/@types/components/Button.d.ts +17 -0
- package/@types/components/Checkbox.d.ts +13 -0
- package/@types/components/ConfirmationMessage.d.ts +7 -0
- package/@types/components/ContentsNav.d.ts +15 -0
- package/@types/components/DatePicker.d.ts +19 -0
- package/@types/components/Details.d.ts +6 -0
- package/@types/components/ErrorMessage.d.ts +6 -0
- package/@types/components/Metadata.d.ts +11 -0
- package/@types/components/NotificationBanner.d.ts +9 -0
- package/@types/components/NotificationPanel.d.ts +7 -0
- package/@types/components/PageHeader.d.ts +6 -0
- package/@types/components/PhaseBanner.d.ts +5 -0
- package/@types/components/Question.d.ts +11 -0
- package/@types/components/RadioButton.d.ts +15 -0
- package/@types/components/Select.d.ts +14 -0
- package/@types/components/SequentialNavigation.d.ts +14 -0
- package/@types/components/SideNavigation.d.ts +19 -0
- package/@types/components/SiteNavigation.d.ts +13 -0
- package/@types/components/SiteSearch.d.ts +14 -0
- package/@types/components/SkipLinks.d.ts +14 -0
- package/@types/components/Tag.d.ts +7 -0
- package/@types/components/TaskList.d.ts +21 -0
- package/@types/components/TextInput.d.ts +12 -0
- package/@types/components/Textarea.d.ts +4 -0
- package/@types/global.d.ts +1 -0
- package/@types/sgds.d.ts +35 -0
- package/package.json +36 -0
- package/src/common/conditional-wrapper.test.tsx +36 -0
- package/src/common/conditional-wrapper.tsx +9 -0
- package/src/common/hint-text.test.tsx +47 -0
- package/src/common/hint-text.tsx +21 -0
- package/src/common/icon.test.tsx +100 -0
- package/src/common/icon.tsx +28 -0
- package/src/common/screen-reader-text.test.tsx +31 -0
- package/src/common/screen-reader-text.tsx +17 -0
- package/src/common/wrapper-tag.test.tsx +42 -0
- package/src/common/wrapper-tag.tsx +15 -0
- package/src/components/accordion/accordion.test.tsx +212 -0
- package/src/components/accordion/accordion.tsx +108 -0
- package/src/components/aspect-box/aspect-box.test.tsx +81 -0
- package/src/components/aspect-box/aspect-box.tsx +57 -0
- package/src/components/back-to-top/back-to-top.test.tsx +45 -0
- package/src/components/back-to-top/back-to-top.tsx +33 -0
- package/src/components/breadcrumbs/breadcrumbs.test.tsx +77 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +53 -0
- package/src/components/button/button.test.tsx +125 -0
- package/src/components/button/button.tsx +48 -0
- package/src/components/checkbox/checkbox.test.tsx +180 -0
- package/src/components/checkbox/checkbox.tsx +107 -0
- package/src/components/confirmation-message/confirmation-message.test.tsx +46 -0
- package/src/components/confirmation-message/confirmation-message.tsx +32 -0
- package/src/components/contents-nav/contents-nav.test.tsx +136 -0
- package/src/components/contents-nav/contents-nav.tsx +54 -0
- package/src/components/date-picker/date-picker.test.tsx +209 -0
- package/src/components/date-picker/date-picker.tsx +129 -0
- package/src/components/details/details.test.tsx +38 -0
- package/src/components/details/details.tsx +25 -0
- package/src/components/error-message/error-message.test.tsx +40 -0
- package/src/components/error-message/error-message.tsx +23 -0
- package/src/components/inset-text/inset-text.test.tsx +33 -0
- package/src/components/inset-text/inset-text.tsx +19 -0
- package/src/components/notification-banner/notification-banner.test.tsx +93 -0
- package/src/components/notification-banner/notification-banner.tsx +70 -0
- package/src/components/notification-panel/notification-panel.test.tsx +77 -0
- package/src/components/notification-panel/notification-panel.tsx +31 -0
- package/src/components/page-header/page-header.test.tsx +48 -0
- package/src/components/page-header/page-header.tsx +22 -0
- package/src/components/page-metadata/page-metadata.test.tsx +56 -0
- package/src/components/page-metadata/page-metadata.tsx +39 -0
- package/src/components/phase-banner/phase-banner.test.tsx +67 -0
- package/src/components/phase-banner/phase-banner.tsx +27 -0
- package/src/components/question/question.test.tsx +69 -0
- package/src/components/question/question.tsx +33 -0
- package/src/components/radio-button/radio-button.test.tsx +190 -0
- package/src/components/radio-button/radio-button.tsx +88 -0
- package/src/components/select/select.test.tsx +208 -0
- package/src/components/select/select.tsx +86 -0
- package/src/components/sequential-navigation/sequential-navigation.test.tsx +67 -0
- package/src/components/sequential-navigation/sequential-navigation.tsx +55 -0
- package/src/components/side-navigation/side-navigation.test.tsx +156 -0
- package/src/components/side-navigation/side-navigation.tsx +85 -0
- package/src/components/site-navigation/site-navigation.test.tsx +63 -0
- package/src/components/site-navigation/site-navigation.tsx +40 -0
- package/src/components/site-search/site-search.test.tsx +153 -0
- package/src/components/site-search/site-search.tsx +97 -0
- package/src/components/skip-links/skip-links.test.tsx +84 -0
- package/src/components/skip-links/skip-links.tsx +39 -0
- package/src/components/tag/tag.test.tsx +45 -0
- package/src/components/tag/tag.tsx +23 -0
- package/src/components/task-list/task-list.test.tsx +409 -0
- package/src/components/task-list/task-list.tsx +132 -0
- package/src/components/text-input/text-input.test.tsx +307 -0
- package/src/components/text-input/text-input.tsx +98 -0
- package/src/components/textarea/textarea.test.tsx +212 -0
- package/src/components/textarea/textarea.tsx +82 -0
- package/src/components/warning-text/warning-text.test.tsx +40 -0
- package/src/components/warning-text/warning-text.tsx +21 -0
- package/tsconfig.json +45 -0
- package/vite.config.ts +12 -0
- package/vitest-setup.ts +13 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import WarningText from './warning-text';
|
|
4
|
+
|
|
5
|
+
const text = `Call 999 if you or someone else is in immediate danger, or if the crime is in progress.`;
|
|
6
|
+
|
|
7
|
+
test('warning text renders correctly', () => {
|
|
8
|
+
|
|
9
|
+
render(
|
|
10
|
+
<WarningText>
|
|
11
|
+
{text}
|
|
12
|
+
</WarningText>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const warningTextOuter = document.querySelector('.ds_warning-text');
|
|
16
|
+
const warningTextInner = warningTextOuter?.querySelector('.ds_warning-text__text');
|
|
17
|
+
const warningTextIcon = warningTextOuter?.querySelector('.ds_warning-text__icon');
|
|
18
|
+
const warningTextTitle = warningTextOuter?.querySelector('strong.visually-hidden');
|
|
19
|
+
|
|
20
|
+
expect(warningTextOuter).toBeInTheDocument();
|
|
21
|
+
expect(warningTextInner).toBeInTheDocument();
|
|
22
|
+
expect(warningTextInner?.textContent).toEqual(text);
|
|
23
|
+
|
|
24
|
+
expect(warningTextIcon).toHaveAttribute('aria-hidden');
|
|
25
|
+
expect(warningTextTitle?.textContent).toEqual('Warning');
|
|
26
|
+
|
|
27
|
+
expect(warningTextInner?.previousSibling).toEqual(warningTextTitle);
|
|
28
|
+
expect(warningTextTitle?.previousSibling).toEqual(warningTextIcon);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('passing additional props', () => {
|
|
32
|
+
render(
|
|
33
|
+
<WarningText data-test="foo">
|
|
34
|
+
{text}
|
|
35
|
+
</WarningText>
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
const warningTextOuter = document.querySelector('.ds_warning-text');
|
|
39
|
+
expect(warningTextOuter?.dataset.test).toEqual('foo');
|
|
40
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const WarningText: React.FC<React.PropsWithChildren> = ({
|
|
2
|
+
children,
|
|
3
|
+
...props
|
|
4
|
+
}) => {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
className="ds_warning-text"
|
|
8
|
+
{...props}
|
|
9
|
+
>
|
|
10
|
+
<strong className="ds_warning-text__icon" aria-hidden="true"></strong>
|
|
11
|
+
<strong className="visually-hidden">Warning</strong>
|
|
12
|
+
<div className="ds_warning-text__text">
|
|
13
|
+
{children}
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
WarningText.displayName = 'WarningText';
|
|
20
|
+
|
|
21
|
+
export default WarningText;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": false,
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "nodenext",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"paths": {
|
|
9
|
+
"@/*": [
|
|
10
|
+
"./*"
|
|
11
|
+
],
|
|
12
|
+
"@design-system/*": [
|
|
13
|
+
"./node_modules/@scottish-government/design-system/src/*"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"target": "esnext",
|
|
17
|
+
"types": [],
|
|
18
|
+
"typeRoots": [
|
|
19
|
+
"./node_modules/@types",
|
|
20
|
+
"./@types"
|
|
21
|
+
],
|
|
22
|
+
"lib": [
|
|
23
|
+
"dom",
|
|
24
|
+
"dom.iterable",
|
|
25
|
+
"esnext"
|
|
26
|
+
],
|
|
27
|
+
"incremental": true,
|
|
28
|
+
"esModuleInterop": true,
|
|
29
|
+
"resolveJsonModule": true,
|
|
30
|
+
|
|
31
|
+
"noFallthroughCasesInSwitch": true,
|
|
32
|
+
"noUnusedLocals": true,
|
|
33
|
+
"noUnusedParameters": true,
|
|
34
|
+
"strict": true
|
|
35
|
+
},
|
|
36
|
+
"include": [
|
|
37
|
+
"@types",
|
|
38
|
+
"src/**/*.tsx",
|
|
39
|
+
"vitest.setup.ts"
|
|
40
|
+
],
|
|
41
|
+
"exclude": [
|
|
42
|
+
"node_modules/**/*",
|
|
43
|
+
"src/**/*.test.tsx"
|
|
44
|
+
]
|
|
45
|
+
}
|
package/vite.config.ts
ADDED
package/vitest-setup.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
|
+
import { vi } from 'vitest';
|
|
3
|
+
import { cleanup } from '@testing-library/react';
|
|
4
|
+
import { afterEach } from 'vitest';
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
cleanup();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// mock CSS.supports()
|
|
11
|
+
Object.defineProperty(global.CSS, 'supports', {
|
|
12
|
+
value: () => vi.fn()
|
|
13
|
+
});
|