@scottish-government/designsystem-react 0.8.0 → 0.10.0-beta.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/.storybook/main.ts +20 -0
- package/.storybook/manager.ts +13 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.tsx +56 -0
- package/.storybook/sgdsArgTypes.ts +123 -0
- package/.storybook/sgdsTheme.ts +9 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/@types/common/AbstractNotificationBanner.d.ts +2 -2
- package/@types/common/ActionLink.d.ts +1 -1
- package/@types/common/Icon.d.ts +1 -1
- package/@types/components/Accordion.d.ts +2 -3
- package/@types/components/Button.d.ts +5 -5
- package/@types/components/CategoryItem.d.ts +10 -0
- package/@types/components/CategoryList.d.ts +7 -0
- package/@types/components/Checkbox.d.ts +2 -2
- package/@types/components/ContentsNav.d.ts +1 -1
- package/@types/components/DatePicker.d.ts +1 -1
- package/@types/components/ErrorMessage.d.ts +1 -2
- package/@types/components/ErrorSummary.d.ts +1 -1
- package/@types/components/FileDownload.d.ts +2 -2
- package/@types/components/Metadata.d.ts +1 -1
- package/@types/components/Pagination.d.ts +1 -1
- package/@types/components/RadioButton.d.ts +2 -2
- package/@types/components/SideNavigation.d.ts +1 -1
- package/@types/components/SiteNavigation.d.ts +1 -1
- package/@types/components/SummaryList.d.ts +1 -1
- package/@types/components/Tabs.d.ts +3 -3
- package/@types/components/TextInput.d.ts +1 -1
- package/@types/sgds.d.ts +2 -1
- package/CHANGELOG.md +29 -0
- package/dist/common/AbstractNotificationBanner.jsx +4 -4
- package/dist/common/Icon.jsx +2 -2
- package/dist/components/Accordion/Accordion.jsx +8 -7
- package/dist/components/Button/Button.jsx +6 -6
- package/dist/components/CategoryItem/CategoryItem.jsx +35 -0
- package/dist/components/CategoryList/CategoryList.jsx +55 -0
- package/dist/components/Checkbox/Checkbox.jsx +7 -4
- package/dist/components/Checkbox/CheckboxGroup.jsx +5 -11
- package/dist/components/ContentsNav/ContentsNav.jsx +2 -2
- package/dist/components/DatePicker/DatePicker.jsx +1 -1
- package/dist/components/ErrorMessage/ErrorMessage.jsx +3 -3
- package/dist/components/FileDownload/FileDownload.jsx +2 -2
- package/dist/components/NotificationBanner/NotificationBanner.jsx +2 -2
- package/dist/components/PageMetadata/PageMetadata.jsx +4 -4
- package/dist/components/Pagination/Pagination.jsx +4 -4
- package/dist/components/Question/Question.jsx +1 -1
- package/dist/components/RadioButton/RadioButton.jsx +6 -2
- package/dist/components/RadioButton/RadioGroup.jsx +7 -47
- package/dist/components/Select/Select.jsx +1 -1
- package/dist/components/SideNavigation/SideNavigation.jsx +2 -2
- package/dist/components/SiteHeader/SiteHeader.jsx +3 -3
- package/dist/components/SiteNavigation/SiteNavigation.jsx +2 -2
- package/dist/components/SiteSearch/SiteSearch.jsx +1 -1
- package/dist/components/SkipLinks/SkipLinks.jsx +1 -1
- package/dist/components/SummaryList/SummaryList.jsx +3 -3
- package/dist/components/Tabs/Tabs.jsx +6 -7
- package/dist/components/TextInput/TextInput.jsx +5 -5
- package/dist/components/Textarea/Textarea.jsx +1 -1
- package/dist/hooks/useTracking.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/context.js +5 -0
- package/package.json +15 -4
- package/src/common/AbstractNotificationBanner.test.tsx +1 -1
- package/src/common/AbstractNotificationBanner.tsx +4 -4
- package/src/common/Icon.test.tsx +1 -1
- package/src/common/Icon.tsx +2 -2
- package/src/components/Accordion/Accordion.stories.tsx +111 -0
- package/src/components/Accordion/Accordion.test.tsx +5 -17
- package/src/components/Accordion/Accordion.tsx +11 -10
- package/src/components/AspectBox/AspectBox.stories.tsx +64 -0
- package/src/components/BackToTop/BackToTop.stories.tsx +36 -0
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +49 -0
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +0 -1
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/src/components/Button/Button.stories.tsx +194 -0
- package/src/components/Button/Button.test.tsx +4 -4
- package/src/components/Button/Button.tsx +9 -9
- package/src/components/CategoryItem/CategoryItem.stories.tsx +55 -0
- package/src/components/CategoryItem/CategoryItem.test.tsx +93 -0
- package/src/components/CategoryItem/CategoryItem.tsx +56 -0
- package/src/components/CategoryList/CategoryList.stories.tsx +65 -0
- package/src/components/CategoryList/CategoryList.test.tsx +59 -0
- package/src/components/CategoryList/CategoryList.tsx +33 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +85 -0
- package/src/components/Checkbox/Checkbox.test.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +11 -6
- package/src/components/Checkbox/CheckboxGroup.stories.tsx +68 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +7 -12
- package/src/components/ConfirmationMessage/ConfirmationMessage.stories.tsx +38 -0
- package/src/components/ContentsNav/ContentsNav.stories.tsx +43 -0
- package/src/components/ContentsNav/ContentsNav.test.tsx +2 -2
- package/src/components/ContentsNav/ContentsNav.tsx +2 -2
- package/src/components/CookieBanner/CookieBanner.stories.tsx +33 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +113 -0
- package/src/components/DatePicker/DatePicker.tsx +1 -1
- package/src/components/Details/Details.stories.tsx +36 -0
- package/src/components/ErrorMessage/ErrorMessage.stories.tsx +19 -0
- package/src/components/ErrorMessage/ErrorMessage.test.tsx +3 -15
- package/src/components/ErrorMessage/ErrorMessage.tsx +1 -3
- package/src/components/ErrorSummary/ErrorSummary.stories.tsx +38 -0
- package/src/components/FileDownload/FileDownload.stories.tsx +75 -0
- package/src/components/FileDownload/FileDownload.test.tsx +1 -1
- package/src/components/FileDownload/FileDownload.tsx +2 -2
- package/src/components/HideThisPage/HideThisPage.stories.tsx +20 -0
- package/src/components/InsetText/InsetText.stories.tsx +21 -0
- package/src/components/NotificationBanner/NotificationBanner.stories.tsx +57 -0
- package/src/components/NotificationBanner/NotificationBanner.test.tsx +1 -1
- package/src/components/NotificationBanner/NotificationBanner.tsx +4 -4
- package/src/components/NotificationPanel/NotificationPanel.stories.tsx +32 -0
- package/src/components/PageHeader/PageHeader.stories.tsx +60 -0
- package/src/components/PageMetadata/PageMetadata.stories.tsx +58 -0
- package/src/components/PageMetadata/PageMetadata.test.tsx +2 -2
- package/src/components/PageMetadata/PageMetadata.tsx +4 -4
- package/src/components/Pagination/Pagination.stories.tsx +69 -0
- package/src/components/Pagination/Pagination.test.tsx +1 -1
- package/src/components/Pagination/Pagination.tsx +4 -4
- package/src/components/PhaseBanner/PhaseBanner.stories.tsx +38 -0
- package/src/components/Question/Question.stories.tsx +78 -0
- package/src/components/Question/Question.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +67 -0
- package/src/components/RadioButton/RadioButton.test.tsx +2 -1
- package/src/components/RadioButton/RadioButton.tsx +9 -3
- package/src/components/RadioButton/RadioGroup.stories.tsx +77 -0
- package/src/components/RadioButton/RadioGroup.test.tsx +2 -2
- package/src/components/RadioButton/RadioGroup.tsx +8 -15
- package/src/components/Select/Select.stories.tsx +76 -0
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/SequentialNavigation/SequentialNavigation.stories.tsx +31 -0
- package/src/components/SideNavigation/SideNavigation.stories.tsx +92 -0
- package/src/components/SideNavigation/SideNavigation.test.tsx +2 -2
- package/src/components/SideNavigation/SideNavigation.tsx +2 -2
- package/src/components/SiteFooter/SiteFooter.stories.tsx +65 -0
- package/src/components/SiteHeader/SiteHeader.stories.tsx +92 -0
- package/src/components/SiteHeader/SiteHeader.tsx +2 -7
- package/src/components/SiteNavigation/SiteNavigation.stories.tsx +45 -0
- package/src/components/SiteNavigation/SiteNavigation.test.tsx +1 -1
- package/src/components/SiteNavigation/SiteNavigation.tsx +2 -2
- package/src/components/SiteSearch/SiteSearch.stories.tsx +81 -0
- package/src/components/SiteSearch/SiteSearch.tsx +1 -1
- package/src/components/SkipLinks/SkipLinks.stories.tsx +57 -0
- package/src/components/SkipLinks/SkipLinks.tsx +1 -1
- package/src/components/SummaryCard/SummaryCard.stories.tsx +46 -0
- package/src/components/SummaryList/SummaryList.stories.tsx +75 -0
- package/src/components/SummaryList/SummaryList.test.tsx +1 -1
- package/src/components/SummaryList/SummaryList.tsx +3 -3
- package/src/components/Table/Table.stories.tsx +96 -0
- package/src/components/Tabs/Tabs.stories.tsx +90 -0
- package/src/components/Tabs/Tabs.test.tsx +6 -8
- package/src/components/Tabs/Tabs.tsx +8 -9
- package/src/components/Tag/Tag.stories.tsx +25 -0
- package/src/components/TaskList/TaskList.stories.tsx +129 -0
- package/src/components/TextInput/TextInput.stories.tsx +123 -0
- package/src/components/TextInput/TextInput.test.tsx +2 -2
- package/src/components/TextInput/TextInput.tsx +5 -5
- package/src/components/Textarea/Textarea.stories.tsx +71 -0
- package/src/components/Textarea/Textarea.tsx +1 -1
- package/src/components/WarningText/WarningText.stories.tsx +21 -0
- package/src/hooks/useTracking.test.tsx +64 -0
- package/src/hooks/useTracking.ts +19 -0
- package/src/utils/context.ts +3 -0
- package/static/data/autocomplete-dummy-data.json +2361 -0
- package/static/images/highland-cow.jpg +0 -0
- package/static/images/scottish-government--min.svg +11 -0
- package/static/images/scottish-government.svg +6 -0
- package/tsconfig.json +3 -2
- package/vite.config.ts +45 -11
- package/vitest-setup.ts +1 -0
- package/vitest.shims.d.ts +1 -0
- package/src/utils/slugify.ts +0 -13
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
"stories": [
|
|
5
|
+
"../src/**/*.mdx",
|
|
6
|
+
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
|
|
7
|
+
],
|
|
8
|
+
"addons": [
|
|
9
|
+
"@chromatic-com/storybook",
|
|
10
|
+
"@storybook/addon-docs",
|
|
11
|
+
"@storybook/addon-onboarding",
|
|
12
|
+
"@storybook/addon-a11y",
|
|
13
|
+
"@storybook/addon-vitest"
|
|
14
|
+
],
|
|
15
|
+
"framework": {
|
|
16
|
+
"name": "@storybook/react-vite",
|
|
17
|
+
"options": {}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export default config;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { addons } from 'storybook/manager-api';
|
|
2
|
+
import capitalize from "lodash/capitalize";
|
|
3
|
+
|
|
4
|
+
import sgdsTheme from './sgdsTheme';
|
|
5
|
+
|
|
6
|
+
addons.setConfig({
|
|
7
|
+
theme: sgdsTheme,
|
|
8
|
+
sidebar: {
|
|
9
|
+
renderLabel: ({ name, type }) => {
|
|
10
|
+
return capitalize(name);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700,400italic&display=swap" rel="stylesheet" type="text/css">
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Preview } from "@storybook/react-vite";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Title,
|
|
5
|
+
Subtitle,
|
|
6
|
+
Description,
|
|
7
|
+
Primary,
|
|
8
|
+
Controls,
|
|
9
|
+
Stories,
|
|
10
|
+
} from '@storybook/addon-docs/blocks';
|
|
11
|
+
|
|
12
|
+
import '@scottish-government/design-system/dist/css/design-system.css';
|
|
13
|
+
|
|
14
|
+
const preview: Preview = {
|
|
15
|
+
parameters: {
|
|
16
|
+
controls: {
|
|
17
|
+
matchers: {
|
|
18
|
+
color: /(background|color)$/i,
|
|
19
|
+
date: /Date$/i,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
a11y: {
|
|
24
|
+
// 'todo' - show a11y violations in the test UI only
|
|
25
|
+
// 'error' - fail CI on a11y violations
|
|
26
|
+
// 'off' - skip a11y checks entirely
|
|
27
|
+
test: "todo",
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
backgrounds: {
|
|
31
|
+
grid: {
|
|
32
|
+
cellSize: 8,
|
|
33
|
+
opacity: 0.25,
|
|
34
|
+
cellAmount: 8,
|
|
35
|
+
offsetX: 30, // Default is 0 if story has 'fullscreen' layout, 16 if layout is 'padded'
|
|
36
|
+
offsetY: 40, // Default is 0 if story has 'fullscreen' layout, 16 if layout is 'padded'
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
docs: {
|
|
41
|
+
page: () => (
|
|
42
|
+
<>
|
|
43
|
+
<Title />
|
|
44
|
+
<Subtitle />
|
|
45
|
+
<Description />
|
|
46
|
+
<Primary />
|
|
47
|
+
<Controls />
|
|
48
|
+
<Stories />
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
tags: ['autodocs']
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default preview;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const SGDSArgTypes = {
|
|
2
|
+
ariaLabel: (options?: any) => {
|
|
3
|
+
return Object.assign({
|
|
4
|
+
type: 'string'
|
|
5
|
+
}, options);
|
|
6
|
+
},
|
|
7
|
+
ariaLive: (options?: any) => {
|
|
8
|
+
return Object.assign({
|
|
9
|
+
options: ['off', 'polite', 'assertive'],
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
type: 'string'
|
|
12
|
+
}, options);
|
|
13
|
+
},
|
|
14
|
+
children: (options?: any) => {
|
|
15
|
+
return Object.assign({
|
|
16
|
+
control: false
|
|
17
|
+
}, options);
|
|
18
|
+
},
|
|
19
|
+
countThreshold: (options?: any) => {
|
|
20
|
+
return Object.assign({
|
|
21
|
+
control: {
|
|
22
|
+
type: 'number', min: 1, max: 100, step: 1
|
|
23
|
+
},
|
|
24
|
+
description: 'Percentage threshold to show the character count at',
|
|
25
|
+
type: 'number'
|
|
26
|
+
}, options);
|
|
27
|
+
},
|
|
28
|
+
errorMessage: (options?: any) => {
|
|
29
|
+
return Object.assign({
|
|
30
|
+
description: 'Text to use for an error message',
|
|
31
|
+
type: 'string'
|
|
32
|
+
}, options);
|
|
33
|
+
},
|
|
34
|
+
hasError: (options?: any) => {
|
|
35
|
+
return Object.assign({
|
|
36
|
+
control: 'boolean',
|
|
37
|
+
description: 'Whether the field is in an error state'
|
|
38
|
+
}, options);
|
|
39
|
+
},
|
|
40
|
+
headingLevel: (options?: any) => {
|
|
41
|
+
return Object.assign({
|
|
42
|
+
description: 'Heading level for the component\'s title',
|
|
43
|
+
options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
|
|
44
|
+
control: { type: 'select' },
|
|
45
|
+
type: 'string'
|
|
46
|
+
}, options);
|
|
47
|
+
},
|
|
48
|
+
hintText: (options?: any) => {
|
|
49
|
+
return Object.assign({
|
|
50
|
+
description: 'Text to use for the field\'s hint text',
|
|
51
|
+
type: 'string'
|
|
52
|
+
}, options);
|
|
53
|
+
},
|
|
54
|
+
id: (options?: any) => {
|
|
55
|
+
return Object.assign({
|
|
56
|
+
type: {
|
|
57
|
+
required: true,
|
|
58
|
+
name: 'string'
|
|
59
|
+
}
|
|
60
|
+
}, options);
|
|
61
|
+
},
|
|
62
|
+
inputWidth: (options?: any) => {
|
|
63
|
+
return Object.assign({
|
|
64
|
+
control: { type: 'select' },
|
|
65
|
+
options: [undefined, 'fixed-20', 'fixed-10', 'fixed-5', 'fixed-4', 'fixed-3', 'fixed-2', 'fluid-three-quarters', 'fluid-two-thirds', 'fluid-half', 'fluid-one-third', 'fluid-one-quarter'],
|
|
66
|
+
type: 'string'
|
|
67
|
+
}, options);
|
|
68
|
+
},
|
|
69
|
+
isSmall: (options?: any) => {
|
|
70
|
+
return Object.assign({
|
|
71
|
+
control: 'boolean',
|
|
72
|
+
description: 'Whether to use the ‘small’ input control variant'
|
|
73
|
+
}, options);
|
|
74
|
+
},
|
|
75
|
+
label: (options?: any) => {
|
|
76
|
+
return Object.assign({
|
|
77
|
+
description: 'Text to use for the field\'s associated label',
|
|
78
|
+
type: {
|
|
79
|
+
required: true,
|
|
80
|
+
name: 'string'
|
|
81
|
+
}
|
|
82
|
+
}, options);
|
|
83
|
+
},
|
|
84
|
+
linkComponent: (options?: any) => {
|
|
85
|
+
return Object.assign({
|
|
86
|
+
control: false,
|
|
87
|
+
description: 'Function that returns an element, to customise the output',
|
|
88
|
+
type: 'function'
|
|
89
|
+
}, options);
|
|
90
|
+
},
|
|
91
|
+
maxlength: (options?: any) => {
|
|
92
|
+
return Object.assign({
|
|
93
|
+
description: 'Maximum number of characters permitted',
|
|
94
|
+
type: 'number'
|
|
95
|
+
}, options);
|
|
96
|
+
},
|
|
97
|
+
noBorder: (options?: any) => {
|
|
98
|
+
return Object.assign({
|
|
99
|
+
control: 'boolean',
|
|
100
|
+
description: 'Use the borderless display variant'
|
|
101
|
+
}, options);
|
|
102
|
+
},
|
|
103
|
+
onBlur: (options?: any) => {
|
|
104
|
+
return Object.assign({
|
|
105
|
+
description: 'Function to fire in response to a blur event',
|
|
106
|
+
type: 'function'
|
|
107
|
+
}, options);
|
|
108
|
+
},
|
|
109
|
+
onChange: (options?: any) => {
|
|
110
|
+
return Object.assign({
|
|
111
|
+
description: 'Function to fire in response to a change event',
|
|
112
|
+
type: 'function'
|
|
113
|
+
}, options);
|
|
114
|
+
},
|
|
115
|
+
onClick: (options?: any) => {
|
|
116
|
+
return Object.assign({
|
|
117
|
+
description: 'Function to fire in response to a click event',
|
|
118
|
+
type: 'function'
|
|
119
|
+
}, options);
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default SGDSArgTypes;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { create } from 'storybook/theming';
|
|
2
|
+
|
|
3
|
+
export default create({
|
|
4
|
+
base: 'light',
|
|
5
|
+
brandTitle: 'Scottish Government Design System',
|
|
6
|
+
brandUrl: 'https://designsystem.gov.scot',
|
|
7
|
+
brandImage: 'static/images/scottish-government--min.svg',
|
|
8
|
+
brandTarget: '_self',
|
|
9
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
|
|
2
|
+
import { setProjectAnnotations } from '@storybook/react-vite';
|
|
3
|
+
import * as projectAnnotations from './preview';
|
|
4
|
+
|
|
5
|
+
// This is an important step to apply the right configuration when testing your stories.
|
|
6
|
+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
|
|
7
|
+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
|
|
@@ -6,11 +6,11 @@ declare namespace SGDS.Common {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
interface AbstractNotificationBanner extends React.AllHTMLAttributes<HTMLDivElement> {
|
|
9
|
-
close?: boolean,
|
|
10
9
|
hasIcon?: boolean,
|
|
11
|
-
icon?: IconName,
|
|
12
10
|
hasColourIcon?: boolean,
|
|
13
11
|
hasInverseIcon?: boolean,
|
|
12
|
+
icon?: IconName,
|
|
13
|
+
isDismissable?: boolean,
|
|
14
14
|
title: string,
|
|
15
15
|
ref?: any
|
|
16
16
|
}
|
package/@types/common/Icon.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ declare namespace SGDS.Component {
|
|
|
4
4
|
type ButtonWidth = 'fluid' | 'fixed' | 'max';
|
|
5
5
|
|
|
6
6
|
interface Button extends React.AllHTMLAttributes<HTMLButtonElement> {
|
|
7
|
-
|
|
8
|
-
iconLeft?: boolean
|
|
9
|
-
iconOnly?: boolean,
|
|
7
|
+
hasLinkStyle?: boolean,
|
|
10
8
|
href?: string,
|
|
11
|
-
|
|
9
|
+
icon?: IconName,
|
|
10
|
+
isIconLeft?: boolean
|
|
11
|
+
isIconOnly?: boolean,
|
|
12
|
+
isSmall?: boolean,
|
|
12
13
|
buttonStyle?: ButtonStyle,
|
|
13
|
-
styleAsLink?: boolean,
|
|
14
14
|
type?: ButtonType
|
|
15
15
|
width?: ButtonWidth
|
|
16
16
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare namespace SGDS.Component {
|
|
2
|
+
interface CategoryItem extends React.AllHTMLAttributes<HTMLElement> {
|
|
3
|
+
className?: string,
|
|
4
|
+
headingLevel?: SGDS.HeadingLevel,
|
|
5
|
+
href?: string,
|
|
6
|
+
linkComponent?: SGDS.LinkComponent
|
|
7
|
+
tagName?: string,
|
|
8
|
+
title: string,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
declare namespace SGDS.Component {
|
|
2
2
|
namespace Checkbox {
|
|
3
3
|
interface Group extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
|
-
|
|
4
|
+
isSmall?: boolean
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
interface Checkbox extends CheckboxRadioBase<HTMLInputElement> {
|
|
9
|
-
|
|
9
|
+
isExclusive?: boolean
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
declare namespace SGDS.Component {
|
|
2
2
|
interface FileDownload extends React.AllHTMLAttributes<HTMLElement> {
|
|
3
3
|
cover?: string,
|
|
4
|
-
icon?: DocumentIconName,
|
|
5
4
|
fileSize?: string,
|
|
6
5
|
fileType?: string,
|
|
7
6
|
fileUrl: string,
|
|
8
|
-
|
|
7
|
+
icon?: DocumentIconName,
|
|
8
|
+
isHighlighted?: boolean,
|
|
9
9
|
title: string
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -2,7 +2,7 @@ declare namespace SGDS.Component {
|
|
|
2
2
|
namespace Pagination {
|
|
3
3
|
interface Page extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
4
|
ariaLabel: React.AriaAttributes['aria-label'],
|
|
5
|
-
|
|
5
|
+
isCurrent?: boolean,
|
|
6
6
|
href: string,
|
|
7
7
|
linkComponent?: SGDS.LinkComponent,
|
|
8
8
|
onClick?: React.EventHandler<any>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare namespace SGDS.Component {
|
|
2
2
|
namespace Tabs {
|
|
3
3
|
interface Item extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
|
-
|
|
4
|
+
isBorderless?: boolean,
|
|
5
5
|
id: string,
|
|
6
6
|
tabLabel: string
|
|
7
7
|
}
|
|
@@ -13,9 +13,9 @@ declare namespace SGDS.Component {
|
|
|
13
13
|
|
|
14
14
|
interface Tabs extends React.AllHTMLAttributes<HTMLElement> {
|
|
15
15
|
baseId: string,
|
|
16
|
-
|
|
16
|
+
isBorderless?: boolean,
|
|
17
17
|
headingLevel?: SGDS.HeadingLevel,
|
|
18
|
-
|
|
18
|
+
isManual?: boolean,
|
|
19
19
|
title: string
|
|
20
20
|
}
|
|
21
21
|
}
|
package/@types/sgds.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare namespace SGDS {
|
|
|
4
4
|
type DocumentIconName = 'Audio' | 'Csv' | 'Excel' | 'File' | 'Generic' | 'Geodata' | 'Ical' | 'Ico' | 'Image' | 'Odf' | 'Odg' | 'Odp' | 'Ods' | 'Odt' | 'Pdf' | 'Ppt' | 'Rtf' | 'Text' | 'Video' | 'Word' | 'Xml' | 'Zip';
|
|
5
5
|
type InputWidth = 'fixed-20' | 'fixed-10' | 'fixed-5' | 'fixed-4' | 'fixed-3' | 'fixed-2' | 'fluid-three-quarters' | 'fluid-two-thirds' | 'fluid-half' | 'fluid-one-third' | 'fluid-one-quarter';
|
|
6
6
|
type TagColour = 'grey' | 'green' | 'teal' | 'blue' | 'purple' | 'pink' | 'red' | 'orange' | 'yellow';
|
|
7
|
+
type TextInputType = 'date' | 'datetime-local' | 'email' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
|
7
8
|
|
|
8
9
|
type LinkComponent = (linkComponent: LinkComponentProps) => React.ReactNode;
|
|
9
10
|
|
|
@@ -25,7 +26,7 @@ declare namespace SGDS {
|
|
|
25
26
|
name?: string,
|
|
26
27
|
onBlur?: React.EventHandler<any>,
|
|
27
28
|
onChange?: React.EventHandler<any>,
|
|
28
|
-
|
|
29
|
+
isSmall?: boolean
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
interface FormFieldBase<T> extends React.AllHTMLAttributes <T> {
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,35 @@ Changes are grouped under the labels: `Added`, `Changed`, `Deprecated`, `Fixed`,
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [0.9.0] - 2025-09-17
|
|
11
|
+
## Added
|
|
12
|
+
- Storybook now added for all components. `npm run storybook`
|
|
13
|
+
- CategoryList component
|
|
14
|
+
- CategoryItem component
|
|
15
|
+
## Changed
|
|
16
|
+
- 'text' prop removed from ErrorMessage. Use children instead.
|
|
17
|
+
- Many boolean prop names updated for clarity/consistency
|
|
18
|
+
- AbstractNotificationBanner (used by NotificationBanner and CookieBanner): close -> isDismissable
|
|
19
|
+
- Accordion.Item: open -> isOpen
|
|
20
|
+
- Button: small -> isSmall
|
|
21
|
+
- Button: iconLeft -> isIconLeft
|
|
22
|
+
- Button: iconOnly -> isIconOnly
|
|
23
|
+
- Button: styleAsLink -> hasLinkStyle
|
|
24
|
+
- Checkbox: exclusive -> isExclusive
|
|
25
|
+
- CheckboxGroup: small -> isSmall
|
|
26
|
+
- ContentsNav: curent -> isCurrent
|
|
27
|
+
- DatePicker: multiple -> isMultiple
|
|
28
|
+
- FileDownload: highlighted -> isHighlighted
|
|
29
|
+
- Metadata: inline -> isInline
|
|
30
|
+
- Pagination.Item: current -> isCurrent
|
|
31
|
+
- RadioButton: inline -> isInline
|
|
32
|
+
- RadioGroup: small -> isSmall
|
|
33
|
+
- SideNavigation.Item: current -> isCurrent
|
|
34
|
+
- SiteNavigation.Item: current -> isCurrent
|
|
35
|
+
- SummaryList: noBorder -> isBorderless
|
|
36
|
+
- Tabs: bordered -> isBorderless (logic inverted), manual -> isManual
|
|
37
|
+
- TextInput: currency -> isCurrency
|
|
38
|
+
|
|
10
39
|
## [0.8.0] - 2025-08-18
|
|
11
40
|
## Added
|
|
12
41
|
- ActionLink component, centralising behaviour used in actions in both SummaryCard and SummaryList
|
|
@@ -9,7 +9,7 @@ const ScreenReaderText_1 = __importDefault(require("./ScreenReaderText"));
|
|
|
9
9
|
const Buttons = ({ children }) => {
|
|
10
10
|
return (<>{children}</>);
|
|
11
11
|
};
|
|
12
|
-
const AbstractNotificationBanner = ({ children, className,
|
|
12
|
+
const AbstractNotificationBanner = ({ children, className, hasColourIcon, hasInverseIcon, icon, isDismissable, title = 'Information', ...props }) => {
|
|
13
13
|
let content = [];
|
|
14
14
|
let buttons;
|
|
15
15
|
react_1.Children.forEach(children, (child) => {
|
|
@@ -28,7 +28,7 @@ const AbstractNotificationBanner = ({ children, className, close, hasColourIcon,
|
|
|
28
28
|
<div className="ds_wrapper">
|
|
29
29
|
<div className={[
|
|
30
30
|
'ds_notification__content',
|
|
31
|
-
|
|
31
|
+
isDismissable && 'ds_notification__content--has-close'
|
|
32
32
|
].join(' ')}>
|
|
33
33
|
<h2 className="visually-hidden">{title}</h2>
|
|
34
34
|
|
|
@@ -45,10 +45,10 @@ const AbstractNotificationBanner = ({ children, className, close, hasColourIcon,
|
|
|
45
45
|
{content}
|
|
46
46
|
</div>
|
|
47
47
|
|
|
48
|
-
{
|
|
48
|
+
{isDismissable &&
|
|
49
49
|
<button type="button" className="ds_notification__close js-close-notification">
|
|
50
50
|
<ScreenReaderText_1.default>Close this notification</ScreenReaderText_1.default>
|
|
51
|
-
<Icon_1.default
|
|
51
|
+
<Icon_1.default isFilled icon="Close" aria-hidden="true"/>
|
|
52
52
|
</button>}
|
|
53
53
|
|
|
54
54
|
{buttons &&
|
package/dist/common/Icon.jsx
CHANGED
|
@@ -38,12 +38,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const react_1 = __importDefault(require("react"));
|
|
40
40
|
const Icons = __importStar(require("../images/icons"));
|
|
41
|
-
const Icon = ({ ariaLabel, className,
|
|
41
|
+
const Icon = ({ ariaLabel, className, isFilled, icon, iconSize }) => {
|
|
42
42
|
const IconComponent = Icons[icon];
|
|
43
43
|
return (<IconComponent aria-hidden={ariaLabel ? undefined : true} aria-label={ariaLabel} className={[
|
|
44
44
|
'ds_icon',
|
|
45
45
|
className,
|
|
46
|
-
|
|
46
|
+
isFilled && 'ds_icon--fill',
|
|
47
47
|
iconSize && `ds_icon--${iconSize}`
|
|
48
48
|
].join(' ')}/>);
|
|
49
49
|
};
|
|
@@ -41,9 +41,11 @@ const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
|
|
|
41
41
|
// @ts-ignore
|
|
42
42
|
const accordion_1 = __importDefault(require("@scottish-government/design-system/src/components/accordion/accordion"));
|
|
43
43
|
let accordionItemCounter = 0;
|
|
44
|
-
const
|
|
44
|
+
const AccordionHeadingLevelContext = (0, react_1.createContext)('h3');
|
|
45
|
+
const AccordionItem = ({ children, className, id: rawId, isOpen = false, title, ...props }) => {
|
|
45
46
|
accordionItemCounter = accordionItemCounter + 1;
|
|
46
|
-
const processedId = rawId || `accordion-item-${
|
|
47
|
+
const processedId = rawId || `accordion-item-${(0, react_1.useId)()}`;
|
|
48
|
+
let headingLevel = (0, react_1.useContext)(AccordionHeadingLevelContext);
|
|
47
49
|
return (<div className={[
|
|
48
50
|
'ds_accordion-item',
|
|
49
51
|
className
|
|
@@ -51,7 +53,7 @@ const AccordionItem = ({ children, className, headingLevel = 'h3', id: rawId, op
|
|
|
51
53
|
<input aria-labelledby={`panel-${processedId}-heading`} className={[
|
|
52
54
|
'ds_accordion-item__control',
|
|
53
55
|
'visually-hidden'
|
|
54
|
-
].join(' ')} defaultChecked={
|
|
56
|
+
].join(' ')} defaultChecked={isOpen} id={`${processedId}-control`} type="checkbox"/>
|
|
55
57
|
<div className="ds_accordion-item__header">
|
|
56
58
|
<WrapperTag_1.default id={`panel-${processedId}-heading`} className="ds_accordion-item__title" tagName={headingLevel}>
|
|
57
59
|
{title}
|
|
@@ -76,9 +78,6 @@ const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, ...p
|
|
|
76
78
|
if (!children) {
|
|
77
79
|
hideOpenAll = true;
|
|
78
80
|
}
|
|
79
|
-
function processChild(child) {
|
|
80
|
-
return react_1.default.cloneElement(child, { headingLevel: headingLevel });
|
|
81
|
-
}
|
|
82
81
|
return (<div className={[
|
|
83
82
|
'ds_accordion',
|
|
84
83
|
className
|
|
@@ -93,7 +92,9 @@ const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, ...p
|
|
|
93
92
|
<span className="visually-hidden">sections</span>
|
|
94
93
|
</button>)}
|
|
95
94
|
|
|
96
|
-
{
|
|
95
|
+
<AccordionHeadingLevelContext value={headingLevel}>
|
|
96
|
+
{children}
|
|
97
|
+
</AccordionHeadingLevelContext>
|
|
97
98
|
</div>);
|
|
98
99
|
};
|
|
99
100
|
Accordion.displayName = 'Accordion';
|