@scottish-government/designsystem-react 0.6.0 → 0.7.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 (151) hide show
  1. package/@types/components/Accordion.d.ts +2 -2
  2. package/@types/components/ConfirmationMessage.d.ts +1 -1
  3. package/@types/components/NotificationPanel.d.ts +1 -1
  4. package/@types/components/SummaryCard.d.ts +1 -1
  5. package/@types/components/Tabs.d.ts +1 -1
  6. package/@types/sgds.d.ts +1 -1
  7. package/CHANGELOG.md +81 -0
  8. package/README.md +4 -0
  9. package/dist/common/AbstractNotificationBanner.jsx +63 -0
  10. package/dist/common/ConditionalWrapper.jsx +8 -0
  11. package/dist/common/FileIcon.jsx +51 -0
  12. package/dist/common/HintText.jsx +9 -0
  13. package/dist/common/Icon.jsx +57 -0
  14. package/dist/common/ScreenReaderText.jsx +9 -0
  15. package/dist/common/WrapperTag.jsx +11 -0
  16. package/dist/components/Accordion/Accordion.jsx +102 -0
  17. package/dist/components/AspectBox/AspectBox.jsx +79 -0
  18. package/dist/components/BackToTop/BackToTop.jsx +27 -0
  19. package/dist/components/Breadcrumbs/Breadcrumbs.jsx +28 -0
  20. package/dist/components/Button/Button.jsx +30 -0
  21. package/dist/components/Checkbox/Checkbox.jsx +62 -0
  22. package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +24 -0
  23. package/dist/components/ContentsNav/ContentsNav.jsx +33 -0
  24. package/dist/components/CookieBanner/CookieBanner.jsx +21 -0
  25. package/dist/components/DatePicker/DatePicker.jsx +54 -0
  26. package/dist/components/Details/Details.jsx +17 -0
  27. package/dist/components/ErrorMessage/ErrorMessage.jsx +12 -0
  28. package/dist/components/ErrorSummary/ErrorSummary.jsx +27 -0
  29. package/dist/components/FileDownload/FileDownload.jsx +50 -0
  30. package/dist/components/HideThisPage/HideThisPage.jsx +71 -0
  31. package/dist/components/InsetText/InsetText.jsx +14 -0
  32. package/dist/components/NotificationBanner/NotificationBanner.jsx +26 -0
  33. package/dist/components/NotificationPanel/NotificationPanel.jsx +21 -0
  34. package/dist/components/PageHeader/PageHeader.jsx +15 -0
  35. package/dist/components/PageMetadata/PageMetadata.jsx +26 -0
  36. package/dist/components/Pagination/Pagination.jsx +97 -0
  37. package/dist/components/PhaseBanner/PhaseBanner.jsx +23 -0
  38. package/dist/components/Question/Question.jsx +22 -0
  39. package/dist/components/RadioButton/RadioButton.jsx +43 -0
  40. package/dist/components/Select/Select.jsx +52 -0
  41. package/dist/components/SequentialNavigation/SequentialNavigation.jsx +31 -0
  42. package/dist/components/SideNavigation/SideNavigation.jsx +52 -0
  43. package/dist/components/SiteHeader/SiteHeader.jsx +68 -0
  44. package/dist/components/SiteNavigation/SiteNavigation.jsx +22 -0
  45. package/dist/components/SiteSearch/SiteSearch.jsx +55 -0
  46. package/dist/components/SkipLinks/SkipLinks.jsx +21 -0
  47. package/dist/components/SummaryCard/SummaryCard.jsx +67 -0
  48. package/dist/components/SummaryList/SummaryList.jsx +75 -0
  49. package/dist/components/Table/Table.jsx +24 -0
  50. package/dist/components/Tabs/Tabs.jsx +99 -0
  51. package/dist/components/Tag/Tag.jsx +13 -0
  52. package/dist/components/TaskList/TaskList.jsx +95 -0
  53. package/dist/components/TextInput/TextInput.jsx +58 -0
  54. package/dist/components/Textarea/Textarea.jsx +54 -0
  55. package/dist/components/WarningText/WarningText.jsx +16 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +1 -1
  58. package/src/common/{abstract-notification-banner.test.tsx → AbstractNotificationBanner.test.tsx} +11 -11
  59. package/src/common/{abstract-notification-banner.tsx → AbstractNotificationBanner.tsx} +2 -2
  60. package/src/common/{conditional-wrapper.test.tsx → ConditionalWrapper.test.tsx} +1 -1
  61. package/src/common/{file-icon.test.tsx → FileIcon.test.tsx} +10 -10
  62. package/src/common/{hint-text.test.tsx → HintText.test.tsx} +12 -12
  63. package/src/common/{icon.test.tsx → Icon.test.tsx} +16 -16
  64. package/src/common/{screen-reader-text.test.tsx → ScreenReaderText.test.tsx} +5 -5
  65. package/src/common/{wrapper-tag.test.tsx → WrapperTag.test.tsx} +5 -5
  66. package/src/components/{accordion/accordion.test.tsx → Accordion/Accordion.test.tsx} +35 -35
  67. package/src/components/{accordion/accordion.tsx → Accordion/Accordion.tsx} +5 -5
  68. package/src/components/{aspect-box/aspect-box.test.tsx → AspectBox/AspectBox.test.tsx} +2 -2
  69. package/src/components/{back-to-top/back-to-top.test.tsx → BackToTop/BackToTop.test.tsx} +1 -1
  70. package/src/components/{back-to-top/back-to-top.tsx → BackToTop/BackToTop.tsx} +1 -1
  71. package/src/components/{breadcrumbs/breadcrumbs.test.tsx → Breadcrumbs/Breadcrumbs.test.tsx} +7 -7
  72. package/src/components/{button/button.test.tsx → Button/Button.test.tsx} +1 -1
  73. package/src/components/{button/button.tsx → Button/Button.tsx} +3 -3
  74. package/src/components/{checkbox/checkbox.test.tsx → Checkbox/Checkbox.test.tsx} +16 -16
  75. package/src/components/{checkbox/checkbox.tsx → Checkbox/Checkbox.tsx} +1 -1
  76. package/src/components/{confirmation-message/confirmation-message.test.tsx → ConfirmationMessage/ConfirmationMessage.test.tsx} +12 -14
  77. package/src/components/{confirmation-message/confirmation-message.tsx → ConfirmationMessage/ConfirmationMessage.tsx} +4 -4
  78. package/src/components/{contents-nav/contents-nav.test.tsx → ContentsNav/ContentsNav.test.tsx} +21 -28
  79. package/src/components/{contents-nav/contents-nav.tsx → ContentsNav/ContentsNav.tsx} +1 -1
  80. package/src/components/{cookie-banner/cookie-banner.test.tsx → CookieBanner/CookieBanner.test.tsx} +3 -3
  81. package/src/components/{cookie-banner/cookie-banner.tsx → CookieBanner/CookieBanner.tsx} +1 -1
  82. package/src/components/{date-picker/date-picker.test.tsx → DatePicker/DatePicker.test.tsx} +76 -66
  83. package/src/components/{date-picker/date-picker.tsx → DatePicker/DatePicker.tsx} +2 -2
  84. package/src/components/{details/details.test.tsx → Details/Details.test.tsx} +10 -10
  85. package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx} +10 -10
  86. package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx} +13 -14
  87. package/src/components/{error-summary/error-summary.tsx → ErrorSummary/ErrorSummary.tsx} +1 -1
  88. package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx} +21 -21
  89. package/src/components/{file-download/file-download.tsx → FileDownload/FileDownload.tsx} +1 -1
  90. package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx} +4 -4
  91. package/src/components/{hide-this-page/hide-this-page.tsx → HideThisPage/HideThisPage.tsx} +3 -3
  92. package/src/components/{inset-text/inset-text.test.tsx → InsetText/InsetText.test.tsx} +1 -1
  93. package/src/components/{notification-banner/notification-banner.test.tsx → NotificationBanner/NotificationBanner.test.tsx} +4 -4
  94. package/src/components/{notification-banner/notification-banner.tsx → NotificationBanner/NotificationBanner.tsx} +1 -1
  95. package/src/components/{notification-panel/notification-panel.test.tsx → NotificationPanel/NotificationPanel.test.tsx} +24 -23
  96. package/src/components/{notification-panel/notification-panel.tsx → NotificationPanel/NotificationPanel.tsx} +3 -3
  97. package/src/components/{page-header/page-header.test.tsx → PageHeader/PageHeader.test.tsx} +9 -9
  98. package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx} +9 -9
  99. package/src/components/{pagination/pagination.test.tsx → Pagination/Pagination.test.tsx} +56 -56
  100. package/src/components/{pagination/pagination.tsx → Pagination/Pagination.tsx} +1 -1
  101. package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx} +9 -9
  102. package/src/components/{phase-banner/phase-banner.tsx → PhaseBanner/PhaseBanner.tsx} +1 -1
  103. package/src/components/{question/question.test.tsx → Question/Question.test.tsx} +10 -10
  104. package/src/components/{question/question.tsx → Question/Question.tsx} +3 -3
  105. package/src/components/{radio-button/radio-button.test.tsx → RadioButton/RadioButton.test.tsx} +23 -23
  106. package/src/components/{radio-button/radio-button.tsx → RadioButton/RadioButton.tsx} +1 -1
  107. package/src/components/{select/select.test.tsx → Select/Select.test.tsx} +67 -64
  108. package/src/components/{select/select.tsx → Select/Select.tsx} +2 -2
  109. package/src/components/{sequential-navigation/sequential-navigation.test.tsx → SequentialNavigation/SequentialNavigation.test.tsx} +18 -18
  110. package/src/components/{side-navigation/side-navigation.test.tsx → SideNavigation/SideNavigation.test.tsx} +8 -8
  111. package/src/components/{site-header/site-header.test.tsx → SiteHeader/SiteHeader.test.tsx} +25 -25
  112. package/src/components/{site-header/site-header.tsx → SiteHeader/SiteHeader.tsx} +4 -4
  113. package/src/components/{site-navigation/site-navigation.test.tsx → SiteNavigation/SiteNavigation.test.tsx} +8 -8
  114. package/src/components/{site-search/site-search.test.tsx → SiteSearch/SiteSearch.test.tsx} +16 -16
  115. package/src/components/{site-search/site-search.tsx → SiteSearch/SiteSearch.tsx} +1 -1
  116. package/src/components/{skip-links/skip-links.test.tsx → SkipLinks/SkipLinks.test.tsx} +15 -15
  117. package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx} +28 -28
  118. package/src/components/{summary-card/summary-card.tsx → SummaryCard/SummaryCard.tsx} +4 -4
  119. package/src/components/{summary-list/summary-list.test.tsx → SummaryList/SummaryList.test.tsx} +55 -56
  120. package/src/components/{summary-list/summary-list.tsx → SummaryList/SummaryList.tsx} +2 -2
  121. package/src/components/{table/table.test.tsx → Table/Table.test.tsx} +4 -4
  122. package/src/components/{tabs/tabs.test.tsx → Tabs/Tabs.test.tsx} +22 -42
  123. package/src/components/{tabs/tabs.tsx → Tabs/Tabs.tsx} +3 -3
  124. package/src/components/{tag/tag.test.tsx → Tag/Tag.test.tsx} +10 -10
  125. package/src/components/{task-list/task-list.test.tsx → TaskList/TaskList.test.tsx} +109 -108
  126. package/src/components/{task-list/task-list.tsx → TaskList/TaskList.tsx} +4 -4
  127. package/src/components/{text-input/text-input.test.tsx → TextInput/TextInput.test.tsx} +92 -87
  128. package/src/components/{text-input/text-input.tsx → TextInput/TextInput.tsx} +4 -4
  129. package/src/components/{textarea/textarea.test.tsx → Textarea/Textarea.test.tsx} +71 -67
  130. package/src/components/{textarea/textarea.tsx → Textarea/Textarea.tsx} +3 -3
  131. package/src/components/{warning-text/warning-text.test.tsx → WarningText/WarningText.test.tsx} +1 -1
  132. /package/src/common/{conditional-wrapper.tsx → ConditionalWrapper.tsx} +0 -0
  133. /package/src/common/{file-icon.tsx → FileIcon.tsx} +0 -0
  134. /package/src/common/{hint-text.tsx → HintText.tsx} +0 -0
  135. /package/src/common/{icon.tsx → Icon.tsx} +0 -0
  136. /package/src/common/{screen-reader-text.tsx → ScreenReaderText.tsx} +0 -0
  137. /package/src/common/{wrapper-tag.tsx → WrapperTag.tsx} +0 -0
  138. /package/src/components/{aspect-box/aspect-box.tsx → AspectBox/AspectBox.tsx} +0 -0
  139. /package/src/components/{breadcrumbs/breadcrumbs.tsx → Breadcrumbs/Breadcrumbs.tsx} +0 -0
  140. /package/src/components/{details/details.tsx → Details/Details.tsx} +0 -0
  141. /package/src/components/{error-message/error-message.tsx → ErrorMessage/ErrorMessage.tsx} +0 -0
  142. /package/src/components/{inset-text/inset-text.tsx → InsetText/InsetText.tsx} +0 -0
  143. /package/src/components/{page-header/page-header.tsx → PageHeader/PageHeader.tsx} +0 -0
  144. /package/src/components/{page-metadata/page-metadata.tsx → PageMetadata/PageMetadata.tsx} +0 -0
  145. /package/src/components/{sequential-navigation/sequential-navigation.tsx → SequentialNavigation/SequentialNavigation.tsx} +0 -0
  146. /package/src/components/{side-navigation/side-navigation.tsx → SideNavigation/SideNavigation.tsx} +0 -0
  147. /package/src/components/{site-navigation/site-navigation.tsx → SiteNavigation/SiteNavigation.tsx} +0 -0
  148. /package/src/components/{skip-links/skip-links.tsx → SkipLinks/SkipLinks.tsx} +0 -0
  149. /package/src/components/{table/table.tsx → Table/Table.tsx} +0 -0
  150. /package/src/components/{tag/tag.tsx → Tag/Tag.tsx} +0 -0
  151. /package/src/components/{warning-text/warning-text.tsx → WarningText/WarningText.tsx} +0 -0
@@ -1,43 +1,43 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen } from '@testing-library/react';
3
- import HintText from './hint-text';
3
+ import HintText from './HintText';
4
4
 
5
- const id = 'hint-text';
6
- const content = 'Hint text';
5
+ const HINT_TEXT_ID = 'hint-text';
6
+ const HINT_TEXT_CONTENT = 'Hint text';
7
7
 
8
8
  test('hint test renders correctly', () => {
9
9
  render(
10
10
  <HintText data-testid="hint-text"
11
- id={id}
12
- text={content}
11
+ id={HINT_TEXT_ID}
12
+ text={HINT_TEXT_CONTENT}
13
13
  />
14
14
  );
15
15
 
16
16
  const hintText = screen.getByTestId('hint-text');
17
17
  expect(hintText).toHaveClass('ds_hint-text');
18
- expect(hintText).toHaveAttribute('id', id);
18
+ expect(hintText).toHaveAttribute('id', HINT_TEXT_ID);
19
19
  expect(hintText.tagName).toEqual('P');
20
- expect(hintText.textContent).toEqual(content);
20
+ expect(hintText.textContent).toEqual(HINT_TEXT_CONTENT);
21
21
  });
22
22
 
23
23
  test('hint test with children instead of text', () => {
24
24
  render(
25
25
  <HintText data-testid="hint-text"
26
- id={id}
26
+ id={HINT_TEXT_ID}
27
27
  >
28
- <span>{content}</span>
28
+ <span>{HINT_TEXT_CONTENT}</span>
29
29
  </HintText>
30
30
  );
31
31
 
32
32
  const hintText = screen.getByTestId('hint-text');
33
- expect(hintText.innerHTML).toEqual(`<span>${content}</span>`);
33
+ expect(hintText.innerHTML).toEqual(`<span>${HINT_TEXT_CONTENT}</span>`);
34
34
  });
35
35
 
36
36
  test('passing additional props', () => {
37
37
  render(
38
38
  <HintText data-testid="hint-text"
39
- id={id}
40
- text={content}
39
+ id={HINT_TEXT_ID}
40
+ text={HINT_TEXT_CONTENT}
41
41
  data-test="foo"
42
42
  />
43
43
  );
@@ -1,13 +1,13 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen } from '@testing-library/react';
3
- import Icon from './icon';
3
+ import Icon from './Icon';
4
4
 
5
- const iconName = 'Search';
5
+ const ICON_NAME = 'Search';
6
6
 
7
7
  test('icon renders correctly', () => {
8
8
  render(
9
9
  <Icon data-testid="icon"
10
- icon={iconName}
10
+ icon={ICON_NAME}
11
11
  />
12
12
  );
13
13
 
@@ -20,24 +20,24 @@ test('icon renders correctly', () => {
20
20
  });
21
21
 
22
22
  test('icon with class name', () => {
23
- const className = 'foo';
23
+ const CLASSNAME = 'foo';
24
24
 
25
25
  render(
26
26
  <Icon data-testid="icon"
27
- icon={iconName}
28
- className={className}
27
+ icon={ICON_NAME}
28
+ className={CLASSNAME}
29
29
  />
30
30
  );
31
31
 
32
32
  const icon = screen.getByRole('img', {hidden: true});
33
33
 
34
- expect(icon).toHaveClass('foo', 'ds_icon');
34
+ expect(icon).toHaveClass(CLASSNAME);
35
35
  });
36
36
 
37
37
  test('icon with fill', () => {
38
38
  render(
39
39
  <Icon data-testid="icon"
40
- icon={iconName}
40
+ icon={ICON_NAME}
41
41
  fill
42
42
  />
43
43
  );
@@ -48,32 +48,32 @@ test('icon with fill', () => {
48
48
  });
49
49
 
50
50
  test('icon with size', () => {
51
- const size = 48;
51
+ const ICON_SIZE = 48;
52
52
 
53
53
  render(
54
54
  <Icon data-testid="icon"
55
- icon={iconName}
56
- iconSize={size}
55
+ icon={ICON_NAME}
56
+ iconSize={ICON_SIZE}
57
57
  />
58
58
  );
59
59
 
60
60
  const icon = screen.getByRole('img', {hidden: true});
61
61
 
62
- expect(icon).toHaveClass(`ds_icon--${size}`);
62
+ expect(icon).toHaveClass(`ds_icon--${ICON_SIZE}`);
63
63
  });
64
64
 
65
65
  test('icon with aria label', () => {
66
- const label = 'My icon';
66
+ const ARIA_LABEL = 'My icon';
67
67
 
68
68
  render(
69
69
  <Icon data-testid="icon"
70
- icon={iconName}
71
- ariaLabel={label}
70
+ icon={ICON_NAME}
71
+ ariaLabel={ARIA_LABEL}
72
72
  />
73
73
  );
74
74
 
75
75
  const icon = screen.getByRole('img', {hidden: true});
76
76
 
77
- expect(icon).toHaveAttribute('aria-label', label);
77
+ expect(icon).toHaveAttribute('aria-label', ARIA_LABEL);
78
78
  expect(icon).not.toHaveAttribute('aria-hidden');
79
79
  });
@@ -1,20 +1,20 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render } from '@testing-library/react';
3
- import ScreenReaderText from './screen-reader-text';
3
+ import ScreenReaderText from './ScreenReaderText';
4
4
 
5
- const content = 'My content';
5
+ const CONTENT = 'My content';
6
6
 
7
7
  test('screen reader text renders correctly', () => {
8
8
  render(
9
9
  <ScreenReaderText>
10
- {content}
10
+ {CONTENT}
11
11
  </ScreenReaderText>
12
12
  );
13
13
 
14
14
  const srtext = document.querySelector('span');
15
15
 
16
16
  expect(srtext).toHaveClass('visually-hidden');
17
- expect(srtext?.textContent).toEqual(content)
17
+ expect(srtext?.textContent).toEqual(CONTENT)
18
18
  });
19
19
 
20
20
  test('passing additional props', () => {
@@ -22,7 +22,7 @@ test('passing additional props', () => {
22
22
  <ScreenReaderText
23
23
  data-test="foo"
24
24
  >
25
- {content}
25
+ {CONTENT}
26
26
  </ScreenReaderText>
27
27
  );
28
28
 
@@ -1,13 +1,13 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render } from '@testing-library/react';
3
- import WrapperTag from './wrapper-tag';
3
+ import WrapperTag from './WrapperTag';
4
4
 
5
- const content = 'My content';
5
+ const CONTENT = 'My content';
6
6
 
7
7
  test('wrapper tag renders correctly', () => {
8
8
  render(
9
9
  <WrapperTag id="foo">
10
- {content}
10
+ {CONTENT}
11
11
  </WrapperTag>
12
12
  );
13
13
 
@@ -21,7 +21,7 @@ test('wrapper tag widh tag name', () => {
21
21
  <WrapperTag id="foo"
22
22
  tagName="section"
23
23
  >
24
- {content}
24
+ {CONTENT}
25
25
  </WrapperTag>
26
26
  );
27
27
 
@@ -33,7 +33,7 @@ test('wrapper tag widh tag name', () => {
33
33
  test('passing additional props', () => {
34
34
  render(
35
35
  <WrapperTag id="foo" data-test="foo">
36
- {content}
36
+ {CONTENT}
37
37
  </WrapperTag>
38
38
  );
39
39
 
@@ -1,18 +1,18 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import Accordion from './accordion';
3
+ import Accordion from './Accordion';
4
4
 
5
- const id = 'my-accordion';
6
- const itemId = 'my-accordion-item';
7
- const titleText = 'Healthcare for veterans';
8
- const contentText = `Veterans are entitled to the same healthcare as any citizen. And there
5
+ const ACCORDION_ID = 'my-accordion';
6
+ const ACCORDION_ITEM_ID = 'my-accordion-item';
7
+ const TITLE_TEXT = 'Healthcare for veterans';
8
+ const CONTENT_TEXT = `Veterans are entitled to the same healthcare as any citizen. And there
9
9
  are health care options and support available specifically for veterans`;
10
10
 
11
11
  test('accordion renders correctly', () => {
12
- const defaultHeaderLevel = 'h3';
12
+ const DEFAULT_HEADING_LEVEL = 'h3';
13
13
 
14
14
  render(
15
- <Accordion id={id} data-testid={id}>
15
+ <Accordion id={ACCORDION_ID} data-testid={ACCORDION_ID}>
16
16
  <Accordion.Item id="accordion-1" title="Healthcare for veterans">
17
17
  <p>Veterans are entitled to the same healthcare as any citizen. And there
18
18
  are health care options and support available specifically for veterans.</p>
@@ -30,7 +30,7 @@ test('accordion renders correctly', () => {
30
30
  </Accordion>
31
31
  );
32
32
 
33
- const accordion = screen.getByTestId(id);
33
+ const accordion = screen.getByTestId(ACCORDION_ID);
34
34
  const openAllButton = document.querySelector('.ds_accordion__open-all');
35
35
  const accordionItems = document.querySelectorAll('.ds_accordion-item');
36
36
  const firstAccordionTitle = document.querySelector('.ds_accordion-item__title');
@@ -45,12 +45,12 @@ test('accordion renders correctly', () => {
45
45
 
46
46
  expect(accordionItems.length).toEqual(3);
47
47
 
48
- expect(firstAccordionTitle?.tagName).toEqual(defaultHeaderLevel.toUpperCase());
48
+ expect(firstAccordionTitle?.tagName).toEqual(DEFAULT_HEADING_LEVEL.toUpperCase());
49
49
  });
50
50
 
51
51
  test('accordion without open all', () => {
52
52
  render(
53
- <Accordion id={id} data-testid={id} hideOpenAll>
53
+ <Accordion id={ACCORDION_ID} data-testid={ACCORDION_ID} hideOpenAll>
54
54
  <Accordion.Item id="accordion-1" title="Healthcare for veterans">
55
55
  <p>Veterans are entitled to the same healthcare as any citizen. And there
56
56
  are health care options and support available specifically for veterans.</p>
@@ -75,7 +75,7 @@ test('accordion without open all', () => {
75
75
 
76
76
  test('empty accordion has no open all', () => {
77
77
  render(
78
- <Accordion id={id} data-testid={id} hideOpenAll>
78
+ <Accordion id={ACCORDION_ID} data-testid={ACCORDION_ID} hideOpenAll>
79
79
  </Accordion>
80
80
  );
81
81
 
@@ -84,11 +84,11 @@ test('empty accordion has no open all', () => {
84
84
  expect(openAllButton).toBeNull();
85
85
  })
86
86
 
87
- test('accordion with custom header level', () => {
88
- const headerLevel = 'h2';
87
+ test('accordion with custom heading level', () => {
88
+ const HEADING_LEVEL = 'h2';
89
89
 
90
90
  render(
91
- <Accordion id={id} data-testid={id} headerLevel={headerLevel}>
91
+ <Accordion id={ACCORDION_ID} data-testid={ACCORDION_ID} headingLevel={HEADING_LEVEL}>
92
92
  <Accordion.Item id="accordion-1" title="Healthcare for veterans">
93
93
  <p>Veterans are entitled to the same healthcare as any citizen. And there
94
94
  are health care options and support available specifically for veterans.</p>
@@ -99,37 +99,37 @@ test('accordion with custom header level', () => {
99
99
  );
100
100
 
101
101
  const firstAccordionTitle = document.querySelector('.ds_accordion-item__title');
102
- expect(firstAccordionTitle?.tagName).toEqual(headerLevel.toUpperCase());
102
+ expect(firstAccordionTitle?.tagName).toEqual(HEADING_LEVEL.toUpperCase());
103
103
  });
104
104
 
105
105
  test('passing additional props to accordion', () => {
106
106
  render(
107
- <Accordion id={id} data-testid={id} data-test="foo">
107
+ <Accordion id={ACCORDION_ID} data-testid={ACCORDION_ID} data-test="foo">
108
108
  </Accordion>
109
109
  );
110
110
 
111
- const accordion = screen.getByTestId(id);
111
+ const accordion = screen.getByTestId(ACCORDION_ID);
112
112
  expect(accordion?.dataset.test).toEqual('foo');
113
113
  });
114
114
 
115
115
  test('passing additional CSS classes', () => {
116
116
  render(
117
- <Accordion id={id} data-testid={id} className="foo">
117
+ <Accordion id={ACCORDION_ID} data-testid={ACCORDION_ID} className="foo">
118
118
  </Accordion>
119
119
  );
120
120
 
121
- const accordion = screen.getByTestId(id);
121
+ const accordion = screen.getByTestId(ACCORDION_ID);
122
122
  expect(accordion).toHaveClass('foo', 'ds_accordion');
123
123
  });
124
124
 
125
125
  test('accordion item renders correctly', () => {
126
126
  render(
127
- <Accordion.Item id={itemId} data-testid={itemId} title={titleText}>
128
- <p>{contentText}</p>
127
+ <Accordion.Item id={ACCORDION_ITEM_ID} data-testid={ACCORDION_ITEM_ID} title={TITLE_TEXT}>
128
+ <p>{CONTENT_TEXT}</p>
129
129
  </Accordion.Item>
130
130
  );
131
131
 
132
- const accordionItem = screen.getByTestId(itemId);
132
+ const accordionItem = screen.getByTestId(ACCORDION_ITEM_ID);
133
133
  const input = within(accordionItem).getByRole('checkbox');
134
134
  const header = document.querySelector('.ds_accordion-item__header');
135
135
  const title = header?.querySelector('.ds_accordion-item__title');
@@ -138,16 +138,16 @@ test('accordion item renders correctly', () => {
138
138
  const body = document.querySelector('.ds_accordion-item__body');
139
139
 
140
140
  expect(accordionItem).toHaveClass('ds_accordion-item');
141
- expect(accordionItem).toHaveAttribute('id', itemId);
141
+ expect(accordionItem).toHaveAttribute('id', ACCORDION_ITEM_ID);
142
142
 
143
143
  expect(input).toHaveClass('ds_accordion-item__control', 'visually-hidden')
144
- expect(input).toHaveAttribute('id', `${itemId}-control`);
144
+ expect(input).toHaveAttribute('id', `${ACCORDION_ITEM_ID}-control`);
145
145
 
146
146
  expect(header?.tagName).toEqual('DIV');
147
147
 
148
- expect(title).toHaveAttribute('id', `panel-${itemId}-heading`);
148
+ expect(title).toHaveAttribute('id', `panel-${ACCORDION_ITEM_ID}-heading`);
149
149
  expect(title?.tagName).toEqual('H3');
150
- expect(title?.textContent).toEqual(titleText);
150
+ expect(title?.textContent).toEqual(TITLE_TEXT);
151
151
 
152
152
  expect(indicator?.tagName).toEqual('SPAN');
153
153
 
@@ -156,12 +156,12 @@ test('accordion item renders correctly', () => {
156
156
  expect(label?.textContent).toEqual('Show this section');
157
157
  expect(label?.children[0]).toHaveClass('visually-hidden');
158
158
 
159
- expect(body?.innerHTML).toEqual(`<p>${contentText}</p>`);
159
+ expect(body?.innerHTML).toEqual(`<p>${CONTENT_TEXT}</p>`);
160
160
  });
161
161
 
162
162
  test('accordion items without ID are given unique IDs', () => {
163
163
  render(
164
- <Accordion id={id} data-testid={id} hideOpenAll>
164
+ <Accordion id={ACCORDION_ID} data-testid={ACCORDION_ID} hideOpenAll>
165
165
  <Accordion.Item data-testid="item1" title="Healthcare for veterans">
166
166
  <p>Veterans are entitled to the same healthcare as any citizen. And there
167
167
  are health care options and support available specifically for veterans.</p>
@@ -194,12 +194,12 @@ test('accordion items without ID are given unique IDs', () => {
194
194
 
195
195
  test('open accordion item', () => {
196
196
  render(
197
- <Accordion.Item open id={itemId} data-testid={itemId} title={titleText}>
198
- <p>{contentText}</p>
197
+ <Accordion.Item open id={ACCORDION_ITEM_ID} data-testid={ACCORDION_ITEM_ID} title={TITLE_TEXT}>
198
+ <p>{CONTENT_TEXT}</p>
199
199
  </Accordion.Item>
200
200
  );
201
201
 
202
- const accordionItem = screen.getByTestId(itemId);
202
+ const accordionItem = screen.getByTestId(ACCORDION_ITEM_ID);
203
203
  const input = within(accordionItem).getByRole('checkbox');
204
204
 
205
205
  expect(input).toHaveAttribute('checked');
@@ -207,7 +207,7 @@ test('open accordion item', () => {
207
207
 
208
208
  test('passing additional props to accordion item', () => {
209
209
  render(
210
- <Accordion.Item id={itemId} data-testid={itemId} title="Healthcare for veterans" data-test="foo">
210
+ <Accordion.Item id={ACCORDION_ITEM_ID} data-testid={ACCORDION_ITEM_ID} title="Healthcare for veterans" data-test="foo">
211
211
  <p>Veterans are entitled to the same healthcare as any citizen. And there
212
212
  are health care options and support available specifically for veterans.</p>
213
213
  <p>If you have a health condition that’s related to your service, you’re
@@ -215,13 +215,13 @@ test('passing additional props to accordion item', () => {
215
215
  </Accordion.Item>
216
216
  );
217
217
 
218
- const accordionItem = screen.getByTestId(itemId);
218
+ const accordionItem = screen.getByTestId(ACCORDION_ITEM_ID);
219
219
  expect(accordionItem?.dataset.test).toEqual('foo');
220
220
  });
221
221
 
222
222
  test('passing additional CSS classes', () => {
223
223
  render(
224
- <Accordion.Item id={itemId} data-testid={itemId} title="Healthcare for veterans" className="foo">
224
+ <Accordion.Item id={ACCORDION_ITEM_ID} data-testid={ACCORDION_ITEM_ID} title="Healthcare for veterans" className="foo">
225
225
  <p>Veterans are entitled to the same healthcare as any citizen. And there
226
226
  are health care options and support available specifically for veterans.</p>
227
227
  <p>If you have a health condition that’s related to your service, you’re
@@ -229,6 +229,6 @@ test('passing additional CSS classes', () => {
229
229
  </Accordion.Item>
230
230
  );
231
231
 
232
- const accordionItem = screen.getByTestId(itemId);
232
+ const accordionItem = screen.getByTestId(ACCORDION_ITEM_ID);
233
233
  expect(accordionItem).toHaveClass('foo', 'ds_accordion-item');
234
234
  });
@@ -1,5 +1,5 @@
1
1
  import React, { Children, useEffect, useRef } from 'react';
2
- import WrapperTag from '../../common/wrapper-tag';
2
+ import WrapperTag from '../../common/WrapperTag';
3
3
  // @ts-ignore
4
4
  import DSAccordion from '@scottish-government/design-system/src/components/accordion/accordion';
5
5
 
@@ -8,7 +8,7 @@ let accordionItemCounter = 0;
8
8
  const AccordionItem: React.FC<SGDS.Component.Accordion.Item> = ({
9
9
  children,
10
10
  className,
11
- headerLevel = 'h3',
11
+ headingLevel = 'h3',
12
12
  id: rawId,
13
13
  open = false,
14
14
  title,
@@ -39,7 +39,7 @@ const AccordionItem: React.FC<SGDS.Component.Accordion.Item> = ({
39
39
  <WrapperTag
40
40
  id={`panel-${processedId}-heading`}
41
41
  className="ds_accordion-item__title"
42
- tagName={headerLevel}
42
+ tagName={headingLevel}
43
43
  >
44
44
  {title}
45
45
  </WrapperTag>
@@ -62,7 +62,7 @@ const Accordion: React.FC<SGDS.Component.Accordion>
62
62
  & { Item: React.FC<SGDS.Component.Accordion.Item> } = ({
63
63
  children,
64
64
  className,
65
- headerLevel = 'h3',
65
+ headingLevel = 'h3',
66
66
  hideOpenAll,
67
67
  ...props
68
68
  }) => {
@@ -79,7 +79,7 @@ const Accordion: React.FC<SGDS.Component.Accordion>
79
79
  }
80
80
 
81
81
  function processChild(child: any) {
82
- return React.cloneElement(child, { headerLevel: headerLevel });
82
+ return React.cloneElement(child, { headingLevel: headingLevel });
83
83
  }
84
84
 
85
85
  return (
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from 'vitest';
2
- import { render, screen } from '@testing-library/react';
3
- import AspectBox from './aspect-box';
2
+ import { render } from '@testing-library/react';
3
+ import AspectBox from './AspectBox';
4
4
 
5
5
  test('aspect box renders correctly', () => {
6
6
  render(
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import BackToTop from './back-to-top';
3
+ import BackToTop from './BackToTop';
4
4
 
5
5
  test('back to top renders correctly', () => {
6
6
  render(
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef } from 'react';
2
+ import Icon from '../../common/Icon';
2
3
  // @ts-ignore
3
4
  import DSBackToTop from '@scottish-government/design-system/src/components/back-to-top/back-to-top';
4
- import Icon from '../../common/icon';
5
5
 
6
6
  const BackToTop: React.FC<SGDS.Component.BackToTop> = ({
7
7
  className,
@@ -1,8 +1,8 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import Breadcrumbs from './breadcrumbs';
3
+ import Breadcrumbs from './Breadcrumbs';
4
4
 
5
- const items = [
5
+ const ITEMS = [
6
6
  { href: 'home', title: 'Home' },
7
7
  { href: 'category', title: 'Category' },
8
8
  { title: 'Page' }
@@ -10,7 +10,7 @@ const items = [
10
10
 
11
11
  test('renders correctly', () => {
12
12
  render(
13
- <Breadcrumbs items={items} />
13
+ <Breadcrumbs items={ITEMS} />
14
14
  );
15
15
 
16
16
  const nav = screen.getByRole('navigation');
@@ -25,7 +25,7 @@ test('renders correctly', () => {
25
25
  expect(list).toHaveClass('ds_breadcrumbs');
26
26
 
27
27
  // check items
28
- expect(listItems.length).toEqual(items.length);
28
+ expect(listItems.length).toEqual(ITEMS.length);
29
29
 
30
30
  listItems.forEach((item, index) => {
31
31
  expect(item).toHaveClass('ds_breadcrumbs__item');
@@ -49,7 +49,7 @@ test('renders with last item hidden', () => {
49
49
  render(
50
50
  <Breadcrumbs
51
51
  hideLastItem
52
- items={items}
52
+ items={ITEMS}
53
53
  />
54
54
  );
55
55
 
@@ -67,7 +67,7 @@ test('renders with last item hidden', () => {
67
67
  test('passing additional props', () => {
68
68
  render(
69
69
  <Breadcrumbs
70
- items={items}
70
+ items={ITEMS}
71
71
  data-test="foo"
72
72
  />
73
73
  );
@@ -79,7 +79,7 @@ test('passing additional props', () => {
79
79
  test('passing additional CSS classes', () => {
80
80
  render(
81
81
  <Breadcrumbs
82
- items={items}
82
+ items={ITEMS}
83
83
  className="foo"
84
84
  />
85
85
  );
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import Button from './button';
3
+ import Button from './Button';
4
4
 
5
5
  test('renders correctly', () => {
6
6
  render(
@@ -1,6 +1,6 @@
1
- import Icon from '../../common/icon';
2
- import ScreenReaderText from '../../common/screen-reader-text';
3
- import WrapperTag from '../../common/wrapper-tag';
1
+ import Icon from '../../common/Icon';
2
+ import ScreenReaderText from '../../common/ScreenReaderText';
3
+ import WrapperTag from '../../common/WrapperTag';
4
4
 
5
5
  const Button: React.FC<SGDS.Component.Button> = ({
6
6
  buttonStyle,
@@ -1,9 +1,9 @@
1
1
  import { test, expect, vi } from 'vitest';
2
2
  import { render, screen, fireEvent } from '@testing-library/react';
3
- import CheckboxGroup, { Checkbox } from './checkbox';
3
+ import CheckboxGroup, { Checkbox } from './Checkbox';
4
4
 
5
5
  test('checkbox group renders correct children', () => {
6
- const items = [
6
+ const ITEMS = [
7
7
  {
8
8
  id: 'universal-credit',
9
9
  label: 'Universal Credit',
@@ -25,18 +25,18 @@ test('checkbox group renders correct children', () => {
25
25
  ];
26
26
 
27
27
  render(
28
- <CheckboxGroup items={items} />
28
+ <CheckboxGroup items={ITEMS} />
29
29
  );
30
30
 
31
31
  const checkboxes = screen.getAllByRole('checkbox');
32
32
  const groupContainer = checkboxes[0].parentElement?.parentElement;
33
- expect(checkboxes.length).toEqual(items.length);
33
+ expect(checkboxes.length).toEqual(ITEMS.length);
34
34
  expect(groupContainer).toHaveClass('ds_checkboxes', 'ds_field-group');
35
35
  });
36
36
 
37
37
  test('checkbox group passes all expected item params', () => {
38
- const onBlurFn = vi.fn();
39
- const onChangeFn = vi.fn();
38
+ const ONBLUR_FUNCTION = vi.fn();
39
+ const ONCHANGE_FUNCTION = vi.fn();
40
40
 
41
41
  render(
42
42
  <CheckboxGroup small items={[
@@ -46,8 +46,8 @@ test('checkbox group passes all expected item params', () => {
46
46
  hintText: 'hint text',
47
47
  id: 'myid',
48
48
  label: 'label text',
49
- onBlur: {onBlurFn},
50
- onChange: {onChangeFn},
49
+ onBlur: {ONBLUR_FUNCTION},
50
+ onChange: {ONCHANGE_FUNCTION},
51
51
  small: true
52
52
  }
53
53
  ]}/>
@@ -65,10 +65,10 @@ test('checkbox group passes all expected item params', () => {
65
65
  expect(checkbox).toHaveAttribute('aria-describedby', hintText.id);
66
66
 
67
67
  // fireEvent.blur(checkbox);
68
- // expect(onBlurFn).toHaveBeenCalled();
68
+ // expect(ONBLUR_FUNCTION).toHaveBeenCalled();
69
69
 
70
70
  // fireEvent.click(checkbox);
71
- // expect(onChangeFn).toHaveBeenCalled();
71
+ // expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
72
72
  });
73
73
 
74
74
  test('individual checkbox renders correctly', () => {
@@ -116,31 +116,31 @@ test('exclusive checkbox', () => {
116
116
  });
117
117
 
118
118
  test('checkbox with blur fn', () => {
119
- const onBlurFn = vi.fn();
119
+ const ONBLUR_FUNCTION = vi.fn();
120
120
 
121
121
  render(
122
- <Checkbox onBlur={onBlurFn} label="Pension Credit" id="pensioncredit" />
122
+ <Checkbox onBlur={ONBLUR_FUNCTION} label="Pension Credit" id="pensioncredit" />
123
123
  );
124
124
 
125
125
  const checkbox = screen.getByRole('checkbox');
126
126
 
127
127
  fireEvent.blur(checkbox);
128
128
 
129
- expect(onBlurFn).toHaveBeenCalled();
129
+ expect(ONBLUR_FUNCTION).toHaveBeenCalled();
130
130
  });
131
131
 
132
132
  test('checkbox with change fn', () => {
133
- const onChangeFn = vi.fn();
133
+ const ONCHANGE_FUNCTION = vi.fn();
134
134
 
135
135
  render(
136
- <Checkbox onChange={onChangeFn} label="Pension Credit" id="pensioncredit" />
136
+ <Checkbox onChange={ONCHANGE_FUNCTION} label="Pension Credit" id="pensioncredit" />
137
137
  );
138
138
 
139
139
  const checkbox = screen.getByRole('checkbox');
140
140
 
141
141
  fireEvent.click(checkbox);
142
142
 
143
- expect(onChangeFn).toHaveBeenCalled();
143
+ expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
144
144
  });
145
145
 
146
146
  test('checkbox with hint text', () => {