uikit-react-public 0.14.21 → 0.21.8

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 (392) hide show
  1. package/README.md +2 -2
  2. package/dist/components/Accordion/Accordion.Heading.d.ts +5 -4
  3. package/dist/components/Accordion/Accordion.Panel.d.ts +2 -2
  4. package/dist/components/Accordion/Accordion.d.ts +1 -1
  5. package/dist/components/Accordion/Accordion.stories.d.ts +57 -0
  6. package/dist/components/Accordion/index.d.ts +2 -0
  7. package/dist/components/AppHeader/AppHeader.d.ts +1 -1
  8. package/dist/components/AppHeader/AppHeaderBottom.d.ts +1 -1
  9. package/dist/components/AppHeader/AppHeaderNav.d.ts +1 -1
  10. package/dist/components/AppHeader/AppHeaderTop.d.ts +1 -1
  11. package/dist/components/Avatar/Avatar.stories.d.ts +107 -1
  12. package/dist/components/Breadcrumbs/Breadcrumb.d.ts +3 -4
  13. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  14. package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +1 -1
  15. package/dist/components/Button/Button.d.ts +8 -3
  16. package/dist/components/Button/Button.stories.d.ts +17 -7
  17. package/dist/components/Button/style/buttonAccentStyle.d.ts +4 -0
  18. package/dist/components/Button/style/buttonPrimaryDestructiveStyle.d.ts +4 -0
  19. package/dist/components/Button/style/buttonPrimaryStyle.d.ts +4 -0
  20. package/dist/components/Button/style/buttonPrimarySubtleStyle.d.ts +4 -0
  21. package/dist/components/Button/style/buttonPrimaryWarningStyle.d.ts +4 -0
  22. package/dist/components/Button/style/buttonSecondaryDestructiveStyle.d.ts +4 -0
  23. package/dist/components/Button/style/buttonSecondaryStyle.d.ts +4 -0
  24. package/dist/components/Button/style/buttonSecondarySubtleStyle.d.ts +4 -0
  25. package/dist/components/Button/style/buttonTertiaryDestructiveStyle.d.ts +4 -0
  26. package/dist/components/Button/style/buttonTertiaryNoPaddingStyle.d.ts +4 -0
  27. package/dist/components/Button/style/buttonTertiaryStyle.d.ts +4 -0
  28. package/dist/components/Calendar/index.d.ts +1 -1
  29. package/dist/components/Checkbox/Checkbox.d.ts +1 -0
  30. package/dist/components/Datepicker/Datepicker.d.ts +1 -1
  31. package/dist/components/Datepicker/Datepicker.stories.d.ts +4 -3
  32. package/dist/components/Datepicker/Datepicker.types.d.ts +4 -5
  33. package/dist/components/Datepicker/subcomponents/CustomDatepicker.d.ts +4 -1
  34. package/dist/components/Datepicker/subcomponents/DatepickerInput.d.ts +15 -2
  35. package/dist/components/Datepicker/subcomponents/Panel.d.ts +1 -1
  36. package/dist/components/Datepicker/subcomponents/VisibleField.d.ts +6 -1
  37. package/dist/components/Datepicker/subcomponents/index.d.ts +0 -1
  38. package/dist/components/Datepicker/utils/index.d.ts +0 -1
  39. package/dist/components/Dialog/BaseDialog.d.ts +2 -1
  40. package/dist/components/Dialog/Dialog.d.ts +2 -0
  41. package/dist/components/FooterNew/BackToTop.d.ts +8 -0
  42. package/dist/components/FooterNew/Footer.d.ts +23 -0
  43. package/dist/components/FooterNew/FooterColumn.d.ts +8 -0
  44. package/dist/components/FooterNew/FooterLinks.d.ts +7 -0
  45. package/dist/components/FooterNew/FooterNavLink.d.ts +8 -0
  46. package/dist/components/FooterNew/LegalAndCopyright.d.ts +14 -0
  47. package/dist/components/FooterNew/LogoAddressAndSocial.d.ts +10 -0
  48. package/dist/components/FooterNew/SocialLink.d.ts +8 -0
  49. package/dist/components/FooterNew/index.d.ts +2 -0
  50. package/dist/components/Header/Header.d.ts +4 -1
  51. package/dist/components/Header/Header.stories.d.ts +40 -0
  52. package/dist/components/HeaderNew/Header.d.ts +18 -0
  53. package/dist/components/HeaderNew/HeaderBorder.d.ts +7 -0
  54. package/dist/components/HeaderNew/HeaderLogo.d.ts +9 -0
  55. package/dist/components/HeaderNew/HeaderMenuContainer.d.ts +7 -0
  56. package/dist/components/HeaderNew/HeaderTitle.d.ts +9 -0
  57. package/dist/components/HeaderNew/__tests__/Header.test.d.ts +1 -0
  58. package/dist/components/HeaderNew/constants.d.ts +3 -0
  59. package/dist/components/HeaderNew/index.d.ts +3 -0
  60. package/dist/components/HeadingNew/Heading.d.ts +13 -0
  61. package/dist/components/HeadingNew/index.d.ts +2 -0
  62. package/dist/components/Icon/svgImports.d.ts +7 -881
  63. package/dist/components/Link/BaseLink.d.ts +14 -5
  64. package/dist/components/Link/Link.d.ts +8 -3
  65. package/dist/components/Link/Link.stories.d.ts +3 -1
  66. package/dist/components/Main/Main.d.ts +21 -0
  67. package/dist/components/Main/Main.stories.d.ts +15 -0
  68. package/dist/components/Main/__tests__/Main.test.d.ts +1 -0
  69. package/dist/components/Main/index.d.ts +2 -0
  70. package/dist/components/MenuNew/Menu.context.d.ts +14 -0
  71. package/dist/components/MenuNew/Menu.d.ts +20 -0
  72. package/dist/components/MenuNew/MenuContent.d.ts +9 -0
  73. package/dist/components/MenuNew/MenuItem.d.ts +10 -0
  74. package/dist/components/MenuNew/MenuSection.d.ts +7 -0
  75. package/dist/components/MenuNew/index.d.ts +6 -0
  76. package/dist/components/MenuNew/trigger/ButtonMenuTrigger.d.ts +8 -0
  77. package/dist/components/MenuNew/trigger/IconMenuTrigger.d.ts +8 -0
  78. package/dist/components/NativeDatepicker/NativeDatepicker.d.ts +3 -0
  79. package/dist/components/NativeDatepicker/NativeDatepicker.stories.d.ts +36 -0
  80. package/dist/components/NativeDatepicker/NativeDatepicker.types.d.ts +10 -0
  81. package/dist/components/NativeDatepicker/index.d.ts +2 -0
  82. package/dist/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.d.ts +1 -1
  83. package/dist/components/NativeDatepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts +1 -0
  84. package/dist/components/NativeDatepicker/utils/index.d.ts +1 -0
  85. package/dist/components/Overlay/Overlay.stories.d.ts +12 -12
  86. package/dist/components/ParagraphNew/Paragraph.d.ts +13 -0
  87. package/dist/components/ParagraphNew/index.d.ts +4 -0
  88. package/dist/components/Select/Select.d.ts +2 -1
  89. package/dist/components/Select/Select.stories.d.ts +167 -3
  90. package/dist/components/Select/Select.types.d.ts +75 -19
  91. package/dist/components/Select/subcomponents/CustomOption.d.ts +1 -1
  92. package/dist/components/Select/subcomponents/CustomSelect.d.ts +3 -2
  93. package/dist/components/Select/subcomponents/FilterInput.d.ts +16 -0
  94. package/dist/components/Select/subcomponents/NativeSelect.d.ts +5 -1
  95. package/dist/components/Select/subcomponents/VisibleField.d.ts +6 -1
  96. package/dist/components/Select/subcomponents/index.d.ts +1 -0
  97. package/dist/components/Spinner/Spinner.d.ts +2 -0
  98. package/dist/components/StandaloneLink/StandaloneLink.d.ts +8 -5
  99. package/dist/components/StandaloneLink/StandaloneLink.stories.d.ts +3 -1
  100. package/dist/components/Table/Table.d.ts +3 -3
  101. package/dist/components/Table/Table.stories.d.ts +3 -3
  102. package/dist/components/Table/Table.types.d.ts +1 -0
  103. package/dist/components/Table/subcomponents/Cell/Cell.d.ts +5 -1
  104. package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +15 -13
  105. package/dist/components/Table/subcomponents/Cell/CellContent.d.ts +5 -1
  106. package/dist/components/Table/subcomponents/HeadCell/HeadCell.d.ts +2 -1
  107. package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +14 -13
  108. package/dist/components/Table/subcomponents/HeadCell/HeadCellContent.d.ts +2 -1
  109. package/dist/components/Table/subcomponents/__tests__/Row.test.d.ts +1 -0
  110. package/dist/components/UclLogoNew/UclLogo.d.ts +8 -0
  111. package/dist/components/UclLogoNew/index.d.ts +2 -0
  112. package/dist/components/WeekPicker/WeekPicker.d.ts +2 -2
  113. package/dist/components/WeekPicker/WeekPicker.stories.d.ts +41 -0
  114. package/dist/components/WeekPicker/WeekPicker.types.d.ts +16 -0
  115. package/dist/components/WeekPicker/index.d.ts +1 -0
  116. package/dist/components/WeekPicker/subcomponents/CustomDatepicker.d.ts +1 -1
  117. package/dist/components/index.d.ts +20 -0
  118. package/dist/hooks/useFocusTrap.d.ts +2 -1
  119. package/dist/index.d.ts +1 -0
  120. package/dist/index.js +22204 -16719
  121. package/dist/theme/__tests__/fonts.test.d.ts +1 -0
  122. package/dist/theme/common/themeCommon.d.ts +904 -0
  123. package/dist/theme/fonts.d.ts +18 -0
  124. package/dist/theme/index.d.ts +6 -3
  125. package/dist/theme/light/lightColour.d.ts +126 -0
  126. package/dist/theme/light/lightTheme.d.ts +3 -0
  127. package/dist/theme/original/color.d.ts +166 -0
  128. package/dist/theme/original/defaultTheme.d.ts +1340 -0
  129. package/dist/theme/original/originalColourNewStructure.d.ts +126 -0
  130. package/dist/theme/useTheme.d.ts +2174 -0
  131. package/dist/utils/__tests__/announce.test.d.ts +1 -0
  132. package/dist/utils/addAlphaToHex.d.ts +5 -0
  133. package/dist/utils/announce.d.ts +6 -0
  134. package/dist/utils/index.d.ts +1 -0
  135. package/dist/utils/scrollToTop.d.ts +2 -0
  136. package/lib/components/Accordion/Accordion.Heading.tsx +65 -34
  137. package/lib/components/Accordion/Accordion.Panel.tsx +11 -7
  138. package/lib/components/Accordion/Accordion.stories.tsx +139 -0
  139. package/lib/components/Accordion/Accordion.tsx +39 -31
  140. package/lib/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +15 -13
  141. package/lib/components/Accordion/index.ts +2 -0
  142. package/lib/components/Alert/Alert.stories.tsx +1 -1
  143. package/lib/components/Alert/Alert.tsx +12 -12
  144. package/lib/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +13 -39
  145. package/lib/components/AppHeader/AppHeader.tsx +6 -11
  146. package/lib/components/AppHeader/AppHeaderBottom.tsx +2 -3
  147. package/lib/components/AppHeader/AppHeaderNav.tsx +2 -3
  148. package/lib/components/AppHeader/AppHeaderTop.tsx +1 -1
  149. package/lib/components/AppHeader/__tests__/__snapshots__/AppHeader.test.tsx.snap +2 -2
  150. package/lib/components/AppMenu/__tests__/__snapshots__/AppMenu.test.tsx.snap +6 -19
  151. package/lib/components/Avatar/Avatar.mdx +117 -0
  152. package/lib/components/Avatar/Avatar.stories.tsx +110 -2
  153. package/lib/components/Badge/Badge.stories.tsx +1 -1
  154. package/lib/components/Blanket/Blanket.stories.tsx +1 -1
  155. package/lib/components/Breadcrumbs/Breadcrumb.tsx +26 -12
  156. package/lib/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
  157. package/lib/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx +9 -27
  158. package/lib/components/Breadcrumbs/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +24 -20
  159. package/lib/components/Button/Button.mdx +32 -279
  160. package/lib/components/Button/Button.stories.tsx +44 -51
  161. package/lib/components/Button/Button.tsx +166 -25
  162. package/lib/components/Button/__tests__/Button.test.tsx +49 -15
  163. package/lib/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +80 -73
  164. package/lib/components/Button/style/buttonAccentStyle.ts +53 -0
  165. package/lib/components/Button/style/buttonPrimaryDestructiveStyle.ts +55 -0
  166. package/lib/components/Button/style/buttonPrimaryStyle.ts +53 -0
  167. package/lib/components/Button/style/buttonPrimarySubtleStyle.ts +64 -0
  168. package/lib/components/Button/style/buttonPrimaryWarningStyle.ts +56 -0
  169. package/lib/components/Button/style/buttonSecondaryDestructiveStyle.ts +63 -0
  170. package/lib/components/Button/style/buttonSecondaryStyle.ts +62 -0
  171. package/lib/components/Button/style/buttonSecondarySubtleStyle.ts +72 -0
  172. package/lib/components/Button/style/buttonTertiaryDestructiveStyle.ts +65 -0
  173. package/lib/components/Button/style/buttonTertiaryNoPaddingStyle.ts +52 -0
  174. package/lib/components/Button/style/buttonTertiaryStyle.ts +62 -0
  175. package/lib/components/Calendar/Calendar.stories.tsx +1 -1
  176. package/lib/components/Calendar/Calendar.tsx +2 -2
  177. package/lib/components/Calendar/__tests__/Calendar.test.tsx +23 -15
  178. package/lib/components/Calendar/__tests__/__snapshots__/Calendar.test.tsx.snap +99 -95
  179. package/lib/components/Calendar/index.ts +1 -5
  180. package/lib/components/Calendar/subcomponents/AcademicWeek.tsx +2 -1
  181. package/lib/components/Calendar/subcomponents/AcademicWeeks.tsx +1 -1
  182. package/lib/components/Calendar/subcomponents/ColumnHeading.tsx +2 -2
  183. package/lib/components/Calendar/subcomponents/Controls.tsx +1 -1
  184. package/lib/components/Calendar/subcomponents/Day.stories.tsx +1 -1
  185. package/lib/components/Calendar/subcomponents/Day.tsx +7 -9
  186. package/lib/components/Calendar/subcomponents/EventDot.tsx +3 -6
  187. package/lib/components/Calendar/subcomponents/index.ts +1 -1
  188. package/lib/components/Calendar/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.ts +43 -11
  189. package/lib/components/Calendar/utils/normaliseMonth/normaliseMonth.test.ts +5 -5
  190. package/lib/components/Checkbox/Checkbox.stories.tsx +1 -1
  191. package/lib/components/Checkbox/Checkbox.tsx +12 -10
  192. package/lib/components/Checkbox/__tests__/Checkbox.test.tsx +29 -0
  193. package/lib/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +4 -4
  194. package/lib/components/Datepicker/Datepicker.lld.md +108 -0
  195. package/lib/components/Datepicker/Datepicker.stories.tsx +44 -5
  196. package/lib/components/Datepicker/Datepicker.tsx +14 -36
  197. package/lib/components/Datepicker/Datepicker.types.ts +5 -14
  198. package/lib/components/Datepicker/__tests__/Datepicker.test.tsx +267 -8
  199. package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +20 -42
  200. package/lib/components/Datepicker/subcomponents/CustomDatepicker.tsx +48 -5
  201. package/lib/components/Datepicker/subcomponents/DatepickerInput.tsx +30 -17
  202. package/lib/components/Datepicker/subcomponents/Panel.tsx +6 -2
  203. package/lib/components/Datepicker/subcomponents/VisibleField.tsx +46 -8
  204. package/lib/components/Datepicker/subcomponents/index.ts +0 -1
  205. package/lib/components/Datepicker/utils/index.ts +0 -1
  206. package/lib/components/Dialog/BaseDialog.tsx +13 -2
  207. package/lib/components/Dialog/Dialog.stories.tsx +1 -1
  208. package/lib/components/Dialog/Dialog.tsx +8 -1
  209. package/lib/components/Dialog/DialogBody.tsx +5 -1
  210. package/lib/components/Dialog/DialogHeader.tsx +2 -1
  211. package/lib/components/Divider/Divider.stories.tsx +1 -1
  212. package/lib/components/Divider/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +12 -12
  213. package/lib/components/FeedbackDialog/FeedbackDialog.stories.tsx +1 -1
  214. package/lib/components/FeedbackDialog/FeedbackDialog.tsx +4 -6
  215. package/lib/components/Field/CharacterCount.tsx +2 -2
  216. package/lib/components/Field/ErrorText.tsx +2 -1
  217. package/lib/components/Field/Field.stories.tsx +1 -1
  218. package/lib/components/Field/Field.tsx +1 -1
  219. package/lib/components/Field/HelperText.tsx +3 -1
  220. package/lib/components/Field/__tests__/Field.test.tsx +13 -0
  221. package/lib/components/FileInput/FileInput.stories.tsx +1 -1
  222. package/lib/components/FileInput/__tests__/__snapshots__/FileInput.test.tsx.snap +4 -20
  223. package/lib/components/Footer/Footer.stories.tsx +1 -1
  224. package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +73 -82
  225. package/lib/components/FooterNew/BackToTop.tsx +83 -0
  226. package/lib/components/FooterNew/Footer.tsx +110 -0
  227. package/lib/components/FooterNew/FooterColumn.tsx +79 -0
  228. package/lib/components/FooterNew/FooterLinks.tsx +44 -0
  229. package/lib/components/FooterNew/FooterNavLink.tsx +63 -0
  230. package/lib/components/FooterNew/LegalAndCopyright.tsx +150 -0
  231. package/lib/components/FooterNew/LogoAddressAndSocial.tsx +154 -0
  232. package/lib/components/FooterNew/SocialLink.tsx +108 -0
  233. package/lib/components/FooterNew/__tests__/Footer.test.tsx +51 -0
  234. package/lib/components/FooterNew/__tests__/__snapshots__/Footer.test.tsx.snap +1107 -0
  235. package/lib/components/FooterNew/index.ts +2 -0
  236. package/lib/components/Header/Header.mdx +52 -0
  237. package/lib/components/Header/Header.stories.tsx +98 -0
  238. package/lib/components/Header/Header.tsx +51 -6
  239. package/lib/components/Header/__tests__/Header.test.tsx +17 -1
  240. package/lib/components/HeaderDraft/__tests__/__snapshots__/Header.test.tsx.snap +3 -2
  241. package/lib/components/HeaderNew/Header.tsx +93 -0
  242. package/lib/components/HeaderNew/HeaderBorder.tsx +55 -0
  243. package/lib/components/HeaderNew/HeaderLogo.tsx +70 -0
  244. package/lib/components/HeaderNew/HeaderMenuContainer.tsx +35 -0
  245. package/lib/components/HeaderNew/HeaderTitle.tsx +53 -0
  246. package/lib/components/HeaderNew/__tests__/Header.test.tsx +42 -0
  247. package/lib/components/HeaderNew/__tests__/__snapshots__/Header.test.tsx.snap +79 -0
  248. package/lib/components/HeaderNew/constants.ts +3 -0
  249. package/lib/components/HeaderNew/index.ts +7 -0
  250. package/lib/components/Heading/Heading.stories.tsx +1 -1
  251. package/lib/components/HeadingNew/Heading.tsx +208 -0
  252. package/lib/components/HeadingNew/index.ts +2 -0
  253. package/lib/components/Icon/Icon.stories.tsx +1 -1
  254. package/lib/components/Icon/__tests__/__snapshots__/Icon.test.tsx.snap +16 -12
  255. package/lib/components/Icon/svgImports.ts +318 -296
  256. package/lib/components/IconButton/IconButton.stories.tsx +1 -1
  257. package/lib/components/IconButton/IconButton.tsx +3 -4
  258. package/lib/components/IconButton/__tests__/__snapshots__/IconButton.test.tsx.snap +12 -9
  259. package/lib/components/Input/Input.stories.tsx +1 -1
  260. package/lib/components/Label/Label.stories.tsx +1 -1
  261. package/lib/components/Link/BaseLink.tsx +114 -71
  262. package/lib/components/Link/Link.stories.tsx +1 -1
  263. package/lib/components/Link/Link.tsx +120 -109
  264. package/lib/components/Link/__tests__/__snapshots__/link.test.tsx.snap +2 -2
  265. package/lib/components/Main/Main.stories.tsx +36 -0
  266. package/lib/components/Main/Main.tsx +46 -0
  267. package/lib/components/Main/__tests__/Main.test.tsx +80 -0
  268. package/lib/components/Main/__tests__/__snapshots__/Main.test.tsx.snap +33 -0
  269. package/lib/components/Main/index.ts +2 -0
  270. package/lib/components/MenuNew/Menu.context.tsx +149 -0
  271. package/lib/components/MenuNew/Menu.tsx +75 -0
  272. package/lib/components/MenuNew/MenuContent.tsx +140 -0
  273. package/lib/components/MenuNew/MenuItem.tsx +101 -0
  274. package/lib/components/MenuNew/MenuSection.tsx +47 -0
  275. package/lib/components/MenuNew/index.ts +8 -0
  276. package/lib/components/MenuNew/trigger/ButtonMenuTrigger.tsx +42 -0
  277. package/lib/components/MenuNew/trigger/IconMenuTrigger.tsx +40 -0
  278. package/lib/components/NativeDatepicker/NativeDatepicker.stories.tsx +100 -0
  279. package/lib/components/{Datepicker/subcomponents → NativeDatepicker}/NativeDatepicker.tsx +14 -15
  280. package/lib/components/NativeDatepicker/NativeDatepicker.types.ts +19 -0
  281. package/lib/components/NativeDatepicker/index.ts +2 -0
  282. package/lib/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.ts +1 -1
  283. package/lib/components/NativeDatepicker/utils/index.ts +1 -0
  284. package/lib/components/Pagination/Pagination.stories.tsx +1 -1
  285. package/lib/components/Pagination/PaginationControls.tsx +59 -17
  286. package/lib/components/Pagination/PaginationInfo.tsx +7 -4
  287. package/lib/components/Paragraph/Paragraph.stories.tsx +1 -1
  288. package/lib/components/ParagraphNew/Paragraph.tsx +200 -0
  289. package/lib/components/ParagraphNew/index.ts +6 -0
  290. package/lib/components/Radio/Radio.stories.tsx +1 -1
  291. package/lib/components/Radio/Radio.tsx +8 -8
  292. package/lib/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap +4 -4
  293. package/lib/components/Search/Search.stories.tsx +1 -1
  294. package/lib/components/Search/Search.tsx +4 -1
  295. package/lib/components/Search/__tests__/Search.test.tsx +19 -1
  296. package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +12 -32
  297. package/lib/components/Select/Select.mdx +192 -0
  298. package/lib/components/Select/Select.stories.tsx +229 -48
  299. package/lib/components/Select/Select.tsx +50 -15
  300. package/lib/components/Select/Select.types.ts +99 -44
  301. package/lib/components/Select/__tests__/Select.test.tsx +698 -8
  302. package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +5 -4
  303. package/lib/components/Select/subcomponents/CustomOption.tsx +12 -4
  304. package/lib/components/Select/subcomponents/CustomSelect.tsx +411 -41
  305. package/lib/components/Select/subcomponents/FilterInput.tsx +90 -0
  306. package/lib/components/Select/subcomponents/NativeSelect.tsx +21 -17
  307. package/lib/components/Select/subcomponents/Panel.tsx +2 -2
  308. package/lib/components/Select/subcomponents/VisibleField.tsx +59 -6
  309. package/lib/components/Select/subcomponents/index.tsx +1 -0
  310. package/lib/components/Snackbar/Snackbar.stories.tsx +1 -1
  311. package/lib/components/Snackbar/__tests__/__snapshots__/Snackbar.test.tsx.snap +9 -15
  312. package/lib/components/Spinner/Spinner.stories.tsx +1 -1
  313. package/lib/components/Spinner/Spinner.tsx +24 -5
  314. package/lib/components/Spinner/__tests__/Spinner.test.tsx +35 -5
  315. package/lib/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap +40 -16
  316. package/lib/components/StandaloneLink/StandaloneLink.stories.tsx +1 -1
  317. package/lib/components/StandaloneLink/StandaloneLink.tsx +180 -163
  318. package/lib/components/StandaloneLink/__tests__/__snapshots__/StandaloneLink.test.tsx.snap +2 -2
  319. package/lib/components/Table/Table.stories.tsx +1 -1
  320. package/lib/components/Table/Table.tsx +2 -0
  321. package/lib/components/Table/Table.types.ts +1 -0
  322. package/lib/components/Table/__tests__/Table.test.tsx +19 -0
  323. package/lib/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +7 -3
  324. package/lib/components/Table/subcomponents/Cell/Cell.stories.tsx +1 -1
  325. package/lib/components/Table/subcomponents/Cell/Cell.tsx +23 -2
  326. package/lib/components/Table/subcomponents/Cell/CellContent.tsx +12 -1
  327. package/lib/components/Table/subcomponents/Cell/__tests__/Cell.test.tsx +106 -0
  328. package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +4 -3
  329. package/lib/components/Table/subcomponents/HeadCell/HeadCell.stories.tsx +1 -1
  330. package/lib/components/Table/subcomponents/HeadCell/HeadCell.tsx +28 -6
  331. package/lib/components/Table/subcomponents/HeadCell/HeadCellContent.tsx +3 -0
  332. package/lib/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.tsx +221 -2
  333. package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +6 -4
  334. package/lib/components/Table/subcomponents/Row.tsx +2 -2
  335. package/lib/components/Table/subcomponents/SortIcon.tsx +1 -0
  336. package/lib/components/Table/subcomponents/__tests__/Row.test.tsx +59 -0
  337. package/lib/components/Tabs/Tab.tsx +3 -3
  338. package/lib/components/Tabs/Tabs.stories.tsx +1 -1
  339. package/lib/components/Tabs/Tabs.tsx +5 -3
  340. package/lib/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +4 -4
  341. package/lib/components/Textarea/Textarea.stories.tsx +1 -1
  342. package/lib/components/Timepicker/Timepicker.stories.tsx +1 -1
  343. package/lib/components/Timepicker/Timepicker.tsx +4 -0
  344. package/lib/components/Timepicker/__tests__/__snapshots__/Timepicker.test.tsx.snap +2 -2
  345. package/lib/components/Toggle/Toggle.stories.tsx +1 -1
  346. package/lib/components/Toggle/Toggle.tsx +5 -5
  347. package/lib/components/Toggle/ToggleHandle.tsx +2 -3
  348. package/lib/components/Tooltip/Tooltip.stories.tsx +1 -1
  349. package/lib/components/Tooltip/Tooltip.tsx +2 -2
  350. package/lib/components/Tooltip/__tests__/__snapshots__/tooltip.test.tsx.snap +2 -2
  351. package/lib/components/UclLogoNew/UclLogo.tsx +42 -0
  352. package/lib/components/UclLogoNew/index.ts +2 -0
  353. package/lib/components/WeekPicker/WeekPicker.stories.tsx +145 -0
  354. package/lib/components/WeekPicker/WeekPicker.tsx +2 -2
  355. package/lib/components/WeekPicker/WeekPicker.types.ts +21 -0
  356. package/lib/components/WeekPicker/index.ts +1 -0
  357. package/lib/components/WeekPicker/subcomponents/CustomDatepicker.tsx +1 -1
  358. package/lib/components/common/Common.mdx +1 -2
  359. package/lib/components/index.ts +30 -3
  360. package/lib/hooks/useFocusTrap.ts +40 -4
  361. package/lib/index.ts +1 -0
  362. package/lib/theme/Colours.mdx +1 -1
  363. package/lib/theme/Theme.mdx +1 -1
  364. package/lib/theme/Typography.mdx +1 -1
  365. package/lib/theme/__tests__/fonts.test.ts +37 -0
  366. package/lib/theme/common/themeCommon.ts +515 -0
  367. package/lib/theme/fonts.ts +110 -0
  368. package/lib/theme/index.ts +6 -6
  369. package/lib/theme/light/lightColour.ts +232 -0
  370. package/lib/theme/light/lightTheme.ts +37 -0
  371. package/lib/theme/{defaultTheme.ts → original/color.ts} +17 -199
  372. package/lib/theme/original/defaultTheme.ts +207 -0
  373. package/lib/theme/original/originalColourNewStructure.ts +185 -0
  374. package/lib/theme/useTheme.tsx +72 -15
  375. package/lib/types/assets.d.ts +10 -0
  376. package/lib/utils/__tests__/announce.test.ts +121 -0
  377. package/lib/utils/addAlphaToHex.ts +29 -0
  378. package/lib/utils/announce.ts +134 -0
  379. package/lib/utils/index.ts +1 -0
  380. package/lib/utils/scrollToTop.ts +5 -0
  381. package/package.json +11 -9
  382. package/dist/components/Button/buttonPrimaryStyle.d.ts +0 -4
  383. package/dist/components/Button/buttonSecondaryStyle.d.ts +0 -4
  384. package/dist/components/Button/buttonTertiaryStyle.d.ts +0 -4
  385. package/dist/components/Datepicker/subcomponents/NativeDatepicker.d.ts +0 -6
  386. package/dist/theme/defaultTheme.d.ts +0 -274
  387. package/lib/components/Accordion/Accordion.stories.tsx.NOT_READY +0 -93
  388. package/lib/components/Button/buttonPrimaryStyle.ts +0 -62
  389. package/lib/components/Button/buttonSecondaryStyle.ts +0 -65
  390. package/lib/components/Button/buttonTertiaryStyle.ts +0 -54
  391. /package/dist/components/{Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts → FooterNew/__tests__/Footer.test.d.ts} +0 -0
  392. /package/lib/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.test.ts +0 -0
@@ -4,13 +4,13 @@ import Button from './Button';
4
4
  import Icon from '../Icon';
5
5
  import { theme } from '../../theme';
6
6
 
7
- // Common margin props documentation currently lives here.
8
7
  const marginKeys = Object.keys(theme.margin) as Array<
9
8
  keyof typeof theme.margin
10
9
  >;
11
10
  const marginKeysAsString = marginKeys
12
11
  .map((key) => `'${key.replace('m', '')}'`)
13
12
  .join(', ');
13
+
14
14
  const commonMarginPropsInfo = {
15
15
  table: {
16
16
  type: {
@@ -18,27 +18,46 @@ const commonMarginPropsInfo = {
18
18
  detail: marginKeysAsString,
19
19
  },
20
20
  defaultValue: { summary: 'undefined' },
21
- // Disabled for most <Button> stories by default
22
21
  disable: true,
23
22
  },
24
23
  };
25
24
 
25
+ const variants = [
26
+ 'accent',
27
+ 'primary',
28
+ 'secondary',
29
+ 'tertiary',
30
+ 'primary-subtle',
31
+ 'secondary-subtle',
32
+ 'tertiary-no-padding',
33
+ 'primary-destructive',
34
+ 'secondary-destructive',
35
+ 'tertiary-destructive',
36
+ 'primary-warning',
37
+ ] as const;
38
+
26
39
  const meta = {
27
- title: 'Components/Ready to use/Button',
40
+ title: 'Components/Button',
28
41
  component: Button,
29
42
  parameters: {
30
43
  layout: 'centered',
31
44
  },
32
45
  argTypes: {
33
46
  variant: {
34
- options: ['primary', 'secondary', 'tertiary'],
47
+ options: variants,
35
48
  control: { type: 'select' },
36
49
  type: 'string',
37
50
  },
38
51
  size: {
39
- options: ['small', 'default', 'large'],
52
+ options: ['xsmall', 'small', 'medium', 'large', 'default'],
40
53
  control: { type: 'select' },
41
54
  type: 'string',
55
+ table: {
56
+ type: {
57
+ summary: 'string',
58
+ detail: "'xsmall' | 'small' | 'medium' | 'large' | 'default'",
59
+ },
60
+ },
42
61
  },
43
62
  as: {
44
63
  options: ['button', 'a'],
@@ -54,6 +73,12 @@ const meta = {
54
73
  destructive: {
55
74
  control: { type: 'boolean' },
56
75
  type: 'boolean',
76
+ description:
77
+ 'Deprecated. Prefer destructive variants directly (e.g. primary-destructive).',
78
+ },
79
+ selected: {
80
+ control: { type: 'boolean' },
81
+ type: 'boolean',
57
82
  },
58
83
  disabled: {
59
84
  control: { type: 'boolean' },
@@ -99,7 +124,6 @@ const meta = {
99
124
  control: { type: 'text' },
100
125
  type: 'string',
101
126
  },
102
- // Common margin props specified here for 'Common Props' documentation
103
127
  m: commonMarginPropsInfo,
104
128
  mv: commonMarginPropsInfo,
105
129
  mh: commonMarginPropsInfo,
@@ -154,20 +178,25 @@ export const Tertiary: Story = {
154
178
  },
155
179
  };
156
180
 
181
+ export const Accent: Story = {
182
+ args: {
183
+ variant: 'accent',
184
+ children: 'Accent button',
185
+ },
186
+ };
187
+
157
188
  export const Destructive: Story = {
158
189
  name: 'Destructive primary',
159
190
  args: {
160
- destructive: true,
191
+ variant: 'primary-destructive',
161
192
  children: 'Destructive button',
162
193
  },
163
194
  };
164
195
 
165
- export const DestructiveSecondary: Story = {
166
- name: 'Destructive secondary',
196
+ export const PrimarySubtle: Story = {
167
197
  args: {
168
- variant: 'secondary',
169
- destructive: true,
170
- children: 'Destructive secondary button',
198
+ variant: 'primary-subtle',
199
+ children: 'Primary subtle button',
171
200
  },
172
201
  };
173
202
 
@@ -187,24 +216,6 @@ export const Large: Story = {
187
216
  },
188
217
  };
189
218
 
190
- export const SmallSecondary: Story = {
191
- name: 'Small secondary',
192
- args: {
193
- size: 'small',
194
- variant: 'secondary',
195
- children: 'Small secondary button',
196
- },
197
- };
198
-
199
- export const LargeSecondary: Story = {
200
- name: 'Large secondary',
201
- args: {
202
- size: 'large',
203
- variant: 'secondary',
204
- children: 'Large secondary button',
205
- },
206
- };
207
-
208
219
  export const Disabled: Story = {
209
220
  name: 'Primary disabled',
210
221
  args: {
@@ -213,24 +224,6 @@ export const Disabled: Story = {
213
224
  },
214
225
  };
215
226
 
216
- export const DisabledSecondary: Story = {
217
- name: 'Secondary disabled',
218
- args: {
219
- variant: 'secondary',
220
- disabled: true,
221
- children: 'Disabled secondary button',
222
- },
223
- };
224
-
225
- export const DisabledTertiary: Story = {
226
- name: 'Tertiary disabled',
227
- args: {
228
- variant: 'tertiary',
229
- disabled: true,
230
- children: 'Disabled tertiary button',
231
- },
232
- };
233
-
234
227
  export const WithIcon: Story & {
235
228
  argTypes: {
236
229
  iconName: {
@@ -255,7 +248,7 @@ export const WithIcon: Story & {
255
248
  const [args] = useArgs();
256
249
 
257
250
  const IconComponent =
258
- args.IconName !== 'none'
251
+ args.iconName !== 'none'
259
252
  ? (Icon[args.iconName as keyof typeof Icon] as React.FC)
260
253
  : null;
261
254
 
@@ -292,7 +285,7 @@ export const IconOnly: Story & {
292
285
  const [args] = useArgs();
293
286
 
294
287
  const IconComponent =
295
- args.IconName !== 'none'
288
+ args.iconName !== 'none'
296
289
  ? (Icon[args.iconName as keyof typeof Icon] as React.FC)
297
290
  : null;
298
291
 
@@ -319,7 +312,7 @@ export const Link: Story = {
319
312
  as: 'a',
320
313
  href: 'https://www.ucl.ac.uk/',
321
314
  target: '_blank',
322
- children: "Got to UCL's website",
315
+ children: "Go to UCL's website",
323
316
  disabled: false,
324
317
  },
325
318
  };
@@ -8,22 +8,54 @@ import {
8
8
  } from 'react';
9
9
  import { css, cx } from '@emotion/css';
10
10
  import useTheme from '../../theme/useTheme';
11
- import buttonPrimaryStyle from './buttonPrimaryStyle';
12
- import buttonSecondaryStyle from './buttonSecondaryStyle';
13
- import buttonTertiaryStyle from './buttonTertiaryStyle';
14
11
  import Spinner from '../Spinner/Spinner';
15
12
  import Overlay from '../Overlay/Overlay';
16
13
  import Tooltip from '../Tooltip/Tooltip';
17
14
  import marginsStyle, { MarginProps } from '../common/marginsStyle';
15
+ import buttonAccentStyle from './style/buttonAccentStyle';
16
+ import buttonPrimaryStyle from './style/buttonPrimaryStyle';
17
+ import buttonSecondaryStyle from './style/buttonSecondaryStyle';
18
+ import buttonTertiaryStyle from './style/buttonTertiaryStyle';
19
+ import buttonPrimaryDestructiveStyle from './style/buttonPrimaryDestructiveStyle';
20
+ import buttonSecondaryDestructiveStyle from './style/buttonSecondaryDestructiveStyle';
21
+ import buttonTertiaryDestructiveStyle from './style/buttonTertiaryDestructiveStyle';
22
+ import buttonPrimaryWarningStyle from './style/buttonPrimaryWarningStyle';
23
+ import buttonPrimarySubtleStyle from './style/buttonPrimarySubtleStyle';
24
+ import buttonSecondarySubtleStyle from './style/buttonSecondarySubtleStyle';
25
+ import buttonTertiaryNoPaddingStyle from './style/buttonTertiaryNoPaddingStyle';
18
26
 
19
27
  export const NAME = 'ucl-uikit-button';
20
28
 
21
29
  type PolymorphicRef<C extends ElementType> = ComponentPropsWithRef<C>['ref'];
22
30
 
31
+ export type ButtonVariant =
32
+ | 'accent'
33
+ | 'primary'
34
+ | 'secondary'
35
+ | 'tertiary'
36
+ | 'primary-subtle'
37
+ | 'secondary-subtle'
38
+ | 'tertiary-no-padding'
39
+ | 'primary-destructive'
40
+ | 'secondary-destructive'
41
+ | 'tertiary-destructive'
42
+ | 'primary-warning';
43
+
44
+ const DESTRUCTIVE_VARIANT_MAP: Partial<Record<ButtonVariant, ButtonVariant>> = {
45
+ primary: 'primary-destructive',
46
+ secondary: 'secondary-destructive',
47
+ tertiary: 'tertiary-destructive',
48
+ };
49
+
50
+ // Legacy size values from the old Button API
51
+ type LegacySize = 'default';
52
+
23
53
  export interface ButtonBaseProps {
24
- variant?: 'primary' | 'secondary' | 'tertiary';
54
+ variant?: ButtonVariant;
55
+ /** @deprecated Use variant="primary-destructive" / "secondary-destructive" instead */
25
56
  destructive?: boolean;
26
- size?: 'large' | 'default' | 'small';
57
+ size?: 'xsmall' | 'small' | 'medium' | 'large' | LegacySize;
58
+ selected?: boolean;
27
59
  disabled?: boolean;
28
60
  icon?: ReactElement;
29
61
  iconPosition?: 'left' | 'right';
@@ -36,15 +68,44 @@ export interface ButtonBaseProps {
36
68
  export type ButtonProps<C extends ElementType = 'button'> = {
37
69
  as?: C;
38
70
  ref?: PolymorphicRef<C>;
71
+ className?: string;
39
72
  } & ButtonBaseProps &
40
73
  MarginProps &
41
74
  Omit<ComponentPropsWithRef<C>, keyof ButtonBaseProps | 'as'>;
42
75
 
76
+ // Maps legacy size "default" to the new equivalent
77
+ const normalizeSizeprop = (
78
+ size: ButtonBaseProps['size']
79
+ ): 'xsmall' | 'small' | 'medium' | 'large' => {
80
+ if (size === 'default') return 'medium';
81
+ return size ?? 'medium';
82
+ };
83
+
84
+ // Maps legacy destructive boolean + base variant to the new variant
85
+ const normalizeVariantProp = (
86
+ variant: ButtonVariant,
87
+ destructive: boolean
88
+ ): ButtonVariant => {
89
+ if (!destructive) return variant;
90
+
91
+ const destructiveVariant = DESTRUCTIVE_VARIANT_MAP[variant];
92
+
93
+ if (!destructiveVariant) {
94
+ console.warn(
95
+ `Button variant '${variant}' does not support the destructive prop. Use a destructive variant explicitly, or use one of: primary, secondary, tertiary.`
96
+ );
97
+ return variant;
98
+ }
99
+
100
+ return destructiveVariant;
101
+ };
102
+
43
103
  const Button = <C extends ElementType = 'button'>({
44
104
  as,
45
105
  variant = 'primary',
46
106
  destructive = false,
47
- size = 'default',
107
+ size = 'medium',
108
+ selected = false,
48
109
  disabled = false,
49
110
  icon,
50
111
  iconPosition = 'left',
@@ -59,24 +120,30 @@ const Button = <C extends ElementType = 'button'>({
59
120
  }: ButtonProps<C>) => {
60
121
  const Component = as || 'button';
61
122
 
62
- if (variant === 'tertiary' && destructive) {
63
- console.warn("Button variant 'tertiary' cannot also be 'destructive'.");
64
- }
65
-
66
123
  const internalRef = useRef(null);
67
124
  const effectiveRef = ref || internalRef;
68
125
  const [isHovered, setIsHovered] = useState(false);
69
126
  const [theme] = useTheme();
70
127
 
128
+ const resolvedVariant = normalizeVariantProp(variant, destructive);
129
+ const resolvedSize = normalizeSizeprop(size);
130
+
71
131
  const baseStyle = css`
132
+ all: unset;
133
+ border: 2px solid transparent;
72
134
  display: inline-flex;
73
135
  align-items: center;
74
136
  justify-content: center;
75
137
  gap: ${theme.padding.p8};
76
138
  position: relative;
77
139
  box-sizing: border-box;
78
- font-family: ${theme.font.family.primary};
79
- font-size: ${theme.font.size.f16};
140
+ border-radius: ${theme.radius.r4};
141
+ font-family: ${theme.typography.body.md.fontFamily};
142
+ font-feature-settings: ${theme.typography.body.md.fontSettings};
143
+ font-size: 18px;
144
+ font-weight: 500;
145
+ -webkit-font-smoothing: antialiased;
146
+ -moz-osx-font-smoothing: grayscale;
80
147
  outline: none;
81
148
  text-decoration: none;
82
149
  user-select: none;
@@ -86,26 +153,33 @@ const Button = <C extends ElementType = 'button'>({
86
153
  }
87
154
  `;
88
155
 
156
+ const iconSize = resolvedSize === 'xsmall' ? 20 : 24;
157
+ const paddingPx = resolvedSize === 'xsmall' ? 8 : 16;
158
+
89
159
  const iconOnlyStyle = css`
90
160
  width: 48px;
91
161
  padding: 0;
92
162
  justify-content: center;
93
163
  `;
94
164
 
165
+ const sizeExtraSmallStyle = css`
166
+ height: 32px;
167
+ padding: 0 ${paddingPx}px;
168
+ `;
169
+
95
170
  const sizeSmallStyle = css`
96
171
  height: 40px;
97
- padding: 0 ${theme.padding.p16};
172
+ padding: 0 ${paddingPx}px;
98
173
  `;
99
174
 
100
- const sizeDefaultStyle = css`
175
+ const sizeMediumStyle = css`
101
176
  height: 48px;
102
- padding: 0 ${theme.padding.p24};
177
+ padding: 0 ${paddingPx}px;
103
178
  `;
104
179
 
105
180
  const sizeLargeStyle = css`
106
181
  height: 56px;
107
- padding: 0 ${theme.padding.p24};
108
- font-size: ${theme.font.size.f18};
182
+ padding: 0 ${paddingPx}px;
109
183
  `;
110
184
 
111
185
  const fullWidthStyle = css`
@@ -113,20 +187,83 @@ const Button = <C extends ElementType = 'button'>({
113
187
  `;
114
188
 
115
189
  const variantStyle = {
116
- primary: buttonPrimaryStyle(theme, destructive, disabled, loading),
117
- secondary: buttonSecondaryStyle(theme, destructive, disabled, loading),
118
- tertiary: buttonTertiaryStyle(theme, disabled, loading),
119
- }[variant];
190
+ accent: buttonAccentStyle(theme, selected, disabled, loading),
191
+ primary: buttonPrimaryStyle(theme, selected, disabled, loading),
192
+ secondary: buttonSecondaryStyle(theme, selected, disabled, loading),
193
+ tertiary: buttonTertiaryStyle(
194
+ theme,
195
+ selected,
196
+ disabled,
197
+ loading,
198
+ paddingPx
199
+ ),
200
+ 'primary-subtle': buttonPrimarySubtleStyle(
201
+ theme,
202
+ selected,
203
+ disabled,
204
+ loading,
205
+ paddingPx
206
+ ),
207
+ 'secondary-subtle': buttonSecondarySubtleStyle(
208
+ theme,
209
+ selected,
210
+ disabled,
211
+ loading,
212
+ paddingPx
213
+ ),
214
+ 'tertiary-no-padding': buttonTertiaryNoPaddingStyle(
215
+ theme,
216
+ disabled,
217
+ loading,
218
+ paddingPx
219
+ ),
220
+ 'primary-destructive': buttonPrimaryDestructiveStyle(
221
+ theme,
222
+ selected,
223
+ disabled,
224
+ loading
225
+ ),
226
+ 'secondary-destructive': buttonSecondaryDestructiveStyle(
227
+ theme,
228
+ selected,
229
+ disabled,
230
+ loading
231
+ ),
232
+ 'tertiary-destructive': buttonTertiaryDestructiveStyle(
233
+ theme,
234
+ selected,
235
+ disabled,
236
+ loading,
237
+ paddingPx
238
+ ),
239
+ 'primary-warning': buttonPrimaryWarningStyle(
240
+ theme,
241
+ selected,
242
+ disabled,
243
+ loading
244
+ ),
245
+ }[resolvedVariant];
246
+
247
+ const commonDisabledStyle = css`
248
+ cursor: not-allowed;
249
+ `;
250
+
251
+ const loadingStyle = css`
252
+ cursor: wait;
253
+ `;
120
254
 
121
255
  const style = cx(
122
256
  NAME,
123
257
  baseStyle,
124
258
  marginsStyle(props, theme),
125
- size === 'small' && sizeSmallStyle,
126
- size === 'default' && sizeDefaultStyle,
127
- size === 'large' && sizeLargeStyle,
259
+ resolvedSize === 'xsmall' && sizeExtraSmallStyle,
260
+ resolvedSize === 'small' && sizeSmallStyle,
261
+ resolvedSize === 'medium' && sizeMediumStyle,
262
+ resolvedSize === 'large' && sizeLargeStyle,
128
263
  fullWidth && fullWidthStyle,
129
264
  variantStyle,
265
+ disabled && commonDisabledStyle,
266
+ loading && loadingStyle,
130
267
  !children && iconOnlyStyle,
131
268
  className
132
269
  );
@@ -149,7 +286,11 @@ const Button = <C extends ElementType = 'button'>({
149
286
  }
150
287
  >
151
288
  {loading ? (
152
- <Spinner />
289
+ <Spinner
290
+ size={iconSize}
291
+ strokeWidth={8}
292
+ inheritColour
293
+ />
153
294
  ) : (
154
295
  <>
155
296
  {icon && iconPosition === 'left' && icon}
@@ -6,8 +6,6 @@ import Icon from '../../Icon';
6
6
  import { ThemeContextProvider } from '../../../theme/useTheme';
7
7
 
8
8
  describe('Button', () => {
9
- // Snapshot tests
10
-
11
9
  test('snapshot: no props', () => {
12
10
  const renderResult = render(
13
11
  <ThemeContextProvider>
@@ -20,7 +18,7 @@ describe('Button', () => {
20
18
  test('snapshot: variant prop', () => {
21
19
  const renderResult = render(
22
20
  <ThemeContextProvider>
23
- <Button variant='secondary' />
21
+ <Button variant='secondary-subtle' />
24
22
  </ThemeContextProvider>
25
23
  );
26
24
  expect(renderResult.container.firstChild).toMatchSnapshot();
@@ -35,7 +33,7 @@ describe('Button', () => {
35
33
  expect(renderResult.container.firstChild).toMatchSnapshot();
36
34
  });
37
35
 
38
- test("Snapshot: 'as' prop with 'a'", () => {
36
+ test("snapshot: 'as' prop with 'a'", () => {
39
37
  const renderResult = render(
40
38
  <ThemeContextProvider>
41
39
  <Button
@@ -49,7 +47,7 @@ describe('Button', () => {
49
47
  expect(renderResult.container.firstChild).toMatchSnapshot();
50
48
  });
51
49
 
52
- test('Snapshot: with icon', () => {
50
+ test('snapshot: with icon', () => {
53
51
  const renderResult = render(
54
52
  <ThemeContextProvider>
55
53
  <Button icon={<Icon.Upload />}>Upload</Button>
@@ -58,7 +56,7 @@ describe('Button', () => {
58
56
  expect(renderResult.container.firstChild).toMatchSnapshot();
59
57
  });
60
58
 
61
- test('Snapshot: with icon & iconPosition right', () => {
59
+ test('snapshot: with icon and iconPosition right', () => {
62
60
  const renderResult = render(
63
61
  <ThemeContextProvider>
64
62
  <Button
@@ -81,8 +79,6 @@ describe('Button', () => {
81
79
  expect(renderResult.container.firstChild).toMatchSnapshot();
82
80
  });
83
81
 
84
- // Interaction tests
85
-
86
82
  test('test ID: default', () => {
87
83
  render(
88
84
  <ThemeContextProvider>
@@ -136,7 +132,7 @@ describe('Button', () => {
136
132
  expect(testClick).not.toBeCalled();
137
133
  });
138
134
 
139
- test("Can accept anchor tag via 'as' prop", () => {
135
+ test("can accept anchor tag via 'as' prop", () => {
140
136
  const testId = 'anchor-button-123';
141
137
  render(
142
138
  <ThemeContextProvider>
@@ -156,7 +152,7 @@ describe('Button', () => {
156
152
  expect(button.tagName).toBe('A');
157
153
  });
158
154
 
159
- test('When disabled and an anchor, will not redirect', async () => {
155
+ test('when disabled and an anchor, will not redirect', () => {
160
156
  const testId = 'anchor-button-456';
161
157
  render(
162
158
  <ThemeContextProvider>
@@ -174,7 +170,7 @@ describe('Button', () => {
174
170
  expect(button).not.toHaveAttribute('href');
175
171
  });
176
172
 
177
- test("Renders an icon when passed via 'icon' prop", () => {
173
+ test("renders an icon when passed via 'icon' prop", () => {
178
174
  render(
179
175
  <ThemeContextProvider>
180
176
  <Button icon={<Icon.Upload />}>Upload</Button>
@@ -184,7 +180,7 @@ describe('Button', () => {
184
180
  expect(icon).toBeDefined();
185
181
  });
186
182
 
187
- test('Displays a Tooltip when passed a tooltip prop as string', async () => {
183
+ test('displays a tooltip when passed a tooltip prop as string', async () => {
188
184
  const user = userEvent.setup();
189
185
  render(
190
186
  <ThemeContextProvider>
@@ -198,7 +194,7 @@ describe('Button', () => {
198
194
  expect(tooltip).toHaveTextContent('Tooltip text');
199
195
  });
200
196
 
201
- test('Can accept an additional aria-label prop', () => {
197
+ test('can accept an additional aria-label prop', () => {
202
198
  const testId = 'aria-label-button';
203
199
  render(
204
200
  <ThemeContextProvider>
@@ -212,7 +208,7 @@ describe('Button', () => {
212
208
  expect(button).toHaveAttribute('aria-label', 'Test aria label');
213
209
  });
214
210
 
215
- test('Renders a loading spinner when passed via loading prop', () => {
211
+ test('renders a loading spinner when loading prop is true', () => {
216
212
  render(
217
213
  <ThemeContextProvider>
218
214
  <Button loading>Submit</Button>
@@ -222,7 +218,7 @@ describe('Button', () => {
222
218
  expect(spinner).toBeDefined();
223
219
  });
224
220
 
225
- test('Will not accept click events while loading', async () => {
221
+ test('will not accept click events while loading', async () => {
226
222
  const user = userEvent.setup();
227
223
  const testClick = vitest.fn();
228
224
  const testId = 'loading-button-789';
@@ -241,4 +237,42 @@ describe('Button', () => {
241
237
  await user.click(button);
242
238
  expect(testClick).not.toBeCalled();
243
239
  });
240
+
241
+ test('maps legacy destructive prop to destructive variants', () => {
242
+ const renderResult = render(
243
+ <ThemeContextProvider>
244
+ <Button destructive>Delete</Button>
245
+ </ThemeContextProvider>
246
+ );
247
+
248
+ expect(renderResult.container.firstChild).toMatchSnapshot();
249
+ });
250
+
251
+ test('warns when destructive prop is used with unsupported variant', () => {
252
+ const warnSpy = vitest.spyOn(console, 'warn').mockImplementation(() => {});
253
+
254
+ render(
255
+ <ThemeContextProvider>
256
+ <Button
257
+ variant='accent'
258
+ destructive
259
+ >
260
+ Accent destructive
261
+ </Button>
262
+ </ThemeContextProvider>
263
+ );
264
+
265
+ expect(warnSpy).toHaveBeenCalledTimes(1);
266
+ warnSpy.mockRestore();
267
+ });
268
+
269
+ test('maps legacy size default to medium', () => {
270
+ const renderResult = render(
271
+ <ThemeContextProvider>
272
+ <Button size='default'>Legacy default size</Button>
273
+ </ThemeContextProvider>
274
+ );
275
+
276
+ expect(renderResult.container.firstChild).toMatchSnapshot();
277
+ });
244
278
  });