@scottish-government/designsystem-react 0.13.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/.storybook/sgdsArgTypes.ts +23 -0
  2. package/CHANGELOG.md +23 -0
  3. package/LICENSE.txt +21 -0
  4. package/README.md +3 -0
  5. package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.d.ts +3 -2
  6. package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.jsx +8 -7
  7. package/dist/common/AbstractNotificationBanner/types.d.ts +13 -0
  8. package/dist/common/AbstractNotificationBanner/types.js +2 -0
  9. package/dist/common/ActionLink/ActionLink.d.ts +2 -1
  10. package/dist/common/ActionLink/types.d.ts +7 -0
  11. package/dist/common/ActionLink/types.js +2 -0
  12. package/dist/common/ConditionalWrapper/ConditionalWrapper.d.ts +2 -1
  13. package/dist/common/ConditionalWrapper/ConditionalWrapper.jsx +4 -2
  14. package/dist/common/ConditionalWrapper/types.d.ts +4 -0
  15. package/dist/common/ConditionalWrapper/types.js +2 -0
  16. package/dist/common/FileIcon/FileIcon.d.ts +2 -1
  17. package/dist/common/FileIcon/types.d.ts +6 -0
  18. package/dist/common/FileIcon/types.js +2 -0
  19. package/dist/common/HintText/HintText.d.ts +2 -1
  20. package/dist/common/HintText/HintText.jsx +3 -3
  21. package/dist/common/HintText/types.d.ts +4 -0
  22. package/dist/common/HintText/types.js +2 -0
  23. package/dist/common/Icon/Icon.d.ts +2 -1
  24. package/dist/common/Icon/Icon.jsx +3 -2
  25. package/dist/common/Icon/types.d.ts +8 -0
  26. package/dist/common/Icon/types.js +2 -0
  27. package/dist/common/ScreenReaderText/ScreenReaderText.d.ts +1 -1
  28. package/dist/common/WrapperTag/WrapperTag.d.ts +385 -1
  29. package/dist/common/WrapperTag/WrapperTag.jsx +5 -2
  30. package/dist/common/WrapperTag/types.d.ts +3 -0
  31. package/dist/common/WrapperTag/types.js +2 -0
  32. package/dist/components/Accordion/Accordion.d.ts +3 -2
  33. package/dist/components/Accordion/Accordion.jsx +12 -11
  34. package/dist/components/Accordion/types.d.ts +11 -0
  35. package/dist/components/Accordion/types.js +2 -0
  36. package/dist/components/AspectBox/AspectBox.d.ts +2 -1
  37. package/dist/components/AspectBox/AspectBox.jsx +3 -9
  38. package/dist/components/AspectBox/types.d.ts +3 -0
  39. package/dist/components/AspectBox/types.js +2 -0
  40. package/dist/components/BackToTop/BackToTop.d.ts +2 -1
  41. package/dist/components/BackToTop/BackToTop.jsx +4 -3
  42. package/dist/components/BackToTop/types.d.ts +3 -0
  43. package/dist/components/BackToTop/types.js +2 -0
  44. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -2
  45. package/dist/components/Breadcrumbs/Breadcrumbs.jsx +6 -2
  46. package/dist/components/Breadcrumbs/types.d.ts +5 -0
  47. package/dist/components/Breadcrumbs/types.js +2 -0
  48. package/dist/components/Button/Button.d.ts +2 -1
  49. package/dist/components/Button/Button.jsx +4 -3
  50. package/dist/components/Button/ButtonGroup.d.ts +2 -1
  51. package/dist/components/Button/ButtonGroup.jsx +9 -4
  52. package/dist/components/Button/types.d.ts +20 -0
  53. package/dist/components/Button/types.js +2 -0
  54. package/dist/components/Card/Card.d.ts +34 -0
  55. package/dist/components/Card/Card.jsx +118 -0
  56. package/dist/components/Card/index.d.ts +1 -0
  57. package/dist/components/Card/index.js +8 -0
  58. package/dist/components/Card/types.d.ts +26 -0
  59. package/dist/components/Card/types.js +2 -0
  60. package/dist/components/CategoryItem/CategoryItem.d.ts +2 -1
  61. package/dist/components/CategoryItem/CategoryItem.jsx +8 -5
  62. package/dist/components/CategoryItem/types.d.ts +9 -0
  63. package/dist/components/CategoryItem/types.js +2 -0
  64. package/dist/components/CategoryList/CategoryList.d.ts +2 -1
  65. package/dist/components/CategoryList/CategoryList.jsx +3 -2
  66. package/dist/components/CategoryList/types.d.ts +5 -0
  67. package/dist/components/CategoryList/types.js +2 -0
  68. package/dist/components/Checkbox/Checkbox.d.ts +2 -1
  69. package/dist/components/Checkbox/Checkbox.jsx +4 -3
  70. package/dist/components/Checkbox/CheckboxGroup.d.ts +2 -1
  71. package/dist/components/Checkbox/CheckboxGroup.jsx +5 -4
  72. package/dist/components/Checkbox/types.d.ts +7 -0
  73. package/dist/components/Checkbox/types.js +2 -0
  74. package/dist/components/ConfirmationMessage/ConfirmationMessage.d.ts +2 -1
  75. package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +3 -2
  76. package/dist/components/ConfirmationMessage/types.d.ts +6 -0
  77. package/dist/components/ConfirmationMessage/types.js +2 -0
  78. package/dist/components/ContentsNav/ContentsNav.d.ts +3 -2
  79. package/dist/components/ContentsNav/ContentsNav.jsx +7 -5
  80. package/dist/components/ContentsNav/types.d.ts +9 -0
  81. package/dist/components/ContentsNav/types.js +2 -0
  82. package/dist/components/CookieBanner/CookieBanner.d.ts +3 -2
  83. package/dist/components/CookieBanner/CookieBanner.jsx +13 -3
  84. package/dist/components/DatePicker/DatePicker.d.ts +2 -1
  85. package/dist/components/DatePicker/DatePicker.jsx +7 -7
  86. package/dist/components/DatePicker/types.d.ts +18 -0
  87. package/dist/components/DatePicker/types.js +2 -0
  88. package/dist/components/Details/Details.d.ts +2 -1
  89. package/dist/components/Details/Details.jsx +6 -2
  90. package/dist/components/Details/types.d.ts +4 -0
  91. package/dist/components/Details/types.js +2 -0
  92. package/dist/components/ErrorMessage/ErrorMessage.d.ts +2 -1
  93. package/dist/components/ErrorMessage/ErrorMessage.jsx +6 -2
  94. package/dist/components/ErrorMessage/types.d.ts +3 -0
  95. package/dist/components/ErrorMessage/types.js +2 -0
  96. package/dist/components/ErrorSummary/ErrorSummary.d.ts +3 -2
  97. package/dist/components/ErrorSummary/ErrorSummary.jsx +6 -2
  98. package/dist/components/ErrorSummary/types.d.ts +8 -0
  99. package/dist/components/ErrorSummary/types.js +2 -0
  100. package/dist/components/FeatureHeader/FeatureHeader.d.ts +7 -5
  101. package/dist/components/FeatureHeader/FeatureHeader.jsx +87 -50
  102. package/dist/components/FeatureHeader/types.d.ts +12 -0
  103. package/dist/components/FeatureHeader/types.js +2 -0
  104. package/dist/components/FileDownload/FileDownload.d.ts +2 -1
  105. package/dist/components/FileDownload/FileDownload.jsx +4 -3
  106. package/dist/components/FileDownload/types.d.ts +10 -0
  107. package/dist/components/FileDownload/types.js +2 -0
  108. package/dist/components/HideThisPage/HideThisPage.d.ts +2 -1
  109. package/dist/components/HideThisPage/HideThisPage.jsx +5 -4
  110. package/dist/components/HideThisPage/types.d.ts +3 -0
  111. package/dist/components/HideThisPage/types.js +2 -0
  112. package/dist/components/InsetText/InsetText.d.ts +1 -1
  113. package/dist/components/InsetText/InsetText.jsx +6 -2
  114. package/dist/components/NotificationBanner/NotificationBanner.d.ts +3 -2
  115. package/dist/components/NotificationBanner/NotificationBanner.jsx +5 -4
  116. package/dist/components/NotificationPanel/NotificationPanel.d.ts +2 -1
  117. package/dist/components/NotificationPanel/NotificationPanel.jsx +3 -2
  118. package/dist/components/NotificationPanel/types.d.ts +6 -0
  119. package/dist/components/NotificationPanel/types.js +2 -0
  120. package/dist/components/NotificationTag/NotificationTag.d.ts +6 -0
  121. package/dist/components/NotificationTag/NotificationTag.jsx +20 -0
  122. package/dist/components/NotificationTag/index.d.ts +1 -0
  123. package/dist/components/NotificationTag/index.js +8 -0
  124. package/dist/components/NotificationTag/types.d.ts +5 -0
  125. package/dist/components/NotificationTag/types.js +2 -0
  126. package/dist/components/PageHeader/PageHeader.d.ts +2 -1
  127. package/dist/components/PageHeader/PageHeader.jsx +6 -2
  128. package/dist/components/PageHeader/types.d.ts +5 -0
  129. package/dist/components/PageHeader/types.js +2 -0
  130. package/dist/components/PageMetadata/PageMetadata.d.ts +3 -2
  131. package/dist/components/PageMetadata/PageMetadata.jsx +8 -4
  132. package/dist/components/PageMetadata/types.d.ts +6 -0
  133. package/dist/components/PageMetadata/types.js +2 -0
  134. package/dist/components/Pagination/Pagination.d.ts +3 -2
  135. package/dist/components/Pagination/Pagination.jsx +7 -5
  136. package/dist/components/Pagination/types.d.ts +18 -0
  137. package/dist/components/Pagination/types.js +2 -0
  138. package/dist/components/PhaseBanner/PhaseBanner.d.ts +2 -1
  139. package/dist/components/PhaseBanner/PhaseBanner.jsx +3 -2
  140. package/dist/components/PhaseBanner/types.d.ts +3 -0
  141. package/dist/components/PhaseBanner/types.js +2 -0
  142. package/dist/components/Question/Question.d.ts +2 -1
  143. package/dist/components/Question/Question.jsx +4 -3
  144. package/dist/components/Question/types.d.ts +9 -0
  145. package/dist/components/Question/types.js +2 -0
  146. package/dist/components/RadioButton/RadioButton.d.ts +2 -1
  147. package/dist/components/RadioButton/RadioButton.jsx +4 -3
  148. package/dist/components/RadioButton/RadioGroup.d.ts +2 -1
  149. package/dist/components/RadioButton/RadioGroup.jsx +3 -2
  150. package/dist/components/RadioButton/types.d.ts +10 -0
  151. package/dist/components/RadioButton/types.js +2 -0
  152. package/dist/components/SearchFacets/SearchFacets.d.ts +4 -3
  153. package/dist/components/SearchFacets/SearchFacets.jsx +3 -2
  154. package/dist/components/SearchFacets/types.d.ts +12 -0
  155. package/dist/components/SearchFacets/types.js +2 -0
  156. package/dist/components/SearchFilters/SearchFilters.d.ts +5 -4
  157. package/dist/components/SearchFilters/types.d.ts +12 -0
  158. package/dist/components/SearchFilters/types.js +2 -0
  159. package/dist/components/SearchResult/SearchResult.d.ts +8 -11
  160. package/dist/components/SearchResult/SearchResult.jsx +6 -7
  161. package/dist/components/SearchResult/types.d.ts +11 -0
  162. package/dist/components/SearchResult/types.js +2 -0
  163. package/dist/components/SearchSort/SearchSort.d.ts +2 -1
  164. package/dist/components/SearchSort/SearchSort.jsx +3 -2
  165. package/dist/components/SearchSort/types.d.ts +7 -0
  166. package/dist/components/SearchSort/types.js +2 -0
  167. package/dist/components/Select/Select.d.ts +2 -1
  168. package/dist/components/Select/Select.jsx +4 -3
  169. package/dist/components/Select/types.d.ts +6 -0
  170. package/dist/components/Select/types.js +2 -0
  171. package/dist/components/SequentialNavigation/SequentialNavigation.d.ts +4 -3
  172. package/dist/components/SequentialNavigation/SequentialNavigation.jsx +10 -6
  173. package/dist/components/SequentialNavigation/types.d.ts +10 -0
  174. package/dist/components/SequentialNavigation/types.js +2 -0
  175. package/dist/components/SideNavigation/SideNavigation.d.ts +4 -3
  176. package/dist/components/SideNavigation/SideNavigation.jsx +10 -7
  177. package/dist/components/SideNavigation/types.d.ts +13 -0
  178. package/dist/components/SideNavigation/types.js +2 -0
  179. package/dist/components/SiteFooter/SiteFooter.d.ts +6 -5
  180. package/dist/components/SiteFooter/SiteFooter.jsx +4 -3
  181. package/dist/components/SiteFooter/types.d.ts +16 -0
  182. package/dist/components/SiteFooter/types.js +2 -0
  183. package/dist/components/SiteHeader/SiteHeader.d.ts +6 -5
  184. package/dist/components/SiteHeader/SiteHeader.jsx +1 -1
  185. package/dist/components/SiteHeader/types.d.ts +20 -0
  186. package/dist/components/SiteHeader/types.js +2 -0
  187. package/dist/components/SiteNavigation/SiteNavigation.d.ts +3 -2
  188. package/dist/components/SiteNavigation/SiteNavigation.jsx +12 -4
  189. package/dist/components/SiteNavigation/types.d.ts +9 -0
  190. package/dist/components/SiteNavigation/types.js +2 -0
  191. package/dist/components/SiteSearch/SiteSearch.d.ts +2 -1
  192. package/dist/components/SiteSearch/SiteSearch.jsx +12 -11
  193. package/dist/components/SiteSearch/types.d.ts +17 -0
  194. package/dist/components/SiteSearch/types.js +2 -0
  195. package/dist/components/SkipLinks/SkipLinks.d.ts +3 -2
  196. package/dist/components/SkipLinks/SkipLinks.jsx +4 -4
  197. package/dist/components/SkipLinks/types.d.ts +8 -0
  198. package/dist/components/SkipLinks/types.js +2 -0
  199. package/dist/components/SummaryCard/SummaryCard.d.ts +4 -2
  200. package/dist/components/SummaryCard/SummaryCard.jsx +5 -4
  201. package/dist/components/SummaryCard/types.d.ts +5 -0
  202. package/dist/components/SummaryCard/types.js +2 -0
  203. package/dist/components/SummaryList/SummaryList.d.ts +6 -4
  204. package/dist/components/SummaryList/SummaryList.jsx +5 -4
  205. package/dist/components/SummaryList/types.d.ts +6 -0
  206. package/dist/components/SummaryList/types.js +2 -0
  207. package/dist/components/Table/Table.d.ts +2 -1
  208. package/dist/components/Table/Table.jsx +5 -4
  209. package/dist/components/Table/types.d.ts +6 -0
  210. package/dist/components/Table/types.js +2 -0
  211. package/dist/components/Tabs/Tabs.d.ts +3 -2
  212. package/dist/components/Tabs/Tabs.jsx +6 -5
  213. package/dist/components/Tabs/types.d.ts +16 -0
  214. package/dist/components/Tabs/types.js +2 -0
  215. package/dist/components/Tag/Tag.d.ts +2 -1
  216. package/dist/components/Tag/Tag.jsx +7 -3
  217. package/dist/components/Tag/types.d.ts +4 -0
  218. package/dist/components/Tag/types.js +2 -0
  219. package/dist/components/TaskList/TaskList.d.ts +4 -3
  220. package/dist/components/TaskList/TaskList.jsx +11 -8
  221. package/dist/components/TaskList/types.d.ts +17 -0
  222. package/dist/components/TaskList/types.js +2 -0
  223. package/dist/components/TextInput/TextInput.d.ts +2 -1
  224. package/dist/components/TextInput/TextInput.jsx +10 -9
  225. package/dist/components/TextInput/types.d.ts +11 -0
  226. package/dist/components/TextInput/types.js +2 -0
  227. package/dist/components/Textarea/Textarea.d.ts +2 -1
  228. package/dist/components/Textarea/Textarea.jsx +6 -5
  229. package/dist/components/WarningText/WarningText.d.ts +1 -1
  230. package/dist/components/WarningText/WarningText.jsx +6 -2
  231. package/dist/hooks/useTracking/useTracking.js +0 -1
  232. package/package.json +5 -3
  233. package/src/common/AbstractNotificationBanner/AbstractNotificationBanner.tsx +8 -6
  234. package/src/common/Icon/Icon.tsx +3 -2
  235. package/src/components/Accordion/Accordion.test.tsx +11 -0
  236. package/src/components/Accordion/Accordion.tsx +11 -10
  237. package/src/components/AspectBox/AspectBox.tsx +4 -11
  238. package/src/components/BackToTop/BackToTop.test.tsx +21 -1
  239. package/src/components/BackToTop/BackToTop.tsx +4 -3
  240. package/src/components/Breadcrumbs/Breadcrumbs.tsx +3 -2
  241. package/src/components/Button/Button.tsx +4 -3
  242. package/src/components/Button/ButtonGroup.stories.tsx +22 -0
  243. package/src/components/Button/ButtonGroup.test.tsx +21 -0
  244. package/src/components/Button/ButtonGroup.tsx +6 -3
  245. package/src/components/Button/types.ts +1 -0
  246. package/src/components/Card/Card.stories.tsx +446 -0
  247. package/src/components/Card/Card.test.tsx +282 -0
  248. package/src/components/Card/Card.tsx +208 -0
  249. package/src/components/Card/index.ts +1 -0
  250. package/src/components/Card/types.ts +30 -0
  251. package/src/components/CategoryItem/CategoryItem.tsx +3 -2
  252. package/src/components/CategoryList/CategoryList.tsx +3 -2
  253. package/src/components/Checkbox/Checkbox.test.tsx +30 -0
  254. package/src/components/Checkbox/Checkbox.tsx +3 -3
  255. package/src/components/Checkbox/CheckboxGroup.test.tsx +10 -0
  256. package/src/components/Checkbox/CheckboxGroup.tsx +5 -4
  257. package/src/components/ConfirmationMessage/ConfirmationMessage.tsx +3 -2
  258. package/src/components/ContentsNav/ContentsNav.tsx +8 -5
  259. package/src/components/CookieBanner/CookieBanner.test.tsx +18 -1
  260. package/src/components/CookieBanner/CookieBanner.tsx +4 -3
  261. package/src/components/DatePicker/DatePicker.test.tsx +52 -14
  262. package/src/components/DatePicker/DatePicker.tsx +6 -7
  263. package/src/components/DatePicker/types.ts +2 -3
  264. package/src/components/Details/Details.tsx +3 -2
  265. package/src/components/ErrorMessage/ErrorMessage.tsx +3 -2
  266. package/src/components/ErrorSummary/ErrorSummary.tsx +3 -2
  267. package/src/components/FeatureHeader/FeatureHeader.stories.tsx +223 -0
  268. package/src/components/FeatureHeader/FeatureHeader.test.tsx +298 -0
  269. package/src/components/FeatureHeader/FeatureHeader.tsx +119 -0
  270. package/src/components/FeatureHeader/index.ts +1 -0
  271. package/src/components/FeatureHeader/types.ts +13 -0
  272. package/src/components/FileDownload/FileDownload.test.tsx +1 -5
  273. package/src/components/FileDownload/FileDownload.tsx +4 -3
  274. package/src/components/HideThisPage/HideThisPage.test.tsx +12 -1
  275. package/src/components/HideThisPage/HideThisPage.tsx +5 -4
  276. package/src/components/InsetText/InsetText.tsx +4 -2
  277. package/src/components/NotificationBanner/NotificationBanner.test.tsx +10 -0
  278. package/src/components/NotificationBanner/NotificationBanner.tsx +4 -3
  279. package/src/components/NotificationPanel/NotificationPanel.tsx +3 -2
  280. package/src/components/NotificationTag/NotificationTag.stories.tsx +68 -0
  281. package/src/components/NotificationTag/NotificationTag.test.tsx +70 -0
  282. package/src/components/NotificationTag/NotificationTag.tsx +32 -0
  283. package/src/components/NotificationTag/index.ts +1 -0
  284. package/src/components/NotificationTag/types.ts +5 -0
  285. package/src/components/PageHeader/PageHeader.tsx +3 -2
  286. package/src/components/PageMetadata/PageMetadata.tsx +5 -4
  287. package/src/components/Pagination/Pagination.test.tsx +20 -0
  288. package/src/components/Pagination/Pagination.tsx +7 -5
  289. package/src/components/PhaseBanner/PhaseBanner.tsx +3 -2
  290. package/src/components/Question/Question.tsx +3 -2
  291. package/src/components/Question/types.ts +2 -2
  292. package/src/components/RadioButton/RadioButton.test.tsx +30 -0
  293. package/src/components/RadioButton/RadioButton.tsx +3 -3
  294. package/src/components/RadioButton/RadioGroup.tsx +3 -2
  295. package/src/components/SearchFacets/SearchFacets.stories.tsx +1 -1
  296. package/src/components/SearchFacets/SearchFacets.tsx +3 -2
  297. package/src/components/SearchResult/SearchResult.stories.tsx +14 -13
  298. package/src/components/SearchResult/SearchResult.test.tsx +5 -4
  299. package/src/components/SearchResult/SearchResult.tsx +6 -7
  300. package/src/components/SearchSort/SearchSort.tsx +3 -2
  301. package/src/components/Select/Select.test.tsx +42 -0
  302. package/src/components/Select/Select.tsx +3 -2
  303. package/src/components/SequentialNavigation/SequentialNavigation.tsx +7 -6
  304. package/src/components/SideNavigation/SideNavigation.test.tsx +24 -0
  305. package/src/components/SideNavigation/SideNavigation.tsx +10 -7
  306. package/src/components/SiteFooter/SiteFooter.tsx +3 -2
  307. package/src/components/SiteHeader/SiteHeader.test.tsx +29 -16
  308. package/src/components/SiteHeader/SiteHeader.tsx +1 -1
  309. package/src/components/SiteNavigation/SiteNavigation.test.tsx +16 -1
  310. package/src/components/SiteNavigation/SiteNavigation.tsx +9 -4
  311. package/src/components/SiteSearch/SiteSearch.test.tsx +22 -0
  312. package/src/components/SiteSearch/SiteSearch.tsx +10 -9
  313. package/src/components/SiteSearch/types.ts +7 -1
  314. package/src/components/SkipLinks/SkipLinks.tsx +4 -4
  315. package/src/components/SummaryCard/SummaryCard.tsx +3 -2
  316. package/src/components/SummaryList/SummaryList.tsx +3 -3
  317. package/src/components/Table/Table.test.tsx +36 -0
  318. package/src/components/Table/Table.tsx +5 -4
  319. package/src/components/Tabs/Tabs.test.tsx +14 -0
  320. package/src/components/Tabs/Tabs.tsx +6 -5
  321. package/src/components/Tag/Tag.tsx +4 -3
  322. package/src/components/TaskList/TaskList.tsx +5 -4
  323. package/src/components/TextInput/TextInput.test.tsx +53 -1
  324. package/src/components/TextInput/TextInput.tsx +12 -7
  325. package/src/components/Textarea/Textarea.test.tsx +53 -1
  326. package/src/components/Textarea/Textarea.tsx +5 -4
  327. package/src/components/WarningText/WarningText.tsx +4 -2
  328. package/src/hooks/useTracking/useTracking.ts +0 -1
  329. package/src/shared-types.ts +3 -3
  330. package/static/images/illustration.svg +502 -0
  331. package/tsconfig.json +0 -3
  332. package/vite.config.ts +4 -0
@@ -1,6 +1,7 @@
1
1
  import Icon from '../../common/Icon';
2
2
  import WrapperTag from '../../common/WrapperTag';
3
3
  import { ConfirmationMessageProps } from './types';
4
+ import clsx from 'clsx';
4
5
 
5
6
  const ConfirmationMessage = ({
6
7
  ariaLive = 'polite',
@@ -13,10 +14,10 @@ const ConfirmationMessage = ({
13
14
  return (
14
15
  <div
15
16
  aria-live={ariaLive}
16
- className={[
17
+ className={clsx([
17
18
  'ds_confirmation-message',
18
19
  className
19
- ].join(' ')}
20
+ ])}
20
21
  {...props}
21
22
  >
22
23
  <Icon className="ds_confirmation-message__icon" icon="CheckCircle" iconSize="24" />
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ContentsNavItemProps, ContentsNavProps } from './types';
3
+ import clsx from 'clsx';
3
4
 
4
5
  const ContentsNavItem = ({
5
6
  children,
@@ -15,13 +16,15 @@ const ContentsNavItem = ({
15
16
  ariaCurrent = 'page';
16
17
  }
17
18
 
19
+ const classNamesString = clsx(classNames);
20
+
18
21
  function processChildren(children: React.ReactNode) {
19
22
  if (linkComponent) {
20
- return linkComponent({ className: classNames.join(' '), href, children });
23
+ return linkComponent({ className: classNamesString, href, children });
21
24
  } else if (href) {
22
- return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNames.join(' ')}>{children}</a>;
25
+ return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNamesString}>{children}</a>;
23
26
  } else {
24
- return <span aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNames.join(' ')}>{children}</span>;
27
+ return <span aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNamesString}>{children}</span>;
25
28
  }
26
29
  }
27
30
 
@@ -44,10 +47,10 @@ const ContentsNav = ({
44
47
  return (
45
48
  <nav
46
49
  aria-label={ariaLabel}
47
- className={[
50
+ className={clsx([
48
51
  'ds_contents-nav',
49
52
  className
50
- ].join(' ')}
53
+ ])}
51
54
  {...props}
52
55
  >
53
56
  <h2 className="ds_contents-nav__title">{title}</h2>
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { test, expect } from 'vitest';
7
- import { render } from '@testing-library/react';
7
+ import { render, screen } from '@testing-library/react';
8
8
  import CookieBanner from './CookieBanner';
9
9
  import Button from '../Button/Button';
10
10
 
@@ -29,3 +29,20 @@ test('cookie banner renders correctly', () => {
29
29
 
30
30
  expect(bannerContainer).toHaveClass('ds_notification', 'ds_notification--large', 'ds_notification--cookie', 'js-initial-cookie-content');
31
31
  });
32
+
33
+ test('instantiating/initialising DS component script', () => {
34
+ render(
35
+ <CookieBanner data-testid="cookie-banner" >
36
+ {BANNER_TEXT}
37
+ <CookieBanner.Buttons>
38
+ <Button className="js-accept-all-cookies" isSmall buttonStyle="secondary">Accept all cookies</Button>
39
+ <Button className="js-accept-essential-cookies" isSmall buttonStyle="secondary">Use essential cookies only</Button>
40
+ <a href="/cookies/">Set cookie preferences</a>
41
+ </CookieBanner.Buttons>
42
+ </CookieBanner>
43
+ );
44
+
45
+ const cookieBanner = screen.getByTestId('cookie-banner');
46
+ expect(cookieBanner).toHaveClass('js-initialised');
47
+ expect(cookieBanner).toHaveClass('js-instantiated');
48
+ });
@@ -1,9 +1,9 @@
1
1
 
2
2
  import { useEffect, useRef } from 'react';
3
3
  import AbstractNotificationBanner from '../../common/AbstractNotificationBanner';
4
- // @ts-expect-error no types from core SGDS
5
4
  import DSCookieBanner from '@scottish-government/design-system/src/components/cookie-notification/cookie-notification.js';
6
5
  import { AbstractNotificationBannerProps } from '../../common/AbstractNotificationBanner/types';
6
+ import clsx from 'clsx';
7
7
 
8
8
  const CookieBanner = ({
9
9
  children,
@@ -14,6 +14,7 @@ const CookieBanner = ({
14
14
  const ref = useRef(null);
15
15
 
16
16
  useEffect(() => {
17
+ /* istanbul ignore else */
17
18
  if (ref.current) {
18
19
  new DSCookieBanner(ref.current).init();
19
20
  }
@@ -22,12 +23,12 @@ const CookieBanner = ({
22
23
  return (
23
24
  <>
24
25
  <AbstractNotificationBanner
25
- className={[
26
+ className={clsx([
26
27
  'ds_notification--large',
27
28
  'ds_notification--cookie',
28
29
  'js-initial-cookie-content',
29
30
  className
30
- ].join(' ')}
31
+ ])}
31
32
  data-module="ds-cookie-notification"
32
33
  ref={ref}
33
34
  title={title}
@@ -59,20 +59,6 @@ test('date picker with hint text', () => {
59
59
  expect(textInput).toHaveAttribute('aria-describedby', hintTextEl.id);
60
60
  });
61
61
 
62
- test('date picker with custom icon path', () => {
63
- const ICON_PATH = '/my/icon/path'
64
-
65
- render(
66
- <DatePicker
67
- id={DATE_PICKER_ID}
68
- label={LABEL_TEXT}
69
- iconPath={ICON_PATH}
70
- />
71
- );
72
-
73
- // todo
74
- });
75
-
76
62
  test('date picker with max date', () => {
77
63
  const MAX_DATE = '28/05/2023'
78
64
 
@@ -139,6 +125,44 @@ test('date picker with change fn', () => {
139
125
  expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
140
126
  });
141
127
 
128
+ test('date picker with onBlur that is not a function', () => {
129
+ render(
130
+ <DatePicker
131
+ id={DATE_PICKER_ID}
132
+ label={LABEL_TEXT}
133
+ // @ts-expect-error onBlur is not a function
134
+ onBlur='foo'
135
+ />
136
+ );
137
+ const datePicker = screen.getAllByRole('generic')[1];
138
+ const textInput = within(datePicker).getByRole('textbox');
139
+
140
+ fireEvent.blur(textInput);
141
+
142
+ // todo: assertion
143
+ // success indicated by no errors thrown
144
+ // error would be thrown on an untestable thread
145
+ });
146
+
147
+ test('date picker with onChange that is not a function', () => {
148
+ render(
149
+ <DatePicker
150
+ id={DATE_PICKER_ID}
151
+ label={LABEL_TEXT}
152
+ // @ts-expect-error onChange is not a function
153
+ onChange='foo'
154
+ />
155
+ );
156
+ const datePicker = screen.getAllByRole('generic')[1];
157
+ const textInput = within(datePicker).getByRole('textbox');
158
+
159
+ fireEvent.change(textInput, { target: { value: 'foo' } });
160
+
161
+ // todo: assertion
162
+ // success indicated by no errors thrown
163
+ // error would be thrown on an untestable thread
164
+ });
165
+
142
166
  test('date picker with initial value', () => {
143
167
  const INITIAL_VALUE = '28/05/2023';
144
168
 
@@ -221,6 +245,20 @@ test('date picker with error message', () => {
221
245
  expect(errorMessageElement).toHaveClass('ds_question__error-message');
222
246
  });
223
247
 
248
+ test('instantiating/initialising DS component script', () => {
249
+ render(
250
+ <DatePicker
251
+ id={DATE_PICKER_ID}
252
+ label={LABEL_TEXT}
253
+ data-test="foo"
254
+ />
255
+ )
256
+
257
+ const datePicker = screen.getAllByRole('generic')[1];
258
+ expect(datePicker).toHaveClass('js-initialised');
259
+ expect(datePicker).toHaveClass('js-instantiated');
260
+ });
261
+
224
262
  test('passing additional props', () => {
225
263
  render(
226
264
  <DatePicker
@@ -1,9 +1,9 @@
1
1
  import { useEffect, useRef } from 'react';
2
- // @ts-expect-error no types from core SGDS
3
2
  import DSDatePicker from '@scottish-government/design-system/src/components/date-picker/date-picker';
4
3
  import ErrorMessage from '../ErrorMessage';
5
4
  import TextInput from '../TextInput';
6
5
  import { DatePickerProps } from './types';
6
+ import clsx from 'clsx';
7
7
 
8
8
  const DatePicker = ({
9
9
  className,
@@ -13,7 +13,6 @@ const DatePicker = ({
13
13
  hasError,
14
14
  hintText,
15
15
  id,
16
- iconPath = './',
17
16
  label,
18
17
  maxDate,
19
18
  minDate,
@@ -28,13 +27,13 @@ const DatePicker = ({
28
27
  const ref = useRef(null);
29
28
 
30
29
  useEffect(() => {
30
+ /* istanbul ignore else */
31
31
  if (ref.current) {
32
32
  new DSDatePicker(ref.current, {
33
- dateSelectCallback,
34
- imagePath: iconPath
33
+ dateSelectCallback
35
34
  }).init();
36
35
  }
37
- }, [ref, dateSelectCallback, iconPath]);
36
+ }, [ref, dateSelectCallback]);
38
37
 
39
38
  function handleBlur(event: React.FocusEvent) {
40
39
  if (typeof onBlur === 'function') {
@@ -50,11 +49,11 @@ const DatePicker = ({
50
49
 
51
50
  return (
52
51
  <div
53
- className={[
52
+ className={clsx([
54
53
  "ds_datepicker",
55
54
  multiple && "ds_datepicker--multiple",
56
55
  className
57
- ].join(' ')}
56
+ ])}
58
57
  data-disableddates={disabledDates}
59
58
  data-maxdate={maxDate}
60
59
  data-mindate={minDate}
@@ -4,10 +4,9 @@ export interface DatePickerProps extends React.AllHTMLAttributes<HTMLElement> {
4
4
  dateSelectCallback?: (date: Date) => void;
5
5
  disabledDates?: string;
6
6
  hasError?: boolean;
7
- errorMessage?: string;
7
+ errorMessage?: string | React.ReactNode;
8
8
  id: string;
9
- hintText?: string;
10
- iconPath?: string;
9
+ hintText?: string | React.ReactNode;
11
10
  label: string;
12
11
  maxDate?: string;
13
12
  minDate?: string;
@@ -1,4 +1,5 @@
1
1
  import { DetailsProps } from "./types";
2
+ import clsx from 'clsx';
2
3
 
3
4
  const Details = ({
4
5
  children,
@@ -8,10 +9,10 @@ const Details = ({
8
9
  }: DetailsProps) => {
9
10
  return (
10
11
  <details
11
- className={[
12
+ className={clsx([
12
13
  "ds_details",
13
14
  className
14
- ].join(' ')}
15
+ ])}
15
16
  {...props}
16
17
  >
17
18
  <summary className="ds_details__summary">
@@ -1,4 +1,5 @@
1
1
  import { ErrorMessageProps } from "./types";
2
+ import clsx from 'clsx';
2
3
 
3
4
  const ErrorMessage = ({
4
5
  children,
@@ -8,10 +9,10 @@ const ErrorMessage = ({
8
9
  }: ErrorMessageProps) => {
9
10
  return (
10
11
  <p
11
- className={[
12
+ className={clsx([
12
13
  'ds_question__error-message',
13
14
  className
14
- ].join(' ')}
15
+ ])}
15
16
  id={id}
16
17
  {...props}
17
18
  >
@@ -1,5 +1,6 @@
1
1
  import { useId } from 'react';
2
2
  import { ErrorSummaryItemProps, ErrorSummaryProps } from './types';
3
+ import clsx from 'clsx';
3
4
 
4
5
  const ErrorSummaryItem = ({
5
6
  children,
@@ -34,10 +35,10 @@ const ErrorSummary = ({
34
35
  const summaryTitleId = useId();
35
36
 
36
37
  return (
37
- <div className={[
38
+ <div className={clsx([
38
39
  'ds_error-summary',
39
40
  className
40
- ].join(' ')}
41
+ ])}
41
42
  aria-labelledby={summaryTitleId}
42
43
  role="alert"
43
44
  {...props}
@@ -0,0 +1,223 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import argTypes from '../../../.storybook/sgdsArgTypes';
3
+
4
+ import FeatureHeader from './FeatureHeader';
5
+ import Button from '../Button';
6
+ // @ts-expect-error no types
7
+ import photograph from '../../../static/images/highland-cow.jpg';
8
+ // @ts-expect-error no types
9
+ import illustration from '../../../static/images/illustration.svg';
10
+
11
+
12
+
13
+ type foo = typeof FeatureHeader;
14
+
15
+
16
+ const meta = {
17
+ title: 'Components/FeatureHeader',
18
+ component: FeatureHeader,
19
+ argTypes: {
20
+ backgroundColor: argTypes.select({options: ['none', 'secondary', 'tertiary', 'brand']}),
21
+ children: argTypes.children(),
22
+ hasCoverImage: argTypes.boolean(),
23
+ hasNoImagePadding: argTypes.boolean(),
24
+ id: argTypes.id({ type: { name: 'string', required: false } }),
25
+ isFullWidth: argTypes.boolean(),
26
+ isWideText: argTypes.boolean(),
27
+ isTopAlignImage: argTypes.boolean(),
28
+ tagName: argTypes.select({ options: ['div', 'header'] })
29
+ },
30
+ args: {
31
+ backgroundColor: 'secondary'
32
+ }
33
+ } satisfies Meta<foo & { image: string }>;
34
+
35
+ export default meta;
36
+ type Story = StoryObj<typeof meta>;
37
+
38
+ export const Default: Story = {
39
+ args: {
40
+ children: <>
41
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
42
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
43
+ <p>The Design System is open source and free to use.</p>
44
+ </FeatureHeader.Primary>
45
+ <FeatureHeader.Secondary>
46
+ <img
47
+ alt=""
48
+ src={illustration}
49
+ />
50
+ </FeatureHeader.Secondary>
51
+ </>
52
+ }
53
+ };
54
+
55
+
56
+ export const WithoutContent: Story = {
57
+ name: 'Without content',
58
+ args: {
59
+ children: <>
60
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
61
+ </FeatureHeader.Primary>
62
+ <FeatureHeader.Secondary>
63
+ <img
64
+ alt=""
65
+ src={illustration}
66
+ />
67
+ </FeatureHeader.Secondary>
68
+ </>
69
+ }
70
+ };
71
+
72
+ export const WithCallToAction: Story = {
73
+ name: 'Call to action',
74
+ args: {
75
+ children: <>
76
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
77
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
78
+ <p>The Design System is open source and free to use.</p>
79
+ <Button href="#foo" icon="ChevronRight">Get started</Button>
80
+ </FeatureHeader.Primary>
81
+ <FeatureHeader.Secondary>
82
+ <img
83
+ alt=""
84
+ src={illustration}
85
+ />
86
+ </FeatureHeader.Secondary>
87
+ </>
88
+ }
89
+ };
90
+
91
+ export const WithCoverImage: Story = {
92
+ name: 'Cover image',
93
+ args: {
94
+ children: <>
95
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
96
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
97
+ <p>The Design System is open source and free to use.</p>
98
+ </FeatureHeader.Primary>
99
+ <FeatureHeader.Secondary>
100
+ <img
101
+ alt=""
102
+ src={illustration}
103
+ />
104
+ </FeatureHeader.Secondary>
105
+ </>,
106
+ hasCoverImage: true
107
+ }
108
+ };
109
+
110
+ export const WithCoverImagePhotograph: Story = {
111
+ name: 'Cover image (photograph)',
112
+ args: {
113
+ children: <>
114
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
115
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
116
+ <p>The Design System is open source and free to use.</p>
117
+ </FeatureHeader.Primary>
118
+ <FeatureHeader.Secondary>
119
+ <img
120
+ alt=""
121
+ src={photograph}
122
+ />
123
+ </FeatureHeader.Secondary>
124
+ </>,
125
+ hasCoverImage: true
126
+ }
127
+ };
128
+
129
+ export const FullWidth: Story = {
130
+ name: 'Full width',
131
+ args: {
132
+ children: <>
133
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
134
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
135
+ <p>The Design System is open source and free to use.</p>
136
+ </FeatureHeader.Primary>
137
+ <FeatureHeader.Secondary>
138
+ <img
139
+ alt=""
140
+ src={illustration}
141
+ />
142
+ </FeatureHeader.Secondary>
143
+ </>,
144
+ isFullWidth: true
145
+ }
146
+ };
147
+
148
+ export const FullWidthImagePaddingRemoved: Story = {
149
+ name: 'Full width with image padding removed',
150
+ args: {
151
+ children: <>
152
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
153
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
154
+ <p>The Design System is open source and free to use.</p>
155
+ </FeatureHeader.Primary>
156
+ <FeatureHeader.Secondary>
157
+ <img
158
+ alt=""
159
+ src={illustration}
160
+ />
161
+ </FeatureHeader.Secondary>
162
+ </>,
163
+ hasNoImagePadding: true,
164
+ isFullWidth: true
165
+ }
166
+ };
167
+
168
+ export const WideText: Story = {
169
+ name: 'Wide text',
170
+ args: {
171
+ children: <>
172
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
173
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
174
+ <p>The Design System is open source and free to use.</p>
175
+ </FeatureHeader.Primary>
176
+ <FeatureHeader.Secondary>
177
+ <img
178
+ alt=""
179
+ src={illustration}
180
+ />
181
+ </FeatureHeader.Secondary>
182
+ </>,
183
+ isWideText: true
184
+ }
185
+ };
186
+
187
+ export const TopAlign: Story = {
188
+ name: 'Top aligned image',
189
+ args: {
190
+ children: <>
191
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
192
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
193
+ <p>The Design System is open source and free to use.</p>
194
+ </FeatureHeader.Primary>
195
+ <FeatureHeader.Secondary>
196
+ <img
197
+ alt=""
198
+ src={illustration}
199
+ />
200
+ </FeatureHeader.Secondary>
201
+ </>,
202
+ isTopAlignImage: true
203
+ }
204
+ };
205
+
206
+ export const TopAlignPhotograph: Story = {
207
+ name: 'Top aligned image (photograph)',
208
+ args: {
209
+ children: <>
210
+ <FeatureHeader.Primary title="Design and build accessible digital services for Scotland">
211
+ <p>The Scottish Government Design System provides static web assets for websites and web applications for the Scottish Government and other Scottish public sector bodies.</p>
212
+ <p>The Design System is open source and free to use.</p>
213
+ </FeatureHeader.Primary>
214
+ <FeatureHeader.Secondary>
215
+ <img
216
+ alt=""
217
+ src={photograph}
218
+ />
219
+ </FeatureHeader.Secondary>
220
+ </>,
221
+ isTopAlignImage: true
222
+ }
223
+ };