@scottish-government/designsystem-react 0.6.0 → 0.7.1

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 (169) 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/{abstract-notification-banner.jsx → AbstractNotificationBanner.jsx} +5 -5
  10. package/dist/components/{accordion/accordion.jsx → Accordion/Accordion.jsx} +6 -6
  11. package/dist/components/{back-to-top/back-to-top.jsx → BackToTop/BackToTop.jsx} +2 -2
  12. package/dist/components/{button/button.jsx → Button/Button.jsx} +7 -7
  13. package/dist/components/{checkbox/checkbox.jsx → Checkbox/Checkbox.jsx} +2 -2
  14. package/dist/components/{confirmation-message/confirmation-message.jsx → ConfirmationMessage/ConfirmationMessage.jsx} +6 -6
  15. package/dist/components/{contents-nav/contents-nav.jsx → ContentsNav/ContentsNav.jsx} +3 -3
  16. package/dist/components/{cookie-banner/cookie-banner.jsx → CookieBanner/CookieBanner.jsx} +4 -4
  17. package/dist/components/{date-picker/date-picker.jsx → DatePicker/DatePicker.jsx} +7 -7
  18. package/dist/components/{error-summary/error-summary.jsx → ErrorSummary/ErrorSummary.jsx} +2 -2
  19. package/dist/components/{file-download/file-download.jsx → FileDownload/FileDownload.jsx} +2 -2
  20. package/dist/components/{hide-this-page/hide-this-page.jsx → HideThisPage/HideThisPage.jsx} +3 -3
  21. package/dist/components/{notification-banner/notification-banner.jsx → NotificationBanner/NotificationBanner.jsx} +4 -4
  22. package/dist/components/{notification-panel/notification-panel.jsx → NotificationPanel/NotificationPanel.jsx} +4 -4
  23. package/dist/components/{pagination/pagination.jsx → Pagination/Pagination.jsx} +3 -3
  24. package/dist/components/{phase-banner/phase-banner.jsx → PhaseBanner/PhaseBanner.jsx} +2 -2
  25. package/dist/components/{question/question.jsx → Question/Question.jsx} +7 -7
  26. package/dist/components/{radio-button/radio-button.jsx → RadioButton/RadioButton.jsx} +2 -2
  27. package/dist/components/{select/select.jsx → Select/Select.jsx} +4 -4
  28. package/dist/components/{site-header/site-header.jsx → SiteHeader/SiteHeader.jsx} +13 -13
  29. package/dist/components/{site-search/site-search.jsx → SiteSearch/SiteSearch.jsx} +2 -2
  30. package/dist/components/{summary-card/summary-card.jsx → SummaryCard/SummaryCard.jsx} +6 -6
  31. package/dist/components/{summary-list/summary-list.jsx → SummaryList/SummaryList.jsx} +8 -8
  32. package/dist/components/{tabs/tabs.jsx → Tabs/Tabs.jsx} +4 -4
  33. package/dist/components/{task-list/task-list.jsx → TaskList/TaskList.jsx} +9 -9
  34. package/dist/components/{text-input/text-input.jsx → TextInput/TextInput.jsx} +11 -11
  35. package/dist/components/{textarea/textarea.jsx → Textarea/Textarea.jsx} +7 -7
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +1 -1
  38. package/src/common/{abstract-notification-banner.test.tsx → AbstractNotificationBanner.test.tsx} +11 -11
  39. package/src/common/{abstract-notification-banner.tsx → AbstractNotificationBanner.tsx} +2 -2
  40. package/src/common/{conditional-wrapper.test.tsx → ConditionalWrapper.test.tsx} +1 -1
  41. package/src/common/{file-icon.test.tsx → FileIcon.test.tsx} +10 -10
  42. package/src/common/{hint-text.test.tsx → HintText.test.tsx} +12 -12
  43. package/src/common/{icon.test.tsx → Icon.test.tsx} +16 -16
  44. package/src/common/{screen-reader-text.test.tsx → ScreenReaderText.test.tsx} +5 -5
  45. package/src/common/{wrapper-tag.test.tsx → WrapperTag.test.tsx} +5 -5
  46. package/src/components/{accordion/accordion.test.tsx → Accordion/Accordion.test.tsx} +35 -35
  47. package/src/components/{accordion/accordion.tsx → Accordion/Accordion.tsx} +5 -5
  48. package/src/components/{aspect-box/aspect-box.test.tsx → AspectBox/AspectBox.test.tsx} +2 -2
  49. package/src/components/{back-to-top/back-to-top.test.tsx → BackToTop/BackToTop.test.tsx} +1 -1
  50. package/src/components/{back-to-top/back-to-top.tsx → BackToTop/BackToTop.tsx} +1 -1
  51. package/src/components/{breadcrumbs/breadcrumbs.test.tsx → Breadcrumbs/Breadcrumbs.test.tsx} +7 -7
  52. package/src/components/{button/button.test.tsx → Button/Button.test.tsx} +1 -1
  53. package/src/components/{button/button.tsx → Button/Button.tsx} +3 -3
  54. package/src/components/{checkbox/checkbox.test.tsx → Checkbox/Checkbox.test.tsx} +16 -16
  55. package/src/components/{checkbox/checkbox.tsx → Checkbox/Checkbox.tsx} +1 -1
  56. package/src/components/{confirmation-message/confirmation-message.test.tsx → ConfirmationMessage/ConfirmationMessage.test.tsx} +12 -14
  57. package/src/components/{confirmation-message/confirmation-message.tsx → ConfirmationMessage/ConfirmationMessage.tsx} +4 -4
  58. package/src/components/{contents-nav/contents-nav.test.tsx → ContentsNav/ContentsNav.test.tsx} +21 -28
  59. package/src/components/{contents-nav/contents-nav.tsx → ContentsNav/ContentsNav.tsx} +1 -1
  60. package/src/components/{cookie-banner/cookie-banner.test.tsx → CookieBanner/CookieBanner.test.tsx} +3 -3
  61. package/src/components/{cookie-banner/cookie-banner.tsx → CookieBanner/CookieBanner.tsx} +1 -1
  62. package/src/components/{date-picker/date-picker.test.tsx → DatePicker/DatePicker.test.tsx} +76 -66
  63. package/src/components/{date-picker/date-picker.tsx → DatePicker/DatePicker.tsx} +2 -2
  64. package/src/components/{details/details.test.tsx → Details/Details.test.tsx} +10 -10
  65. package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx} +10 -10
  66. package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx} +13 -14
  67. package/src/components/{error-summary/error-summary.tsx → ErrorSummary/ErrorSummary.tsx} +1 -1
  68. package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx} +21 -21
  69. package/src/components/{file-download/file-download.tsx → FileDownload/FileDownload.tsx} +1 -1
  70. package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx} +4 -4
  71. package/src/components/{hide-this-page/hide-this-page.tsx → HideThisPage/HideThisPage.tsx} +3 -3
  72. package/src/components/{inset-text/inset-text.test.tsx → InsetText/InsetText.test.tsx} +1 -1
  73. package/src/components/{notification-banner/notification-banner.test.tsx → NotificationBanner/NotificationBanner.test.tsx} +4 -4
  74. package/src/components/{notification-banner/notification-banner.tsx → NotificationBanner/NotificationBanner.tsx} +1 -1
  75. package/src/components/{notification-panel/notification-panel.test.tsx → NotificationPanel/NotificationPanel.test.tsx} +24 -23
  76. package/src/components/{notification-panel/notification-panel.tsx → NotificationPanel/NotificationPanel.tsx} +3 -3
  77. package/src/components/{page-header/page-header.test.tsx → PageHeader/PageHeader.test.tsx} +9 -9
  78. package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx} +9 -9
  79. package/src/components/{pagination/pagination.test.tsx → Pagination/Pagination.test.tsx} +56 -56
  80. package/src/components/{pagination/pagination.tsx → Pagination/Pagination.tsx} +1 -1
  81. package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx} +9 -9
  82. package/src/components/{phase-banner/phase-banner.tsx → PhaseBanner/PhaseBanner.tsx} +1 -1
  83. package/src/components/{question/question.test.tsx → Question/Question.test.tsx} +10 -10
  84. package/src/components/{question/question.tsx → Question/Question.tsx} +3 -3
  85. package/src/components/{radio-button/radio-button.test.tsx → RadioButton/RadioButton.test.tsx} +23 -23
  86. package/src/components/{radio-button/radio-button.tsx → RadioButton/RadioButton.tsx} +1 -1
  87. package/src/components/{select/select.test.tsx → Select/Select.test.tsx} +67 -64
  88. package/src/components/{select/select.tsx → Select/Select.tsx} +2 -2
  89. package/src/components/{sequential-navigation/sequential-navigation.test.tsx → SequentialNavigation/SequentialNavigation.test.tsx} +18 -18
  90. package/src/components/{side-navigation/side-navigation.test.tsx → SideNavigation/SideNavigation.test.tsx} +8 -8
  91. package/src/components/{site-header/site-header.test.tsx → SiteHeader/SiteHeader.test.tsx} +25 -25
  92. package/src/components/{site-header/site-header.tsx → SiteHeader/SiteHeader.tsx} +4 -4
  93. package/src/components/{site-navigation/site-navigation.test.tsx → SiteNavigation/SiteNavigation.test.tsx} +8 -8
  94. package/src/components/{site-search/site-search.test.tsx → SiteSearch/SiteSearch.test.tsx} +16 -16
  95. package/src/components/{site-search/site-search.tsx → SiteSearch/SiteSearch.tsx} +1 -1
  96. package/src/components/{skip-links/skip-links.test.tsx → SkipLinks/SkipLinks.test.tsx} +15 -15
  97. package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx} +28 -28
  98. package/src/components/{summary-card/summary-card.tsx → SummaryCard/SummaryCard.tsx} +4 -4
  99. package/src/components/{summary-list/summary-list.test.tsx → SummaryList/SummaryList.test.tsx} +55 -56
  100. package/src/components/{summary-list/summary-list.tsx → SummaryList/SummaryList.tsx} +2 -2
  101. package/src/components/{table/table.test.tsx → Table/Table.test.tsx} +4 -4
  102. package/src/components/{tabs/tabs.test.tsx → Tabs/Tabs.test.tsx} +22 -42
  103. package/src/components/{tabs/tabs.tsx → Tabs/Tabs.tsx} +3 -3
  104. package/src/components/{tag/tag.test.tsx → Tag/Tag.test.tsx} +10 -10
  105. package/src/components/{task-list/task-list.test.tsx → TaskList/TaskList.test.tsx} +109 -108
  106. package/src/components/{task-list/task-list.tsx → TaskList/TaskList.tsx} +4 -4
  107. package/src/components/{text-input/text-input.test.tsx → TextInput/TextInput.test.tsx} +92 -87
  108. package/src/components/{text-input/text-input.tsx → TextInput/TextInput.tsx} +4 -4
  109. package/src/components/{textarea/textarea.test.tsx → Textarea/Textarea.test.tsx} +71 -67
  110. package/src/components/{textarea/textarea.tsx → Textarea/Textarea.tsx} +3 -3
  111. package/src/components/{warning-text/warning-text.test.tsx → WarningText/WarningText.test.tsx} +1 -1
  112. package/dist/icons/ArrowUpward.jsx +0 -41
  113. package/dist/icons/CalendarToday.jsx +0 -41
  114. package/dist/icons/Cancel.jsx +0 -40
  115. package/dist/icons/CheckCircle.jsx +0 -41
  116. package/dist/icons/ChevronLeft.jsx +0 -41
  117. package/dist/icons/ChevronRight.jsx +0 -41
  118. package/dist/icons/Close.jsx +0 -41
  119. package/dist/icons/Description.jsx +0 -41
  120. package/dist/icons/DoubleChevronLeft.jsx +0 -40
  121. package/dist/icons/DoubleChevronRight.jsx +0 -40
  122. package/dist/icons/Error.jsx +0 -41
  123. package/dist/icons/ExpandLess.jsx +0 -41
  124. package/dist/icons/ExpandMore.jsx +0 -41
  125. package/dist/icons/List.jsx +0 -44
  126. package/dist/icons/Menu.jsx +0 -41
  127. package/dist/icons/PriorityHigh.jsx +0 -42
  128. package/dist/icons/Search.jsx +0 -41
  129. package/dist/icons/index.js +0 -40
  130. /package/dist/common/{conditional-wrapper.jsx → ConditionalWrapper.jsx} +0 -0
  131. /package/dist/common/{file-icon.jsx → FileIcon.jsx} +0 -0
  132. /package/dist/common/{hint-text.jsx → HintText.jsx} +0 -0
  133. /package/dist/common/{icon.jsx → Icon.jsx} +0 -0
  134. /package/dist/common/{screen-reader-text.jsx → ScreenReaderText.jsx} +0 -0
  135. /package/dist/common/{wrapper-tag.jsx → WrapperTag.jsx} +0 -0
  136. /package/dist/components/{aspect-box/aspect-box.jsx → AspectBox/AspectBox.jsx} +0 -0
  137. /package/dist/components/{breadcrumbs/breadcrumbs.jsx → Breadcrumbs/Breadcrumbs.jsx} +0 -0
  138. /package/dist/components/{details/details.jsx → Details/Details.jsx} +0 -0
  139. /package/dist/components/{error-message/error-message.jsx → ErrorMessage/ErrorMessage.jsx} +0 -0
  140. /package/dist/components/{inset-text/inset-text.jsx → InsetText/InsetText.jsx} +0 -0
  141. /package/dist/components/{page-header/page-header.jsx → PageHeader/PageHeader.jsx} +0 -0
  142. /package/dist/components/{page-metadata/page-metadata.jsx → PageMetadata/PageMetadata.jsx} +0 -0
  143. /package/dist/components/{sequential-navigation/sequential-navigation.jsx → SequentialNavigation/SequentialNavigation.jsx} +0 -0
  144. /package/dist/components/{side-navigation/side-navigation.jsx → SideNavigation/SideNavigation.jsx} +0 -0
  145. /package/dist/components/{site-navigation/site-navigation.jsx → SiteNavigation/SiteNavigation.jsx} +0 -0
  146. /package/dist/components/{skip-links/skip-links.jsx → SkipLinks/SkipLinks.jsx} +0 -0
  147. /package/dist/components/{table/table.jsx → Table/Table.jsx} +0 -0
  148. /package/dist/components/{tag/tag.jsx → Tag/Tag.jsx} +0 -0
  149. /package/dist/components/{warning-text/warning-text.jsx → WarningText/WarningText.jsx} +0 -0
  150. /package/src/common/{conditional-wrapper.tsx → ConditionalWrapper.tsx} +0 -0
  151. /package/src/common/{file-icon.tsx → FileIcon.tsx} +0 -0
  152. /package/src/common/{hint-text.tsx → HintText.tsx} +0 -0
  153. /package/src/common/{icon.tsx → Icon.tsx} +0 -0
  154. /package/src/common/{screen-reader-text.tsx → ScreenReaderText.tsx} +0 -0
  155. /package/src/common/{wrapper-tag.tsx → WrapperTag.tsx} +0 -0
  156. /package/src/components/{aspect-box/aspect-box.tsx → AspectBox/AspectBox.tsx} +0 -0
  157. /package/src/components/{breadcrumbs/breadcrumbs.tsx → Breadcrumbs/Breadcrumbs.tsx} +0 -0
  158. /package/src/components/{details/details.tsx → Details/Details.tsx} +0 -0
  159. /package/src/components/{error-message/error-message.tsx → ErrorMessage/ErrorMessage.tsx} +0 -0
  160. /package/src/components/{inset-text/inset-text.tsx → InsetText/InsetText.tsx} +0 -0
  161. /package/src/components/{page-header/page-header.tsx → PageHeader/PageHeader.tsx} +0 -0
  162. /package/src/components/{page-metadata/page-metadata.tsx → PageMetadata/PageMetadata.tsx} +0 -0
  163. /package/src/components/{sequential-navigation/sequential-navigation.tsx → SequentialNavigation/SequentialNavigation.tsx} +0 -0
  164. /package/src/components/{side-navigation/side-navigation.tsx → SideNavigation/SideNavigation.tsx} +0 -0
  165. /package/src/components/{site-navigation/site-navigation.tsx → SiteNavigation/SiteNavigation.tsx} +0 -0
  166. /package/src/components/{skip-links/skip-links.tsx → SkipLinks/SkipLinks.tsx} +0 -0
  167. /package/src/components/{table/table.tsx → Table/Table.tsx} +0 -0
  168. /package/src/components/{tag/tag.tsx → Tag/Tag.tsx} +0 -0
  169. /package/src/components/{warning-text/warning-text.tsx → WarningText/WarningText.tsx} +0 -0
@@ -1,9 +1,9 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import SiteHeader from './site-header';
4
- import SiteNavigation from '../site-navigation/site-navigation';
5
- import SiteSearch from '../site-search/site-search';
6
- import PhaseBanner from '../phase-banner/phase-banner';
3
+ import SiteHeader from './SiteHeader';
4
+ import SiteNavigation from '../SiteNavigation/SiteNavigation';
5
+ import SiteSearch from '../SiteSearch/SiteSearch';
6
+ import PhaseBanner from '../PhaseBanner/PhaseBanner';
7
7
 
8
8
  test('site header renders correctly (maximal, testing markup structure)', () => {
9
9
  render(
@@ -67,14 +67,14 @@ test('site header renders correctly (maximal, testing markup structure)', () =>
67
67
  });
68
68
 
69
69
  test('site header branding: logo only, default URL', () => {
70
- const logo = {
70
+ const LOGO = {
71
71
  alt: 'The Scottish Government',
72
72
  src: './scottish-government.svg'
73
73
  };
74
74
 
75
75
  render(
76
76
  <SiteHeader
77
- logo={logo}
77
+ logo={LOGO}
78
78
  />
79
79
  );
80
80
 
@@ -87,24 +87,24 @@ test('site header branding: logo only, default URL', () => {
87
87
  expect(siteHeaderLogoLink).toHaveAttribute('href', '/');
88
88
 
89
89
  expect(siteHeaderLogoImg).toHaveClass('ds_site-branding__logo-image');
90
- expect(siteHeaderLogoImg).toHaveAttribute('src', logo.src);
91
- expect(siteHeaderLogoImg).toHaveAttribute('alt', logo.alt);
90
+ expect(siteHeaderLogoImg).toHaveAttribute('src', LOGO.src);
91
+ expect(siteHeaderLogoImg).toHaveAttribute('alt', LOGO.alt);
92
92
 
93
93
  expect(siteHeaderLogoImg.parentElement).toEqual(siteHeaderLogoLink);
94
94
  expect(siteHeaderLogoLink.parentElement).toEqual(siteHeaderBranding);
95
95
  });
96
96
 
97
97
  test('site header branding: logo and site title', () => {
98
- const logo = {
98
+ const LOGO = {
99
99
  alt: 'The Scottish Government',
100
100
  src: './scottish-government.svg'
101
101
  };
102
- const siteTitleContent = 'Design System React';
102
+ const SITE_TITLE_CONTENT = 'Design System React';
103
103
 
104
104
  render(
105
105
  <SiteHeader
106
- logo={logo}
107
- siteTitle={siteTitleContent}
106
+ logo={LOGO}
107
+ siteTitle={SITE_TITLE_CONTENT}
108
108
  />
109
109
  );
110
110
 
@@ -114,13 +114,13 @@ test('site header branding: logo and site title', () => {
114
114
  const siteTitle = siteHeader.querySelector('.ds_site-branding__title');
115
115
 
116
116
  expect(siteTitle?.tagName).toEqual('DIV');
117
- expect(siteTitle?.textContent).toEqual(siteTitleContent);
117
+ expect(siteTitle?.textContent).toEqual(SITE_TITLE_CONTENT);
118
118
  expect(siteTitle?.parentElement).toEqual(siteHeaderBranding);
119
119
  expect(siteTitle?.previousElementSibling).toEqual(siteHeaderLogoLink);
120
120
  });
121
121
 
122
122
  test('site header branding: custom link URL', () => {
123
- const logo = {
123
+ const LOGO = {
124
124
  alt: 'The Scottish Government',
125
125
  href: '/home.aspx',
126
126
  src: './scottish-government.svg'
@@ -128,18 +128,18 @@ test('site header branding: custom link URL', () => {
128
128
 
129
129
  render(
130
130
  <SiteHeader
131
- logo={logo}
131
+ logo={LOGO}
132
132
  />
133
133
  );
134
134
 
135
135
  const siteHeader = screen.getByRole('banner');
136
136
  const siteHeaderLogoLink = within(siteHeader).getByRole('link');
137
137
 
138
- expect(siteHeaderLogoLink).toHaveAttribute('href', logo.href);
138
+ expect(siteHeaderLogoLink).toHaveAttribute('href', LOGO.href);
139
139
  });
140
140
 
141
141
  test('site header with site search', () => {
142
- const searchProps = {
142
+ const SEARCH_PROPS = {
143
143
  action: 'apple',
144
144
  autocompleteEndpoint: 'banana',
145
145
  autocompleteSuggestionMappingFunction: 'cucumber',
@@ -152,8 +152,8 @@ test('site header with site search', () => {
152
152
 
153
153
  render(
154
154
  <>
155
- <SiteHeader siteSearch={searchProps} />
156
- <SiteSearch data-testid="sitesearch" {...searchProps} />
155
+ <SiteHeader siteSearch={SEARCH_PROPS} />
156
+ <SiteSearch data-testid="sitesearch" {...SEARCH_PROPS} />
157
157
  </>
158
158
  );
159
159
 
@@ -165,7 +165,7 @@ test('site header with site search', () => {
165
165
  });
166
166
 
167
167
  test('site header with site navigation', () => {
168
- const navigationItems = [
168
+ const NAVIGATION_ITEMS = [
169
169
  { title: 'About', href: '#about' },
170
170
  { title: 'Get started', href: '#get-started' },
171
171
  { title: 'Styles', href: '#styles' },
@@ -176,8 +176,8 @@ test('site header with site navigation', () => {
176
176
 
177
177
  render(
178
178
  <>
179
- <SiteHeader navigationItems={navigationItems} />
180
- <SiteNavigation data-testid="sitenavigation" items={navigationItems} />
179
+ <SiteHeader navigationItems={NAVIGATION_ITEMS} />
180
+ <SiteNavigation data-testid="sitenavigation" items={NAVIGATION_ITEMS} />
181
181
  </>
182
182
  );
183
183
 
@@ -212,15 +212,15 @@ test('site header with site navigation', () => {
212
212
  });
213
213
 
214
214
  test('site header with phase banner', () => {
215
- const phaseBannerProps = {
215
+ const PHASE_BANNER_PROPS = {
216
216
  content: 'My content',
217
217
  phaseName: 'Beta'
218
218
  };
219
219
 
220
220
  render(
221
221
  <>
222
- <SiteHeader phaseBanner={phaseBannerProps} />
223
- <PhaseBanner data-testid="phasebanner" {...phaseBannerProps} />
222
+ <SiteHeader phaseBanner={PHASE_BANNER_PROPS} />
223
+ <PhaseBanner data-testid="phasebanner" {...PHASE_BANNER_PROPS} />
224
224
  </>
225
225
  );
226
226
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  import { useEffect, useRef } from 'react';
4
4
 
5
- import Icon from '../../common/icon';
6
- import PhaseBanner from '../phase-banner/phase-banner';
7
- import SiteNavigation from "../site-navigation/site-navigation";
8
- import SiteSearch from "../site-search/site-search";
5
+ import Icon from '../../common/Icon';
6
+ import PhaseBanner from '../PhaseBanner/PhaseBanner';
7
+ import SiteNavigation from "../SiteNavigation/SiteNavigation";
8
+ import SiteSearch from "../SiteSearch/SiteSearch";
9
9
 
10
10
  // @ts-ignore
11
11
  import DSMobileMenu from '@scottish-government/design-system/src/components/site-navigation/site-navigation';
@@ -1,8 +1,8 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import SiteNavigation from './site-navigation';
3
+ import SiteNavigation from './SiteNavigation';
4
4
 
5
- const items = [
5
+ const ITEMS = [
6
6
  {title: 'About', href: '#about'},
7
7
  {title: 'Get started', href: '#get-started'},
8
8
  {title: 'Styles', href: '#styles'},
@@ -13,7 +13,7 @@ const items = [
13
13
 
14
14
  test('renders correctly', () => {
15
15
  render(
16
- <SiteNavigation items={items}/>
16
+ <SiteNavigation items={ITEMS}/>
17
17
  );
18
18
 
19
19
  const nav = screen.getByRole('navigation');
@@ -29,7 +29,7 @@ test('renders correctly', () => {
29
29
  expect(list).toHaveClass('ds_site-navigation__list');
30
30
 
31
31
  // check items
32
- expect(listItems.length).toEqual(items.length);
32
+ expect(listItems.length).toEqual(ITEMS.length);
33
33
 
34
34
  listItems.forEach((item, index) => {
35
35
  expect(item).toHaveClass('ds_site-navigation__item');
@@ -38,8 +38,8 @@ test('renders correctly', () => {
38
38
 
39
39
  expect(link).toHaveClass('ds_site-navigation__link');
40
40
  expect(link).not.toHaveClass('ds_current');
41
- expect(link.textContent).toEqual(items[index].title);
42
- expect(link).toHaveAttribute('href', items[index].href)
41
+ expect(link.textContent).toEqual(ITEMS[index].title);
42
+ expect(link).toHaveAttribute('href', ITEMS[index].href)
43
43
  });
44
44
  });
45
45
 
@@ -55,7 +55,7 @@ test('highlights current item', () => {
55
55
 
56
56
  test('passing additional props', () => {
57
57
  render(
58
- <SiteNavigation data-test="foo" items={items}/>
58
+ <SiteNavigation data-test="foo" items={ITEMS}/>
59
59
  );
60
60
 
61
61
  const nav = screen.getByRole('navigation');
@@ -64,7 +64,7 @@ test('passing additional props', () => {
64
64
 
65
65
  test('passing additional CSS classes', () => {
66
66
  render(
67
- <SiteNavigation className="foo" items={items}/>
67
+ <SiteNavigation className="foo" items={ITEMS}/>
68
68
  );
69
69
 
70
70
  const nav = screen.getByRole('navigation');
@@ -1,10 +1,10 @@
1
1
  import { test, expect, vi } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import SiteSearch from './site-search';
3
+ import SiteSearch from './SiteSearch';
4
4
 
5
- const id = 'site-search';
6
- const labelText = 'Search';
7
- const placeholderText = 'Search';
5
+ const SITE_SEARCH_ID = 'site-search';
6
+ const LABEL_TEXT = 'Search';
7
+ const PLACEHOLDER_TEXT = 'Search';
8
8
 
9
9
  test('site search renders correctly', () => {
10
10
  render(
@@ -26,17 +26,17 @@ test('site search renders correctly', () => {
26
26
  expect(searchForm).toHaveAttribute('method', 'GET');
27
27
  expect(searchForm).toHaveAttribute('action', '/search');
28
28
 
29
- expect(searchLabel?.textContent).toEqual(labelText);
30
- expect(searchLabel).toHaveAttribute('for', id);
31
- expect(searchLabel).toHaveAttribute('id', `${id}-label`);
29
+ expect(searchLabel?.textContent).toEqual(LABEL_TEXT);
30
+ expect(searchLabel).toHaveAttribute('for', SITE_SEARCH_ID);
31
+ expect(searchLabel).toHaveAttribute('id', `${SITE_SEARCH_ID}-label`);
32
32
  expect(searchLabel).toHaveClass('ds_label', 'visually-hidden');
33
33
 
34
34
  expect(inputWrapper).toHaveClass('ds_input__wrapper ds_input__wrapper--has-icon');
35
35
  expect(inputWrapper?.tagName).toEqual('DIV');
36
36
 
37
37
  expect(searchInput).toHaveClass('ds_input', 'ds_site-search__input');
38
- expect(searchInput).toHaveAttribute('id', id);
39
- expect(searchInput).toHaveAttribute('placeholder', placeholderText);
38
+ expect(searchInput).toHaveAttribute('id', SITE_SEARCH_ID);
39
+ expect(searchInput).toHaveAttribute('placeholder', PLACEHOLDER_TEXT);
40
40
  expect(searchInput).toHaveAttribute('required');
41
41
  expect(searchInput).toHaveAttribute('spellcheck', 'false');
42
42
  expect(searchInput).toHaveAttribute('type', 'search');
@@ -102,13 +102,13 @@ test('custom placeholder', () => {
102
102
  });
103
103
 
104
104
  test('autocomplete', () => {
105
- const autocompleteSuggestionMappingFunction = vi.fn();
106
- const suggestionsId = 'autocomplete-suggestions';
105
+ const AUTOCOMPLETE_SUGGESTION_MAPPING_FUNCTION = vi.fn();
106
+ const SUGGESTIONS_ID = 'autocomplete-suggestions';
107
107
 
108
108
  render(
109
109
  <SiteSearch
110
110
  autocompleteEndpoint="/endpoint"
111
- autocompleteSuggestionMappingFunction={autocompleteSuggestionMappingFunction}
111
+ autocompleteSuggestionMappingFunction={AUTOCOMPLETE_SUGGESTION_MAPPING_FUNCTION}
112
112
  />
113
113
  )
114
114
 
@@ -120,7 +120,7 @@ test('autocomplete', () => {
120
120
  const suggestionsList = within(searchForm).getByRole('listbox');
121
121
 
122
122
  expect(searchFormContainer).toHaveClass('ds_autocomplete');
123
- expect(searchFormContainer).toHaveAttribute('id', `${id}-autocomplete`);
123
+ expect(searchFormContainer).toHaveAttribute('id', `${SITE_SEARCH_ID}-autocomplete`);
124
124
 
125
125
  expect(autocompleteStatus).toBeInTheDocument();
126
126
  expect(autocompleteStatus).toHaveClass('visually-hidden');
@@ -129,15 +129,15 @@ test('autocomplete', () => {
129
129
  expect(autocompleteStatus.tagName).toEqual('DIV');
130
130
 
131
131
  expect(searchInput).toHaveAttribute('aria-autocomplete', 'list');
132
- expect(searchInput).toHaveAttribute('aria-owns', suggestionsId);
132
+ expect(searchInput).toHaveAttribute('aria-owns', SUGGESTIONS_ID);
133
133
  expect(searchInput).toHaveAttribute('autocomplete', 'off');
134
134
  expect(searchInput).toHaveClass('js-autocomplete-input');
135
135
 
136
- expect(suggestionsContainer).toHaveAttribute('id', suggestionsId);
136
+ expect(suggestionsContainer).toHaveAttribute('id', SUGGESTIONS_ID);
137
137
  expect(suggestionsContainer?.tagName).toEqual('DIV');
138
138
 
139
139
  expect(suggestionsList).toHaveClass('ds_autocomplete__suggestions-list');
140
- expect(suggestionsList).toHaveAttribute('aria-labelledby', `${id}-label`);
140
+ expect(suggestionsList).toHaveAttribute('aria-labelledby', `${SITE_SEARCH_ID}-label`);
141
141
  expect(suggestionsList.tagName).toEqual('OL');
142
142
 
143
143
  });
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  // @ts-ignore
3
3
  import DSAutocomplete from '@scottish-government/design-system/src/components/autocomplete/autocomplete';
4
- import Button from '../button/button';
4
+ import Button from '../Button/Button';
5
5
 
6
6
  const SiteSearch: React.FC<SGDS.Component.SiteSearch> = function ({
7
7
  action = '/search',
@@ -1,9 +1,9 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import SkipLinks from './skip-links';
3
+ import SkipLinks from './SkipLinks';
4
4
 
5
- const mainContentId = 'main-content';
6
- const linkText = 'Skip to main content';
5
+ const MAIN_CONTENT_ID = 'main-content';
6
+ const LINK_TEXT = 'Skip to main content';
7
7
 
8
8
  test('skip links renders correctly', () => {
9
9
  render(
@@ -24,43 +24,43 @@ test('skip links renders correctly', () => {
24
24
  expect(skipLinksListItem).toHaveClass('ds_skip-links__item');
25
25
 
26
26
  expect(skipLinksLink).toHaveClass('ds_skip-links__link');
27
- expect(skipLinksLink).toHaveAttribute('href', `#${mainContentId}`);
28
- expect(skipLinksLink.textContent).toEqual(linkText);
27
+ expect(skipLinksLink).toHaveAttribute('href', `#${MAIN_CONTENT_ID}`);
28
+ expect(skipLinksLink.textContent).toEqual(LINK_TEXT);
29
29
  });
30
30
 
31
31
  test('custom link text', () => {
32
- const mainLinkText = 'foo';
32
+ const MAIN_LINK_TEXT = 'foo';
33
33
 
34
34
  render(
35
- <SkipLinks mainLinkText={mainLinkText} />
35
+ <SkipLinks mainLinkText={MAIN_LINK_TEXT} />
36
36
  );
37
37
 
38
38
  const skipLinksList = screen.getByRole('list');
39
39
  const skipLinksLink = within(skipLinksList).getByRole('link');
40
40
 
41
- expect(skipLinksLink.textContent).toEqual(mainLinkText);
41
+ expect(skipLinksLink.textContent).toEqual(MAIN_LINK_TEXT);
42
42
  });
43
43
 
44
44
  test('custom link target', () => {
45
- const customId = 'bar'
45
+ const CUSTOM_ID = 'bar'
46
46
 
47
47
  render(
48
- <SkipLinks mainContentId={customId} />
48
+ <SkipLinks mainContentId={CUSTOM_ID} />
49
49
  );
50
50
 
51
51
  const skipLinksList = screen.getByRole('list');
52
52
  const skipLinksLink = within(skipLinksList).getByRole('link');
53
53
 
54
- expect(skipLinksLink).toHaveAttribute('href', `#${customId}`)
54
+ expect(skipLinksLink).toHaveAttribute('href', `#${CUSTOM_ID}`)
55
55
  });
56
56
 
57
57
  test('additional links', () => {
58
- const items = [
58
+ const ITEMS = [
59
59
  { title: 'foo', targetId: 'bar' }
60
60
  ];
61
61
 
62
62
  render(
63
- <SkipLinks items={items} />
63
+ <SkipLinks items={ITEMS} />
64
64
  );
65
65
 
66
66
  const skipLinksList = screen.getByRole('list');
@@ -68,8 +68,8 @@ test('additional links', () => {
68
68
  const skipLinksSecondLink = within(skipLinksList).getAllByRole('link')[1];
69
69
 
70
70
  expect(skipLinksListItems.length).toEqual(2);
71
- expect(skipLinksSecondLink).toHaveAttribute('href', `#${items[0].targetId}`);
72
- expect(skipLinksSecondLink.textContent).toEqual(items[0].title);
71
+ expect(skipLinksSecondLink).toHaveAttribute('href', `#${ITEMS[0].targetId}`);
72
+ expect(skipLinksSecondLink.textContent).toEqual(ITEMS[0].title);
73
73
  })
74
74
 
75
75
  test('passing additional props', () => {
@@ -1,22 +1,22 @@
1
1
  import { test, expect, vi } from 'vitest';
2
2
  import { render, screen, within, fireEvent } from '@testing-library/react';
3
- import SummaryCard from './summary-card';
4
- import SummaryList from '../summary-list/summary-list';
3
+ import SummaryCard from './SummaryCard';
4
+ import SummaryList from '../SummaryList/SummaryList';
5
5
 
6
- const onClickFn = vi.fn();
6
+ const ONCLICK_FUNCTION = vi.fn();
7
7
 
8
- const actions = [
8
+ const ACTIONS = [
9
9
  {
10
10
  title: 'Change',
11
11
  href: '#foo'
12
12
  },
13
13
  {
14
14
  title: 'Delete',
15
- onclick: onClickFn
15
+ onclick: ONCLICK_FUNCTION
16
16
  }
17
17
  ];
18
18
 
19
- const items = [
19
+ const ITEMS = [
20
20
  {
21
21
  title: 'Phone number',
22
22
  value: '0123 456 7890'
@@ -27,19 +27,21 @@ const items = [
27
27
  }
28
28
  ];
29
29
 
30
- const titleText = 'Joe Bloggs';
30
+ const TITLE_TEXT = 'Joe Bloggs';
31
31
 
32
32
  test('summary card renders correctly', () => {
33
+ const DESCRIBEDBY_ID = 'summary-card-joe-bloggs';
34
+
33
35
  render(
34
36
  <>
35
37
  <SummaryCard
36
38
  data-testid="foo"
37
- actions={actions}
38
- items={items}
39
- title={titleText}
39
+ actions={ACTIONS}
40
+ items={ITEMS}
41
+ title={TITLE_TEXT}
40
42
  />
41
43
 
42
- <SummaryList data-testid="bar" items={items}/>
44
+ <SummaryList data-testid="bar" items={ITEMS}/>
43
45
  </>
44
46
  );
45
47
 
@@ -52,20 +54,18 @@ test('summary card renders correctly', () => {
52
54
  const thisList = within(content).getByRole('list');
53
55
  const comparisonList = screen.getByTestId('bar');
54
56
 
55
- const describedById = 'summary-card-joe-bloggs';
56
-
57
57
  expect(summaryCard).toHaveClass('ds_summary-card');
58
58
 
59
59
  expect(header).toHaveClass('ds_summary-card__header');
60
60
  expect(header?.tagName).toEqual('DIV');
61
61
 
62
62
  expect(title).toHaveClass('ds_summary-card__header-title');
63
- expect(title).toHaveAttribute('id', describedById);
63
+ expect(title).toHaveAttribute('id', DESCRIBEDBY_ID);
64
64
  expect(title?.tagName).toEqual('H3');
65
- expect(title.textContent).toEqual(titleText);
65
+ expect(title.textContent).toEqual(TITLE_TEXT);
66
66
 
67
67
  expect(actionsList?.tagName).toEqual('UL');
68
- expect(actionsList.children.length).toEqual(actions.length);
68
+ expect(actionsList.children.length).toEqual(ACTIONS.length);
69
69
  expect(actionsList.children[0]).toHaveClass('ds_summary-card__actions-list-item');
70
70
  expect(actionsList.children[0].tagName).toEqual('LI');
71
71
  expect(actionsList.children[0].innerHTML).toEqual('<a aria-describedby="summary-card-joe-bloggs" class="ds_link" href="#foo">Change</a>');
@@ -73,7 +73,7 @@ test('summary card renders correctly', () => {
73
73
 
74
74
  fireEvent.click(actionsList.children[1].children[0]);
75
75
 
76
- expect(onClickFn).toHaveBeenCalled();
76
+ expect(ONCLICK_FUNCTION).toHaveBeenCalled();
77
77
 
78
78
  expect(content).toHaveClass('ds_summary-card__content');
79
79
  expect(content?.tagName).toEqual('DIV');
@@ -81,14 +81,14 @@ test('summary card renders correctly', () => {
81
81
  expect(thisList?.innerHTML).toEqual(comparisonList?.innerHTML);
82
82
  });
83
83
 
84
- test('custom header level', () => {
84
+ test('custom heading level', () => {
85
85
  render(
86
86
  <SummaryCard
87
87
  data-testid="foo"
88
- actions={actions}
89
- headerLevel="h2"
90
- items={items}
91
- title={titleText}
88
+ actions={ACTIONS}
89
+ headingLevel="h2"
90
+ items={ITEMS}
91
+ title={TITLE_TEXT}
92
92
  />
93
93
  );
94
94
 
@@ -102,9 +102,9 @@ test('passing additional props', () => {
102
102
  render(
103
103
  <SummaryCard
104
104
  data-testid="foo"
105
- actions={actions}
106
- items={items}
107
- title={titleText}
105
+ actions={ACTIONS}
106
+ items={ITEMS}
107
+ title={TITLE_TEXT}
108
108
  data-test="foo"
109
109
  />
110
110
  );
@@ -117,9 +117,9 @@ test('passing additional CSS classes', () => {
117
117
  render(
118
118
  <SummaryCard
119
119
  data-testid="foo"
120
- actions={actions}
121
- items={items}
122
- title={titleText}
120
+ actions={ACTIONS}
121
+ items={ITEMS}
122
+ title={TITLE_TEXT}
123
123
  className="foo"
124
124
  />
125
125
  );
@@ -1,5 +1,5 @@
1
- import SummaryList, { Action } from "../summary-list/summary-list";
2
- import WrapperTag from "../../common/wrapper-tag";
1
+ import SummaryList, { Action } from "../SummaryList/SummaryList";
2
+ import WrapperTag from "../../common/WrapperTag";
3
3
 
4
4
  function convertToSlug(string: string) {
5
5
  return string.toLowerCase()
@@ -10,7 +10,7 @@ function convertToSlug(string: string) {
10
10
  const SummaryCard: React.FC<SGDS.Component.SummaryCard> = ({
11
11
  actions,
12
12
  className,
13
- headerLevel = 'h3',
13
+ headingLevel = 'h3',
14
14
  items,
15
15
  title,
16
16
  ...props
@@ -29,7 +29,7 @@ const SummaryCard: React.FC<SGDS.Component.SummaryCard> = ({
29
29
  <WrapperTag
30
30
  className="ds_summary-card__header-title"
31
31
  id={describedById}
32
- tagName={headerLevel}
32
+ tagName={headingLevel}
33
33
  >{title}</WrapperTag>
34
34
 
35
35
  <ul className="ds_summary-card__actions-list">