@scottish-government/designsystem-react 0.13.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/sgdsArgTypes.ts +23 -0
- package/CHANGELOG.md +23 -0
- package/LICENSE.txt +21 -0
- package/README.md +4 -5
- 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/dist/index.d.ts +4 -0
- package/dist/index.js +40 -0
- package/dist/shared-types.d.ts +35 -0
- package/dist/shared-types.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +5 -3
- package/src/common/AbstractNotificationBanner/AbstractNotificationBanner.tsx +8 -6
- package/src/common/Icon/Icon.tsx +3 -2
- package/src/components/Accordion/Accordion.test.tsx +11 -0
- package/src/components/Accordion/Accordion.tsx +11 -10
- package/src/components/AspectBox/AspectBox.tsx +4 -11
- package/src/components/BackToTop/BackToTop.test.tsx +21 -1
- package/src/components/BackToTop/BackToTop.tsx +4 -3
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +3 -2
- package/src/components/Button/Button.tsx +4 -3
- package/src/components/Button/ButtonGroup.stories.tsx +22 -0
- package/src/components/Button/ButtonGroup.test.tsx +21 -0
- package/src/components/Button/ButtonGroup.tsx +6 -3
- package/src/components/Button/types.ts +1 -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 +3 -2
- package/src/components/CategoryList/CategoryList.tsx +3 -2
- package/src/components/Checkbox/Checkbox.test.tsx +30 -0
- package/src/components/Checkbox/Checkbox.tsx +3 -3
- package/src/components/Checkbox/CheckboxGroup.test.tsx +10 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +5 -4
- package/src/components/ConfirmationMessage/ConfirmationMessage.tsx +3 -2
- package/src/components/ContentsNav/ContentsNav.tsx +8 -5
- package/src/components/CookieBanner/CookieBanner.test.tsx +18 -1
- package/src/components/CookieBanner/CookieBanner.tsx +5 -4
- package/src/components/DatePicker/DatePicker.test.tsx +52 -14
- package/src/components/DatePicker/DatePicker.tsx +6 -7
- package/src/components/DatePicker/types.ts +2 -3
- package/src/components/Details/Details.tsx +3 -2
- package/src/components/ErrorMessage/ErrorMessage.tsx +3 -2
- package/src/components/ErrorSummary/ErrorSummary.tsx +3 -2
- package/src/components/FeatureHeader/FeatureHeader.stories.tsx +223 -0
- package/src/components/FeatureHeader/FeatureHeader.test.tsx +298 -0
- package/src/components/FeatureHeader/FeatureHeader.tsx +119 -0
- package/src/components/FeatureHeader/index.ts +1 -0
- package/src/components/FeatureHeader/types.ts +13 -0
- package/src/components/FileDownload/FileDownload.test.tsx +1 -5
- package/src/components/FileDownload/FileDownload.tsx +4 -3
- package/src/components/HideThisPage/HideThisPage.test.tsx +12 -1
- package/src/components/HideThisPage/HideThisPage.tsx +5 -4
- package/src/components/InsetText/InsetText.tsx +4 -2
- package/src/components/NotificationBanner/NotificationBanner.test.tsx +10 -0
- package/src/components/NotificationBanner/NotificationBanner.tsx +4 -3
- package/src/components/NotificationPanel/NotificationPanel.tsx +3 -2
- 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 +3 -2
- package/src/components/PageMetadata/PageMetadata.tsx +5 -4
- package/src/components/Pagination/Pagination.test.tsx +20 -0
- package/src/components/Pagination/Pagination.tsx +7 -5
- package/src/components/PhaseBanner/PhaseBanner.tsx +3 -2
- package/src/components/Question/Question.tsx +3 -2
- package/src/components/Question/types.ts +2 -2
- package/src/components/RadioButton/RadioButton.test.tsx +30 -0
- package/src/components/RadioButton/RadioButton.tsx +3 -3
- package/src/components/RadioButton/RadioGroup.tsx +3 -2
- package/src/components/SearchFacets/SearchFacets.stories.tsx +1 -1
- package/src/components/SearchFacets/SearchFacets.tsx +3 -2
- package/src/components/SearchResult/SearchResult.stories.tsx +14 -13
- package/src/components/SearchResult/SearchResult.test.tsx +5 -4
- package/src/components/SearchResult/SearchResult.tsx +6 -7
- package/src/components/SearchSort/SearchSort.tsx +3 -2
- package/src/components/Select/Select.test.tsx +42 -0
- package/src/components/Select/Select.tsx +3 -2
- package/src/components/SequentialNavigation/SequentialNavigation.tsx +7 -6
- package/src/components/SideNavigation/SideNavigation.test.tsx +24 -0
- package/src/components/SideNavigation/SideNavigation.tsx +10 -7
- package/src/components/SiteFooter/SiteFooter.tsx +3 -2
- package/src/components/SiteHeader/SiteHeader.test.tsx +29 -16
- package/src/components/SiteHeader/SiteHeader.tsx +1 -1
- package/src/components/SiteNavigation/SiteNavigation.test.tsx +16 -1
- package/src/components/SiteNavigation/SiteNavigation.tsx +9 -4
- package/src/components/SiteSearch/SiteSearch.test.tsx +22 -0
- package/src/components/SiteSearch/SiteSearch.tsx +10 -9
- package/src/components/SiteSearch/types.ts +7 -1
- package/src/components/SkipLinks/SkipLinks.tsx +4 -4
- package/src/components/SummaryCard/SummaryCard.tsx +3 -2
- package/src/components/SummaryList/SummaryList.tsx +4 -4
- package/src/components/Table/Table.test.tsx +36 -0
- package/src/components/Table/Table.tsx +5 -4
- package/src/components/Tabs/Tabs.test.tsx +14 -0
- package/src/components/Tabs/Tabs.tsx +6 -5
- package/src/components/Tag/Tag.tsx +4 -3
- package/src/components/TaskList/TaskList.tsx +5 -4
- package/src/components/TextInput/TextInput.test.tsx +53 -1
- package/src/components/TextInput/TextInput.tsx +12 -7
- package/src/components/Textarea/Textarea.test.tsx +53 -1
- package/src/components/Textarea/Textarea.tsx +5 -4
- package/src/components/WarningText/WarningText.tsx +4 -2
- 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 +3 -3
- package/static/images/illustration.svg +502 -0
- package/tsconfig.json +0 -3
- package/vite.config.ts +4 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { test, expect, describe } from 'vitest';
|
|
2
|
+
import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
import FeatureHeader from './FeatureHeader';
|
|
4
|
+
|
|
5
|
+
const TITLE_TEXT = 'Design and build accessible digital services for Scotland';
|
|
6
|
+
|
|
7
|
+
describe('feature header', () => {
|
|
8
|
+
test('feature header renders correctly', () => {
|
|
9
|
+
render(
|
|
10
|
+
<FeatureHeader data-testid="feature-header">
|
|
11
|
+
<FeatureHeader.Primary
|
|
12
|
+
data-testid="feature-header-primary"
|
|
13
|
+
title={TITLE_TEXT}
|
|
14
|
+
>
|
|
15
|
+
</FeatureHeader.Primary>
|
|
16
|
+
<FeatureHeader.Secondary data-testid="feature-header-secondary">
|
|
17
|
+
<img src="foo" data-testid="feature-header-image" />
|
|
18
|
+
</FeatureHeader.Secondary>
|
|
19
|
+
</FeatureHeader>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
23
|
+
const featureHeaderPrimaryElement = screen.getByTestId('feature-header-primary');
|
|
24
|
+
const featureHeaderSecondaryElement = screen.getByTestId('feature-header-secondary');
|
|
25
|
+
const featureHeaderTitleElement = within(featureHeaderPrimaryElement).getByRole('heading');
|
|
26
|
+
const featureHeaderImageElement = screen.getByTestId('feature-header-image');
|
|
27
|
+
|
|
28
|
+
expect(featureHeaderElement).toHaveClass('ds_feature-header');
|
|
29
|
+
expect(featureHeaderElement.tagName).toEqual('DIV');
|
|
30
|
+
|
|
31
|
+
expect(featureHeaderPrimaryElement).toHaveClass('ds_feature-header__primary');
|
|
32
|
+
expect(featureHeaderPrimaryElement.tagName).toEqual('DIV');
|
|
33
|
+
expect(featureHeaderPrimaryElement.parentElement).toEqual(featureHeaderElement);
|
|
34
|
+
|
|
35
|
+
expect(featureHeaderSecondaryElement).toHaveClass('ds_feature-header__secondary');
|
|
36
|
+
expect(featureHeaderSecondaryElement.tagName).toEqual('DIV');
|
|
37
|
+
expect(featureHeaderSecondaryElement.parentElement).toEqual(featureHeaderElement);
|
|
38
|
+
expect(featureHeaderSecondaryElement.previousElementSibling).toEqual(featureHeaderPrimaryElement);
|
|
39
|
+
|
|
40
|
+
expect(featureHeaderTitleElement).toHaveClass('ds_feature-header__title');
|
|
41
|
+
expect(featureHeaderTitleElement.tagName).toEqual('H1');
|
|
42
|
+
expect(featureHeaderTitleElement.textContent).toEqual(TITLE_TEXT);
|
|
43
|
+
|
|
44
|
+
expect(featureHeaderImageElement).toHaveClass('ds_feature-header__image');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('image CSS class added to svg element correctly', () => {
|
|
48
|
+
render(
|
|
49
|
+
<FeatureHeader data-testid="feature-header">
|
|
50
|
+
<FeatureHeader.Primary
|
|
51
|
+
data-testid="feature-header-primary"
|
|
52
|
+
title={TITLE_TEXT}
|
|
53
|
+
>
|
|
54
|
+
</FeatureHeader.Primary>
|
|
55
|
+
<FeatureHeader.Secondary data-testid="feature-header-secondary">
|
|
56
|
+
<svg version="1.1"
|
|
57
|
+
data-testid="feature-header-image"
|
|
58
|
+
width="300"
|
|
59
|
+
height="200"
|
|
60
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
61
|
+
</svg>
|
|
62
|
+
</FeatureHeader.Secondary>
|
|
63
|
+
</FeatureHeader>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const featureHeaderImageElement = screen.getByTestId('feature-header-image');
|
|
67
|
+
|
|
68
|
+
expect(featureHeaderImageElement).toHaveClass('ds_feature-header__image');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('image CSS class added to picture element correctly', () => {
|
|
72
|
+
render(
|
|
73
|
+
<FeatureHeader data-testid="feature-header">
|
|
74
|
+
<FeatureHeader.Primary
|
|
75
|
+
data-testid="feature-header-primary"
|
|
76
|
+
title={TITLE_TEXT}
|
|
77
|
+
>
|
|
78
|
+
</FeatureHeader.Primary>
|
|
79
|
+
<FeatureHeader.Secondary data-testid="feature-header-secondary">
|
|
80
|
+
<picture data-testid="feature-header-image">
|
|
81
|
+
</picture>
|
|
82
|
+
</FeatureHeader.Secondary>
|
|
83
|
+
</FeatureHeader>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const featureHeaderImageElement = screen.getByTestId('feature-header-image');
|
|
87
|
+
|
|
88
|
+
expect(featureHeaderImageElement).toHaveClass('ds_feature-header__image');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('image CSS class NOT added to other elements in Secondary', () => {
|
|
92
|
+
render(
|
|
93
|
+
<FeatureHeader data-testid="feature-header">
|
|
94
|
+
<FeatureHeader.Primary
|
|
95
|
+
data-testid="feature-header-primary"
|
|
96
|
+
title={TITLE_TEXT}
|
|
97
|
+
>
|
|
98
|
+
</FeatureHeader.Primary>
|
|
99
|
+
<FeatureHeader.Secondary data-testid="feature-header-secondary">
|
|
100
|
+
<p data-testid="feature-header-non-image">
|
|
101
|
+
</p>
|
|
102
|
+
</FeatureHeader.Secondary>
|
|
103
|
+
</FeatureHeader>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const featureHeaderNonImageElement = screen.getByTestId('feature-header-non-image');
|
|
107
|
+
|
|
108
|
+
expect(featureHeaderNonImageElement).not.toHaveClass('ds_feature-header__image');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('ds_wrapper class included when full width', () => {
|
|
112
|
+
render(
|
|
113
|
+
<FeatureHeader
|
|
114
|
+
data-testid="feature-header"
|
|
115
|
+
isFullWidth
|
|
116
|
+
>
|
|
117
|
+
<FeatureHeader.Primary
|
|
118
|
+
data-testid="feature-header-primary"
|
|
119
|
+
title={TITLE_TEXT}
|
|
120
|
+
>
|
|
121
|
+
</FeatureHeader.Primary>
|
|
122
|
+
<FeatureHeader.Secondary data-testid="feature-header-secondary">
|
|
123
|
+
<img src="foo" data-testid="feature-header-image" />
|
|
124
|
+
</FeatureHeader.Secondary>
|
|
125
|
+
</FeatureHeader>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
129
|
+
const featureHeaderPrimaryElement = screen.getByTestId('feature-header-primary');
|
|
130
|
+
const featureHeaderSecondaryElement = screen.getByTestId('feature-header-secondary');
|
|
131
|
+
|
|
132
|
+
const featureHeaderWrapperElement = featureHeaderElement.querySelector('.ds_wrapper');
|
|
133
|
+
|
|
134
|
+
expect(featureHeaderWrapperElement).toBeInTheDocument();
|
|
135
|
+
expect(featureHeaderWrapperElement?.parentElement).toEqual(featureHeaderElement);
|
|
136
|
+
expect(featureHeaderPrimaryElement.parentElement).toEqual(featureHeaderWrapperElement);
|
|
137
|
+
expect(featureHeaderSecondaryElement.parentElement).toEqual(featureHeaderWrapperElement);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('feature header has correct CSS class for secondary background', () => {
|
|
141
|
+
render(
|
|
142
|
+
<FeatureHeader
|
|
143
|
+
data-testid="feature-header"
|
|
144
|
+
backgroundColor="secondary"
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
149
|
+
|
|
150
|
+
expect(featureHeaderElement).toHaveClass('ds_feature-header--background-secondary');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('feature header has correct CSS class for tertiary background', () => {
|
|
154
|
+
render(
|
|
155
|
+
<FeatureHeader
|
|
156
|
+
data-testid="feature-header"
|
|
157
|
+
backgroundColor="tertiary"
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
162
|
+
|
|
163
|
+
expect(featureHeaderElement).toHaveClass('ds_feature-header--background-tertiary');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('feature header has correct CSS class for brand background', () => {
|
|
167
|
+
render(
|
|
168
|
+
<FeatureHeader
|
|
169
|
+
data-testid="feature-header"
|
|
170
|
+
backgroundColor="brand"
|
|
171
|
+
/>
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
175
|
+
|
|
176
|
+
expect(featureHeaderElement).toHaveClass('ds_feature-header--background');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('feature header does nothing with unrecognised background colours', () => {
|
|
180
|
+
render(
|
|
181
|
+
<FeatureHeader
|
|
182
|
+
data-testid="feature-header"
|
|
183
|
+
// @ts-expect-error deliberately invalid value
|
|
184
|
+
backgroundColor="foo"
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
189
|
+
const cleanedClass = featureHeaderElement.getAttribute('class')?.trim().replace(/\s+/g, ' ');
|
|
190
|
+
|
|
191
|
+
expect(cleanedClass).toEqual('ds_feature-header');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test('feature header as HEADER element', () => {
|
|
195
|
+
render(
|
|
196
|
+
<FeatureHeader
|
|
197
|
+
data-testid="feature-header"
|
|
198
|
+
tagName="header"
|
|
199
|
+
/>
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
203
|
+
|
|
204
|
+
expect(featureHeaderElement.tagName).toEqual('HEADER');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('feature header with wide text', () => {
|
|
208
|
+
render(
|
|
209
|
+
<FeatureHeader
|
|
210
|
+
data-testid="feature-header"
|
|
211
|
+
isWideText
|
|
212
|
+
/>
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
216
|
+
|
|
217
|
+
expect(featureHeaderElement).toHaveClass('ds_feature-header--wide');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test('feature header with top aligned image', () => {
|
|
221
|
+
render(
|
|
222
|
+
<FeatureHeader
|
|
223
|
+
data-testid="feature-header"
|
|
224
|
+
isTopAlignImage
|
|
225
|
+
/>
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
229
|
+
|
|
230
|
+
expect(featureHeaderElement).toHaveClass('ds_feature-header--top');
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test('feature header with cover image', () => {
|
|
234
|
+
render(
|
|
235
|
+
<FeatureHeader
|
|
236
|
+
data-testid="feature-header"
|
|
237
|
+
hasCoverImage
|
|
238
|
+
>
|
|
239
|
+
<FeatureHeader.Primary
|
|
240
|
+
data-testid="feature-header-primary"
|
|
241
|
+
title={TITLE_TEXT}
|
|
242
|
+
>
|
|
243
|
+
</FeatureHeader.Primary>
|
|
244
|
+
<FeatureHeader.Secondary data-testid="feature-header-secondary">
|
|
245
|
+
<img src="foo" data-testid="feature-header-image" />
|
|
246
|
+
</FeatureHeader.Secondary>
|
|
247
|
+
</FeatureHeader>
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const featureHeaderSecondaryElement = screen.getByTestId('feature-header-secondary');
|
|
251
|
+
|
|
252
|
+
expect(featureHeaderSecondaryElement).toHaveClass('ds_feature-header__secondary--cover');
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test('feature header with no image padding', () => {
|
|
256
|
+
render(
|
|
257
|
+
<FeatureHeader
|
|
258
|
+
data-testid="feature-header"
|
|
259
|
+
hasNoImagePadding
|
|
260
|
+
>
|
|
261
|
+
<FeatureHeader.Primary
|
|
262
|
+
data-testid="feature-header-primary"
|
|
263
|
+
title={TITLE_TEXT}
|
|
264
|
+
>
|
|
265
|
+
</FeatureHeader.Primary>
|
|
266
|
+
<FeatureHeader.Secondary data-testid="feature-header-secondary">
|
|
267
|
+
<img src="foo" data-testid="feature-header-image" />
|
|
268
|
+
</FeatureHeader.Secondary>
|
|
269
|
+
</FeatureHeader>
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const featureHeaderSecondaryElement = screen.getByTestId('feature-header-secondary');
|
|
273
|
+
|
|
274
|
+
expect(featureHeaderSecondaryElement).toHaveClass('ds_feature-header__secondary--no-padding');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test('passing additional props', () => {
|
|
278
|
+
render(
|
|
279
|
+
<FeatureHeader data-testid="feature-header"
|
|
280
|
+
data-test="foo"
|
|
281
|
+
/>
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
285
|
+
expect(featureHeaderElement?.dataset.test).toEqual('foo');
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
test('passing additional CSS classes', () => {
|
|
289
|
+
render(
|
|
290
|
+
<FeatureHeader data-testid="feature-header"
|
|
291
|
+
className="foo"
|
|
292
|
+
/>
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const featureHeaderElement = screen.getByTestId('feature-header');
|
|
296
|
+
expect(featureHeaderElement).toHaveClass('foo');
|
|
297
|
+
});
|
|
298
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { Children, createContext, useContext } from 'react';
|
|
2
|
+
import { FeatureHeaderProps, FeatureHeaderPrimaryProps } from './types';
|
|
3
|
+
import { ConditionalWrapper, WrapperTag } from '../../common';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
6
|
+
type FeatureHeaderSettingsContextProps = {
|
|
7
|
+
hasCoverImage?: boolean,
|
|
8
|
+
hasNoImagePadding?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const FeatureHeaderSettingsContext = createContext<FeatureHeaderSettingsContextProps>({
|
|
12
|
+
hasCoverImage: undefined,
|
|
13
|
+
hasNoImagePadding: undefined
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const Primary = ({
|
|
17
|
+
children,
|
|
18
|
+
title,
|
|
19
|
+
...props
|
|
20
|
+
}: FeatureHeaderPrimaryProps) => {
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
className="ds_feature-header__primary"
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
<h1 className="ds_feature-header__title">
|
|
27
|
+
{title}
|
|
28
|
+
</h1>
|
|
29
|
+
{children}
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const Secondary = ({
|
|
35
|
+
children,
|
|
36
|
+
...props
|
|
37
|
+
}: React.AllHTMLAttributes<HTMLDivElement>) => {
|
|
38
|
+
const hasCoverImage = useContext(FeatureHeaderSettingsContext).hasCoverImage;
|
|
39
|
+
const hasNoImagePadding = useContext(FeatureHeaderSettingsContext).hasNoImagePadding;
|
|
40
|
+
|
|
41
|
+
children = Children.map(children, child => {
|
|
42
|
+
const thisChild = child as React.ReactElement<HTMLElement>;
|
|
43
|
+
if (thisChild && ['img', 'svg', 'picture'].includes(thisChild.type as string)) {
|
|
44
|
+
return React.cloneElement(thisChild, { className: 'ds_feature-header__image' });
|
|
45
|
+
} else {
|
|
46
|
+
return child;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className={clsx([
|
|
52
|
+
'ds_feature-header__secondary',
|
|
53
|
+
hasCoverImage && 'ds_feature-header__secondary--cover',
|
|
54
|
+
hasNoImagePadding && 'ds_feature-header__secondary--no-padding'
|
|
55
|
+
])}
|
|
56
|
+
{...props}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const FeatureHeader = ({
|
|
64
|
+
backgroundColor,
|
|
65
|
+
children,
|
|
66
|
+
className,
|
|
67
|
+
hasCoverImage,
|
|
68
|
+
hasNoImagePadding,
|
|
69
|
+
id,
|
|
70
|
+
isFullWidth,
|
|
71
|
+
isWideText,
|
|
72
|
+
isTopAlignImage,
|
|
73
|
+
tagName = 'div',
|
|
74
|
+
...props
|
|
75
|
+
}: FeatureHeaderProps) => {
|
|
76
|
+
let backgroundColorClassName;
|
|
77
|
+
if (backgroundColor === 'secondary') {
|
|
78
|
+
backgroundColorClassName = 'ds_feature-header--background-secondary';
|
|
79
|
+
} else if (backgroundColor === 'tertiary') {
|
|
80
|
+
backgroundColorClassName = 'ds_feature-header--background-tertiary';
|
|
81
|
+
} else if (backgroundColor === 'brand') {
|
|
82
|
+
backgroundColorClassName = 'ds_feature-header--background';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<WrapperTag
|
|
87
|
+
className={clsx([
|
|
88
|
+
'ds_feature-header',
|
|
89
|
+
isFullWidth && 'ds_feature-header--fullwidth',
|
|
90
|
+
isWideText && 'ds_feature-header--wide',
|
|
91
|
+
isTopAlignImage && 'ds_feature-header--top',
|
|
92
|
+
backgroundColorClassName && backgroundColorClassName,
|
|
93
|
+
className
|
|
94
|
+
])}
|
|
95
|
+
id={id}
|
|
96
|
+
tagName={tagName}
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
<ConditionalWrapper
|
|
100
|
+
condition={!!isFullWidth}
|
|
101
|
+
wrapper={(children: React.JSX.Element) => <div className="ds_wrapper">{children}</div>}
|
|
102
|
+
>
|
|
103
|
+
<FeatureHeaderSettingsContext value={{
|
|
104
|
+
hasCoverImage, hasNoImagePadding
|
|
105
|
+
}}>
|
|
106
|
+
{children}
|
|
107
|
+
</FeatureHeaderSettingsContext>
|
|
108
|
+
</ConditionalWrapper>
|
|
109
|
+
</WrapperTag>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
FeatureHeader.displayName = 'FeatureHeader';
|
|
114
|
+
Primary.displayName = 'FeatureHeader.Primary';
|
|
115
|
+
Secondary.displayName = 'FeatureHeader.Secondary';
|
|
116
|
+
FeatureHeader.Primary = Primary;
|
|
117
|
+
FeatureHeader.Secondary = Secondary;
|
|
118
|
+
|
|
119
|
+
export default FeatureHeader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './FeatureHeader';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface FeatureHeaderPrimaryProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
2
|
+
title: string
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface FeatureHeaderProps extends React.AllHTMLAttributes<HTMLElement> {
|
|
6
|
+
backgroundColor?: 'secondary' | 'tertiary' | 'brand'
|
|
7
|
+
hasCoverImage?: boolean
|
|
8
|
+
hasNoImagePadding?: boolean
|
|
9
|
+
isFullWidth?: boolean
|
|
10
|
+
isWideText?: boolean
|
|
11
|
+
isTopAlignImage?: boolean
|
|
12
|
+
tagName?: 'div' | 'header'
|
|
13
|
+
}
|
|
@@ -53,10 +53,6 @@ test('highlighted file download', () => {
|
|
|
53
53
|
expect(fileDownload).toHaveClass('ds_file-download--highlighted');
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
// test('file download with specific icon', () => {
|
|
57
|
-
|
|
58
|
-
// });
|
|
59
|
-
|
|
60
56
|
test('file download with cover image', () => {
|
|
61
57
|
const COVER_URL = 'my-image.png';
|
|
62
58
|
|
|
@@ -66,7 +62,7 @@ test('file download with cover image', () => {
|
|
|
66
62
|
|
|
67
63
|
const thumbnailImage = screen.getByRole('presentation', {hidden: true});
|
|
68
64
|
|
|
69
|
-
expect(thumbnailImage).toHaveClass('ds_file-download__thumbnail-image');
|
|
65
|
+
expect(thumbnailImage).toHaveClass('ds_file-download__thumbnail-image', 'ds_file-download__thumbnail-image--outlined');
|
|
70
66
|
expect(thumbnailImage).toHaveAttribute('alt', '');
|
|
71
67
|
expect(thumbnailImage).toHaveAttribute('src', COVER_URL);
|
|
72
68
|
expect(thumbnailImage.tagName).toEqual('IMG');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useId } from 'react';
|
|
2
2
|
import FileIcon from '../../common/FileIcon';
|
|
3
3
|
import { FileDownloadProps } from './types';
|
|
4
|
+
import clsx from 'clsx';
|
|
4
5
|
|
|
5
6
|
const FileDownload = ({
|
|
6
7
|
className,
|
|
@@ -17,17 +18,17 @@ const FileDownload = ({
|
|
|
17
18
|
const metaContainerId = `file-download-${useId()}`;
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
|
-
<div className={[
|
|
21
|
+
<div className={clsx([
|
|
21
22
|
'ds_file-download',
|
|
22
23
|
isHighlighted && 'ds_file-download--highlighted',
|
|
23
24
|
className
|
|
24
|
-
]
|
|
25
|
+
])}
|
|
25
26
|
{...props}
|
|
26
27
|
>
|
|
27
28
|
<div className="ds_file-download__thumbnail">
|
|
28
29
|
<a className="ds_file-download__thumbnail-link" aria-hidden="true" tabIndex={-1} href={fileUrl}>
|
|
29
30
|
{cover ?
|
|
30
|
-
<img alt="" className="ds_file-download__thumbnail-image" src={cover}/>
|
|
31
|
+
<img alt="" className="ds_file-download__thumbnail-image ds_file-download__thumbnail-image--outlined" src={cover}/>
|
|
31
32
|
:
|
|
32
33
|
<FileIcon ariaLabel="" className="ds_file-download__thumbnail-image" icon={icon} />
|
|
33
34
|
}
|
|
@@ -49,7 +49,18 @@ test('custom escape URL', () => {
|
|
|
49
49
|
const link = within(hideThisPageElement).getByRole('link');
|
|
50
50
|
|
|
51
51
|
expect(link).toHaveAttribute('href', ESCAPE_URL);
|
|
52
|
-
})
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('instantiating/initialising DS component script', () => {
|
|
55
|
+
render(
|
|
56
|
+
<HideThisPage data-testid="htp" />
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const hideThisPageElement = screen.getByTestId('htp');
|
|
60
|
+
const link = within(hideThisPageElement).getByRole('link');
|
|
61
|
+
expect(link).toHaveClass('js-initialised');
|
|
62
|
+
expect(link).toHaveClass('js-instantiated');
|
|
63
|
+
});
|
|
53
64
|
|
|
54
65
|
test('passing additional props', () => {
|
|
55
66
|
render(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
// @ts-expect-error no types from core SGDS
|
|
3
2
|
import DSHideThisPage from '@scottish-government/design-system/src/components/hide-this-page/hide-this-page';
|
|
4
3
|
import { HideThisPageProps } from './types';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
const HideThisPage = ({
|
|
7
7
|
className,
|
|
@@ -11,8 +11,9 @@ const HideThisPage = ({
|
|
|
11
11
|
const ref = useRef(null);
|
|
12
12
|
|
|
13
13
|
useEffect(() => {
|
|
14
|
+
/* istanbul ignore else */
|
|
14
15
|
if (ref.current) {
|
|
15
|
-
new DSHideThisPage().init();
|
|
16
|
+
new DSHideThisPage(ref.current).init();
|
|
16
17
|
|
|
17
18
|
const HIDE_THIS_PAGE_DIV_ID = 'hide-this-page-instruction';
|
|
18
19
|
if (!document.getElementById(HIDE_THIS_PAGE_DIV_ID)) {
|
|
@@ -30,10 +31,10 @@ const HideThisPage = ({
|
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<div
|
|
33
|
-
className={[
|
|
34
|
+
className={clsx([
|
|
34
35
|
'ds_hide-page',
|
|
35
36
|
className
|
|
36
|
-
]
|
|
37
|
+
])}
|
|
37
38
|
ref={ref}
|
|
38
39
|
{...props}
|
|
39
40
|
>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
1
3
|
const InsetText = ({
|
|
2
4
|
children,
|
|
3
5
|
className,
|
|
@@ -5,10 +7,10 @@ const InsetText = ({
|
|
|
5
7
|
}: React.AllHTMLAttributes<HTMLElement>) => {
|
|
6
8
|
return (
|
|
7
9
|
<div
|
|
8
|
-
className={[
|
|
10
|
+
className={clsx([
|
|
9
11
|
'ds_inset-text',
|
|
10
12
|
className
|
|
11
|
-
]
|
|
13
|
+
])}
|
|
12
14
|
{...props}
|
|
13
15
|
>
|
|
14
16
|
<div className="ds_inset-text__text">
|
|
@@ -42,3 +42,13 @@ test('notification banner with icon', () => {
|
|
|
42
42
|
expect(bannerIcon).toHaveClass('ds_icon');
|
|
43
43
|
expect(bannerIcon).toHaveAttribute('aria-hidden');
|
|
44
44
|
});
|
|
45
|
+
|
|
46
|
+
test('instantiating/initialising DS component script', () => {
|
|
47
|
+
render(
|
|
48
|
+
<NotificationBanner data-testid="notification-banner" />
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const notificationBanner = screen.getByTestId('notification-banner');
|
|
52
|
+
expect(notificationBanner).toHaveClass('js-initialised');
|
|
53
|
+
expect(notificationBanner).toHaveClass('js-instantiated');
|
|
54
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import AbstractNotificationBanner from '../../common/AbstractNotificationBanner';
|
|
3
|
-
// @ts-expect-error no types from core SGDS
|
|
4
3
|
import DSNotificationBanner from '@scottish-government/design-system/src/components/notification-banner/notification-banner';
|
|
5
4
|
import { AbstractNotificationBannerProps } from '../../common/AbstractNotificationBanner/types';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
const NotificationBanner = ({
|
|
8
8
|
children,
|
|
@@ -17,6 +17,7 @@ const NotificationBanner = ({
|
|
|
17
17
|
const ref = useRef(null);
|
|
18
18
|
|
|
19
19
|
useEffect(() => {
|
|
20
|
+
/* istanbul ignore else */
|
|
20
21
|
if (ref.current) {
|
|
21
22
|
new DSNotificationBanner(ref.current).init();
|
|
22
23
|
}
|
|
@@ -24,10 +25,10 @@ const NotificationBanner = ({
|
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
27
|
<AbstractNotificationBanner
|
|
27
|
-
className={[
|
|
28
|
+
className={clsx([
|
|
28
29
|
'ds_reversed',
|
|
29
30
|
className
|
|
30
|
-
]
|
|
31
|
+
])}
|
|
31
32
|
isDismissable={isDismissable}
|
|
32
33
|
icon={hasIcon ? "PriorityHigh" : undefined}
|
|
33
34
|
hasColourIcon={hasColourIcon}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import WrapperTag from '../../common/WrapperTag';
|
|
2
2
|
import { NotificationPanelProps } from './types';
|
|
3
|
+
import clsx from 'clsx';
|
|
3
4
|
|
|
4
5
|
const NotificationPanel = function ({
|
|
5
6
|
ariaLive,
|
|
@@ -12,10 +13,10 @@ const NotificationPanel = function ({
|
|
|
12
13
|
return (
|
|
13
14
|
<div
|
|
14
15
|
aria-live={ariaLive}
|
|
15
|
-
className={[
|
|
16
|
+
className={clsx([
|
|
16
17
|
'ds_notification-panel',
|
|
17
18
|
className
|
|
18
|
-
]
|
|
19
|
+
])}
|
|
19
20
|
{...props}
|
|
20
21
|
>
|
|
21
22
|
<WrapperTag
|