@scottish-government/designsystem-react 0.12.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.ts +6 -6
- package/.storybook/sgdsArgTypes.ts +107 -43
- package/CHANGELOG.md +49 -0
- package/LICENSE.txt +21 -0
- package/README.md +3 -0
- package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.d.ts +3 -2
- package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.jsx +8 -7
- package/dist/common/AbstractNotificationBanner/types.d.ts +13 -0
- package/dist/common/AbstractNotificationBanner/types.js +2 -0
- package/dist/common/ActionLink/ActionLink.d.ts +2 -1
- package/dist/common/ActionLink/types.d.ts +7 -0
- package/dist/common/ActionLink/types.js +2 -0
- package/dist/common/ConditionalWrapper/ConditionalWrapper.d.ts +2 -1
- package/dist/common/ConditionalWrapper/ConditionalWrapper.jsx +4 -2
- package/dist/common/ConditionalWrapper/types.d.ts +4 -0
- package/dist/common/ConditionalWrapper/types.js +2 -0
- package/dist/common/FileIcon/FileIcon.d.ts +2 -1
- package/dist/common/FileIcon/types.d.ts +6 -0
- package/dist/common/FileIcon/types.js +2 -0
- package/dist/common/HintText/HintText.d.ts +2 -1
- package/dist/common/HintText/HintText.jsx +3 -3
- package/dist/common/HintText/types.d.ts +4 -0
- package/dist/common/HintText/types.js +2 -0
- package/dist/common/Icon/Icon.d.ts +2 -1
- package/dist/common/Icon/Icon.jsx +3 -2
- package/dist/common/Icon/types.d.ts +8 -0
- package/dist/common/Icon/types.js +2 -0
- package/dist/common/ScreenReaderText/ScreenReaderText.d.ts +1 -1
- package/dist/common/WrapperTag/WrapperTag.d.ts +385 -1
- package/dist/common/WrapperTag/WrapperTag.jsx +5 -2
- package/dist/common/WrapperTag/types.d.ts +3 -0
- package/dist/common/WrapperTag/types.js +2 -0
- package/dist/components/Accordion/Accordion.d.ts +3 -2
- package/dist/components/Accordion/Accordion.jsx +12 -11
- package/dist/components/Accordion/types.d.ts +11 -0
- package/dist/components/Accordion/types.js +2 -0
- package/dist/components/AspectBox/AspectBox.d.ts +2 -1
- package/dist/components/AspectBox/AspectBox.jsx +3 -9
- package/dist/components/AspectBox/types.d.ts +3 -0
- package/dist/components/AspectBox/types.js +2 -0
- package/dist/components/BackToTop/BackToTop.d.ts +2 -1
- package/dist/components/BackToTop/BackToTop.jsx +4 -3
- package/dist/components/BackToTop/types.d.ts +3 -0
- package/dist/components/BackToTop/types.js +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +6 -2
- package/dist/components/Breadcrumbs/types.d.ts +5 -0
- package/dist/components/Breadcrumbs/types.js +2 -0
- package/dist/components/Button/Button.d.ts +2 -1
- package/dist/components/Button/Button.jsx +4 -3
- package/dist/components/Button/ButtonGroup.d.ts +2 -1
- package/dist/components/Button/ButtonGroup.jsx +9 -4
- package/dist/components/Button/types.d.ts +20 -0
- package/dist/components/Button/types.js +2 -0
- package/dist/components/Card/Card.d.ts +34 -0
- package/dist/components/Card/Card.jsx +118 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/Card/index.js +8 -0
- package/dist/components/Card/types.d.ts +26 -0
- package/dist/components/Card/types.js +2 -0
- package/dist/components/CategoryItem/CategoryItem.d.ts +2 -1
- package/dist/components/CategoryItem/CategoryItem.jsx +8 -5
- package/dist/components/CategoryItem/types.d.ts +9 -0
- package/dist/components/CategoryItem/types.js +2 -0
- package/dist/components/CategoryList/CategoryList.d.ts +2 -1
- package/dist/components/CategoryList/CategoryList.jsx +3 -2
- package/dist/components/CategoryList/types.d.ts +5 -0
- package/dist/components/CategoryList/types.js +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +2 -1
- package/dist/components/Checkbox/Checkbox.jsx +4 -3
- package/dist/components/Checkbox/CheckboxGroup.d.ts +2 -1
- package/dist/components/Checkbox/CheckboxGroup.jsx +5 -4
- package/dist/components/Checkbox/types.d.ts +7 -0
- package/dist/components/Checkbox/types.js +2 -0
- package/dist/components/ConfirmationMessage/ConfirmationMessage.d.ts +2 -1
- package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +3 -2
- package/dist/components/ConfirmationMessage/types.d.ts +6 -0
- package/dist/components/ConfirmationMessage/types.js +2 -0
- package/dist/components/ContentsNav/ContentsNav.d.ts +3 -2
- package/dist/components/ContentsNav/ContentsNav.jsx +7 -5
- package/dist/components/ContentsNav/types.d.ts +9 -0
- package/dist/components/ContentsNav/types.js +2 -0
- package/dist/components/CookieBanner/CookieBanner.d.ts +3 -2
- package/dist/components/CookieBanner/CookieBanner.jsx +13 -3
- package/dist/components/DatePicker/DatePicker.d.ts +2 -1
- package/dist/components/DatePicker/DatePicker.jsx +7 -7
- package/dist/components/DatePicker/types.d.ts +18 -0
- package/dist/components/DatePicker/types.js +2 -0
- package/dist/components/Details/Details.d.ts +2 -1
- package/dist/components/Details/Details.jsx +6 -2
- package/dist/components/Details/types.d.ts +4 -0
- package/dist/components/Details/types.js +2 -0
- package/dist/components/ErrorMessage/ErrorMessage.d.ts +2 -1
- package/dist/components/ErrorMessage/ErrorMessage.jsx +6 -2
- package/dist/components/ErrorMessage/types.d.ts +3 -0
- package/dist/components/ErrorMessage/types.js +2 -0
- package/dist/components/ErrorSummary/ErrorSummary.d.ts +3 -2
- package/dist/components/ErrorSummary/ErrorSummary.jsx +6 -2
- package/dist/components/ErrorSummary/types.d.ts +8 -0
- package/dist/components/ErrorSummary/types.js +2 -0
- package/dist/components/FeatureHeader/FeatureHeader.d.ts +7 -5
- package/dist/components/FeatureHeader/FeatureHeader.jsx +87 -50
- package/dist/components/FeatureHeader/types.d.ts +12 -0
- package/dist/components/FeatureHeader/types.js +2 -0
- package/dist/components/FileDownload/FileDownload.d.ts +2 -1
- package/dist/components/FileDownload/FileDownload.jsx +4 -3
- package/dist/components/FileDownload/types.d.ts +10 -0
- package/dist/components/FileDownload/types.js +2 -0
- package/dist/components/HideThisPage/HideThisPage.d.ts +2 -1
- package/dist/components/HideThisPage/HideThisPage.jsx +5 -4
- package/dist/components/HideThisPage/types.d.ts +3 -0
- package/dist/components/HideThisPage/types.js +2 -0
- package/dist/components/InsetText/InsetText.d.ts +1 -1
- package/dist/components/InsetText/InsetText.jsx +6 -2
- package/dist/components/NotificationBanner/NotificationBanner.d.ts +3 -2
- package/dist/components/NotificationBanner/NotificationBanner.jsx +5 -4
- package/dist/components/NotificationPanel/NotificationPanel.d.ts +2 -1
- package/dist/components/NotificationPanel/NotificationPanel.jsx +3 -2
- package/dist/components/NotificationPanel/types.d.ts +6 -0
- package/dist/components/NotificationPanel/types.js +2 -0
- package/dist/components/NotificationTag/NotificationTag.d.ts +6 -0
- package/dist/components/NotificationTag/NotificationTag.jsx +20 -0
- package/dist/components/NotificationTag/index.d.ts +1 -0
- package/dist/components/NotificationTag/index.js +8 -0
- package/dist/components/NotificationTag/types.d.ts +5 -0
- package/dist/components/NotificationTag/types.js +2 -0
- package/dist/components/PageHeader/PageHeader.d.ts +2 -1
- package/dist/components/PageHeader/PageHeader.jsx +6 -2
- package/dist/components/PageHeader/types.d.ts +5 -0
- package/dist/components/PageHeader/types.js +2 -0
- package/dist/components/PageMetadata/PageMetadata.d.ts +3 -2
- package/dist/components/PageMetadata/PageMetadata.jsx +8 -4
- package/dist/components/PageMetadata/types.d.ts +6 -0
- package/dist/components/PageMetadata/types.js +2 -0
- package/dist/components/Pagination/Pagination.d.ts +3 -2
- package/dist/components/Pagination/Pagination.jsx +7 -5
- package/dist/components/Pagination/types.d.ts +18 -0
- package/dist/components/Pagination/types.js +2 -0
- package/dist/components/PhaseBanner/PhaseBanner.d.ts +2 -1
- package/dist/components/PhaseBanner/PhaseBanner.jsx +3 -2
- package/dist/components/PhaseBanner/types.d.ts +3 -0
- package/dist/components/PhaseBanner/types.js +2 -0
- package/dist/components/Question/Question.d.ts +2 -1
- package/dist/components/Question/Question.jsx +4 -3
- package/dist/components/Question/types.d.ts +9 -0
- package/dist/components/Question/types.js +2 -0
- package/dist/components/RadioButton/RadioButton.d.ts +2 -1
- package/dist/components/RadioButton/RadioButton.jsx +4 -3
- package/dist/components/RadioButton/RadioGroup.d.ts +2 -1
- package/dist/components/RadioButton/RadioGroup.jsx +3 -2
- package/dist/components/RadioButton/types.d.ts +10 -0
- package/dist/components/RadioButton/types.js +2 -0
- package/dist/components/SearchFacets/SearchFacets.d.ts +4 -3
- package/dist/components/SearchFacets/SearchFacets.jsx +3 -2
- package/dist/components/SearchFacets/types.d.ts +12 -0
- package/dist/components/SearchFacets/types.js +2 -0
- package/dist/components/SearchFilters/SearchFilters.d.ts +5 -4
- package/dist/components/SearchFilters/types.d.ts +12 -0
- package/dist/components/SearchFilters/types.js +2 -0
- package/dist/components/SearchResult/SearchResult.d.ts +8 -11
- package/dist/components/SearchResult/SearchResult.jsx +6 -7
- package/dist/components/SearchResult/types.d.ts +11 -0
- package/dist/components/SearchResult/types.js +2 -0
- package/dist/components/SearchSort/SearchSort.d.ts +2 -1
- package/dist/components/SearchSort/SearchSort.jsx +3 -2
- package/dist/components/SearchSort/types.d.ts +7 -0
- package/dist/components/SearchSort/types.js +2 -0
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.jsx +4 -3
- package/dist/components/Select/types.d.ts +6 -0
- package/dist/components/Select/types.js +2 -0
- package/dist/components/SequentialNavigation/SequentialNavigation.d.ts +4 -3
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +10 -6
- package/dist/components/SequentialNavigation/types.d.ts +10 -0
- package/dist/components/SequentialNavigation/types.js +2 -0
- package/dist/components/SideNavigation/SideNavigation.d.ts +4 -3
- package/dist/components/SideNavigation/SideNavigation.jsx +10 -7
- package/dist/components/SideNavigation/types.d.ts +13 -0
- package/dist/components/SideNavigation/types.js +2 -0
- package/dist/components/SiteFooter/SiteFooter.d.ts +6 -5
- package/dist/components/SiteFooter/SiteFooter.jsx +4 -3
- package/dist/components/SiteFooter/types.d.ts +16 -0
- package/dist/components/SiteFooter/types.js +2 -0
- package/dist/components/SiteHeader/SiteHeader.d.ts +6 -5
- package/dist/components/SiteHeader/SiteHeader.jsx +1 -1
- package/dist/components/SiteHeader/types.d.ts +20 -0
- package/dist/components/SiteHeader/types.js +2 -0
- package/dist/components/SiteNavigation/SiteNavigation.d.ts +3 -2
- package/dist/components/SiteNavigation/SiteNavigation.jsx +12 -4
- package/dist/components/SiteNavigation/types.d.ts +9 -0
- package/dist/components/SiteNavigation/types.js +2 -0
- package/dist/components/SiteSearch/SiteSearch.d.ts +2 -1
- package/dist/components/SiteSearch/SiteSearch.jsx +12 -11
- package/dist/components/SiteSearch/types.d.ts +17 -0
- package/dist/components/SiteSearch/types.js +2 -0
- package/dist/components/SkipLinks/SkipLinks.d.ts +3 -2
- package/dist/components/SkipLinks/SkipLinks.jsx +4 -4
- package/dist/components/SkipLinks/types.d.ts +8 -0
- package/dist/components/SkipLinks/types.js +2 -0
- package/dist/components/SummaryCard/SummaryCard.d.ts +4 -2
- package/dist/components/SummaryCard/SummaryCard.jsx +5 -4
- package/dist/components/SummaryCard/types.d.ts +5 -0
- package/dist/components/SummaryCard/types.js +2 -0
- package/dist/components/SummaryList/SummaryList.d.ts +6 -4
- package/dist/components/SummaryList/SummaryList.jsx +5 -4
- package/dist/components/SummaryList/types.d.ts +6 -0
- package/dist/components/SummaryList/types.js +2 -0
- package/dist/components/Table/Table.d.ts +2 -1
- package/dist/components/Table/Table.jsx +5 -4
- package/dist/components/Table/types.d.ts +6 -0
- package/dist/components/Table/types.js +2 -0
- package/dist/components/Tabs/Tabs.d.ts +3 -2
- package/dist/components/Tabs/Tabs.jsx +6 -5
- package/dist/components/Tabs/types.d.ts +16 -0
- package/dist/components/Tabs/types.js +2 -0
- package/dist/components/Tag/Tag.d.ts +2 -1
- package/dist/components/Tag/Tag.jsx +7 -3
- package/dist/components/Tag/types.d.ts +4 -0
- package/dist/components/Tag/types.js +2 -0
- package/dist/components/TaskList/TaskList.d.ts +4 -3
- package/dist/components/TaskList/TaskList.jsx +11 -8
- package/dist/components/TaskList/types.d.ts +17 -0
- package/dist/components/TaskList/types.js +2 -0
- package/dist/components/TextInput/TextInput.d.ts +2 -1
- package/dist/components/TextInput/TextInput.jsx +10 -9
- package/dist/components/TextInput/types.d.ts +11 -0
- package/dist/components/TextInput/types.js +2 -0
- package/dist/components/Textarea/Textarea.d.ts +2 -1
- package/dist/components/Textarea/Textarea.jsx +6 -5
- package/dist/components/WarningText/WarningText.d.ts +1 -1
- package/dist/components/WarningText/WarningText.jsx +6 -2
- package/dist/hooks/useTracking/useTracking.js +0 -1
- package/eslint.config.mjs +32 -0
- package/package.json +12 -5
- package/src/common/AbstractNotificationBanner/AbstractNotificationBanner.tsx +13 -10
- package/src/common/AbstractNotificationBanner/types.ts +15 -0
- package/src/common/ActionLink/ActionLink.tsx +3 -1
- package/src/common/ActionLink/types.ts +8 -0
- package/src/common/ConditionalWrapper/ConditionalWrapper.tsx +10 -2
- package/src/common/ConditionalWrapper/types.ts +4 -0
- package/src/common/FileIcon/FileIcon.tsx +2 -1
- package/src/common/FileIcon/types.ts +7 -0
- package/src/common/HintText/HintText.test.tsx +3 -15
- package/src/common/HintText/HintText.tsx +4 -4
- package/src/common/HintText/types.ts +4 -0
- package/src/common/Icon/Icon.tsx +5 -3
- package/src/common/Icon/types.ts +9 -0
- package/src/common/ScreenReaderText/ScreenReaderText.tsx +1 -1
- package/src/common/WrapperTag/WrapperTag.tsx +5 -3
- package/src/common/WrapperTag/types.ts +3 -0
- package/src/components/Accordion/Accordion.Item.stories.tsx +1 -5
- package/src/components/Accordion/Accordion.stories.tsx +5 -5
- package/src/components/Accordion/Accordion.test.tsx +11 -0
- package/src/components/Accordion/Accordion.tsx +15 -13
- package/src/components/Accordion/types.ts +13 -0
- package/src/components/AspectBox/AspectBox.stories.tsx +1 -2
- package/src/components/AspectBox/AspectBox.tsx +8 -14
- package/src/components/AspectBox/types.ts +3 -0
- package/src/components/BackToTop/BackToTop.test.tsx +21 -1
- package/src/components/BackToTop/BackToTop.tsx +6 -4
- package/src/components/BackToTop/types.ts +3 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +7 -4
- package/src/components/Breadcrumbs/types.ts +6 -0
- package/src/components/Button/Button.tsx +6 -4
- package/src/components/Button/ButtonGroup.stories.tsx +22 -0
- package/src/components/Button/ButtonGroup.test.tsx +21 -0
- package/src/components/Button/ButtonGroup.tsx +9 -4
- package/src/components/Button/types.ts +22 -0
- package/src/components/Card/Card.stories.tsx +446 -0
- package/src/components/Card/Card.test.tsx +282 -0
- package/src/components/Card/Card.tsx +208 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Card/types.ts +30 -0
- package/src/components/CategoryItem/CategoryItem.tsx +10 -6
- package/src/components/CategoryItem/types.ts +10 -0
- package/src/components/CategoryList/CategoryList.tsx +7 -4
- package/src/components/CategoryList/types.ts +5 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +3 -3
- package/src/components/Checkbox/Checkbox.test.tsx +30 -0
- package/src/components/Checkbox/Checkbox.tsx +8 -7
- package/src/components/Checkbox/CheckboxGroup.test.tsx +10 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +7 -6
- package/src/components/Checkbox/types.ts +9 -0
- package/src/components/ConfirmationMessage/ConfirmationMessage.tsx +5 -3
- package/src/components/ConfirmationMessage/types.ts +7 -0
- package/src/components/ContentsNav/ContentsNav.stories.tsx +5 -1
- package/src/components/ContentsNav/ContentsNav.tsx +11 -7
- package/src/components/ContentsNav/types.ts +11 -0
- package/src/components/CookieBanner/CookieBanner.Buttons.stories.tsx +3 -3
- package/src/components/CookieBanner/CookieBanner.stories.tsx +6 -6
- package/src/components/CookieBanner/CookieBanner.test.tsx +24 -1
- package/src/components/CookieBanner/CookieBanner.tsx +16 -5
- package/src/components/DatePicker/DatePicker.test.tsx +52 -19
- package/src/components/DatePicker/DatePicker.tsx +8 -8
- package/src/components/DatePicker/types.ts +19 -0
- package/src/components/Details/Details.stories.tsx +1 -1
- package/src/components/Details/Details.tsx +6 -3
- package/src/components/Details/types.ts +4 -0
- package/src/components/ErrorMessage/ErrorMessage.tsx +6 -3
- package/src/components/ErrorMessage/types.ts +3 -0
- package/src/components/ErrorSummary/ErrorSummary.test.tsx +1 -1
- package/src/components/ErrorSummary/ErrorSummary.tsx +6 -4
- package/src/components/ErrorSummary/types.ts +11 -0
- package/src/components/FeatureHeader/FeatureHeader.stories.tsx +186 -23
- package/src/components/FeatureHeader/FeatureHeader.test.tsx +298 -0
- package/src/components/FeatureHeader/FeatureHeader.tsx +83 -58
- package/src/components/FeatureHeader/types.ts +13 -0
- package/src/components/FileDownload/FileDownload.test.tsx +1 -5
- package/src/components/FileDownload/FileDownload.tsx +6 -4
- package/src/components/FileDownload/types.ts +11 -0
- package/src/components/HideThisPage/HideThisPage.test.tsx +12 -1
- package/src/components/HideThisPage/HideThisPage.tsx +7 -5
- package/src/components/HideThisPage/types.ts +3 -0
- package/src/components/InsetText/InsetText.tsx +5 -3
- package/src/components/NotificationBanner/NotificationBanner.stories.tsx +2 -2
- package/src/components/NotificationBanner/NotificationBanner.test.tsx +10 -0
- package/src/components/NotificationBanner/NotificationBanner.tsx +8 -6
- package/src/components/NotificationPanel/NotificationPanel.tsx +5 -3
- package/src/components/NotificationPanel/types.ts +7 -0
- package/src/components/NotificationTag/NotificationTag.stories.tsx +68 -0
- package/src/components/NotificationTag/NotificationTag.test.tsx +70 -0
- package/src/components/NotificationTag/NotificationTag.tsx +32 -0
- package/src/components/NotificationTag/index.ts +1 -0
- package/src/components/NotificationTag/types.ts +5 -0
- package/src/components/PageHeader/PageHeader.tsx +6 -3
- package/src/components/PageHeader/types.ts +5 -0
- package/src/components/PageMetadata/PageMetadata.stories.tsx +1 -1
- package/src/components/PageMetadata/PageMetadata.tsx +10 -7
- package/src/components/PageMetadata/types.ts +7 -0
- package/src/components/Pagination/Pagination.test.tsx +20 -0
- package/src/components/Pagination/Pagination.tsx +12 -8
- package/src/components/Pagination/types.ts +20 -0
- package/src/components/PhaseBanner/PhaseBanner.stories.tsx +1 -4
- package/src/components/PhaseBanner/PhaseBanner.tsx +5 -3
- package/src/components/PhaseBanner/types.ts +3 -0
- package/src/components/Question/Question.tsx +6 -4
- package/src/components/Question/types.ts +9 -0
- package/src/components/RadioButton/RadioButton.test.tsx +30 -0
- package/src/components/RadioButton/RadioButton.tsx +8 -7
- package/src/components/RadioButton/RadioGroup.tsx +5 -3
- package/src/components/RadioButton/types.ts +12 -0
- package/src/components/SearchFacets/SearchFacets.Group.stories.tsx +2 -3
- package/src/components/SearchFacets/SearchFacets.stories.tsx +2 -2
- package/src/components/SearchFacets/SearchFacets.tsx +10 -8
- package/src/components/SearchFacets/types.ts +14 -0
- package/src/components/SearchFilters/SearchFilters.Panel.stories.tsx +18 -7
- package/src/components/SearchFilters/SearchFilters.stories.tsx +1 -1
- package/src/components/SearchFilters/SearchFilters.tsx +4 -3
- package/src/components/SearchFilters/types.ts +14 -0
- package/src/components/SearchResult/SearchResult.stories.tsx +23 -23
- package/src/components/SearchResult/SearchResult.test.tsx +5 -4
- package/src/components/SearchResult/SearchResult.tsx +15 -15
- package/src/components/SearchResult/types.ts +13 -0
- package/src/components/SearchSort/SearchSort.stories.tsx +2 -1
- package/src/components/SearchSort/SearchSort.tsx +5 -3
- package/src/components/SearchSort/types.ts +7 -0
- package/src/components/Select/Select.test.tsx +42 -0
- package/src/components/Select/Select.tsx +8 -6
- package/src/components/Select/types.ts +7 -0
- package/src/components/SequentialNavigation/SequentialNavigation.tsx +13 -10
- package/src/components/SequentialNavigation/types.ts +12 -0
- package/src/components/SideNavigation/SideNavigation.test.tsx +24 -0
- package/src/components/SideNavigation/SideNavigation.tsx +14 -10
- package/src/components/SideNavigation/types.ts +16 -0
- package/src/components/SiteFooter/SiteFooter.tsx +10 -8
- package/src/components/SiteFooter/types.ts +20 -0
- package/src/components/SiteHeader/SiteHeader.stories.tsx +4 -3
- package/src/components/SiteHeader/SiteHeader.test.tsx +29 -16
- package/src/components/SiteHeader/SiteHeader.tsx +10 -9
- package/src/components/SiteHeader/types.ts +22 -0
- package/src/components/SiteNavigation/SiteNavigation.test.tsx +16 -1
- package/src/components/SiteNavigation/SiteNavigation.tsx +13 -6
- package/src/components/SiteNavigation/types.ts +11 -0
- package/src/components/SiteSearch/SiteSearch.stories.tsx +4 -2
- package/src/components/SiteSearch/SiteSearch.test.tsx +22 -0
- package/src/components/SiteSearch/SiteSearch.tsx +15 -13
- package/src/components/SiteSearch/types.ts +19 -0
- package/src/components/SkipLinks/SkipLinks.stories.tsx +3 -3
- package/src/components/SkipLinks/SkipLinks.tsx +7 -7
- package/src/components/SkipLinks/types.ts +9 -0
- package/src/components/SummaryCard/SummaryCard.test.tsx +0 -11
- package/src/components/SummaryCard/SummaryCard.tsx +9 -6
- package/src/components/SummaryCard/types.ts +6 -0
- package/src/components/SummaryList/SummaryList.Item.stories.tsx +5 -5
- package/src/components/SummaryList/SummaryList.stories.tsx +1 -1
- package/src/components/SummaryList/SummaryList.test.tsx +1 -6
- package/src/components/SummaryList/SummaryList.tsx +11 -9
- package/src/components/SummaryList/types.ts +7 -0
- package/src/components/Table/Table.test.tsx +36 -0
- package/src/components/Table/Table.tsx +7 -5
- package/src/components/Table/types.ts +6 -0
- package/src/components/Tabs/Tabs.Item.stories.tsx +7 -7
- package/src/components/Tabs/Tabs.stories.tsx +3 -3
- package/src/components/Tabs/Tabs.test.tsx +14 -0
- package/src/components/Tabs/Tabs.tsx +12 -9
- package/src/components/Tabs/types.ts +19 -0
- package/src/components/Tag/Tag.tsx +7 -4
- package/src/components/Tag/types.ts +5 -0
- package/src/components/TaskList/TaskList.Group.stories.tsx +0 -5
- package/src/components/TaskList/TaskList.stories.tsx +0 -1
- package/src/components/TaskList/TaskList.tsx +17 -13
- package/src/components/TaskList/types.ts +20 -0
- package/src/components/TextInput/TextInput.test.tsx +53 -1
- package/src/components/TextInput/TextInput.tsx +17 -12
- package/src/components/TextInput/types.ts +12 -0
- package/src/components/Textarea/Textarea.test.tsx +53 -1
- package/src/components/Textarea/Textarea.tsx +10 -8
- package/src/components/WarningText/WarningText.tsx +5 -3
- package/src/hooks/useTracking/useTracking.test.tsx +5 -7
- package/src/hooks/useTracking/useTracking.ts +0 -1
- package/src/images/icons/arrow_upward.tsx +10 -10
- package/src/images/icons/calendar_today.tsx +10 -10
- package/src/images/icons/cancel.tsx +8 -8
- package/src/images/icons/check_circle.tsx +10 -10
- package/src/images/icons/chevron_left.tsx +10 -10
- package/src/images/icons/chevron_right.tsx +10 -10
- package/src/images/icons/close.tsx +10 -10
- package/src/images/icons/description.tsx +10 -10
- package/src/images/icons/double_chevron_left.tsx +8 -8
- package/src/images/icons/double_chevron_right.tsx +8 -8
- package/src/images/icons/error.tsx +10 -10
- package/src/images/icons/expand_less.tsx +10 -10
- package/src/images/icons/expand_more.tsx +10 -10
- package/src/images/icons/list.tsx +13 -13
- package/src/images/icons/menu.tsx +10 -10
- package/src/images/icons/priority_high.tsx +11 -11
- package/src/images/icons/search.tsx +10 -10
- package/src/shared-types.ts +40 -0
- package/static/images/illustration.svg +502 -0
- package/tsconfig.json +0 -3
- package/vite.config.ts +6 -1
- package/@types/common/AbstractNotificationBanner.d.ts +0 -17
- package/@types/common/ActionLink.d.ts +0 -8
- package/@types/common/ConditionalWrapper.d.ts +0 -6
- package/@types/common/FileIcon.d.ts +0 -7
- package/@types/common/HintText.d.ts +0 -6
- package/@types/common/Icon.d.ts +0 -9
- package/@types/common/ScreenReaderText.d.ts +0 -4
- package/@types/common/WrapperTag.d.ts +0 -5
- package/@types/components/Accordion.d.ts +0 -15
- package/@types/components/AspectBox.d.ts +0 -5
- package/@types/components/BackToTop.d.ts +0 -5
- package/@types/components/Breadcrumbs.d.ts +0 -11
- package/@types/components/Button.d.ts +0 -17
- package/@types/components/ButtonGroup.d.ts +0 -5
- package/@types/components/CategoryItem.d.ts +0 -10
- package/@types/components/CategoryList.d.ts +0 -7
- package/@types/components/Checkbox.d.ts +0 -11
- package/@types/components/ConfirmationMessage.d.ts +0 -7
- package/@types/components/ContentsNav.d.ts +0 -13
- package/@types/components/DatePicker.d.ts +0 -20
- package/@types/components/Details.d.ts +0 -6
- package/@types/components/ErrorMessage.d.ts +0 -5
- package/@types/components/ErrorSummary.d.ts +0 -12
- package/@types/components/FileDownload.d.ts +0 -11
- package/@types/components/HideThisPage.d.ts +0 -5
- package/@types/components/InsetText.d.ts +0 -5
- package/@types/components/Metadata.d.ts +0 -11
- package/@types/components/NotificationPanel.d.ts +0 -7
- package/@types/components/PageHeader.d.ts +0 -7
- package/@types/components/Pagination.d.ts +0 -22
- package/@types/components/PhaseBanner.d.ts +0 -5
- package/@types/components/Question.d.ts +0 -11
- package/@types/components/RadioButton.d.ts +0 -14
- package/@types/components/SearchFacets.d.ts +0 -18
- package/@types/components/SearchFilters.d.ts +0 -14
- package/@types/components/SearchResult.d.ts +0 -30
- package/@types/components/SearchSort.d.ts +0 -9
- package/@types/components/Select.d.ts +0 -7
- package/@types/components/SequentialNavigation.d.ts +0 -14
- package/@types/components/SideNavigation.d.ts +0 -18
- package/@types/components/SiteFooter.d.ts +0 -25
- package/@types/components/SiteHeader.d.ts +0 -20
- package/@types/components/SiteNavigation.d.ts +0 -13
- package/@types/components/SiteSearch.d.ts +0 -14
- package/@types/components/SkipLinks.d.ts +0 -13
- package/@types/components/SummaryCard.d.ts +0 -6
- package/@types/components/SummaryList.d.ts +0 -14
- package/@types/components/Table.d.ts +0 -8
- package/@types/components/Tabs.d.ts +0 -21
- package/@types/components/Tag.d.ts +0 -5
- package/@types/components/TaskList.d.ts +0 -22
- package/@types/components/TextInput.d.ts +0 -12
- package/@types/components/Textarea.d.ts +0 -4
- package/@types/components/WarningText.d.ts +0 -5
- package/@types/global.d.ts +0 -1
- package/@types/sgds.d.ts +0 -49
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -40
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LinkComponent } from "../../shared-types";
|
|
2
|
+
|
|
3
|
+
export interface SiteFooterLinkProps extends React.AllHTMLAttributes<HTMLLIElement> {
|
|
4
|
+
href?: string;
|
|
5
|
+
linkComponent?: LinkComponent;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface SiteFooterLicenseProps extends React.AllHTMLAttributes<HTMLDivElement> {
|
|
9
|
+
href?: string;
|
|
10
|
+
logoSrc?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SiteFooterOrgProps extends React.AllHTMLAttributes<HTMLDivElement> {
|
|
14
|
+
href?: string;
|
|
15
|
+
title: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SiteFooterProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
@@ -17,6 +17,7 @@ const meta = {
|
|
|
17
17
|
<SiteHeader.Brand
|
|
18
18
|
homeUrl="/"
|
|
19
19
|
siteTitle="Design System React"
|
|
20
|
+
key="1"
|
|
20
21
|
>
|
|
21
22
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 206.7 30.7">
|
|
22
23
|
<title>The Scottish Government</title>
|
|
@@ -26,7 +27,7 @@ const meta = {
|
|
|
26
27
|
<path fill="#333e48" d="M205.1 12.8c.8 0 1.3-.2 1.6-.5l-.4-1.3c-.1.2-.4.3-.8.3-.5 0-.8-.4-.8-1V6.1h1.6V4.6h-1.6V2.3H203v2.2h-1.3V6h1.3v4.7c0 1.4.7 2.1 2.1 2.1m-4.7-.2V6.9c0-1.7-.9-2.6-2.6-2.6-1.3 0-2.3.7-2.9 1.3v-1h-1.8v8.1h1.8V7c.4-.5 1.2-1.1 2.1-1.1 1 0 1.6.4 1.6 1.7v5.1h1.8zm-10.5-4.7h-4.5c.1-1 .8-2.1 2.3-2.1 1.5 0 2.1 1.2 2.2 2.1m-2.2 4.9c1.3 0 2.5-.4 3.3-1.2l-.8-1.2c-.6.6-1.5.9-2.3.9-1.5 0-2.4-1-2.6-2.2h6.2v-.4c0-2.5-1.5-4.4-4-4.4a4 4 0 0 0-4.1 4.2c.1 2.6 1.9 4.3 4.3 4.3m-5.9-.2V6.8c0-1.6-.9-2.4-2.3-2.4-1.2 0-2.3.8-2.7 1.5-.3-.9-1-1.5-2.2-1.5-1.2 0-2.3.8-2.6 1.3V4.6h-1.8v8.1h1.8V7c.4-.5 1.1-1.1 1.9-1.1 1 0 1.3.6 1.3 1.5v5.3h1.8V7c.4-.5 1.1-1.1 1.9-1.1 1 0 1.3.6 1.3 1.5v5.3h1.6zm-13.9 0V6.9c0-1.7-.9-2.6-2.6-2.6-1.3 0-2.3.7-2.9 1.3v-1h-1.8v8.1h1.8V7c.4-.5 1.2-1.1 2.1-1.1 1 0 1.6.4 1.6 1.7v5.1h1.8zm-11.1 0V7.1c.4-.6 1.3-1.1 2.1-1.1h.5V4.4c-1 0-2 .6-2.6 1.4V4.6H155v8.1h1.8zm-5.1-4.7h-4.5c.1-1 .8-2.1 2.3-2.1 1.5 0 2.1 1.2 2.2 2.1m-2.2 4.9c1.3 0 2.5-.4 3.3-1.2l-.8-1.2c-.6.6-1.5.9-2.3.9-1.5 0-2.4-1-2.6-2.2h6.2v-.4c0-2.5-1.5-4.4-4-4.4a4 4 0 0 0-4.1 4.2c.1 2.6 1.9 4.3 4.3 4.3m-7.8-.2 3.3-8.1h-1.9l-2.4 6.1-2.4-6.1h-1.9l3.3 8.1h2zm-9.7-1.3c-1.5 0-2.3-1.3-2.3-2.7 0-1.4.8-2.7 2.3-2.7 1.5 0 2.3 1.3 2.3 2.7 0 1.4-.8 2.7-2.3 2.7m0 1.5c2.6 0 4.1-1.9 4.1-4.2 0-2.3-1.6-4.2-4.1-4.2s-4.1 1.9-4.1 4.2a4 4 0 0 0 4.1 4.2m-10.7 0c3.5 0 5.6-2.4 5.6-6.2h-6.1v1.7h4a3.2 3.2 0 0 1-3.3 2.7c-2.2 0-3.8-1.7-3.8-4 0-2.4 1.6-4 3.8-4 1.2 0 2.3.7 2.9 1.5l1.6-.9a5.2 5.2 0 0 0-4.5-2.3 5.7 5.7 0 0 0-5.9 5.8c0 3.5 2.7 5.7 5.7 5.7m-11.5-.2V6.9c0-1.7-.9-2.6-2.6-2.6-1.3 0-2.3.7-2.8 1.3V1.5h-1.8v11.2h1.8V7c.4-.5 1.2-1.1 2.1-1.1 1 0 1.6.4 1.6 1.6v5.1h1.7zm-12.2.2c2.2 0 3.4-1.1 3.4-2.5 0-3.2-4.9-2.1-4.9-3.6 0-.6.6-1 1.5-1 1 0 1.9.4 2.4 1l.7-1.2a4.8 4.8 0 0 0-3.1-1.1c-2 0-3.2 1.1-3.2 2.4 0 3.1 4.9 2 4.9 3.6 0 .6-.6 1.1-1.6 1.1a4 4 0 0 1-2.7-1.1l-.8 1.3c.8.7 2 1.1 3.4 1.1m-5-8.2h-1.8v8.1h1.8V4.6zm-.9-1c.6 0 1.1-.5 1.1-1.1 0-.6-.5-1.1-1.1-1.1-.6 0-1.1.5-1.1 1.1 0 .6.5 1.1 1.1 1.1M88 12.8c.8 0 1.3-.2 1.6-.5l-.4-1.3c-.1.2-.4.3-.8.3-.5 0-.8-.4-.8-1V6.1h1.6V4.6h-1.6V2.3h-1.8v2.2h-1.3V6h1.3v4.7c.1 1.4.8 2.1 2.2 2.1m-5.6 0c.8 0 1.3-.2 1.6-.5l-.4-1.3c-.1.2-.4.3-.8.3-.5 0-.8-.4-.8-1V6.1h1.6V4.6H82V2.3h-1.8v2.2h-1.3V6h1.3v4.7c.1 1.4.8 2.1 2.2 2.1m-8.3-1.5c-1.5 0-2.3-1.3-2.3-2.7 0-1.4.8-2.7 2.3-2.7 1.5 0 2.3 1.3 2.3 2.7 0 1.4-.8 2.7-2.3 2.7m0 1.5c2.6 0 4.1-1.9 4.1-4.2 0-2.3-1.6-4.2-4.1-4.2-2.6 0-4.1 1.9-4.1 4.2a4 4 0 0 0 4.1 4.2m-8.1 0c1.6 0 2.5-.7 3.1-1.4L68 10.3c-.5.6-1.1 1-1.9 1-1.5 0-2.4-1.1-2.4-2.7s1-2.7 2.4-2.7c.8 0 1.4.3 1.9.9l1.2-1.1c-.6-.7-1.6-1.3-3.2-1.3a4.1 4.1 0 0 0-4.2 4.2c.1 2.4 1.8 4.2 4.2 4.2m-9.7 0c3 0 4.3-1.6 4.3-3.5 0-4.1-6.5-2.9-6.5-4.9.1-.8.8-1.4 1.9-1.4 1.2 0 2.4.4 3.2 1.3l1.1-1.5c-1-1-2.4-1.6-4.2-1.6-2.5 0-4.1 1.4-4.1 3.3 0 4.1 6.5 2.6 6.5 5 0 .8-.6 1.5-2.2 1.5s-2.8-.7-3.5-1.6l-1.1 1.5a6 6 0 0 0 4.6 1.9"/>
|
|
27
28
|
</svg>
|
|
28
29
|
</SiteHeader.Brand>,
|
|
29
|
-
<SiteHeader.Navigation>
|
|
30
|
+
<SiteHeader.Navigation key="2">
|
|
30
31
|
<SiteNavigation>
|
|
31
32
|
<SiteNavigation.Item href="#about">
|
|
32
33
|
About
|
|
@@ -51,10 +52,10 @@ const meta = {
|
|
|
51
52
|
</SiteNavigation.Item>
|
|
52
53
|
</SiteNavigation>
|
|
53
54
|
</SiteHeader.Navigation>,
|
|
54
|
-
<SiteHeader.Search>
|
|
55
|
+
<SiteHeader.Search key="3">
|
|
55
56
|
<SiteSearch id="site-header-search" />
|
|
56
57
|
</SiteHeader.Search>,
|
|
57
|
-
<SiteHeader.Phase>
|
|
58
|
+
<SiteHeader.Phase key="4">
|
|
58
59
|
<PhaseBanner phaseName="Beta">
|
|
59
60
|
This is a new service. Your{' '}
|
|
60
61
|
<a href="#feedback">
|
|
@@ -5,6 +5,17 @@ import SiteNavigation from '../SiteNavigation';
|
|
|
5
5
|
import SiteSearch from '../SiteSearch';
|
|
6
6
|
import PhaseBanner from '../PhaseBanner';
|
|
7
7
|
|
|
8
|
+
const NAVIGATION_ITEMS = (
|
|
9
|
+
<>
|
|
10
|
+
<SiteNavigation.Item href="#about">About</SiteNavigation.Item>
|
|
11
|
+
<SiteNavigation.Item href="#get-started">Get started</SiteNavigation.Item>
|
|
12
|
+
<SiteNavigation.Item href="#styles">Styles</SiteNavigation.Item>
|
|
13
|
+
<SiteNavigation.Item href="#components" isCurrent>Components</SiteNavigation.Item>
|
|
14
|
+
<SiteNavigation.Item href="#patterns">Patterns</SiteNavigation.Item>
|
|
15
|
+
<SiteNavigation.Item href="#guidance">Guidance</SiteNavigation.Item>
|
|
16
|
+
</>
|
|
17
|
+
);
|
|
18
|
+
|
|
8
19
|
test('site header renders correctly (maximal, testing markup structure)', () => {
|
|
9
20
|
render(
|
|
10
21
|
<SiteHeader>
|
|
@@ -13,12 +24,7 @@ test('site header renders correctly (maximal, testing markup structure)', () =>
|
|
|
13
24
|
</SiteHeader.Brand>
|
|
14
25
|
<SiteHeader.Navigation>
|
|
15
26
|
<SiteNavigation>
|
|
16
|
-
|
|
17
|
-
<SiteNavigation.Item href="#get-started">Get started</SiteNavigation.Item>
|
|
18
|
-
<SiteNavigation.Item href="#styles">Styles</SiteNavigation.Item>
|
|
19
|
-
<SiteNavigation.Item href="#components" current>Components</SiteNavigation.Item>
|
|
20
|
-
<SiteNavigation.Item href="#patterns">Patterns</SiteNavigation.Item>
|
|
21
|
-
<SiteNavigation.Item href="#guidance">Guidance</SiteNavigation.Item>
|
|
27
|
+
{NAVIGATION_ITEMS}
|
|
22
28
|
</SiteNavigation>
|
|
23
29
|
</SiteHeader.Navigation>
|
|
24
30
|
<SiteHeader.Search>
|
|
@@ -155,16 +161,7 @@ test('site header logo link link with custom element', () => {
|
|
|
155
161
|
});
|
|
156
162
|
|
|
157
163
|
test('site header with site navigation', () => {
|
|
158
|
-
|
|
159
|
-
<>
|
|
160
|
-
<SiteNavigation.Item href="#about">About</SiteNavigation.Item>
|
|
161
|
-
<SiteNavigation.Item href="#get-started">Get started</SiteNavigation.Item>
|
|
162
|
-
<SiteNavigation.Item href="#styles">Styles</SiteNavigation.Item>
|
|
163
|
-
<SiteNavigation.Item href="#components" current>Components</SiteNavigation.Item>
|
|
164
|
-
<SiteNavigation.Item href="#patterns">Patterns</SiteNavigation.Item>
|
|
165
|
-
<SiteNavigation.Item href="#guidance">Guidance</SiteNavigation.Item>
|
|
166
|
-
</>
|
|
167
|
-
);
|
|
164
|
+
|
|
168
165
|
|
|
169
166
|
render(
|
|
170
167
|
<>
|
|
@@ -240,6 +237,22 @@ test('site header with phase banner', () => {
|
|
|
240
237
|
expect(siteHeaderPhaseBanner?.innerHTML).toEqual(phaseBannerReference.innerHTML);
|
|
241
238
|
});
|
|
242
239
|
|
|
240
|
+
test('instantiating/initialising DS component script', () => {
|
|
241
|
+
render(
|
|
242
|
+
<SiteHeader>
|
|
243
|
+
<SiteHeader.Navigation>
|
|
244
|
+
<SiteNavigation>
|
|
245
|
+
{NAVIGATION_ITEMS}
|
|
246
|
+
</SiteNavigation>
|
|
247
|
+
</SiteHeader.Navigation>
|
|
248
|
+
</SiteHeader>
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
const mobileNav = screen.getAllByRole('navigation')[0];
|
|
252
|
+
expect(mobileNav).toHaveClass('js-initialised');
|
|
253
|
+
expect(mobileNav).toHaveClass('js-instantiated');
|
|
254
|
+
});
|
|
255
|
+
|
|
243
256
|
test('passing additional props', () => {
|
|
244
257
|
render(
|
|
245
258
|
<SiteHeader data-test="foo" />
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React, { Children, useEffect, useRef } from 'react';
|
|
2
2
|
import Icon from '../../common/Icon';
|
|
3
3
|
import SiteNavigation from '../SiteNavigation';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
4
|
import DSMobileMenu from '@scottish-government/design-system/src/components/site-navigation/site-navigation';
|
|
5
|
+
import { SiteHeaderBrandProps, SiteHeaderProps } from './types';
|
|
6
|
+
import { SiteNavigationProps } from '../SiteNavigation/types';
|
|
7
7
|
|
|
8
8
|
const Brand = ({
|
|
9
9
|
children,
|
|
10
10
|
homeUrl = '/',
|
|
11
11
|
linkComponent,
|
|
12
12
|
siteTitle
|
|
13
|
-
}:
|
|
13
|
+
}: SiteHeaderBrandProps) => {
|
|
14
14
|
function processChildren(children: React.ReactNode) {
|
|
15
15
|
const image = React.cloneElement(children as React.ReactElement<HTMLImageElement>, { className: 'ds_site-branding__logo-image' });
|
|
16
16
|
|
|
@@ -36,26 +36,26 @@ const Brand = ({
|
|
|
36
36
|
|
|
37
37
|
const Navigation = ({
|
|
38
38
|
children
|
|
39
|
-
}:
|
|
39
|
+
}: React.AllHTMLAttributes<HTMLElement>) => {
|
|
40
40
|
return children;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const Phase = ({
|
|
44
44
|
children
|
|
45
|
-
}:
|
|
45
|
+
}: React.AllHTMLAttributes<HTMLElement>) => {
|
|
46
46
|
return children;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const Search = ({
|
|
50
50
|
children
|
|
51
|
-
}:
|
|
51
|
+
}: React.AllHTMLAttributes<HTMLElement>) => {
|
|
52
52
|
return children;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const SiteHeader = ({
|
|
56
56
|
children,
|
|
57
57
|
...props
|
|
58
|
-
}:
|
|
58
|
+
}: SiteHeaderProps) => {
|
|
59
59
|
const mobileMenuRef = useRef(null);
|
|
60
60
|
|
|
61
61
|
let branding: React.ReactNode;
|
|
@@ -66,14 +66,14 @@ const SiteHeader = ({
|
|
|
66
66
|
|
|
67
67
|
// assign to slots
|
|
68
68
|
Children.forEach(children, (child: React.ReactNode) => {
|
|
69
|
-
const thisChild = child as React.
|
|
69
|
+
const thisChild = child as React.JSX.Element;
|
|
70
70
|
if (thisChild && thisChild.type === Brand) {
|
|
71
71
|
branding = thisChild;
|
|
72
72
|
} else if (thisChild && thisChild.type === Navigation) {
|
|
73
73
|
navigation = thisChild;
|
|
74
74
|
|
|
75
75
|
if (thisChild.props.children.type === SiteNavigation) {
|
|
76
|
-
mobileNavigation = React.cloneElement(thisChild.props.children as React.ReactElement<
|
|
76
|
+
mobileNavigation = React.cloneElement(thisChild.props.children as React.ReactElement<SiteNavigationProps>, { className: 'ds_site-navigation--mobile', id: 'mobile-navigation', ref: mobileMenuRef});
|
|
77
77
|
}
|
|
78
78
|
} else if (thisChild && thisChild.type === Phase) {
|
|
79
79
|
phase = thisChild;
|
|
@@ -83,6 +83,7 @@ const SiteHeader = ({
|
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
useEffect(() => {
|
|
86
|
+
/* istanbul ignore else */
|
|
86
87
|
if (mobileMenuRef.current) {
|
|
87
88
|
new DSMobileMenu(mobileMenuRef.current).init();
|
|
88
89
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LinkComponent } from "../../shared-types";
|
|
2
|
+
import { PhaseBannerProps } from "../PhaseBanner/types";
|
|
3
|
+
import { SiteNavigationItemProps } from "../SiteNavigation/types";
|
|
4
|
+
import { SiteSearchProps } from "../SiteSearch/types";
|
|
5
|
+
|
|
6
|
+
export interface SiteHeaderBrandProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
7
|
+
homeUrl: string;
|
|
8
|
+
linkComponent?: LinkComponent;
|
|
9
|
+
siteTitle?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SiteHeaderProps extends React.AllHTMLAttributes<HTMLHeadingElement> {
|
|
13
|
+
logo?: {
|
|
14
|
+
alt?: string;
|
|
15
|
+
href?: string;
|
|
16
|
+
src?: string;
|
|
17
|
+
};
|
|
18
|
+
navigationItems?: SiteNavigationItemProps[];
|
|
19
|
+
phaseBanner?: PhaseBannerProps;
|
|
20
|
+
siteSearch?: SiteSearchProps;
|
|
21
|
+
siteTitle?: string;
|
|
22
|
+
}
|
|
@@ -45,7 +45,7 @@ test('site navigation link renders correctly', () => {
|
|
|
45
45
|
expect(link).toHaveAttribute('href', LINK_HREF)
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
test('site navigation
|
|
48
|
+
test('site navigation item with custom link element', () => {
|
|
49
49
|
render(
|
|
50
50
|
<SiteNavigation.Item href={LINK_HREF} linkComponent={
|
|
51
51
|
({ className, ...props }) => (
|
|
@@ -62,6 +62,21 @@ test('site navigation link with custom element', () => {
|
|
|
62
62
|
expect(link?.textContent).toEqual(LINK_TEXT);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
test('site navigation item without href', () => {
|
|
66
|
+
render(
|
|
67
|
+
// @ts-expect-error required prop missing
|
|
68
|
+
<SiteNavigation.Item>
|
|
69
|
+
{LINK_TEXT}
|
|
70
|
+
</SiteNavigation.Item>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const item = screen.getByRole('listitem');
|
|
74
|
+
const link = within(item).queryByRole('link');
|
|
75
|
+
|
|
76
|
+
expect(link).not.toBeInTheDocument();
|
|
77
|
+
expect(item.textContent).toEqual(LINK_TEXT);
|
|
78
|
+
});
|
|
79
|
+
|
|
65
80
|
test('highlights current item', () => {
|
|
66
81
|
render(
|
|
67
82
|
<SiteNavigation.Item href={LINK_HREF} isCurrent>{LINK_TEXT}</SiteNavigation.Item>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { SiteNavigationItemProps, SiteNavigationProps } from "./types";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
|
|
1
4
|
const Item = ({
|
|
2
5
|
children,
|
|
3
6
|
isCurrent = false,
|
|
4
7
|
href,
|
|
5
8
|
linkComponent
|
|
6
|
-
}:
|
|
9
|
+
}: SiteNavigationItemProps) => {
|
|
7
10
|
const classNames = ['ds_site-navigation__link'];
|
|
8
11
|
let ariaCurrent: React.AriaAttributes["aria-current"];
|
|
9
12
|
|
|
@@ -12,11 +15,15 @@ const Item = ({
|
|
|
12
15
|
ariaCurrent = 'page';
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
const classNamesString = clsx(classNames);
|
|
19
|
+
|
|
15
20
|
function processChildren(children: React.ReactNode) {
|
|
16
21
|
if (linkComponent) {
|
|
17
|
-
return linkComponent({ className:
|
|
22
|
+
return linkComponent({ className: classNamesString, href, children });
|
|
18
23
|
} else if (href) {
|
|
19
|
-
return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={
|
|
24
|
+
return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNamesString}>{children}</a>;
|
|
25
|
+
} else {
|
|
26
|
+
return <span className={classNamesString}>{children}</span>;
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
29
|
|
|
@@ -33,13 +40,13 @@ const SiteNavigation = ({
|
|
|
33
40
|
children,
|
|
34
41
|
className,
|
|
35
42
|
...props
|
|
36
|
-
}:
|
|
43
|
+
}: SiteNavigationProps) => {
|
|
37
44
|
return (
|
|
38
45
|
<nav
|
|
39
|
-
className={[
|
|
46
|
+
className={clsx([
|
|
40
47
|
'ds_site-navigation',
|
|
41
48
|
className
|
|
42
|
-
]
|
|
49
|
+
])}
|
|
43
50
|
{...props}
|
|
44
51
|
>
|
|
45
52
|
<ul className="ds_site-navigation__list">
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LinkComponent } from '../../shared-types';
|
|
2
|
+
|
|
3
|
+
export interface SiteNavigationItemProps extends React.AllHTMLAttributes<HTMLLIElement> {
|
|
4
|
+
isCurrent?: boolean;
|
|
5
|
+
href: string;
|
|
6
|
+
linkComponent?: LinkComponent;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SiteNavigationProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
10
|
+
ref?: React.RefObject<null>;
|
|
11
|
+
}
|
|
@@ -11,8 +11,10 @@ type AutocompleteResponseObject = {
|
|
|
11
11
|
category: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
type SuggestionObject = { response: string };
|
|
15
|
+
|
|
16
|
+
const suggestionMappingFunction = function (suggestionObj: SuggestionObject) {
|
|
17
|
+
const responseObj = JSON.parse(suggestionObj.response).map((item: string) => ({
|
|
16
18
|
key: '',
|
|
17
19
|
displayText: item,
|
|
18
20
|
weight: '',
|
|
@@ -142,6 +142,28 @@ test('autocomplete', () => {
|
|
|
142
142
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
+
test('instantiating/initialising DS component script: autocomplete', () => {
|
|
146
|
+
render(
|
|
147
|
+
<SiteSearch autocompleteEndpoint="/endpoint" />
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const searchForm = screen.getByRole('search');
|
|
151
|
+
const searchFormContainer = searchForm.parentElement;
|
|
152
|
+
expect(searchFormContainer).toHaveClass('js-initialised');
|
|
153
|
+
expect(searchFormContainer).toHaveClass('js-instantiated');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('instantiating/initialising DS component script: no autocomplete', () => {
|
|
157
|
+
render(
|
|
158
|
+
<SiteSearch />
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const searchForm = screen.getByRole('search');
|
|
162
|
+
const searchFormContainer = searchForm.parentElement;
|
|
163
|
+
expect(searchFormContainer).not.toHaveClass('js-initialised');
|
|
164
|
+
expect(searchFormContainer).not.toHaveClass('js-instantiated');
|
|
165
|
+
});
|
|
166
|
+
|
|
145
167
|
test('passing additional props', () => {
|
|
146
168
|
render(
|
|
147
169
|
<SiteSearch data-test="foo" />
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
// @ts-ignore
|
|
3
2
|
import DSAutocomplete from '@scottish-government/design-system/src/components/autocomplete/autocomplete';
|
|
4
3
|
import Button from '../Button';
|
|
4
|
+
import { SiteSearchProps, SuggestionMappingFunctionProps } from './types';
|
|
5
|
+
import clsx from 'clsx';
|
|
5
6
|
|
|
6
7
|
const SiteSearch = function ({
|
|
7
8
|
action = '/search',
|
|
@@ -14,19 +15,20 @@ const SiteSearch = function ({
|
|
|
14
15
|
name = 'q',
|
|
15
16
|
placeholder = 'Search',
|
|
16
17
|
...props
|
|
17
|
-
}:
|
|
18
|
+
}: SiteSearchProps) {
|
|
18
19
|
const ref = useRef(null);
|
|
19
20
|
const hasAutocomplete = !!autocompleteEndpoint;
|
|
20
|
-
|
|
21
|
+
const autocompleteId = hasAutocomplete ? id + '-autocomplete' : '';
|
|
21
22
|
|
|
22
23
|
type AutoCompleteOptions = {
|
|
23
24
|
minLength?: number,
|
|
24
|
-
suggestionMappingFunction?:
|
|
25
|
+
suggestionMappingFunction?: SuggestionMappingFunctionProps,
|
|
25
26
|
throttleDelay?: number
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
useEffect(() => {
|
|
29
|
-
|
|
30
|
+
const autocompleteElement = document.getElementById(autocompleteId);
|
|
31
|
+
if (hasAutocomplete && autocompleteElement && ref.current) {
|
|
30
32
|
const options: AutoCompleteOptions = {};
|
|
31
33
|
if (minLength) {
|
|
32
34
|
options.minLength = minLength;
|
|
@@ -36,7 +38,7 @@ const SiteSearch = function ({
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
const autocomplete = new DSAutocomplete(
|
|
39
|
-
|
|
41
|
+
autocompleteElement,
|
|
40
42
|
autocompleteEndpoint,
|
|
41
43
|
options
|
|
42
44
|
);
|
|
@@ -47,11 +49,11 @@ const SiteSearch = function ({
|
|
|
47
49
|
|
|
48
50
|
return (
|
|
49
51
|
<div
|
|
50
|
-
className={[
|
|
51
|
-
'ds_site-search',
|
|
52
|
+
className={clsx([
|
|
53
|
+
'ds_site-search',
|
|
52
54
|
className,
|
|
53
|
-
hasAutocomplete
|
|
54
|
-
]
|
|
55
|
+
hasAutocomplete && 'ds_autocomplete'
|
|
56
|
+
])}
|
|
55
57
|
id={autocompleteId ? autocompleteId : undefined}
|
|
56
58
|
ref={ref}
|
|
57
59
|
{...props}
|
|
@@ -68,11 +70,11 @@ const SiteSearch = function ({
|
|
|
68
70
|
<input aria-autocomplete={hasAutocomplete ? 'list' : undefined}
|
|
69
71
|
aria-owns={hasAutocomplete ? 'autocomplete-suggestions' : undefined}
|
|
70
72
|
autoComplete={hasAutocomplete ? 'off' : undefined}
|
|
71
|
-
className={[
|
|
73
|
+
className={clsx([
|
|
72
74
|
'ds_input',
|
|
73
75
|
'ds_site-search__input',
|
|
74
|
-
hasAutocomplete
|
|
75
|
-
]
|
|
76
|
+
hasAutocomplete && 'js-autocomplete-input'
|
|
77
|
+
])}
|
|
76
78
|
id={id}
|
|
77
79
|
name={name}
|
|
78
80
|
placeholder={placeholder}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type FormMethods = 'GET' | 'POST';
|
|
2
|
+
|
|
3
|
+
export type Suggestion = {
|
|
4
|
+
displayText: string;
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type SuggestionMappingFunctionProps = (suggestions: object[]) => Suggestion[];
|
|
9
|
+
|
|
10
|
+
export interface SiteSearchProps extends React.AllHTMLAttributes<HTMLInputElement> {
|
|
11
|
+
action?: string;
|
|
12
|
+
autocompleteEndpoint?: string;
|
|
13
|
+
autocompleteSuggestionMappingFunction?: SuggestionMappingFunctionProps;
|
|
14
|
+
id: string;
|
|
15
|
+
method?: FormMethods;
|
|
16
|
+
minLength?: number;
|
|
17
|
+
name?: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
}
|
|
@@ -8,16 +8,16 @@ const meta = {
|
|
|
8
8
|
component: SkipLinks,
|
|
9
9
|
argTypes: {
|
|
10
10
|
mainContentId: {
|
|
11
|
-
description: 'The id attribute of the
|
|
11
|
+
description: 'The id attribute of the \'main content\' element to link to',
|
|
12
12
|
type: 'string'
|
|
13
13
|
},
|
|
14
14
|
mainLinkText: {
|
|
15
|
-
description: 'The text to use for the
|
|
15
|
+
description: 'The text to use for the \'main content\' link',
|
|
16
16
|
type: 'string'
|
|
17
17
|
},
|
|
18
18
|
isStatic: {
|
|
19
19
|
control: 'boolean',
|
|
20
|
-
description: 'Use the
|
|
20
|
+
description: 'Use the \'static\' display variant'
|
|
21
21
|
},
|
|
22
22
|
children: argTypes.children()
|
|
23
23
|
},
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
// @ts-ignore
|
|
4
2
|
import dsSkipLinks from '@scottish-government/design-system/src/components/skip-links/skip-links';
|
|
3
|
+
import { SkipLinksLinkProps, SkipLinksProps } from './types';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
const Link = ({
|
|
7
7
|
children,
|
|
8
8
|
fragmentId
|
|
9
|
-
}:
|
|
9
|
+
}: SkipLinksLinkProps) => {
|
|
10
10
|
return (
|
|
11
11
|
<li
|
|
12
12
|
className="ds_skip-links__item"
|
|
@@ -22,7 +22,7 @@ const SkipLinks = ({
|
|
|
22
22
|
mainLinkText = 'Skip to main content',
|
|
23
23
|
isStatic,
|
|
24
24
|
...props
|
|
25
|
-
}:
|
|
25
|
+
}: SkipLinksProps) => {
|
|
26
26
|
|
|
27
27
|
useEffect(() => {
|
|
28
28
|
dsSkipLinks.init();
|
|
@@ -30,10 +30,10 @@ const SkipLinks = ({
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<div
|
|
33
|
-
className={[
|
|
33
|
+
className={clsx([
|
|
34
34
|
'ds_skip-links',
|
|
35
|
-
isStatic && 'ds_skip-links--static'
|
|
36
|
-
]
|
|
35
|
+
isStatic && 'ds_skip-links--static'
|
|
36
|
+
])}
|
|
37
37
|
{...props}
|
|
38
38
|
>
|
|
39
39
|
<ul className="ds_skip-links__list">
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SkipLinksLinkProps extends React.AllHTMLAttributes<HTMLLIElement> {
|
|
2
|
+
fragmentId: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface SkipLinksProps extends React.AllHTMLAttributes<HTMLDivElement> {
|
|
6
|
+
mainContentId?: string;
|
|
7
|
+
mainLinkText?: string;
|
|
8
|
+
isStatic?: boolean;
|
|
9
|
+
}
|
|
@@ -16,17 +16,6 @@ const ACTIONS = [
|
|
|
16
16
|
}
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
-
const ITEMS = [
|
|
20
|
-
{
|
|
21
|
-
title: 'Phone number',
|
|
22
|
-
value: '0123 456 7890'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
title: 'Address',
|
|
26
|
-
value: `Victoria Quay\nEdinburgh\nEH6 6QQ`
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
|
|
30
19
|
const TITLE_TEXT = 'Joe Bloggs';
|
|
31
20
|
|
|
32
21
|
test('summary card renders correctly', () => {
|
|
@@ -3,6 +3,9 @@ import React, { Children, useId } from 'react';
|
|
|
3
3
|
import ActionLink from '../../common/ActionLink';
|
|
4
4
|
import ConditionalWrapper from '../../common/ConditionalWrapper';
|
|
5
5
|
import WrapperTag from "../../common/WrapperTag";
|
|
6
|
+
import { SummaryCardProps } from './types';
|
|
7
|
+
import { ActionLinkProps } from '../../common/ActionLink/types';
|
|
8
|
+
import clsx from 'clsx';
|
|
6
9
|
|
|
7
10
|
const SummaryCard = ({
|
|
8
11
|
children,
|
|
@@ -10,14 +13,14 @@ const SummaryCard = ({
|
|
|
10
13
|
headingLevel = 'h3',
|
|
11
14
|
title,
|
|
12
15
|
...props
|
|
13
|
-
}:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
}: SummaryCardProps) => {
|
|
17
|
+
const actions: React.ReactElement[] = [];
|
|
18
|
+
const remainingChildren: React.ReactElement[] = [];
|
|
16
19
|
|
|
17
20
|
const describedById = useId();
|
|
18
21
|
|
|
19
22
|
Children.forEach(children, (child: React.ReactNode) => {
|
|
20
|
-
const thisChild = child as React.ReactElement<
|
|
23
|
+
const thisChild = child as React.ReactElement<ActionLinkProps>;
|
|
21
24
|
if (thisChild && thisChild.type === ActionLink) {
|
|
22
25
|
actions.push(React.cloneElement(thisChild, { describedby: describedById }));
|
|
23
26
|
} else {
|
|
@@ -27,10 +30,10 @@ const SummaryCard = ({
|
|
|
27
30
|
|
|
28
31
|
return (
|
|
29
32
|
<div
|
|
30
|
-
className={[
|
|
33
|
+
className={clsx([
|
|
31
34
|
'ds_summary-card',
|
|
32
35
|
className
|
|
33
|
-
]
|
|
36
|
+
])}
|
|
34
37
|
{...props}
|
|
35
38
|
>
|
|
36
39
|
<div className="ds_summary-card__header">
|
|
@@ -14,7 +14,7 @@ const meta = {
|
|
|
14
14
|
)
|
|
15
15
|
],
|
|
16
16
|
argTypes: {
|
|
17
|
-
|
|
17
|
+
title: {
|
|
18
18
|
description: 'Title of the summary list item.',
|
|
19
19
|
type: {
|
|
20
20
|
name: 'string',
|
|
@@ -26,16 +26,16 @@ const meta = {
|
|
|
26
26
|
args: {
|
|
27
27
|
title: 'Contact details',
|
|
28
28
|
children: [
|
|
29
|
-
<SummaryList.Value name="Email">
|
|
29
|
+
<SummaryList.Value name="Email" key="1">
|
|
30
30
|
email@gov.scot
|
|
31
31
|
</SummaryList.Value>,
|
|
32
|
-
<SummaryList.Value name="Telephone">
|
|
32
|
+
<SummaryList.Value name="Telephone" key="2">
|
|
33
33
|
0123 456 7890
|
|
34
34
|
</SummaryList.Value>,
|
|
35
|
-
<SummaryList.Action href="foo">
|
|
35
|
+
<SummaryList.Action href="foo" key="3">
|
|
36
36
|
Change
|
|
37
37
|
</SummaryList.Action>,
|
|
38
|
-
<SummaryList.Action onclick={function w(){}}>
|
|
38
|
+
<SummaryList.Action onclick={function w(){}} key="4">
|
|
39
39
|
Delete
|
|
40
40
|
</SummaryList.Action>
|
|
41
41
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test, expect, vi } from 'vitest';
|
|
2
|
-
import { within, render, screen
|
|
2
|
+
import { within, render, screen } from '@testing-library/react';
|
|
3
3
|
import SummaryList from './SummaryList';
|
|
4
4
|
|
|
5
5
|
const ONCLICK_FUNCTION = vi.fn();
|
|
@@ -7,11 +7,6 @@ const TITLE = 'Name';
|
|
|
7
7
|
const VALUE_1 = 'Jane Smith';
|
|
8
8
|
const VALUE_2 = 'Tony Brown';
|
|
9
9
|
|
|
10
|
-
const ACTION_HREF = "#foo"
|
|
11
|
-
const ACTION_ONCLICK = ONCLICK_FUNCTION;
|
|
12
|
-
const ACTION_TEXT = 'Name';
|
|
13
|
-
const DESCRIBEDBY_ID = 'q1-name';
|
|
14
|
-
|
|
15
10
|
test('summary list renders correctly', () => {
|
|
16
11
|
render(
|
|
17
12
|
<SummaryList data-testid="summarylist">
|