uikit-react-public 0.17.4 → 0.21.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/components/Accordion/Accordion.Heading.d.ts +1 -0
- package/dist/components/AppHeader/AppHeader.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderBottom.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderNav.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderTop.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumb.d.ts +3 -4
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +7 -3
- package/dist/components/Button/Button.stories.d.ts +17 -7
- package/dist/components/Button/style/buttonAccentStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimarySubtleStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryWarningStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondaryStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondarySubtleStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryNoPaddingStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryStyle.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/FooterNew/BackToTop.d.ts +8 -0
- package/dist/components/FooterNew/Footer.d.ts +23 -0
- package/dist/components/FooterNew/FooterColumn.d.ts +8 -0
- package/dist/components/FooterNew/FooterLinks.d.ts +7 -0
- package/dist/components/FooterNew/FooterNavLink.d.ts +8 -0
- package/dist/components/FooterNew/LegalAndCopyright.d.ts +14 -0
- package/dist/components/FooterNew/LogoAddressAndSocial.d.ts +10 -0
- package/dist/components/FooterNew/SocialLink.d.ts +8 -0
- package/dist/components/FooterNew/__tests__/Footer.test.d.ts +1 -0
- package/dist/components/FooterNew/index.d.ts +2 -0
- package/dist/components/HeaderNew/Header.d.ts +18 -0
- package/dist/components/HeaderNew/HeaderBorder.d.ts +7 -0
- package/dist/components/HeaderNew/HeaderLogo.d.ts +9 -0
- package/dist/components/HeaderNew/HeaderMenuContainer.d.ts +7 -0
- package/dist/components/HeaderNew/HeaderTitle.d.ts +9 -0
- package/dist/components/HeaderNew/__tests__/Header.test.d.ts +1 -0
- package/dist/components/HeaderNew/constants.d.ts +3 -0
- package/dist/components/HeaderNew/index.d.ts +3 -0
- package/dist/components/Heading/Heading.d.ts +6 -4
- package/dist/components/Heading/Heading.stories.d.ts +8 -6
- package/dist/components/Icon/svgImports.d.ts +7 -881
- package/dist/components/Link/BaseLink.d.ts +14 -5
- package/dist/components/Link/Link.d.ts +8 -3
- package/dist/components/Link/Link.stories.d.ts +3 -1
- package/dist/components/MenuNew/Menu.context.d.ts +14 -0
- package/dist/components/MenuNew/Menu.d.ts +20 -0
- package/dist/components/MenuNew/MenuContent.d.ts +9 -0
- package/dist/components/MenuNew/MenuItem.d.ts +10 -0
- package/dist/components/MenuNew/MenuSection.d.ts +7 -0
- package/dist/components/MenuNew/index.d.ts +6 -0
- package/dist/components/MenuNew/trigger/ButtonMenuTrigger.d.ts +8 -0
- package/dist/components/MenuNew/trigger/IconMenuTrigger.d.ts +8 -0
- package/dist/components/Overlay/Overlay.stories.d.ts +12 -12
- package/dist/components/Paragraph/Paragraph.d.ts +5 -2
- package/dist/components/Paragraph/Paragraph.stories.d.ts +6 -3
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.stories.d.ts +13 -1
- package/dist/components/Select/Select.types.d.ts +40 -13
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +3 -3
- package/dist/components/Select/subcomponents/FilterInput.d.ts +3 -1
- package/dist/components/Select/subcomponents/NativeSelect.d.ts +2 -2
- package/dist/components/Select/subcomponents/VisibleField.d.ts +4 -1
- package/dist/components/Spinner/Spinner.d.ts +2 -0
- package/dist/components/StandaloneLink/StandaloneLink.d.ts +8 -5
- package/dist/components/StandaloneLink/StandaloneLink.stories.d.ts +3 -1
- package/dist/components/Table/Table.d.ts +3 -3
- package/dist/components/Table/Table.stories.d.ts +3 -3
- package/dist/components/Table/Table.types.d.ts +1 -0
- package/dist/components/Table/subcomponents/Cell/Cell.d.ts +5 -1
- package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +15 -13
- package/dist/components/Table/subcomponents/Cell/CellContent.d.ts +5 -1
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.d.ts +2 -1
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +14 -13
- package/dist/components/Table/subcomponents/HeadCell/HeadCellContent.d.ts +2 -1
- package/dist/components/Table/subcomponents/__tests__/Row.test.d.ts +1 -0
- package/dist/components/UclLogoNew/UclLogo.d.ts +8 -0
- package/dist/components/UclLogoNew/index.d.ts +2 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/index.js +20104 -15317
- package/dist/theme/__tests__/fonts.test.d.ts +1 -0
- package/dist/theme/common/themeCommon.d.ts +904 -0
- package/dist/theme/fonts.d.ts +18 -0
- package/dist/theme/index.d.ts +6 -3
- package/dist/theme/light/lightColour.d.ts +126 -0
- package/dist/theme/light/lightTheme.d.ts +3 -0
- package/dist/theme/original/color.d.ts +166 -0
- package/dist/theme/original/defaultTheme.d.ts +1340 -0
- package/dist/theme/original/originalColourNewStructure.d.ts +126 -0
- package/dist/theme/useTheme.d.ts +2174 -0
- package/dist/utils/addAlphaToHex.d.ts +5 -0
- package/dist/utils/scrollToTop.d.ts +2 -0
- package/lib/components/Accordion/Accordion.Heading.tsx +51 -39
- package/lib/components/Accordion/Accordion.Panel.tsx +0 -4
- package/lib/components/Accordion/Accordion.tsx +34 -28
- package/lib/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +12 -10
- package/lib/components/Alert/Alert.tsx +12 -12
- package/lib/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +13 -39
- package/lib/components/AppHeader/AppHeader.tsx +6 -11
- package/lib/components/AppHeader/AppHeaderBottom.tsx +2 -3
- package/lib/components/AppHeader/AppHeaderNav.tsx +2 -3
- package/lib/components/AppHeader/AppHeaderTop.tsx +1 -1
- package/lib/components/AppHeader/__tests__/__snapshots__/AppHeader.test.tsx.snap +2 -2
- package/lib/components/AppMenu/__tests__/__snapshots__/AppMenu.test.tsx.snap +6 -19
- package/lib/components/Badge/Badge.stories.tsx +1 -1
- package/lib/components/Breadcrumbs/Breadcrumb.tsx +26 -12
- package/lib/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/lib/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx +9 -27
- package/lib/components/Breadcrumbs/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +24 -20
- package/lib/components/Button/Button.mdx +32 -279
- package/lib/components/Button/Button.stories.tsx +43 -50
- package/lib/components/Button/Button.tsx +165 -25
- package/lib/components/Button/__tests__/Button.test.tsx +49 -15
- package/lib/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +80 -73
- package/lib/components/Button/style/buttonAccentStyle.ts +53 -0
- package/lib/components/Button/style/buttonPrimaryDestructiveStyle.ts +55 -0
- package/lib/components/Button/style/buttonPrimaryStyle.ts +53 -0
- package/lib/components/Button/style/buttonPrimarySubtleStyle.ts +64 -0
- package/lib/components/Button/style/buttonPrimaryWarningStyle.ts +56 -0
- package/lib/components/Button/style/buttonSecondaryDestructiveStyle.ts +63 -0
- package/lib/components/Button/style/buttonSecondaryStyle.ts +62 -0
- package/lib/components/Button/style/buttonSecondarySubtleStyle.ts +72 -0
- package/lib/components/Button/style/buttonTertiaryDestructiveStyle.ts +65 -0
- package/lib/components/Button/style/buttonTertiaryNoPaddingStyle.ts +52 -0
- package/lib/components/Button/style/buttonTertiaryStyle.ts +62 -0
- package/lib/components/Calendar/Calendar.stories.tsx +33 -13
- package/lib/components/Calendar/Calendar.tsx +2 -2
- package/lib/components/Calendar/__tests__/__snapshots__/Calendar.test.tsx.snap +99 -95
- package/lib/components/Calendar/subcomponents/AcademicWeek.tsx +2 -1
- package/lib/components/Calendar/subcomponents/AcademicWeeks.tsx +2 -3
- package/lib/components/Calendar/subcomponents/ColumnHeading.tsx +3 -7
- package/lib/components/Calendar/subcomponents/Controls.tsx +1 -1
- package/lib/components/Calendar/subcomponents/Day.stories.tsx +1 -1
- package/lib/components/Calendar/subcomponents/Day.tsx +7 -9
- package/lib/components/Calendar/subcomponents/EventDot.tsx +4 -8
- package/lib/components/Checkbox/Checkbox.stories.tsx +1 -1
- package/lib/components/Checkbox/Checkbox.tsx +12 -10
- package/lib/components/Checkbox/__tests__/Checkbox.test.tsx +29 -0
- package/lib/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +4 -4
- package/lib/components/Datepicker/__tests__/Datepicker.test.tsx +117 -0
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +16 -44
- package/lib/components/Datepicker/subcomponents/CustomDatepicker.tsx +10 -1
- package/lib/components/Datepicker/subcomponents/VisibleField.tsx +24 -23
- package/lib/components/Dialog/BaseDialog.tsx +2 -2
- package/lib/components/Dialog/Dialog.stories.tsx +1 -1
- package/lib/components/Divider/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +12 -12
- package/lib/components/FeedbackDialog/FeedbackDialog.stories.tsx +1 -1
- package/lib/components/FeedbackDialog/FeedbackDialog.tsx +4 -6
- package/lib/components/Field/CharacterCount.tsx +2 -2
- package/lib/components/Field/ErrorText.tsx +1 -1
- package/lib/components/Field/Field.tsx +1 -1
- package/lib/components/Field/HelperText.tsx +3 -1
- package/lib/components/FileInput/FileInput.stories.tsx +1 -1
- package/lib/components/FileInput/__tests__/__snapshots__/FileInput.test.tsx.snap +4 -20
- package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +70 -79
- package/lib/components/FooterNew/BackToTop.tsx +83 -0
- package/lib/components/FooterNew/Footer.tsx +110 -0
- package/lib/components/FooterNew/FooterColumn.tsx +79 -0
- package/lib/components/FooterNew/FooterLinks.tsx +44 -0
- package/lib/components/FooterNew/FooterNavLink.tsx +63 -0
- package/lib/components/FooterNew/LegalAndCopyright.tsx +150 -0
- package/lib/components/FooterNew/LogoAddressAndSocial.tsx +154 -0
- package/lib/components/FooterNew/SocialLink.tsx +108 -0
- package/lib/components/FooterNew/__tests__/Footer.test.tsx +51 -0
- package/lib/components/FooterNew/__tests__/__snapshots__/Footer.test.tsx.snap +1107 -0
- package/lib/components/FooterNew/index.ts +2 -0
- package/lib/components/HeaderDraft/__tests__/__snapshots__/Header.test.tsx.snap +3 -2
- package/lib/components/HeaderNew/Header.tsx +93 -0
- package/lib/components/HeaderNew/HeaderBorder.tsx +55 -0
- package/lib/components/HeaderNew/HeaderLogo.tsx +70 -0
- package/lib/components/HeaderNew/HeaderMenuContainer.tsx +35 -0
- package/lib/components/HeaderNew/HeaderTitle.tsx +53 -0
- package/lib/components/HeaderNew/__tests__/Header.test.tsx +42 -0
- package/lib/components/HeaderNew/__tests__/__snapshots__/Header.test.tsx.snap +79 -0
- package/lib/components/HeaderNew/constants.ts +3 -0
- package/lib/components/HeaderNew/index.ts +7 -0
- package/lib/components/Heading/Heading.stories.tsx +34 -41
- package/lib/components/Heading/Heading.tsx +180 -49
- package/lib/components/Heading/__tests__/__snapshots__/Heading.test.tsx.snap +4 -4
- package/lib/components/Icon/__tests__/__snapshots__/Icon.test.tsx.snap +16 -12
- package/lib/components/Icon/svgImports.ts +318 -296
- package/lib/components/IconButton/IconButton.tsx +3 -4
- package/lib/components/IconButton/__tests__/__snapshots__/IconButton.test.tsx.snap +12 -9
- package/lib/components/Link/BaseLink.tsx +114 -71
- package/lib/components/Link/Link.stories.tsx +1 -1
- package/lib/components/Link/Link.tsx +120 -109
- package/lib/components/Link/__tests__/__snapshots__/link.test.tsx.snap +2 -2
- package/lib/components/MenuNew/Menu.context.tsx +149 -0
- package/lib/components/MenuNew/Menu.tsx +75 -0
- package/lib/components/MenuNew/MenuContent.tsx +140 -0
- package/lib/components/MenuNew/MenuItem.tsx +101 -0
- package/lib/components/MenuNew/MenuSection.tsx +47 -0
- package/lib/components/MenuNew/index.ts +8 -0
- package/lib/components/MenuNew/trigger/ButtonMenuTrigger.tsx +42 -0
- package/lib/components/MenuNew/trigger/IconMenuTrigger.tsx +40 -0
- package/lib/components/Pagination/Pagination.stories.tsx +1 -1
- package/lib/components/Pagination/PaginationControls.tsx +4 -5
- package/lib/components/Pagination/PaginationInfo.tsx +2 -3
- package/lib/components/Paragraph/Paragraph.stories.tsx +29 -27
- package/lib/components/Paragraph/Paragraph.tsx +212 -81
- package/lib/components/Paragraph/__tests__/__snapshots__/Paragraph.test.tsx.snap +5 -5
- package/lib/components/Radio/Radio.stories.tsx +1 -1
- package/lib/components/Radio/Radio.tsx +8 -8
- package/lib/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap +4 -4
- package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +12 -32
- package/lib/components/Select/Select.mdx +23 -0
- package/lib/components/Select/Select.stories.tsx +43 -10
- package/lib/components/Select/Select.tsx +14 -3
- package/lib/components/Select/Select.types.ts +53 -16
- package/lib/components/Select/__tests__/Select.test.tsx +250 -1
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +5 -4
- package/lib/components/Select/subcomponents/CustomOption.tsx +10 -3
- package/lib/components/Select/subcomponents/CustomSelect.tsx +110 -10
- package/lib/components/Select/subcomponents/FilterInput.tsx +13 -3
- package/lib/components/Select/subcomponents/NativeSelect.tsx +10 -18
- package/lib/components/Select/subcomponents/Panel.tsx +2 -2
- package/lib/components/Select/subcomponents/VisibleField.tsx +48 -3
- package/lib/components/Snackbar/__tests__/__snapshots__/Snackbar.test.tsx.snap +9 -15
- package/lib/components/Spinner/Spinner.tsx +24 -5
- package/lib/components/Spinner/__tests__/Spinner.test.tsx +35 -5
- package/lib/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap +40 -16
- package/lib/components/StandaloneLink/StandaloneLink.stories.tsx +1 -1
- package/lib/components/StandaloneLink/StandaloneLink.tsx +180 -163
- package/lib/components/StandaloneLink/__tests__/__snapshots__/StandaloneLink.test.tsx.snap +2 -2
- package/lib/components/Table/Table.stories.tsx +1 -1
- package/lib/components/Table/Table.tsx +2 -0
- package/lib/components/Table/Table.types.ts +1 -0
- package/lib/components/Table/__tests__/Table.test.tsx +19 -0
- package/lib/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +7 -3
- package/lib/components/Table/subcomponents/Cell/Cell.stories.tsx +1 -1
- package/lib/components/Table/subcomponents/Cell/Cell.tsx +23 -2
- package/lib/components/Table/subcomponents/Cell/CellContent.tsx +12 -1
- package/lib/components/Table/subcomponents/Cell/__tests__/Cell.test.tsx +106 -0
- package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +4 -3
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.stories.tsx +1 -1
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.tsx +28 -6
- package/lib/components/Table/subcomponents/HeadCell/HeadCellContent.tsx +3 -0
- package/lib/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.tsx +221 -2
- package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +6 -4
- package/lib/components/Table/subcomponents/Row.tsx +2 -2
- package/lib/components/Table/subcomponents/SortIcon.tsx +1 -0
- package/lib/components/Table/subcomponents/__tests__/Row.test.tsx +59 -0
- package/lib/components/Tabs/Tab.tsx +3 -3
- package/lib/components/Tabs/Tabs.stories.tsx +1 -1
- package/lib/components/Tabs/Tabs.tsx +5 -3
- package/lib/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +4 -4
- package/lib/components/Timepicker/Timepicker.stories.tsx +1 -1
- package/lib/components/Toggle/Toggle.tsx +5 -5
- package/lib/components/Toggle/ToggleHandle.tsx +2 -3
- package/lib/components/Tooltip/Tooltip.tsx +2 -2
- package/lib/components/Tooltip/__tests__/__snapshots__/tooltip.test.tsx.snap +2 -2
- package/lib/components/UclLogoNew/UclLogo.tsx +42 -0
- package/lib/components/UclLogoNew/index.ts +2 -0
- package/lib/components/WeekPicker/WeekPicker.stories.tsx +3 -5
- package/lib/components/common/Common.mdx +0 -1
- package/lib/components/index.ts +19 -1
- package/lib/theme/Colours.mdx +1 -1
- package/lib/theme/Theme.mdx +1 -1
- package/lib/theme/Typography.mdx +1 -1
- package/lib/theme/__tests__/fonts.test.ts +37 -0
- package/lib/theme/common/themeCommon.ts +515 -0
- package/lib/theme/fonts.ts +110 -0
- package/lib/theme/index.ts +6 -6
- package/lib/theme/light/lightColour.ts +232 -0
- package/lib/theme/light/lightTheme.ts +37 -0
- package/lib/theme/{defaultTheme.ts → original/color.ts} +17 -199
- package/lib/theme/original/defaultTheme.ts +207 -0
- package/lib/theme/original/originalColourNewStructure.ts +185 -0
- package/lib/theme/useTheme.tsx +72 -15
- package/lib/types/assets.d.ts +10 -0
- package/lib/utils/addAlphaToHex.ts +29 -0
- package/lib/utils/scrollToTop.ts +5 -0
- package/package.json +11 -6
- package/dist/components/Button/buttonPrimaryStyle.d.ts +0 -4
- package/dist/components/Button/buttonSecondaryStyle.d.ts +0 -4
- package/dist/components/Button/buttonTertiaryStyle.d.ts +0 -4
- package/dist/theme/defaultTheme.d.ts +0 -274
- package/lib/components/Button/buttonPrimaryStyle.ts +0 -62
- package/lib/components/Button/buttonSecondaryStyle.ts +0 -65
- package/lib/components/Button/buttonTertiaryStyle.ts +0 -54
|
@@ -1,94 +1,225 @@
|
|
|
1
|
-
import { memo, HTMLAttributes,
|
|
1
|
+
import { memo, HTMLAttributes, JSX } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
3
|
import useTheme from '../../theme/useTheme';
|
|
4
4
|
import marginsStyle, { MarginProps } from '../common/marginsStyle';
|
|
5
5
|
|
|
6
6
|
export const NAME = 'ucl-uikit-heading';
|
|
7
7
|
|
|
8
|
+
export type HeadingLevel = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
9
|
+
|
|
8
10
|
export interface HeadingBaseProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
9
|
-
level?: 1 | 2 | 3 | 4;
|
|
10
|
-
|
|
11
|
+
level?: HeadingLevel | 1 | 2 | 3 | 4;
|
|
12
|
+
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div' | 'span';
|
|
13
|
+
margins?: boolean; // deprecated
|
|
11
14
|
testId?: string;
|
|
15
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export type HeadingProps = HeadingBaseProps & MarginProps;
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const Heading = memo(
|
|
21
|
+
({
|
|
22
|
+
level = 1,
|
|
23
|
+
as,
|
|
24
|
+
margins = true,
|
|
25
|
+
testId = NAME,
|
|
26
|
+
className,
|
|
27
|
+
ref,
|
|
28
|
+
noMargins,
|
|
29
|
+
...props
|
|
30
|
+
}: HeadingProps) => {
|
|
20
31
|
const [theme] = useTheme();
|
|
21
32
|
|
|
22
33
|
const {
|
|
23
|
-
|
|
34
|
+
typography: {
|
|
35
|
+
heading: { xxl, xl, lg, md, sm, xs },
|
|
36
|
+
},
|
|
24
37
|
} = theme;
|
|
25
38
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
const mappedLevel: HeadingLevel =
|
|
40
|
+
level === 1
|
|
41
|
+
? 'xxl'
|
|
42
|
+
: level === 2
|
|
43
|
+
? 'xl'
|
|
44
|
+
: level === 3
|
|
45
|
+
? 'lg'
|
|
46
|
+
: level === 4
|
|
47
|
+
? 'md'
|
|
48
|
+
: level;
|
|
49
|
+
|
|
50
|
+
const defaultHeadingTag =
|
|
51
|
+
mappedLevel === 'xxl'
|
|
52
|
+
? 'h1'
|
|
53
|
+
: mappedLevel === 'xl'
|
|
54
|
+
? 'h2'
|
|
55
|
+
: mappedLevel === 'lg'
|
|
56
|
+
? 'h3'
|
|
57
|
+
: mappedLevel === 'md'
|
|
58
|
+
? 'h4'
|
|
59
|
+
: mappedLevel === 'sm'
|
|
60
|
+
? 'h5'
|
|
61
|
+
: 'h6';
|
|
62
|
+
|
|
63
|
+
const baseStyle = css`
|
|
64
|
+
font-family: ${md.md.fontFamily};
|
|
65
|
+
font-feature-settings: ${md.md.fontSettings};
|
|
66
|
+
color: ${theme.colour.text.default};
|
|
67
|
+
margin: 0;
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
const levelXxlStyle = css`
|
|
71
|
+
font-size: ${xxl.sm.fontSize}px;
|
|
72
|
+
font-weight: ${xxl.sm.fontWeight};
|
|
73
|
+
line-height: ${xxl.sm.lineHeight}%;
|
|
74
|
+
@media screen and (min-width: ${theme.breakpoints.tablet}px) {
|
|
75
|
+
font-size: ${xxl.md.fontSize}px;
|
|
76
|
+
font-weight: ${xxl.md.fontWeight};
|
|
77
|
+
line-height: ${xxl.md.lineHeight}%;
|
|
31
78
|
}
|
|
32
79
|
`;
|
|
33
80
|
|
|
34
|
-
const
|
|
35
|
-
font-size: ${
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
81
|
+
const levelXlStyle = css`
|
|
82
|
+
font-size: ${xl.sm.fontSize}px;
|
|
83
|
+
font-weight: ${xl.sm.fontWeight};
|
|
84
|
+
line-height: ${xl.sm.lineHeight}%;
|
|
85
|
+
@media screen and (min-width: ${theme.breakpoints.tablet}px) {
|
|
86
|
+
font-size: ${xl.md.fontSize}px;
|
|
87
|
+
font-weight: ${xl.md.fontWeight};
|
|
88
|
+
line-height: ${xl.md.lineHeight}%;
|
|
40
89
|
}
|
|
41
90
|
`;
|
|
42
91
|
|
|
43
|
-
const
|
|
44
|
-
font-size: ${
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
92
|
+
const levelLgStyle = css`
|
|
93
|
+
font-size: ${lg.sm.fontSize}px;
|
|
94
|
+
font-weight: ${lg.sm.fontWeight};
|
|
95
|
+
line-height: ${lg.sm.lineHeight}%;
|
|
96
|
+
@media screen and (min-width: ${theme.breakpoints.tablet}px) {
|
|
97
|
+
font-size: ${lg.md.fontSize}px;
|
|
98
|
+
font-weight: ${lg.md.fontWeight};
|
|
99
|
+
line-height: ${lg.md.lineHeight}%;
|
|
48
100
|
}
|
|
49
101
|
`;
|
|
50
102
|
|
|
51
|
-
const
|
|
52
|
-
font-size: ${
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
103
|
+
const levelMdStyle = css`
|
|
104
|
+
font-size: ${md.sm.fontSize}px;
|
|
105
|
+
font-weight: ${md.sm.fontWeight};
|
|
106
|
+
line-height: ${md.sm.lineHeight}%;
|
|
107
|
+
@media screen and (min-width: ${theme.breakpoints.tablet}px) {
|
|
108
|
+
font-size: ${md.md.fontSize}px;
|
|
109
|
+
font-weight: ${md.md.fontWeight};
|
|
110
|
+
line-height: ${md.md.lineHeight}%;
|
|
56
111
|
}
|
|
57
112
|
`;
|
|
58
113
|
|
|
59
|
-
const
|
|
60
|
-
font-
|
|
61
|
-
font-weight:
|
|
62
|
-
|
|
114
|
+
const levelSmStyle = css`
|
|
115
|
+
font-size: ${sm.sm.fontSize}px;
|
|
116
|
+
font-weight: ${sm.sm.fontWeight};
|
|
117
|
+
line-height: ${sm.sm.lineHeight}%;
|
|
118
|
+
@media screen and (min-width: ${theme.breakpoints.tablet}px) {
|
|
119
|
+
font-size: ${sm.md.fontSize}px;
|
|
120
|
+
font-weight: ${sm.md.fontWeight};
|
|
121
|
+
line-height: ${sm.md.lineHeight}%;
|
|
122
|
+
}
|
|
63
123
|
`;
|
|
64
124
|
|
|
65
|
-
const
|
|
66
|
-
|
|
125
|
+
const levelXsStyle = css`
|
|
126
|
+
font-size: ${xs.sm.fontSize}px;
|
|
127
|
+
font-weight: ${xs.sm.fontWeight};
|
|
128
|
+
line-height: ${xs.sm.lineHeight}%;
|
|
129
|
+
@media screen and (min-width: ${theme.breakpoints.tablet}px) {
|
|
130
|
+
font-size: ${xs.md.fontSize}px;
|
|
131
|
+
font-weight: ${xs.md.fontWeight};
|
|
132
|
+
line-height: ${xs.md.lineHeight}%;
|
|
133
|
+
}
|
|
67
134
|
`;
|
|
68
135
|
|
|
69
136
|
const style = cx(
|
|
70
137
|
NAME,
|
|
71
138
|
baseStyle,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
139
|
+
mappedLevel === 'xxl' && levelXxlStyle,
|
|
140
|
+
mappedLevel === 'xl' && levelXlStyle,
|
|
141
|
+
mappedLevel === 'lg' && levelLgStyle,
|
|
142
|
+
mappedLevel === 'md' && levelMdStyle,
|
|
143
|
+
mappedLevel === 'sm' && levelSmStyle,
|
|
144
|
+
mappedLevel === 'xs' && levelXsStyle,
|
|
145
|
+
marginsStyle(
|
|
146
|
+
{ ...props, noMargins: noMargins || margins === false },
|
|
147
|
+
theme
|
|
148
|
+
),
|
|
78
149
|
className
|
|
79
150
|
);
|
|
80
151
|
|
|
81
|
-
const
|
|
152
|
+
const headingTag = (as || defaultHeadingTag) as keyof JSX.IntrinsicElements;
|
|
82
153
|
|
|
83
154
|
return (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
155
|
+
<>
|
|
156
|
+
{headingTag === 'h1' && (
|
|
157
|
+
<h1
|
|
158
|
+
ref={ref}
|
|
159
|
+
className={style}
|
|
160
|
+
data-testid={testId}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
)}
|
|
164
|
+
{headingTag === 'h2' && (
|
|
165
|
+
<h2
|
|
166
|
+
ref={ref}
|
|
167
|
+
className={style}
|
|
168
|
+
data-testid={testId}
|
|
169
|
+
{...props}
|
|
170
|
+
/>
|
|
171
|
+
)}
|
|
172
|
+
{headingTag === 'h3' && (
|
|
173
|
+
<h3
|
|
174
|
+
ref={ref}
|
|
175
|
+
className={style}
|
|
176
|
+
data-testid={testId}
|
|
177
|
+
{...props}
|
|
178
|
+
/>
|
|
179
|
+
)}
|
|
180
|
+
{headingTag === 'h4' && (
|
|
181
|
+
<h4
|
|
182
|
+
ref={ref}
|
|
183
|
+
className={style}
|
|
184
|
+
data-testid={testId}
|
|
185
|
+
{...props}
|
|
186
|
+
/>
|
|
187
|
+
)}
|
|
188
|
+
{headingTag === 'h5' && (
|
|
189
|
+
<h5
|
|
190
|
+
ref={ref}
|
|
191
|
+
className={style}
|
|
192
|
+
data-testid={testId}
|
|
193
|
+
{...props}
|
|
194
|
+
/>
|
|
195
|
+
)}
|
|
196
|
+
{headingTag === 'h6' && (
|
|
197
|
+
<h6
|
|
198
|
+
ref={ref}
|
|
199
|
+
className={style}
|
|
200
|
+
data-testid={testId}
|
|
201
|
+
{...props}
|
|
202
|
+
/>
|
|
203
|
+
)}
|
|
204
|
+
{headingTag === 'span' && (
|
|
205
|
+
<span
|
|
206
|
+
ref={ref as React.Ref<HTMLSpanElement>}
|
|
207
|
+
className={style}
|
|
208
|
+
data-testid={testId}
|
|
209
|
+
{...props}
|
|
210
|
+
/>
|
|
211
|
+
)}
|
|
212
|
+
{headingTag === 'div' && (
|
|
213
|
+
<div
|
|
214
|
+
ref={ref as React.Ref<HTMLDivElement>}
|
|
215
|
+
className={style}
|
|
216
|
+
data-testid={testId}
|
|
217
|
+
{...props}
|
|
218
|
+
/>
|
|
219
|
+
)}
|
|
220
|
+
</>
|
|
90
221
|
);
|
|
91
222
|
}
|
|
92
223
|
);
|
|
93
224
|
|
|
94
|
-
export default
|
|
225
|
+
export default Heading;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Heading > snapshot: custom test id 1`] = `
|
|
4
4
|
<h1
|
|
5
|
-
class="ucl-uikit-heading css-
|
|
5
|
+
class="ucl-uikit-heading css-7nmnfv"
|
|
6
6
|
data-testid="custom-test-id"
|
|
7
7
|
>
|
|
8
8
|
This is a test
|
|
@@ -11,7 +11,7 @@ exports[`Heading > snapshot: custom test id 1`] = `
|
|
|
11
11
|
|
|
12
12
|
exports[`Heading > snapshot: level 1`] = `
|
|
13
13
|
<h1
|
|
14
|
-
class="ucl-uikit-heading css-
|
|
14
|
+
class="ucl-uikit-heading css-7nmnfv"
|
|
15
15
|
data-testid="ucl-uikit-heading"
|
|
16
16
|
>
|
|
17
17
|
Level 1
|
|
@@ -20,7 +20,7 @@ exports[`Heading > snapshot: level 1`] = `
|
|
|
20
20
|
|
|
21
21
|
exports[`Heading > snapshot: minimal props 1`] = `
|
|
22
22
|
<h1
|
|
23
|
-
class="ucl-uikit-heading css-
|
|
23
|
+
class="ucl-uikit-heading css-7nmnfv"
|
|
24
24
|
data-testid="ucl-uikit-heading"
|
|
25
25
|
>
|
|
26
26
|
This is a test
|
|
@@ -29,7 +29,7 @@ exports[`Heading > snapshot: minimal props 1`] = `
|
|
|
29
29
|
|
|
30
30
|
exports[`Heading > snapshot: no margins 1`] = `
|
|
31
31
|
<h1
|
|
32
|
-
class="ucl-uikit-heading css-
|
|
32
|
+
class="ucl-uikit-heading css-kt47of"
|
|
33
33
|
data-testid="ucl-uikit-heading"
|
|
34
34
|
>
|
|
35
35
|
No margins
|
|
@@ -5,11 +5,12 @@ exports[`Icon > Snapshot: title prop 1`] = `
|
|
|
5
5
|
class="ucl-uikit-icon css-148hpxb"
|
|
6
6
|
data-testid="ucl-uikit-icon"
|
|
7
7
|
fill="none"
|
|
8
|
+
focusable="false"
|
|
8
9
|
height="24"
|
|
9
10
|
stroke="currentColor"
|
|
10
11
|
stroke-linecap="round"
|
|
11
12
|
stroke-linejoin="round"
|
|
12
|
-
stroke-width="
|
|
13
|
+
stroke-width="2"
|
|
13
14
|
viewBox="0 0 24 24"
|
|
14
15
|
width="24"
|
|
15
16
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -17,8 +18,8 @@ exports[`Icon > Snapshot: title prop 1`] = `
|
|
|
17
18
|
<title>
|
|
18
19
|
Custom Title
|
|
19
20
|
</title>
|
|
20
|
-
<
|
|
21
|
-
|
|
21
|
+
<path
|
|
22
|
+
d="M20 6 9 17l-5-5"
|
|
22
23
|
/>
|
|
23
24
|
</svg>
|
|
24
25
|
`;
|
|
@@ -28,17 +29,18 @@ exports[`Icon > snapshot: className prop 1`] = `
|
|
|
28
29
|
class="ucl-uikit-icon css-148hpxb a-class-name"
|
|
29
30
|
data-testid="ucl-uikit-icon"
|
|
30
31
|
fill="none"
|
|
32
|
+
focusable="false"
|
|
31
33
|
height="24"
|
|
32
34
|
stroke="currentColor"
|
|
33
35
|
stroke-linecap="round"
|
|
34
36
|
stroke-linejoin="round"
|
|
35
|
-
stroke-width="
|
|
37
|
+
stroke-width="2"
|
|
36
38
|
viewBox="0 0 24 24"
|
|
37
39
|
width="24"
|
|
38
40
|
xmlns="http://www.w3.org/2000/svg"
|
|
39
41
|
>
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
+
<path
|
|
43
|
+
d="M20 6 9 17l-5-5"
|
|
42
44
|
/>
|
|
43
45
|
</svg>
|
|
44
46
|
`;
|
|
@@ -48,17 +50,18 @@ exports[`Icon > snapshot: no props 1`] = `
|
|
|
48
50
|
class="ucl-uikit-icon css-148hpxb"
|
|
49
51
|
data-testid="ucl-uikit-icon"
|
|
50
52
|
fill="none"
|
|
53
|
+
focusable="false"
|
|
51
54
|
height="24"
|
|
52
55
|
stroke="currentColor"
|
|
53
56
|
stroke-linecap="round"
|
|
54
57
|
stroke-linejoin="round"
|
|
55
|
-
stroke-width="
|
|
58
|
+
stroke-width="2"
|
|
56
59
|
viewBox="0 0 24 24"
|
|
57
60
|
width="24"
|
|
58
61
|
xmlns="http://www.w3.org/2000/svg"
|
|
59
62
|
>
|
|
60
|
-
<
|
|
61
|
-
|
|
63
|
+
<path
|
|
64
|
+
d="M20 6 9 17l-5-5"
|
|
62
65
|
/>
|
|
63
66
|
</svg>
|
|
64
67
|
`;
|
|
@@ -68,17 +71,18 @@ exports[`Icon > snapshot: size prop 1`] = `
|
|
|
68
71
|
class="ucl-uikit-icon css-148hpxb"
|
|
69
72
|
data-testid="ucl-uikit-icon"
|
|
70
73
|
fill="none"
|
|
74
|
+
focusable="false"
|
|
71
75
|
height="32"
|
|
72
76
|
stroke="currentColor"
|
|
73
77
|
stroke-linecap="round"
|
|
74
78
|
stroke-linejoin="round"
|
|
75
|
-
stroke-width="
|
|
79
|
+
stroke-width="2"
|
|
76
80
|
viewBox="0 0 24 24"
|
|
77
81
|
width="32"
|
|
78
82
|
xmlns="http://www.w3.org/2000/svg"
|
|
79
83
|
>
|
|
80
|
-
<
|
|
81
|
-
|
|
84
|
+
<path
|
|
85
|
+
d="M20 6 9 17l-5-5"
|
|
82
86
|
/>
|
|
83
87
|
</svg>
|
|
84
88
|
`;
|