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.
- package/README.md +2 -2
- package/dist/components/Accordion/Accordion.Heading.d.ts +5 -4
- package/dist/components/Accordion/Accordion.Panel.d.ts +2 -2
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Accordion/Accordion.stories.d.ts +57 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/AppHeader/AppHeader.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderBottom.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderNav.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderTop.d.ts +1 -1
- package/dist/components/Avatar/Avatar.stories.d.ts +107 -1
- package/dist/components/Breadcrumbs/Breadcrumb.d.ts +3 -4
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +8 -3
- package/dist/components/Button/Button.stories.d.ts +17 -7
- package/dist/components/Button/style/buttonAccentStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimarySubtleStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryWarningStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondaryStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondarySubtleStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryNoPaddingStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryStyle.d.ts +4 -0
- package/dist/components/Calendar/index.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/Datepicker/Datepicker.d.ts +1 -1
- package/dist/components/Datepicker/Datepicker.stories.d.ts +4 -3
- package/dist/components/Datepicker/Datepicker.types.d.ts +4 -5
- package/dist/components/Datepicker/subcomponents/CustomDatepicker.d.ts +4 -1
- package/dist/components/Datepicker/subcomponents/DatepickerInput.d.ts +15 -2
- package/dist/components/Datepicker/subcomponents/Panel.d.ts +1 -1
- package/dist/components/Datepicker/subcomponents/VisibleField.d.ts +6 -1
- package/dist/components/Datepicker/subcomponents/index.d.ts +0 -1
- package/dist/components/Datepicker/utils/index.d.ts +0 -1
- package/dist/components/Dialog/BaseDialog.d.ts +2 -1
- package/dist/components/Dialog/Dialog.d.ts +2 -0
- package/dist/components/FooterNew/BackToTop.d.ts +8 -0
- package/dist/components/FooterNew/Footer.d.ts +23 -0
- package/dist/components/FooterNew/FooterColumn.d.ts +8 -0
- package/dist/components/FooterNew/FooterLinks.d.ts +7 -0
- package/dist/components/FooterNew/FooterNavLink.d.ts +8 -0
- package/dist/components/FooterNew/LegalAndCopyright.d.ts +14 -0
- package/dist/components/FooterNew/LogoAddressAndSocial.d.ts +10 -0
- package/dist/components/FooterNew/SocialLink.d.ts +8 -0
- package/dist/components/FooterNew/index.d.ts +2 -0
- package/dist/components/Header/Header.d.ts +4 -1
- package/dist/components/Header/Header.stories.d.ts +40 -0
- package/dist/components/HeaderNew/Header.d.ts +18 -0
- package/dist/components/HeaderNew/HeaderBorder.d.ts +7 -0
- package/dist/components/HeaderNew/HeaderLogo.d.ts +9 -0
- package/dist/components/HeaderNew/HeaderMenuContainer.d.ts +7 -0
- package/dist/components/HeaderNew/HeaderTitle.d.ts +9 -0
- package/dist/components/HeaderNew/__tests__/Header.test.d.ts +1 -0
- package/dist/components/HeaderNew/constants.d.ts +3 -0
- package/dist/components/HeaderNew/index.d.ts +3 -0
- package/dist/components/HeadingNew/Heading.d.ts +13 -0
- package/dist/components/HeadingNew/index.d.ts +2 -0
- package/dist/components/Icon/svgImports.d.ts +7 -881
- package/dist/components/Link/BaseLink.d.ts +14 -5
- package/dist/components/Link/Link.d.ts +8 -3
- package/dist/components/Link/Link.stories.d.ts +3 -1
- package/dist/components/Main/Main.d.ts +21 -0
- package/dist/components/Main/Main.stories.d.ts +15 -0
- package/dist/components/Main/__tests__/Main.test.d.ts +1 -0
- package/dist/components/Main/index.d.ts +2 -0
- package/dist/components/MenuNew/Menu.context.d.ts +14 -0
- package/dist/components/MenuNew/Menu.d.ts +20 -0
- package/dist/components/MenuNew/MenuContent.d.ts +9 -0
- package/dist/components/MenuNew/MenuItem.d.ts +10 -0
- package/dist/components/MenuNew/MenuSection.d.ts +7 -0
- package/dist/components/MenuNew/index.d.ts +6 -0
- package/dist/components/MenuNew/trigger/ButtonMenuTrigger.d.ts +8 -0
- package/dist/components/MenuNew/trigger/IconMenuTrigger.d.ts +8 -0
- package/dist/components/NativeDatepicker/NativeDatepicker.d.ts +3 -0
- package/dist/components/NativeDatepicker/NativeDatepicker.stories.d.ts +36 -0
- package/dist/components/NativeDatepicker/NativeDatepicker.types.d.ts +10 -0
- package/dist/components/NativeDatepicker/index.d.ts +2 -0
- package/dist/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.d.ts +1 -1
- package/dist/components/NativeDatepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts +1 -0
- package/dist/components/NativeDatepicker/utils/index.d.ts +1 -0
- package/dist/components/Overlay/Overlay.stories.d.ts +12 -12
- package/dist/components/ParagraphNew/Paragraph.d.ts +13 -0
- package/dist/components/ParagraphNew/index.d.ts +4 -0
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.stories.d.ts +167 -3
- package/dist/components/Select/Select.types.d.ts +75 -19
- package/dist/components/Select/subcomponents/CustomOption.d.ts +1 -1
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +3 -2
- package/dist/components/Select/subcomponents/FilterInput.d.ts +16 -0
- package/dist/components/Select/subcomponents/NativeSelect.d.ts +5 -1
- package/dist/components/Select/subcomponents/VisibleField.d.ts +6 -1
- package/dist/components/Select/subcomponents/index.d.ts +1 -0
- package/dist/components/Spinner/Spinner.d.ts +2 -0
- package/dist/components/StandaloneLink/StandaloneLink.d.ts +8 -5
- package/dist/components/StandaloneLink/StandaloneLink.stories.d.ts +3 -1
- package/dist/components/Table/Table.d.ts +3 -3
- package/dist/components/Table/Table.stories.d.ts +3 -3
- package/dist/components/Table/Table.types.d.ts +1 -0
- package/dist/components/Table/subcomponents/Cell/Cell.d.ts +5 -1
- package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +15 -13
- package/dist/components/Table/subcomponents/Cell/CellContent.d.ts +5 -1
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.d.ts +2 -1
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +14 -13
- package/dist/components/Table/subcomponents/HeadCell/HeadCellContent.d.ts +2 -1
- package/dist/components/Table/subcomponents/__tests__/Row.test.d.ts +1 -0
- package/dist/components/UclLogoNew/UclLogo.d.ts +8 -0
- package/dist/components/UclLogoNew/index.d.ts +2 -0
- package/dist/components/WeekPicker/WeekPicker.d.ts +2 -2
- package/dist/components/WeekPicker/WeekPicker.stories.d.ts +41 -0
- package/dist/components/WeekPicker/WeekPicker.types.d.ts +16 -0
- package/dist/components/WeekPicker/index.d.ts +1 -0
- package/dist/components/WeekPicker/subcomponents/CustomDatepicker.d.ts +1 -1
- package/dist/components/index.d.ts +20 -0
- package/dist/hooks/useFocusTrap.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22204 -16719
- package/dist/theme/__tests__/fonts.test.d.ts +1 -0
- package/dist/theme/common/themeCommon.d.ts +904 -0
- package/dist/theme/fonts.d.ts +18 -0
- package/dist/theme/index.d.ts +6 -3
- package/dist/theme/light/lightColour.d.ts +126 -0
- package/dist/theme/light/lightTheme.d.ts +3 -0
- package/dist/theme/original/color.d.ts +166 -0
- package/dist/theme/original/defaultTheme.d.ts +1340 -0
- package/dist/theme/original/originalColourNewStructure.d.ts +126 -0
- package/dist/theme/useTheme.d.ts +2174 -0
- package/dist/utils/__tests__/announce.test.d.ts +1 -0
- package/dist/utils/addAlphaToHex.d.ts +5 -0
- package/dist/utils/announce.d.ts +6 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/scrollToTop.d.ts +2 -0
- package/lib/components/Accordion/Accordion.Heading.tsx +65 -34
- package/lib/components/Accordion/Accordion.Panel.tsx +11 -7
- package/lib/components/Accordion/Accordion.stories.tsx +139 -0
- package/lib/components/Accordion/Accordion.tsx +39 -31
- package/lib/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +15 -13
- package/lib/components/Accordion/index.ts +2 -0
- package/lib/components/Alert/Alert.stories.tsx +1 -1
- package/lib/components/Alert/Alert.tsx +12 -12
- package/lib/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +13 -39
- package/lib/components/AppHeader/AppHeader.tsx +6 -11
- package/lib/components/AppHeader/AppHeaderBottom.tsx +2 -3
- package/lib/components/AppHeader/AppHeaderNav.tsx +2 -3
- package/lib/components/AppHeader/AppHeaderTop.tsx +1 -1
- package/lib/components/AppHeader/__tests__/__snapshots__/AppHeader.test.tsx.snap +2 -2
- package/lib/components/AppMenu/__tests__/__snapshots__/AppMenu.test.tsx.snap +6 -19
- package/lib/components/Avatar/Avatar.mdx +117 -0
- package/lib/components/Avatar/Avatar.stories.tsx +110 -2
- package/lib/components/Badge/Badge.stories.tsx +1 -1
- package/lib/components/Blanket/Blanket.stories.tsx +1 -1
- package/lib/components/Breadcrumbs/Breadcrumb.tsx +26 -12
- package/lib/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/lib/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx +9 -27
- package/lib/components/Breadcrumbs/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +24 -20
- package/lib/components/Button/Button.mdx +32 -279
- package/lib/components/Button/Button.stories.tsx +44 -51
- package/lib/components/Button/Button.tsx +166 -25
- package/lib/components/Button/__tests__/Button.test.tsx +49 -15
- package/lib/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +80 -73
- package/lib/components/Button/style/buttonAccentStyle.ts +53 -0
- package/lib/components/Button/style/buttonPrimaryDestructiveStyle.ts +55 -0
- package/lib/components/Button/style/buttonPrimaryStyle.ts +53 -0
- package/lib/components/Button/style/buttonPrimarySubtleStyle.ts +64 -0
- package/lib/components/Button/style/buttonPrimaryWarningStyle.ts +56 -0
- package/lib/components/Button/style/buttonSecondaryDestructiveStyle.ts +63 -0
- package/lib/components/Button/style/buttonSecondaryStyle.ts +62 -0
- package/lib/components/Button/style/buttonSecondarySubtleStyle.ts +72 -0
- package/lib/components/Button/style/buttonTertiaryDestructiveStyle.ts +65 -0
- package/lib/components/Button/style/buttonTertiaryNoPaddingStyle.ts +52 -0
- package/lib/components/Button/style/buttonTertiaryStyle.ts +62 -0
- package/lib/components/Calendar/Calendar.stories.tsx +1 -1
- package/lib/components/Calendar/Calendar.tsx +2 -2
- package/lib/components/Calendar/__tests__/Calendar.test.tsx +23 -15
- package/lib/components/Calendar/__tests__/__snapshots__/Calendar.test.tsx.snap +99 -95
- package/lib/components/Calendar/index.ts +1 -5
- package/lib/components/Calendar/subcomponents/AcademicWeek.tsx +2 -1
- package/lib/components/Calendar/subcomponents/AcademicWeeks.tsx +1 -1
- package/lib/components/Calendar/subcomponents/ColumnHeading.tsx +2 -2
- package/lib/components/Calendar/subcomponents/Controls.tsx +1 -1
- package/lib/components/Calendar/subcomponents/Day.stories.tsx +1 -1
- package/lib/components/Calendar/subcomponents/Day.tsx +7 -9
- package/lib/components/Calendar/subcomponents/EventDot.tsx +3 -6
- package/lib/components/Calendar/subcomponents/index.ts +1 -1
- package/lib/components/Calendar/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.ts +43 -11
- package/lib/components/Calendar/utils/normaliseMonth/normaliseMonth.test.ts +5 -5
- package/lib/components/Checkbox/Checkbox.stories.tsx +1 -1
- package/lib/components/Checkbox/Checkbox.tsx +12 -10
- package/lib/components/Checkbox/__tests__/Checkbox.test.tsx +29 -0
- package/lib/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +4 -4
- package/lib/components/Datepicker/Datepicker.lld.md +108 -0
- package/lib/components/Datepicker/Datepicker.stories.tsx +44 -5
- package/lib/components/Datepicker/Datepicker.tsx +14 -36
- package/lib/components/Datepicker/Datepicker.types.ts +5 -14
- package/lib/components/Datepicker/__tests__/Datepicker.test.tsx +267 -8
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +20 -42
- package/lib/components/Datepicker/subcomponents/CustomDatepicker.tsx +48 -5
- package/lib/components/Datepicker/subcomponents/DatepickerInput.tsx +30 -17
- package/lib/components/Datepicker/subcomponents/Panel.tsx +6 -2
- package/lib/components/Datepicker/subcomponents/VisibleField.tsx +46 -8
- package/lib/components/Datepicker/subcomponents/index.ts +0 -1
- package/lib/components/Datepicker/utils/index.ts +0 -1
- package/lib/components/Dialog/BaseDialog.tsx +13 -2
- package/lib/components/Dialog/Dialog.stories.tsx +1 -1
- package/lib/components/Dialog/Dialog.tsx +8 -1
- package/lib/components/Dialog/DialogBody.tsx +5 -1
- package/lib/components/Dialog/DialogHeader.tsx +2 -1
- package/lib/components/Divider/Divider.stories.tsx +1 -1
- package/lib/components/Divider/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +12 -12
- package/lib/components/FeedbackDialog/FeedbackDialog.stories.tsx +1 -1
- package/lib/components/FeedbackDialog/FeedbackDialog.tsx +4 -6
- package/lib/components/Field/CharacterCount.tsx +2 -2
- package/lib/components/Field/ErrorText.tsx +2 -1
- package/lib/components/Field/Field.stories.tsx +1 -1
- package/lib/components/Field/Field.tsx +1 -1
- package/lib/components/Field/HelperText.tsx +3 -1
- package/lib/components/Field/__tests__/Field.test.tsx +13 -0
- package/lib/components/FileInput/FileInput.stories.tsx +1 -1
- package/lib/components/FileInput/__tests__/__snapshots__/FileInput.test.tsx.snap +4 -20
- package/lib/components/Footer/Footer.stories.tsx +1 -1
- package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +73 -82
- package/lib/components/FooterNew/BackToTop.tsx +83 -0
- package/lib/components/FooterNew/Footer.tsx +110 -0
- package/lib/components/FooterNew/FooterColumn.tsx +79 -0
- package/lib/components/FooterNew/FooterLinks.tsx +44 -0
- package/lib/components/FooterNew/FooterNavLink.tsx +63 -0
- package/lib/components/FooterNew/LegalAndCopyright.tsx +150 -0
- package/lib/components/FooterNew/LogoAddressAndSocial.tsx +154 -0
- package/lib/components/FooterNew/SocialLink.tsx +108 -0
- package/lib/components/FooterNew/__tests__/Footer.test.tsx +51 -0
- package/lib/components/FooterNew/__tests__/__snapshots__/Footer.test.tsx.snap +1107 -0
- package/lib/components/FooterNew/index.ts +2 -0
- package/lib/components/Header/Header.mdx +52 -0
- package/lib/components/Header/Header.stories.tsx +98 -0
- package/lib/components/Header/Header.tsx +51 -6
- package/lib/components/Header/__tests__/Header.test.tsx +17 -1
- package/lib/components/HeaderDraft/__tests__/__snapshots__/Header.test.tsx.snap +3 -2
- package/lib/components/HeaderNew/Header.tsx +93 -0
- package/lib/components/HeaderNew/HeaderBorder.tsx +55 -0
- package/lib/components/HeaderNew/HeaderLogo.tsx +70 -0
- package/lib/components/HeaderNew/HeaderMenuContainer.tsx +35 -0
- package/lib/components/HeaderNew/HeaderTitle.tsx +53 -0
- package/lib/components/HeaderNew/__tests__/Header.test.tsx +42 -0
- package/lib/components/HeaderNew/__tests__/__snapshots__/Header.test.tsx.snap +79 -0
- package/lib/components/HeaderNew/constants.ts +3 -0
- package/lib/components/HeaderNew/index.ts +7 -0
- package/lib/components/Heading/Heading.stories.tsx +1 -1
- package/lib/components/HeadingNew/Heading.tsx +208 -0
- package/lib/components/HeadingNew/index.ts +2 -0
- package/lib/components/Icon/Icon.stories.tsx +1 -1
- package/lib/components/Icon/__tests__/__snapshots__/Icon.test.tsx.snap +16 -12
- package/lib/components/Icon/svgImports.ts +318 -296
- package/lib/components/IconButton/IconButton.stories.tsx +1 -1
- package/lib/components/IconButton/IconButton.tsx +3 -4
- package/lib/components/IconButton/__tests__/__snapshots__/IconButton.test.tsx.snap +12 -9
- package/lib/components/Input/Input.stories.tsx +1 -1
- package/lib/components/Label/Label.stories.tsx +1 -1
- package/lib/components/Link/BaseLink.tsx +114 -71
- package/lib/components/Link/Link.stories.tsx +1 -1
- package/lib/components/Link/Link.tsx +120 -109
- package/lib/components/Link/__tests__/__snapshots__/link.test.tsx.snap +2 -2
- package/lib/components/Main/Main.stories.tsx +36 -0
- package/lib/components/Main/Main.tsx +46 -0
- package/lib/components/Main/__tests__/Main.test.tsx +80 -0
- package/lib/components/Main/__tests__/__snapshots__/Main.test.tsx.snap +33 -0
- package/lib/components/Main/index.ts +2 -0
- package/lib/components/MenuNew/Menu.context.tsx +149 -0
- package/lib/components/MenuNew/Menu.tsx +75 -0
- package/lib/components/MenuNew/MenuContent.tsx +140 -0
- package/lib/components/MenuNew/MenuItem.tsx +101 -0
- package/lib/components/MenuNew/MenuSection.tsx +47 -0
- package/lib/components/MenuNew/index.ts +8 -0
- package/lib/components/MenuNew/trigger/ButtonMenuTrigger.tsx +42 -0
- package/lib/components/MenuNew/trigger/IconMenuTrigger.tsx +40 -0
- package/lib/components/NativeDatepicker/NativeDatepicker.stories.tsx +100 -0
- package/lib/components/{Datepicker/subcomponents → NativeDatepicker}/NativeDatepicker.tsx +14 -15
- package/lib/components/NativeDatepicker/NativeDatepicker.types.ts +19 -0
- package/lib/components/NativeDatepicker/index.ts +2 -0
- package/lib/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.ts +1 -1
- package/lib/components/NativeDatepicker/utils/index.ts +1 -0
- package/lib/components/Pagination/Pagination.stories.tsx +1 -1
- package/lib/components/Pagination/PaginationControls.tsx +59 -17
- package/lib/components/Pagination/PaginationInfo.tsx +7 -4
- package/lib/components/Paragraph/Paragraph.stories.tsx +1 -1
- package/lib/components/ParagraphNew/Paragraph.tsx +200 -0
- package/lib/components/ParagraphNew/index.ts +6 -0
- package/lib/components/Radio/Radio.stories.tsx +1 -1
- package/lib/components/Radio/Radio.tsx +8 -8
- package/lib/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap +4 -4
- package/lib/components/Search/Search.stories.tsx +1 -1
- package/lib/components/Search/Search.tsx +4 -1
- package/lib/components/Search/__tests__/Search.test.tsx +19 -1
- package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +12 -32
- package/lib/components/Select/Select.mdx +192 -0
- package/lib/components/Select/Select.stories.tsx +229 -48
- package/lib/components/Select/Select.tsx +50 -15
- package/lib/components/Select/Select.types.ts +99 -44
- package/lib/components/Select/__tests__/Select.test.tsx +698 -8
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +5 -4
- package/lib/components/Select/subcomponents/CustomOption.tsx +12 -4
- package/lib/components/Select/subcomponents/CustomSelect.tsx +411 -41
- package/lib/components/Select/subcomponents/FilterInput.tsx +90 -0
- package/lib/components/Select/subcomponents/NativeSelect.tsx +21 -17
- package/lib/components/Select/subcomponents/Panel.tsx +2 -2
- package/lib/components/Select/subcomponents/VisibleField.tsx +59 -6
- package/lib/components/Select/subcomponents/index.tsx +1 -0
- package/lib/components/Snackbar/Snackbar.stories.tsx +1 -1
- package/lib/components/Snackbar/__tests__/__snapshots__/Snackbar.test.tsx.snap +9 -15
- package/lib/components/Spinner/Spinner.stories.tsx +1 -1
- package/lib/components/Spinner/Spinner.tsx +24 -5
- package/lib/components/Spinner/__tests__/Spinner.test.tsx +35 -5
- package/lib/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap +40 -16
- package/lib/components/StandaloneLink/StandaloneLink.stories.tsx +1 -1
- package/lib/components/StandaloneLink/StandaloneLink.tsx +180 -163
- package/lib/components/StandaloneLink/__tests__/__snapshots__/StandaloneLink.test.tsx.snap +2 -2
- package/lib/components/Table/Table.stories.tsx +1 -1
- package/lib/components/Table/Table.tsx +2 -0
- package/lib/components/Table/Table.types.ts +1 -0
- package/lib/components/Table/__tests__/Table.test.tsx +19 -0
- package/lib/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +7 -3
- package/lib/components/Table/subcomponents/Cell/Cell.stories.tsx +1 -1
- package/lib/components/Table/subcomponents/Cell/Cell.tsx +23 -2
- package/lib/components/Table/subcomponents/Cell/CellContent.tsx +12 -1
- package/lib/components/Table/subcomponents/Cell/__tests__/Cell.test.tsx +106 -0
- package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +4 -3
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.stories.tsx +1 -1
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.tsx +28 -6
- package/lib/components/Table/subcomponents/HeadCell/HeadCellContent.tsx +3 -0
- package/lib/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.tsx +221 -2
- package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +6 -4
- package/lib/components/Table/subcomponents/Row.tsx +2 -2
- package/lib/components/Table/subcomponents/SortIcon.tsx +1 -0
- package/lib/components/Table/subcomponents/__tests__/Row.test.tsx +59 -0
- package/lib/components/Tabs/Tab.tsx +3 -3
- package/lib/components/Tabs/Tabs.stories.tsx +1 -1
- package/lib/components/Tabs/Tabs.tsx +5 -3
- package/lib/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +4 -4
- package/lib/components/Textarea/Textarea.stories.tsx +1 -1
- package/lib/components/Timepicker/Timepicker.stories.tsx +1 -1
- package/lib/components/Timepicker/Timepicker.tsx +4 -0
- package/lib/components/Timepicker/__tests__/__snapshots__/Timepicker.test.tsx.snap +2 -2
- package/lib/components/Toggle/Toggle.stories.tsx +1 -1
- package/lib/components/Toggle/Toggle.tsx +5 -5
- package/lib/components/Toggle/ToggleHandle.tsx +2 -3
- package/lib/components/Tooltip/Tooltip.stories.tsx +1 -1
- package/lib/components/Tooltip/Tooltip.tsx +2 -2
- package/lib/components/Tooltip/__tests__/__snapshots__/tooltip.test.tsx.snap +2 -2
- package/lib/components/UclLogoNew/UclLogo.tsx +42 -0
- package/lib/components/UclLogoNew/index.ts +2 -0
- package/lib/components/WeekPicker/WeekPicker.stories.tsx +145 -0
- package/lib/components/WeekPicker/WeekPicker.tsx +2 -2
- package/lib/components/WeekPicker/WeekPicker.types.ts +21 -0
- package/lib/components/WeekPicker/index.ts +1 -0
- package/lib/components/WeekPicker/subcomponents/CustomDatepicker.tsx +1 -1
- package/lib/components/common/Common.mdx +1 -2
- package/lib/components/index.ts +30 -3
- package/lib/hooks/useFocusTrap.ts +40 -4
- package/lib/index.ts +1 -0
- package/lib/theme/Colours.mdx +1 -1
- package/lib/theme/Theme.mdx +1 -1
- package/lib/theme/Typography.mdx +1 -1
- package/lib/theme/__tests__/fonts.test.ts +37 -0
- package/lib/theme/common/themeCommon.ts +515 -0
- package/lib/theme/fonts.ts +110 -0
- package/lib/theme/index.ts +6 -6
- package/lib/theme/light/lightColour.ts +232 -0
- package/lib/theme/light/lightTheme.ts +37 -0
- package/lib/theme/{defaultTheme.ts → original/color.ts} +17 -199
- package/lib/theme/original/defaultTheme.ts +207 -0
- package/lib/theme/original/originalColourNewStructure.ts +185 -0
- package/lib/theme/useTheme.tsx +72 -15
- package/lib/types/assets.d.ts +10 -0
- package/lib/utils/__tests__/announce.test.ts +121 -0
- package/lib/utils/addAlphaToHex.ts +29 -0
- package/lib/utils/announce.ts +134 -0
- package/lib/utils/index.ts +1 -0
- package/lib/utils/scrollToTop.ts +5 -0
- package/package.json +11 -9
- package/dist/components/Button/buttonPrimaryStyle.d.ts +0 -4
- package/dist/components/Button/buttonSecondaryStyle.d.ts +0 -4
- package/dist/components/Button/buttonTertiaryStyle.d.ts +0 -4
- package/dist/components/Datepicker/subcomponents/NativeDatepicker.d.ts +0 -6
- package/dist/theme/defaultTheme.d.ts +0 -274
- package/lib/components/Accordion/Accordion.stories.tsx.NOT_READY +0 -93
- package/lib/components/Button/buttonPrimaryStyle.ts +0 -62
- package/lib/components/Button/buttonSecondaryStyle.ts +0 -65
- package/lib/components/Button/buttonTertiaryStyle.ts +0 -54
- /package/dist/components/{Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts → FooterNew/__tests__/Footer.test.d.ts} +0 -0
- /package/lib/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.test.ts +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as HeaderStories from "./Header.stories";
|
|
2
|
+
import { Meta, Title, Subtitle, Canvas, Controls } from "@storybook/blocks";
|
|
3
|
+
|
|
4
|
+
export const usage = {
|
|
5
|
+
default: `<Header title='App Name' />`,
|
|
6
|
+
homeLink: `<Header title='App Name' homeLinkHref='/' homeLinkAriaLabel='Go to home' />`,
|
|
7
|
+
menu: `<Header title='App Name' homeLinkHref='/'>
|
|
8
|
+
<Header.Menu>
|
|
9
|
+
<Menu title='App Name'>
|
|
10
|
+
<Menu.Section>
|
|
11
|
+
<Menu.Item icon={<Icon.Home size={20} />}>Home Page</Menu.Item>
|
|
12
|
+
<Menu.Item icon={<Icon.Tool size={20} />}>Tools</Menu.Item>
|
|
13
|
+
</Menu.Section>
|
|
14
|
+
</Menu>
|
|
15
|
+
</Header.Menu>
|
|
16
|
+
</Header>`,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
<Meta of={HeaderStories} />
|
|
20
|
+
<Title />
|
|
21
|
+
<Subtitle>A simple header with optional menu and home link support.</Subtitle>
|
|
22
|
+
|
|
23
|
+
Use `<Header>` to display the UCL logo and app title at the top of a page. Pass
|
|
24
|
+
`homeLinkHref` to make the logo/title clickable, and wrap a menu in `<Header.Menu>`
|
|
25
|
+
to add a menu button on the right.
|
|
26
|
+
|
|
27
|
+
<Canvas source={{ code: usage.default }} />
|
|
28
|
+
|
|
29
|
+
## Home link
|
|
30
|
+
|
|
31
|
+
Add `homeLinkHref` (and optionally `homeLinkAriaLabel`) to make the logo/title act as a home link.
|
|
32
|
+
For client routing, pass your router link through `homeLinkProps` (e.g. `homeLinkProps={{ component: RouterLink }}`, with `import { Link as RouterLink } from 'react-router-dom'` or `'wouter'`).
|
|
33
|
+
|
|
34
|
+
<Canvas of={HeaderStories.WithHomeLink} source={{ code: usage.homeLink }} />
|
|
35
|
+
|
|
36
|
+
## Menu
|
|
37
|
+
|
|
38
|
+
Wrap a `Menu` inside `Header.Menu` to show a menu button on the right.
|
|
39
|
+
|
|
40
|
+
<Canvas of={HeaderStories.WithMenu} source={{ code: usage.menu }} />
|
|
41
|
+
|
|
42
|
+
## Fixed header
|
|
43
|
+
|
|
44
|
+
Use `fixed` to pin the header to the top of the viewport.
|
|
45
|
+
|
|
46
|
+
<Canvas of={HeaderStories.Fixed} />
|
|
47
|
+
|
|
48
|
+
## Props
|
|
49
|
+
Full props specification for `<Header>` is below.
|
|
50
|
+
<Canvas source={{ code: usage.default }} />
|
|
51
|
+
You can use the controls below to manipulate the `<Header>` component above.
|
|
52
|
+
<Controls />
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Header from './Header';
|
|
3
|
+
import Menu from '../Menu';
|
|
4
|
+
import Icon from '../Icon';
|
|
5
|
+
|
|
6
|
+
const storyWrapperStyle: React.CSSProperties = { minHeight: 400 };
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Components/Header',
|
|
10
|
+
component: Header,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: 'fullscreen',
|
|
13
|
+
},
|
|
14
|
+
argTypes: {
|
|
15
|
+
title: { control: 'text' },
|
|
16
|
+
fixed: { control: 'boolean' },
|
|
17
|
+
homeLinkHref: { control: 'text' },
|
|
18
|
+
homeLinkAriaLabel: { control: 'text' },
|
|
19
|
+
className: { control: 'text' },
|
|
20
|
+
children: { control: false },
|
|
21
|
+
},
|
|
22
|
+
args: {
|
|
23
|
+
title: 'App Name',
|
|
24
|
+
},
|
|
25
|
+
tags: ['autodocs'],
|
|
26
|
+
} satisfies Meta<typeof Header>;
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
render: (args) => (
|
|
33
|
+
<div style={{ overflow: 'hidden' }}>
|
|
34
|
+
<Header {...args} />
|
|
35
|
+
</div>
|
|
36
|
+
),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Fixed: Story = {
|
|
40
|
+
render: (args) => (
|
|
41
|
+
<div
|
|
42
|
+
style={{
|
|
43
|
+
height: '240px',
|
|
44
|
+
overflowY: 'auto',
|
|
45
|
+
position: 'relative',
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<Header
|
|
49
|
+
{...args}
|
|
50
|
+
fixed
|
|
51
|
+
title='App Name'
|
|
52
|
+
/>
|
|
53
|
+
<div
|
|
54
|
+
style={{
|
|
55
|
+
paddingTop: '88px', // keep content below the fixed header
|
|
56
|
+
height: '600px',
|
|
57
|
+
margin: '0 16px',
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
Scroll inside this panel; the header should stay fixed to the top of the
|
|
61
|
+
viewport.
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const WithHomeLink: Story = {
|
|
68
|
+
name: 'With home link',
|
|
69
|
+
render: (args) => (
|
|
70
|
+
<div style={{ overflow: 'hidden' }}>
|
|
71
|
+
<Header {...args} />
|
|
72
|
+
</div>
|
|
73
|
+
),
|
|
74
|
+
args: {
|
|
75
|
+
homeLinkHref: '/',
|
|
76
|
+
homeLinkAriaLabel: 'Go to home',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const WithMenu: Story = {
|
|
81
|
+
render: (args) => (
|
|
82
|
+
<div style={storyWrapperStyle}>
|
|
83
|
+
<Header {...args}>
|
|
84
|
+
<Header.Menu>
|
|
85
|
+
<Menu title='App Name'>
|
|
86
|
+
<Menu.Section>
|
|
87
|
+
<Menu.Item icon={<Icon.Home size={20} />}>Home Page</Menu.Item>
|
|
88
|
+
<Menu.Item icon={<Icon.Tool size={20} />}>Tools</Menu.Item>
|
|
89
|
+
</Menu.Section>
|
|
90
|
+
<Menu.Section>
|
|
91
|
+
<Menu.Item icon={<Icon.Settings size={20} />}>Settings</Menu.Item>
|
|
92
|
+
</Menu.Section>
|
|
93
|
+
</Menu>
|
|
94
|
+
</Header.Menu>
|
|
95
|
+
</Header>
|
|
96
|
+
</div>
|
|
97
|
+
),
|
|
98
|
+
};
|
|
@@ -3,6 +3,7 @@ import { css, cx } from '@emotion/css';
|
|
|
3
3
|
import { useTheme } from '../..';
|
|
4
4
|
import UclLogo from '../UclLogo/UclLogo';
|
|
5
5
|
import HeaderMenu from './HeaderMenu';
|
|
6
|
+
import Link from '../Link';
|
|
6
7
|
|
|
7
8
|
export const NAME = 'ucl-uikit-header';
|
|
8
9
|
export const HEADER_DESKTOP_HEIGHT_PX = 72;
|
|
@@ -15,6 +16,9 @@ export interface HeaderProps extends HTMLAttributes<HTMLElement> {
|
|
|
15
16
|
titleAs?: React.ElementType<React.HTMLAttributes<HTMLElement>>;
|
|
16
17
|
titleClassName?: string;
|
|
17
18
|
titleProps?: Record<string, unknown>;
|
|
19
|
+
homeLinkHref?: string;
|
|
20
|
+
homeLinkProps?: Record<string, unknown>;
|
|
21
|
+
homeLinkAriaLabel?: string;
|
|
18
22
|
testId?: string;
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -24,6 +28,9 @@ const Header = ({
|
|
|
24
28
|
titleAs = 'div',
|
|
25
29
|
titleClassName,
|
|
26
30
|
titleProps,
|
|
31
|
+
homeLinkHref,
|
|
32
|
+
homeLinkProps,
|
|
33
|
+
homeLinkAriaLabel = 'Go to homepage',
|
|
27
34
|
testId = NAME,
|
|
28
35
|
className,
|
|
29
36
|
children,
|
|
@@ -86,16 +93,33 @@ const Header = ({
|
|
|
86
93
|
}
|
|
87
94
|
`;
|
|
88
95
|
|
|
96
|
+
const linkStyle = css`
|
|
97
|
+
color: inherit;
|
|
98
|
+
text-decoration: none;
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
gap: 8px;
|
|
102
|
+
&:visited {
|
|
103
|
+
color: inherit;
|
|
104
|
+
}
|
|
105
|
+
&:hover {
|
|
106
|
+
color: inherit;
|
|
107
|
+
}
|
|
108
|
+
&:active {
|
|
109
|
+
color: inherit;
|
|
110
|
+
}
|
|
111
|
+
&:focus-visible {
|
|
112
|
+
outline: none;
|
|
113
|
+
box-shadow: ${theme.boxShadow.focus};
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
|
|
89
117
|
const titleStyle = cx(titleBaseStyle, titleClassName);
|
|
90
118
|
|
|
91
119
|
const TitleComponent = titleAs;
|
|
92
120
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
className={style}
|
|
96
|
-
data-testid={testId}
|
|
97
|
-
{...props}
|
|
98
|
-
>
|
|
121
|
+
const headerContent = (
|
|
122
|
+
<>
|
|
99
123
|
<UclLogo className={uclLogoStyle} />
|
|
100
124
|
{title && (
|
|
101
125
|
<TitleComponent
|
|
@@ -105,6 +129,27 @@ const Header = ({
|
|
|
105
129
|
{title}
|
|
106
130
|
</TitleComponent>
|
|
107
131
|
)}
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<header
|
|
137
|
+
className={style}
|
|
138
|
+
data-testid={testId}
|
|
139
|
+
{...props}
|
|
140
|
+
>
|
|
141
|
+
{homeLinkHref ? (
|
|
142
|
+
<Link
|
|
143
|
+
href={homeLinkHref}
|
|
144
|
+
aria-label={homeLinkAriaLabel}
|
|
145
|
+
className={linkStyle}
|
|
146
|
+
{...homeLinkProps}
|
|
147
|
+
>
|
|
148
|
+
{headerContent}
|
|
149
|
+
</Link>
|
|
150
|
+
) : (
|
|
151
|
+
headerContent
|
|
152
|
+
)}
|
|
108
153
|
|
|
109
154
|
{children}
|
|
110
155
|
</header>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import Header from '../Header';
|
|
4
4
|
import { ThemeContextProvider } from '../../../theme/useTheme';
|
|
5
5
|
|
|
@@ -23,4 +23,20 @@ describe('Header', () => {
|
|
|
23
23
|
);
|
|
24
24
|
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
25
25
|
});
|
|
26
|
+
|
|
27
|
+
test('wraps logo/title in a home link when homeLinkHref is provided', () => {
|
|
28
|
+
render(
|
|
29
|
+
<ThemeContextProvider>
|
|
30
|
+
<Header
|
|
31
|
+
title='LIDS'
|
|
32
|
+
homeLinkHref='/'
|
|
33
|
+
homeLinkAriaLabel='Go home'
|
|
34
|
+
/>
|
|
35
|
+
</ThemeContextProvider>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const link = screen.getByLabelText('Go home');
|
|
39
|
+
expect(link).toBeInTheDocument();
|
|
40
|
+
expect(link.getAttribute('href')).toBe('/');
|
|
41
|
+
});
|
|
26
42
|
});
|
|
@@ -72,6 +72,7 @@ exports[`Header > snapshot: variant=avatar 1`] = `
|
|
|
72
72
|
class="ucl-uikit-icon css-10o3g4f"
|
|
73
73
|
data-testid="ucl-uikit-icon"
|
|
74
74
|
fill="none"
|
|
75
|
+
focusable="false"
|
|
75
76
|
height="24"
|
|
76
77
|
stroke="currentColor"
|
|
77
78
|
stroke-linecap="round"
|
|
@@ -81,8 +82,8 @@ exports[`Header > snapshot: variant=avatar 1`] = `
|
|
|
81
82
|
width="24"
|
|
82
83
|
xmlns="http://www.w3.org/2000/svg"
|
|
83
84
|
>
|
|
84
|
-
<
|
|
85
|
-
|
|
85
|
+
<path
|
|
86
|
+
d="m6 9 6 6 6-6"
|
|
86
87
|
/>
|
|
87
88
|
</svg>
|
|
88
89
|
</div>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { memo, HTMLAttributes } from 'react';
|
|
2
|
+
import { css, cx } from '@emotion/css';
|
|
3
|
+
import { useTheme } from '../..';
|
|
4
|
+
import HeaderMenuContainer from './HeaderMenuContainer';
|
|
5
|
+
import HeaderTitle from './HeaderTitle';
|
|
6
|
+
import HeaderLogo from './HeaderLogo';
|
|
7
|
+
import HeaderBorder from './HeaderBorder';
|
|
8
|
+
import { HEADER_MOBILE_HEIGHT_PX, HEADER_TABLET_HEIGHT_PX } from './constants';
|
|
9
|
+
|
|
10
|
+
export const NAME = 'ucl-uikit-header';
|
|
11
|
+
|
|
12
|
+
export interface HeaderProps extends HTMLAttributes<HTMLElement> {
|
|
13
|
+
title: string;
|
|
14
|
+
titleAs?: React.ElementType<React.HTMLAttributes<HTMLElement>>;
|
|
15
|
+
titleClassName?: string;
|
|
16
|
+
titleProps?: Record<string, unknown>;
|
|
17
|
+
homeLinkHref?: string;
|
|
18
|
+
homeLinkProps?: Record<string, unknown>;
|
|
19
|
+
testId?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Header = ({
|
|
23
|
+
title,
|
|
24
|
+
titleAs = 'div',
|
|
25
|
+
titleClassName,
|
|
26
|
+
titleProps,
|
|
27
|
+
homeLinkHref,
|
|
28
|
+
homeLinkProps,
|
|
29
|
+
testId = NAME,
|
|
30
|
+
className,
|
|
31
|
+
children,
|
|
32
|
+
...props
|
|
33
|
+
}: HeaderProps) => {
|
|
34
|
+
const [theme] = useTheme();
|
|
35
|
+
|
|
36
|
+
const baseStyle = css`
|
|
37
|
+
position: relative;
|
|
38
|
+
background-color: ${theme.colour.surface.primary};
|
|
39
|
+
font-family: ${theme.font.family.primary};
|
|
40
|
+
font-synthesis: none;
|
|
41
|
+
text-rendering: optimizeLegibility;
|
|
42
|
+
-webkit-font-smoothing: antialiased;
|
|
43
|
+
-moz-osx-font-smoothing: grayscale;
|
|
44
|
+
color: ${theme.color.text.inverted};
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
height: ${HEADER_MOBILE_HEIGHT_PX}px;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
padding: 0 ${theme.padding.p16} 0 ${theme.padding.p40};
|
|
50
|
+
border-bottom: ${theme.colour.border.subtle};
|
|
51
|
+
|
|
52
|
+
@media (min-width: ${theme.breakpoints.desktop}px) {
|
|
53
|
+
height: ${HEADER_TABLET_HEIGHT_PX}px;
|
|
54
|
+
padding: 0 ${theme.padding.p64};
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const style = cx(NAME, baseStyle, className);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<header
|
|
62
|
+
className={style}
|
|
63
|
+
data-testid={testId}
|
|
64
|
+
{...props}
|
|
65
|
+
>
|
|
66
|
+
<HeaderBorder />
|
|
67
|
+
<HeaderLogo
|
|
68
|
+
linkHref={homeLinkHref}
|
|
69
|
+
linkProps={homeLinkProps}
|
|
70
|
+
/>
|
|
71
|
+
<HeaderTitle
|
|
72
|
+
className={titleClassName}
|
|
73
|
+
title={title}
|
|
74
|
+
as={titleAs}
|
|
75
|
+
{...titleProps}
|
|
76
|
+
/>
|
|
77
|
+
{children}
|
|
78
|
+
</header>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const MemoAppHeader = memo(Header);
|
|
83
|
+
|
|
84
|
+
export interface IHeaderSubComponents {
|
|
85
|
+
MenuContainer: typeof HeaderMenuContainer;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const HeaderWithSubComponents = MemoAppHeader as typeof MemoAppHeader &
|
|
89
|
+
IHeaderSubComponents;
|
|
90
|
+
|
|
91
|
+
HeaderWithSubComponents.MenuContainer = HeaderMenuContainer;
|
|
92
|
+
|
|
93
|
+
export default HeaderWithSubComponents;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { css, cx } from '@emotion/css';
|
|
2
|
+
import { useTheme } from '../..';
|
|
3
|
+
import { HTMLAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
export const NAME = 'ucl-uikit-header__border';
|
|
6
|
+
|
|
7
|
+
export interface HeaderBorderProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
testId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const HeaderBorder = ({
|
|
12
|
+
testId = NAME,
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: HeaderBorderProps) => {
|
|
16
|
+
const [theme] = useTheme();
|
|
17
|
+
|
|
18
|
+
const baseStyle = css`
|
|
19
|
+
position: absolute;
|
|
20
|
+
left: 16px;
|
|
21
|
+
height: 100%;
|
|
22
|
+
width: 16px;
|
|
23
|
+
background-color: ${theme.colour.border.brand};
|
|
24
|
+
|
|
25
|
+
@media (min-width: ${theme.breakpoints.desktop}px) {
|
|
26
|
+
left: 0;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const style = cx(NAME, baseStyle, className);
|
|
31
|
+
|
|
32
|
+
const stripeStyle = css`
|
|
33
|
+
position: absolute;
|
|
34
|
+
left: 4px;
|
|
35
|
+
height: 100%;
|
|
36
|
+
width: 4px;
|
|
37
|
+
background-color: ${theme.colour.border.inverse};
|
|
38
|
+
|
|
39
|
+
@media (min-width: ${theme.breakpoints.desktop}px) {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={style}
|
|
47
|
+
data-test={testId}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
<div className={stripeStyle} />
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default HeaderBorder;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { css, cx } from '@emotion/css';
|
|
2
|
+
import { UclLogoNew, UclLogoProps, useTheme } from '../..';
|
|
3
|
+
|
|
4
|
+
export const NAME = 'ucl-uikit-header__logo';
|
|
5
|
+
|
|
6
|
+
export interface HeaderLogoProps extends UclLogoProps {
|
|
7
|
+
linkHref?: string;
|
|
8
|
+
linkProps?: Record<string, unknown>;
|
|
9
|
+
testId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const HeaderLogo = ({
|
|
13
|
+
linkHref,
|
|
14
|
+
linkProps,
|
|
15
|
+
testId = NAME,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}: HeaderLogoProps) => {
|
|
19
|
+
const [theme] = useTheme();
|
|
20
|
+
|
|
21
|
+
const baseStyle = css`
|
|
22
|
+
display: none;
|
|
23
|
+
height: 29px;
|
|
24
|
+
color: ${theme.colour.fill.brand};
|
|
25
|
+
|
|
26
|
+
@media (min-width: ${theme.breakpoints.desktop}px) {
|
|
27
|
+
display: block;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const style = cx(NAME, baseStyle, className);
|
|
32
|
+
|
|
33
|
+
const linkStyle = css`
|
|
34
|
+
color: inherit;
|
|
35
|
+
text-decoration: none;
|
|
36
|
+
|
|
37
|
+
&:visited,
|
|
38
|
+
&:active,
|
|
39
|
+
&:hover {
|
|
40
|
+
color: inherit;
|
|
41
|
+
text-decoration: none;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
if (linkHref) {
|
|
46
|
+
return (
|
|
47
|
+
<a
|
|
48
|
+
href={linkHref}
|
|
49
|
+
className={linkStyle}
|
|
50
|
+
{...linkProps}
|
|
51
|
+
>
|
|
52
|
+
<UclLogoNew
|
|
53
|
+
className={style}
|
|
54
|
+
data-test={testId}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
</a>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<UclLogoNew
|
|
63
|
+
className={style}
|
|
64
|
+
data-test={testId}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default HeaderLogo;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import { css, cx } from '@emotion/css';
|
|
3
|
+
|
|
4
|
+
export const NAME = 'ucl-uikit-header__menu-container';
|
|
5
|
+
|
|
6
|
+
export interface HeaderMenuContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
testId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const HeaderMenuContainer: React.FC<HeaderMenuContainerProps> = ({
|
|
11
|
+
testId = NAME,
|
|
12
|
+
className,
|
|
13
|
+
children,
|
|
14
|
+
...props
|
|
15
|
+
}) => {
|
|
16
|
+
|
|
17
|
+
const baseStyle = css`
|
|
18
|
+
width: fit-content;
|
|
19
|
+
margin-left: auto;
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const style = cx(NAME, baseStyle, className);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
className={style}
|
|
27
|
+
data-testid={testId}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default HeaderMenuContainer;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { css, cx } from '@emotion/css';
|
|
2
|
+
import { useTheme } from '../..';
|
|
3
|
+
import { HTMLAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
export const NAME = 'ucl-uikit-header__title';
|
|
6
|
+
|
|
7
|
+
export interface HeaderTitleProps extends HTMLAttributes<HTMLElement> {
|
|
8
|
+
title: string;
|
|
9
|
+
as?: React.ElementType<React.HTMLAttributes<HTMLElement>>;
|
|
10
|
+
testId?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const HeaderTitle = ({
|
|
14
|
+
title,
|
|
15
|
+
as = 'span',
|
|
16
|
+
testId = NAME,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: HeaderTitleProps) => {
|
|
20
|
+
const [theme] = useTheme();
|
|
21
|
+
|
|
22
|
+
const baseStyle = css`
|
|
23
|
+
margin: 0 ${theme.margin.m4};
|
|
24
|
+
height: 29px;
|
|
25
|
+
color: ${theme.colour.text.brandPrimary};
|
|
26
|
+
font-family: ${theme.typography.heading.lg.md.fontFamily};
|
|
27
|
+
font-feature-settings: ${theme.typography.heading.lg.md.fontSettings};
|
|
28
|
+
font-size: ${theme.typography.heading.xs.md.fontSize}px;
|
|
29
|
+
font-weight: ${theme.typography.heading.xs.md.fontWeight};
|
|
30
|
+
|
|
31
|
+
@media (min-width: ${theme.breakpoints.desktop}px) {
|
|
32
|
+
margin: 0 ${theme.margin.m20};
|
|
33
|
+
font-size: ${theme.typography.heading.lg.md.fontSize}px;
|
|
34
|
+
font-weight: ${theme.typography.heading.lg.md.fontWeight};
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const style = cx(NAME, baseStyle, className);
|
|
39
|
+
|
|
40
|
+
const Comp = as;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Comp
|
|
44
|
+
className={style}
|
|
45
|
+
data-test={testId}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{title}
|
|
49
|
+
</Comp>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default HeaderTitle;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import Header from '../Header';
|
|
4
|
+
import { ThemeContextProvider } from '../../../theme/useTheme';
|
|
5
|
+
|
|
6
|
+
describe('Header', () => {
|
|
7
|
+
// Snapshot tests
|
|
8
|
+
|
|
9
|
+
test('snapshot: variant=breadcrumbs', () => {
|
|
10
|
+
const renderResult = render(
|
|
11
|
+
<ThemeContextProvider>
|
|
12
|
+
<Header title='LIDS' />
|
|
13
|
+
</ThemeContextProvider>
|
|
14
|
+
);
|
|
15
|
+
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('snapshot: variant=avatar', () => {
|
|
19
|
+
const renderResult = render(
|
|
20
|
+
<ThemeContextProvider>
|
|
21
|
+
<Header title='LIDS' />
|
|
22
|
+
</ThemeContextProvider>
|
|
23
|
+
);
|
|
24
|
+
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('wraps logo/title in a home link when homeLinkHref is provided', () => {
|
|
28
|
+
render(
|
|
29
|
+
<ThemeContextProvider>
|
|
30
|
+
<Header
|
|
31
|
+
title='LIDS'
|
|
32
|
+
homeLinkHref='/'
|
|
33
|
+
homeLinkProps={{ 'aria-label': 'Go home' }}
|
|
34
|
+
/>
|
|
35
|
+
</ThemeContextProvider>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const link = screen.getByLabelText('Go home');
|
|
39
|
+
expect(link).toBeInTheDocument();
|
|
40
|
+
expect(link.getAttribute('href')).toBe('/');
|
|
41
|
+
});
|
|
42
|
+
});
|