@scottish-government/designsystem-react 0.10.1 → 0.11.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.
Files changed (109) hide show
  1. package/.storybook/manager.ts +1 -7
  2. package/.storybook/sgdsArgTypes.ts +19 -0
  3. package/@types/components/Accordion.d.ts +3 -2
  4. package/@types/components/ButtonGroup.d.ts +5 -0
  5. package/@types/components/RadioButton.d.ts +2 -2
  6. package/@types/components/SearchFacets.d.ts +18 -0
  7. package/@types/components/SearchFilters.d.ts +14 -0
  8. package/@types/components/SearchResult.d.ts +30 -0
  9. package/@types/components/SearchSort.d.ts +9 -0
  10. package/@types/components/SideNavigation.d.ts +1 -1
  11. package/CHANGELOG.md +31 -5
  12. package/README.md +3 -0
  13. package/dist/common/AbstractNotificationBanner.jsx +2 -5
  14. package/dist/components/Accordion/Accordion.jsx +8 -3
  15. package/dist/components/ButtonGroup/ButtonGroup.jsx +13 -0
  16. package/dist/components/RadioButton/RadioGroup.jsx +1 -1
  17. package/dist/components/SearchFacets/SearchFacets.jsx +101 -0
  18. package/dist/components/SearchFilters/SearchFilters.jsx +63 -0
  19. package/dist/components/SearchResult/SearchResult.jsx +93 -0
  20. package/dist/components/SearchSort/SearchSort.jsx +28 -0
  21. package/dist/components/SideNavigation/SideNavigation.jsx +2 -2
  22. package/dist/components/TaskList/TaskList.jsx +1 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +3 -3
  25. package/src/common/AbstractNotificationBanner.tsx +2 -6
  26. package/src/components/Accordion/Accordion.Item.stories.tsx +63 -0
  27. package/src/components/Accordion/Accordion.stories.tsx +4 -54
  28. package/src/components/Accordion/Accordion.test.tsx +48 -14
  29. package/src/components/Accordion/Accordion.tsx +12 -1
  30. package/src/components/AspectBox/AspectBox.stories.tsx +1 -1
  31. package/src/components/BackToTop/BackToTop.stories.tsx +1 -1
  32. package/src/components/Breadcrumbs/Breadcrumbs.Item.stories.tsx +42 -0
  33. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +0 -1
  34. package/src/components/Button/Button.stories.tsx +1 -1
  35. package/src/components/ButtonGroup/ButtonGroup.stories.tsx +41 -0
  36. package/src/components/ButtonGroup/ButtonGroup.test.tsx +45 -0
  37. package/src/components/ButtonGroup/ButtonGroup.tsx +20 -0
  38. package/src/components/CategoryItem/CategoryItem.stories.tsx +1 -1
  39. package/src/components/CategoryList/CategoryList.stories.tsx +1 -1
  40. package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
  41. package/src/components/Checkbox/CheckboxGroup.stories.tsx +1 -1
  42. package/src/components/ConfirmationMessage/ConfirmationMessage.stories.tsx +1 -1
  43. package/src/components/ContentsNav/ContentsNav.Item.stories.tsx +53 -0
  44. package/src/components/ContentsNav/ContentsNav.stories.tsx +1 -2
  45. package/src/components/CookieBanner/CookieBanner.Buttons.stories.tsx +27 -0
  46. package/src/components/CookieBanner/CookieBanner.stories.tsx +2 -2
  47. package/src/components/DatePicker/DatePicker.stories.tsx +1 -1
  48. package/src/components/ErrorMessage/ErrorMessage.stories.tsx +1 -1
  49. package/src/components/ErrorSummary/ErrorSummary.Item.stories.tsx +35 -0
  50. package/src/components/ErrorSummary/ErrorSummary.stories.tsx +1 -2
  51. package/src/components/FileDownload/FileDownload.stories.tsx +1 -1
  52. package/src/components/HideThisPage/HideThisPage.stories.tsx +1 -1
  53. package/src/components/InsetText/InsetText.stories.tsx +1 -1
  54. package/src/components/NotificationBanner/NotificationBanner.stories.tsx +1 -1
  55. package/src/components/NotificationPanel/NotificationPanel.stories.tsx +1 -1
  56. package/src/components/PageHeader/PageHeader.stories.tsx +1 -1
  57. package/src/components/PageMetadata/PageMetadata.Item.stories.tsx +40 -0
  58. package/src/components/PageMetadata/PageMetadata.stories.tsx +10 -5
  59. package/src/components/PhaseBanner/PhaseBanner.stories.tsx +1 -1
  60. package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
  61. package/src/components/RadioButton/RadioGroup.stories.tsx +1 -1
  62. package/src/components/RadioButton/RadioGroup.tsx +2 -2
  63. package/src/components/SearchFacets/SearchFacets.Group.stories.tsx +56 -0
  64. package/src/components/SearchFacets/SearchFacets.Item.stories.tsx +53 -0
  65. package/src/components/SearchFacets/SearchFacets.stories.tsx +38 -0
  66. package/src/components/SearchFacets/SearchFacets.test.tsx +214 -0
  67. package/src/components/SearchFacets/SearchFacets.tsx +99 -0
  68. package/src/components/SearchFilters/SearchFilters.Panel.stories.tsx +201 -0
  69. package/src/components/SearchFilters/SearchFilters.stories.tsx +137 -0
  70. package/src/components/SearchFilters/SearchFilters.test.tsx +161 -0
  71. package/src/components/SearchFilters/SearchFilters.tsx +89 -0
  72. package/src/components/SearchResult/SearchResult.stories.tsx +111 -0
  73. package/src/components/SearchResult/SearchResult.test.tsx +215 -0
  74. package/src/components/SearchResult/SearchResult.tsx +137 -0
  75. package/src/components/SearchSort/SearchSort.stories.tsx +32 -0
  76. package/src/components/SearchSort/SearchSort.test.tsx +129 -0
  77. package/src/components/SearchSort/SearchSort.tsx +45 -0
  78. package/src/components/SequentialNavigation/SequentialNavigation.Next.stories.tsx +35 -0
  79. package/src/components/SequentialNavigation/SequentialNavigation.Previous.stories.tsx +35 -0
  80. package/src/components/SequentialNavigation/SequentialNavigation.stories.tsx +1 -2
  81. package/src/components/SequentialNavigation/SequentialNavigation.test.tsx +15 -0
  82. package/src/components/SideNavigation/SideNavigation.Item.stories.tsx +45 -0
  83. package/src/components/SideNavigation/SideNavigation.List.stories.tsx +53 -0
  84. package/src/components/SideNavigation/SideNavigation.stories.tsx +1 -2
  85. package/src/components/SideNavigation/SideNavigation.tsx +2 -1
  86. package/src/components/SiteFooter/SiteFooter.License.stories.tsx +46 -0
  87. package/src/components/SiteFooter/SiteFooter.Link.stories.tsx +34 -0
  88. package/src/components/SiteFooter/SiteFooter.Links.stories.tsx +32 -0
  89. package/src/components/SiteFooter/SiteFooter.Org.stories.tsx +45 -0
  90. package/src/components/SiteFooter/SiteFooter.stories.tsx +1 -1
  91. package/src/components/SiteHeader/SiteHeader.Brand.stories.tsx +45 -0
  92. package/src/components/SiteHeader/SiteHeader.stories.tsx +1 -1
  93. package/src/components/SiteNavigation/SiteNavigation.Item.stories.tsx +40 -0
  94. package/src/components/SiteNavigation/SiteNavigation.stories.tsx +1 -2
  95. package/src/components/SkipLinks/SkipLinks.Item.stories.tsx +37 -0
  96. package/src/components/SkipLinks/SkipLinks.stories.tsx +1 -1
  97. package/src/components/SummaryCard/SummaryCard.Action.stories.tsx +39 -0
  98. package/src/components/SummaryCard/SummaryCard.stories.tsx +8 -1
  99. package/src/components/SummaryList/SummaryList.Action.stories.tsx +32 -0
  100. package/src/components/SummaryList/SummaryList.Item.stories.tsx +50 -0
  101. package/src/components/SummaryList/SummaryList.Value.stories.tsx +30 -0
  102. package/src/components/SummaryList/SummaryList.stories.tsx +1 -1
  103. package/src/components/Tabs/Tabs.Item.stories.tsx +37 -0
  104. package/src/components/Tag/Tag.stories.tsx +2 -6
  105. package/src/components/TaskList/TaskList.Group.stories.tsx +110 -0
  106. package/src/components/TaskList/TaskList.Item.stories.tsx +77 -0
  107. package/src/components/TaskList/TaskList.stories.tsx +1 -1
  108. package/src/components/TaskList/TaskList.test.tsx +21 -1
  109. package/src/components/TaskList/TaskList.tsx +1 -0
@@ -0,0 +1,37 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import argTypes from '../../../.storybook/sgdsArgTypes';
3
+
4
+ import Tabs from './Tabs';
5
+
6
+ const meta = {
7
+ title: 'Components/Tabs/Tabs.Item',
8
+ component: Tabs.Item,
9
+ argTypes: {
10
+ tabLabel: {
11
+ description: '',
12
+ type: {
13
+ name: 'string',
14
+ required: true
15
+ }
16
+ },
17
+ children: argTypes.children()
18
+ },
19
+ args: {
20
+ baseId: 'my-tabs',
21
+ children: [
22
+ <h3>Search for training courses and funding</h3>,
23
+ <p>A wide range of training courses for your employees are available.</p>,
24
+ <p>Opportunities include distance learning, short courses and vocational training.</p>,
25
+ <p><a href="#">Visit My World of Work to search for training courses</a>.</p>,
26
+ <p>You can also <a href="#">search for training courses, and funding towards training</a>.</p>
27
+ ],
28
+ tabLabel: 'Courses and funding'
29
+ }
30
+ } satisfies Meta<typeof Tabs.Item>;
31
+
32
+ export default meta;
33
+ type Story = StoryObj<typeof meta>;
34
+
35
+ export const Default: Story = {
36
+
37
+ };
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import argTypes from '../../../.storybook/sgdsArgTypes';
2
3
 
3
4
  import Tag from './Tag';
4
5
 
@@ -6,12 +7,7 @@ const meta = {
6
7
  title: 'Components/Tag',
7
8
  component: Tag,
8
9
  argTypes: {
9
- colour: {
10
- control: { type: 'select' },
11
- description: 'The tag colour to use',
12
- options: ['', 'blue', 'green', 'grey', 'orange', 'pink', 'purple', 'red', 'teal', 'yellow'],
13
- type: 'string'
14
- },
10
+ colour: argTypes.tagColour(),
15
11
  },
16
12
  } satisfies Meta<typeof Tag>;
17
13
 
@@ -0,0 +1,110 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import argTypes from '../../../.storybook/sgdsArgTypes';
3
+
4
+ import TaskList from './TaskList';
5
+
6
+ const meta = {
7
+ title: 'Components/TaskList/TaskList.Group',
8
+ component: TaskList.Group,
9
+ decorators: [
10
+ Story => (
11
+ <div className="ds_task-list">
12
+ <ul>
13
+ <Story />
14
+ </ul>
15
+ </div>
16
+ )
17
+ ],
18
+ argTypes: {
19
+ headingId: {
20
+ description: 'ID of the task list\'s heading element',
21
+ type: 'string'
22
+ },
23
+ linkComponent: argTypes.linkComponent(),
24
+ title: {
25
+ description: 'The title of the task list',
26
+ type: {
27
+ name: 'string',
28
+ required: true
29
+ }
30
+ },
31
+ children: argTypes.children()
32
+ },
33
+ args: {
34
+ title: 'Tell us about your daily living and mobility circumstances'
35
+ }
36
+ } satisfies Meta<typeof TaskList.Group>;
37
+
38
+ export default meta;
39
+ type Story = StoryObj<typeof meta>;
40
+
41
+ export const Default: Story = {
42
+ render: (args) => (
43
+ <TaskList.Group {...args}>
44
+ <TaskList.Item
45
+ href="#preparing-food"
46
+ id="task-preparing-food"
47
+ statusText="In progress"
48
+ tagColour="grey"
49
+ title="Preparing food"
50
+ >
51
+ Questions about your ability to prepare a simple meal safely and any help you need to do this.
52
+ </TaskList.Item>
53
+ <TaskList.Item
54
+ href="#taking-nutrition"
55
+ id="task-taking-nutrition"
56
+ statusText="Not started"
57
+ tagColour="grey"
58
+ title="Taking nutrition"
59
+ >
60
+ Questions about your ability to eat and drink and any help you need to do this.
61
+ </TaskList.Item>
62
+ <TaskList.Item
63
+ href="#managing-therapy"
64
+ id="task-managing-therapy"
65
+ statusText="Not started"
66
+ tagColour="grey"
67
+ title="Managing therapy or monitoring a health condition"
68
+ >
69
+ Questions about any help you need to monitor changes in your health condition, take medication or do therapy at home.
70
+ </TaskList.Item>
71
+ </TaskList.Group>
72
+ )
73
+ };
74
+
75
+ export const WithIntroduction: Story = {
76
+ args: {
77
+ intro: 'This information will be used to check what additional benefits you may be able to apply for.'
78
+ },
79
+ render: (args) => (
80
+ <TaskList.Group {...args}>
81
+ <TaskList.Item
82
+ href="#preparing-food"
83
+ id="task-preparing-food"
84
+ statusText="In progress"
85
+ tagColour="grey"
86
+ title="Preparing food"
87
+ >
88
+ Questions about your ability to prepare a simple meal safely and any help you need to do this.
89
+ </TaskList.Item>
90
+ <TaskList.Item
91
+ href="#taking-nutrition"
92
+ id="task-taking-nutrition"
93
+ statusText="Not started"
94
+ tagColour="grey"
95
+ title="Taking nutrition"
96
+ >
97
+ Questions about your ability to eat and drink and any help you need to do this.
98
+ </TaskList.Item>
99
+ <TaskList.Item
100
+ href="#managing-therapy"
101
+ id="task-managing-therapy"
102
+ statusText="Not started"
103
+ tagColour="grey"
104
+ title="Managing therapy or monitoring a health condition"
105
+ >
106
+ Questions about any help you need to monitor changes in your health condition, take medication or do therapy at home.
107
+ </TaskList.Item>
108
+ </TaskList.Group>
109
+ )
110
+ };
@@ -0,0 +1,77 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import argTypes from '../../../.storybook/sgdsArgTypes';
3
+
4
+ import TaskList from './TaskList';
5
+
6
+ const meta = {
7
+ title: 'Components/TaskList/TaskList.Item',
8
+ component: TaskList.Item,
9
+ decorators: [
10
+ Story => (
11
+ <ul>
12
+ <Story />
13
+ </ul>
14
+ )
15
+ ],
16
+ argTypes: {
17
+ href: argTypes.href(),
18
+ id: {
19
+ description: 'The value of the task\'s id attribute',
20
+ type: 'string'
21
+ },
22
+ isComplete: {
23
+ control: 'boolean',
24
+ description: 'Whether the task is complete'
25
+ },
26
+ statusText: {
27
+ description: 'The text to use for the task\'s status tag',
28
+ type: 'string'
29
+ },
30
+ tagColour: argTypes.tagColour(),
31
+ title: {
32
+ description: 'The title of the task item',
33
+ type: {
34
+ name: 'string',
35
+ required: true
36
+ }
37
+ },
38
+ children: argTypes.children()
39
+ },
40
+ args: {
41
+ title: 'Medications'
42
+ }
43
+ } satisfies Meta<typeof TaskList.Item>;
44
+
45
+ export default meta;
46
+ type Story = StoryObj<typeof meta>;
47
+
48
+ export const Default: Story = {
49
+
50
+ };
51
+
52
+ export const WithTextDescription: Story = {
53
+ args: {
54
+ children: 'Tell us about any medication you need.'
55
+ }
56
+ };
57
+
58
+ export const WithStatusTag: Story = {
59
+ args: {
60
+ children: 'Tell us about any medication you need.',
61
+ statusText: 'Cannot start yet'
62
+ }
63
+ };
64
+
65
+ export const WithLink: Story = {
66
+ args: {
67
+ children: 'Tell us about any medication you need.',
68
+ href: '#medication'
69
+ }
70
+ };
71
+
72
+ export const Complete: Story = {
73
+ args: {
74
+ children: 'Tell us about any medication you need.',
75
+ isComplete: true
76
+ }
77
+ };
@@ -4,7 +4,7 @@ import argTypes from '../../../.storybook/sgdsArgTypes';
4
4
  import TaskList from './TaskList';
5
5
 
6
6
  const meta = {
7
- title: 'Components/Task list',
7
+ title: 'Components/TaskList',
8
8
  component: TaskList,
9
9
  argTypes: {
10
10
  headingId: {
@@ -219,10 +219,29 @@ test('task with custom link element', () => {
219
219
  });
220
220
 
221
221
  test('completed task has green tag', () => {
222
+ const STATUS_TEXT = 'MY STATUS TEXT';
223
+
224
+ render(
225
+ <TaskList.Item
226
+ id={TASK_ITEM.id}
227
+ statusText={STATUS_TEXT}
228
+ title={TASK_ITEM.title}
229
+ isComplete
230
+ >
231
+ {TASK_SUMMARY_CONTENT}
232
+ </TaskList.Item>
233
+ );
234
+
235
+ const tag = document.querySelector('.ds_tag');
236
+
237
+ expect(tag).toHaveClass('ds_tag--green');
238
+ expect(tag?.textContent).toEqual(STATUS_TEXT);
239
+ });
240
+
241
+ test('completed task has default text if no statusText set', () => {
222
242
  render(
223
243
  <TaskList.Item
224
244
  id={TASK_ITEM.id}
225
- statusText={TASK_ITEM.statusText}
226
245
  title={TASK_ITEM.title}
227
246
  isComplete
228
247
  >
@@ -233,6 +252,7 @@ test('completed task has green tag', () => {
233
252
  const tag = document.querySelector('.ds_tag');
234
253
 
235
254
  expect(tag).toHaveClass('ds_tag--green');
255
+ expect(tag?.textContent).toEqual('Completed');
236
256
  });
237
257
 
238
258
  test('specific tag colour', () => {
@@ -18,6 +18,7 @@ const TaskItem = ({
18
18
  }: SGDS.Component.TaskList.Item) => {
19
19
  if (isComplete) {
20
20
  tagColour = 'green';
21
+ statusText = statusText || 'Completed'
21
22
  }
22
23
 
23
24
  const LINK_CLASS = 'ds_task-list__task-link';