carbon-react 119.12.1 → 120.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/esm/__internal__/input/input-presentation.style.d.ts +1 -1
- package/esm/__spec_helper__/test-utils.d.ts +3 -2
- package/esm/__spec_helper__/test-utils.js +15 -1
- package/esm/components/box/box.component.d.ts +23 -6
- package/esm/components/box/box.component.js +3570 -103
- package/esm/components/box/box.style.d.ts +3 -0
- package/esm/components/box/box.style.js +112 -0
- package/esm/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/esm/components/drawer/drawer.style.d.ts +2 -1
- package/esm/components/duelling-picklist/picklist/picklist.style.js +4 -2
- package/esm/components/flat-table/flat-table.style.js +2 -2
- package/esm/components/heading/heading.style.d.ts +4 -9
- package/esm/components/menu/menu-full-screen/menu-full-screen.style.js +2 -2
- package/esm/components/menu/scrollable-block/scrollable-block.style.js +2 -2
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js +1 -1
- package/esm/components/typography/typography.component.d.ts +25 -15
- package/esm/components/typography/typography.component.js +37 -184
- package/esm/components/typography/typography.style.d.ts +12 -0
- package/esm/components/typography/typography.style.js +190 -0
- package/esm/components/vertical-menu/vertical-menu.style.js +3 -3
- package/esm/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-flexbox-props.js +5 -0
- package/esm/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-grid-props.js +5 -0
- package/esm/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-layout-props.js +5 -0
- package/esm/style/utils/index.d.ts +4 -1
- package/esm/style/utils/index.js +4 -1
- package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
- package/lib/__spec_helper__/test-utils.d.ts +3 -2
- package/lib/__spec_helper__/test-utils.js +16 -1
- package/lib/components/box/box.component.d.ts +23 -6
- package/lib/components/box/box.component.js +3569 -105
- package/lib/components/box/box.style.d.ts +3 -0
- package/lib/components/box/box.style.js +122 -0
- package/lib/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/lib/components/drawer/drawer.style.d.ts +2 -1
- package/lib/components/duelling-picklist/picklist/picklist.style.js +2 -1
- package/lib/components/flat-table/flat-table.style.js +1 -1
- package/lib/components/heading/heading.style.d.ts +4 -9
- package/lib/components/menu/menu-full-screen/menu-full-screen.style.js +1 -1
- package/lib/components/menu/scrollable-block/scrollable-block.style.js +1 -1
- package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js +1 -1
- package/lib/components/typography/typography.component.d.ts +25 -15
- package/lib/components/typography/typography.component.js +39 -187
- package/lib/components/typography/typography.style.d.ts +12 -0
- package/lib/components/typography/typography.style.js +200 -0
- package/lib/components/vertical-menu/vertical-menu.style.js +1 -1
- package/lib/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-flexbox-props.js +14 -0
- package/lib/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-grid-props.js +14 -0
- package/lib/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-layout-props.js +14 -0
- package/lib/style/utils/index.d.ts +4 -1
- package/lib/style/utils/index.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { space, layout, flexbox, grid, position as positionFn } from "styled-system";
|
|
3
|
+
import BaseTheme from "../../style/themes/base";
|
|
4
|
+
import styledColor from "../../style/utils/color";
|
|
5
|
+
import boxConfig from "./box.config";
|
|
6
|
+
const calculatePosition = props => {
|
|
7
|
+
const {
|
|
8
|
+
position,
|
|
9
|
+
...rest
|
|
10
|
+
} = positionFn(props);
|
|
11
|
+
return {
|
|
12
|
+
position,
|
|
13
|
+
zIndex: ["sticky", "fixed"].includes(position) ? 1 : undefined,
|
|
14
|
+
...rest
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const StyledBox = styled.div`
|
|
18
|
+
${space}
|
|
19
|
+
${layout}
|
|
20
|
+
${flexbox}
|
|
21
|
+
${grid}
|
|
22
|
+
${calculatePosition}
|
|
23
|
+
|
|
24
|
+
${({
|
|
25
|
+
theme,
|
|
26
|
+
borderRadius = "borderRadius000"
|
|
27
|
+
}) => !theme.roundedCornersOptOut && css`
|
|
28
|
+
border-radius: var(--${borderRadius});
|
|
29
|
+
`}
|
|
30
|
+
|
|
31
|
+
${({
|
|
32
|
+
color,
|
|
33
|
+
bg,
|
|
34
|
+
backgroundColor,
|
|
35
|
+
...rest
|
|
36
|
+
}) => styledColor({
|
|
37
|
+
color,
|
|
38
|
+
bg,
|
|
39
|
+
backgroundColor,
|
|
40
|
+
...rest
|
|
41
|
+
})}
|
|
42
|
+
|
|
43
|
+
${({
|
|
44
|
+
overflowWrap
|
|
45
|
+
}) => overflowWrap && css`
|
|
46
|
+
overflow-wrap: ${overflowWrap};
|
|
47
|
+
`}
|
|
48
|
+
|
|
49
|
+
${({
|
|
50
|
+
height
|
|
51
|
+
}) => height && css`
|
|
52
|
+
height: ${height};
|
|
53
|
+
`}
|
|
54
|
+
|
|
55
|
+
${({
|
|
56
|
+
width
|
|
57
|
+
}) => width && css`
|
|
58
|
+
width: ${width};
|
|
59
|
+
`}
|
|
60
|
+
|
|
61
|
+
${({
|
|
62
|
+
scrollVariant
|
|
63
|
+
}) => scrollVariant && css`
|
|
64
|
+
scrollbar-color: ${boxConfig[scrollVariant].thumb}
|
|
65
|
+
${boxConfig[scrollVariant].track};
|
|
66
|
+
|
|
67
|
+
&::-webkit-scrollbar {
|
|
68
|
+
width: 8px;
|
|
69
|
+
}
|
|
70
|
+
&::-webkit-scrollbar-track {
|
|
71
|
+
background-color: ${boxConfig[scrollVariant].track};
|
|
72
|
+
}
|
|
73
|
+
&::-webkit-scrollbar-thumb {
|
|
74
|
+
background-color: ${boxConfig[scrollVariant].thumb};
|
|
75
|
+
}
|
|
76
|
+
`}
|
|
77
|
+
|
|
78
|
+
${({
|
|
79
|
+
boxSizing
|
|
80
|
+
}) => boxSizing && css`
|
|
81
|
+
box-sizing: ${boxSizing};
|
|
82
|
+
`}
|
|
83
|
+
|
|
84
|
+
${({
|
|
85
|
+
display,
|
|
86
|
+
gap,
|
|
87
|
+
columnGap,
|
|
88
|
+
rowGap
|
|
89
|
+
}) => (display === "flex" || display === "inline-flex" || display === "grid" || display === "inline-grid") && css`
|
|
90
|
+
${gap !== undefined && css`
|
|
91
|
+
gap: ${boxConfig.gap(gap)};
|
|
92
|
+
`}
|
|
93
|
+
|
|
94
|
+
${columnGap !== undefined && css`
|
|
95
|
+
column-gap: ${boxConfig.gap(columnGap)};
|
|
96
|
+
`}
|
|
97
|
+
|
|
98
|
+
${rowGap !== undefined && css`
|
|
99
|
+
row-gap: ${boxConfig.gap(rowGap)};
|
|
100
|
+
`}
|
|
101
|
+
`};
|
|
102
|
+
|
|
103
|
+
${({
|
|
104
|
+
boxShadow
|
|
105
|
+
}) => boxShadow && css`
|
|
106
|
+
box-shadow: var(--${boxShadow});
|
|
107
|
+
`}
|
|
108
|
+
`;
|
|
109
|
+
StyledBox.defaultProps = {
|
|
110
|
+
theme: BaseTheme
|
|
111
|
+
};
|
|
112
|
+
export default StyledBox;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export interface StyledDismissibleBoxProps {
|
|
2
3
|
/** Flag to control whether the thicker left border highlight should be rendered */
|
|
3
4
|
hasBorderLeftHighlight?: boolean;
|
|
4
5
|
/** Set the base color variant */
|
|
5
6
|
variant?: "light" | "dark";
|
|
6
7
|
}
|
|
7
|
-
declare const StyledDismissibleBox: import("styled-components").StyledComponent<"
|
|
8
|
+
declare const StyledDismissibleBox: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../box").BoxProps & import("react").RefAttributes<HTMLDivElement>>, any, StyledDismissibleBoxProps, never>;
|
|
8
9
|
export { StyledDismissibleBox };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare const StyledSidebarHeader: import("styled-components").StyledComponent<"div", any, {
|
|
2
3
|
isExpanded?: boolean | undefined;
|
|
3
4
|
}, never>;
|
|
@@ -7,7 +8,7 @@ interface StyledDrawerSidebarProps {
|
|
|
7
8
|
isExpanded?: boolean;
|
|
8
9
|
hasControls: boolean;
|
|
9
10
|
}
|
|
10
|
-
declare const StyledDrawerSidebar: import("styled-components").StyledComponent<"
|
|
11
|
+
declare const StyledDrawerSidebar: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../box").BoxProps & import("react").RefAttributes<HTMLDivElement>>, any, StyledDrawerSidebarProps, never>;
|
|
11
12
|
interface StyledDrawerContentProps {
|
|
12
13
|
animationDuration?: string;
|
|
13
14
|
backgroundColor?: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import StyledBox from "../../box/box.style";
|
|
3
|
+
|
|
4
|
+
// TODO: remove polymorphism when we revisit as part of ticket FE-6177
|
|
5
|
+
const StyledPicklist = styled(StyledBox).attrs({
|
|
4
6
|
as: "ul"
|
|
5
7
|
})`
|
|
6
8
|
position: relative;
|
|
@@ -7,7 +7,7 @@ import StyledFlatTableCheckbox from "./flat-table-checkbox/flat-table-checkbox.s
|
|
|
7
7
|
import { baseTheme } from "../../style/themes";
|
|
8
8
|
import { StyledFlatTableCell } from "./flat-table-cell/flat-table-cell.style";
|
|
9
9
|
import cellSizes from "./cell-sizes.style";
|
|
10
|
-
import
|
|
10
|
+
import StyledBox from "../box/box.style";
|
|
11
11
|
import { StyledPagerContainer } from "../pager/pager.style";
|
|
12
12
|
import addFocusStyling from "../../style/utils/add-focus-styling";
|
|
13
13
|
const HEADER_OVERLAY_INCREMENT = 3;
|
|
@@ -93,7 +93,7 @@ const StyledFlatTable = styled.table`
|
|
|
93
93
|
}
|
|
94
94
|
`}
|
|
95
95
|
`;
|
|
96
|
-
const StyledFlatTableWrapper = styled(
|
|
96
|
+
const StyledFlatTableWrapper = styled(StyledBox)`
|
|
97
97
|
border-top-left-radius: var(--borderRadius100);
|
|
98
98
|
border-top-right-radius: var(--borderRadius100);
|
|
99
99
|
${({
|
|
@@ -11,15 +11,10 @@ declare const StyledHeadingBackButton: import("styled-components").StyledCompone
|
|
|
11
11
|
declare type StyledHeadingTitleProps = {
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
|
-
declare const StyledHeadingTitle: import("styled-components").StyledComponent<
|
|
15
|
-
as: import("react").
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
textTransform: string;
|
|
19
|
-
textDecoration: string;
|
|
20
|
-
lineHeight: string;
|
|
21
|
-
defaultMargin: string;
|
|
22
|
-
} & import("../typography").TypographyProps & StyledHeadingTitleProps, "as" | "textDecoration" | "size" | "lineHeight" | "textTransform" | "weight" | "defaultMargin">;
|
|
14
|
+
declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
|
|
15
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
|
+
displayName: string;
|
|
17
|
+
}, any, StyledHeadingTitleProps, never>;
|
|
23
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
24
19
|
declare type StyledSubHeaderProps = {
|
|
25
20
|
hasBackLink?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { baseTheme } from "../../../style/themes";
|
|
3
3
|
import StyledIconButton from "../../icon-button/icon-button.style";
|
|
4
|
-
import
|
|
4
|
+
import StyledBox from "../../box/box.style";
|
|
5
5
|
import StyledSearch from "../../search/search.style";
|
|
6
6
|
import StyledIcon from "../../icon/icon.style";
|
|
7
7
|
import StyledButton from "../../button/button.style";
|
|
@@ -90,7 +90,7 @@ const StyledMenuFullscreen = styled.div`
|
|
|
90
90
|
`}
|
|
91
91
|
`}
|
|
92
92
|
|
|
93
|
-
${
|
|
93
|
+
${StyledBox} {
|
|
94
94
|
&::-webkit-scrollbar {
|
|
95
95
|
width: 16px;
|
|
96
96
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import StyledMenuItemWrapper from "../menu-item/menu-item.style";
|
|
3
3
|
import menuConfigVariants from "../menu.config";
|
|
4
|
-
import
|
|
4
|
+
import StyledBox from "../../box/box.style";
|
|
5
5
|
import { StyledMenuItem } from "../menu.style";
|
|
6
6
|
import { StyledLink } from "../../link/link.style";
|
|
7
7
|
const StyledScrollableBlock = styled.li`
|
|
@@ -13,7 +13,7 @@ const StyledScrollableBlock = styled.li`
|
|
|
13
13
|
background-color: ${variant === "default" ? menuConfigVariants[menuType].submenuItemBackground : menuConfigVariants[menuType].alternate};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
${
|
|
16
|
+
${StyledBox} {
|
|
17
17
|
border-radius: var(--borderRadius000);
|
|
18
18
|
border-bottom-left-radius: var(--borderRadius100);
|
|
19
19
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
3
4
|
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
4
5
|
export declare type VariantTypes = typeof VARIANT_TYPES[number];
|
|
5
|
-
export interface TypographyProps extends SpaceProps,
|
|
6
|
+
export interface TypographyProps extends SpaceProps, TagProps {
|
|
6
7
|
/** Override the variant component */
|
|
7
8
|
as?: React.ElementType;
|
|
9
|
+
/** Set the ID attribute of the Typography component */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Content to be rendered inside the Typography component */
|
|
12
|
+
children?: React.ReactNode;
|
|
8
13
|
/** The visual style to apply to the component */
|
|
9
14
|
variant?: VariantTypes;
|
|
10
15
|
/** Override the variant font-size */
|
|
@@ -21,22 +26,27 @@ export interface TypographyProps extends SpaceProps, ColorProps {
|
|
|
21
26
|
display?: string;
|
|
22
27
|
/** Override the list-style-type */
|
|
23
28
|
listStyleType?: string;
|
|
24
|
-
/** Override the white-space
|
|
29
|
+
/** Override the white-space */
|
|
25
30
|
whiteSpace?: string;
|
|
26
|
-
/** Override the word-wrap
|
|
31
|
+
/** Override the word-wrap */
|
|
27
32
|
wordWrap?: string;
|
|
28
|
-
/** Override the text-overflow
|
|
33
|
+
/** Override the text-overflow */
|
|
29
34
|
textOverflow?: string;
|
|
30
35
|
/** Apply truncation */
|
|
31
36
|
truncate?: boolean;
|
|
37
|
+
/** Override the color style */
|
|
38
|
+
color?: string;
|
|
39
|
+
/** Override the backgroundColor style */
|
|
40
|
+
backgroundColor?: string;
|
|
41
|
+
/** Override the bg value shorthand for backgroundColor */
|
|
42
|
+
bg?: string;
|
|
43
|
+
/** Override the opacity value */
|
|
44
|
+
opacity?: string | number;
|
|
45
|
+
/** @private @ignore */
|
|
46
|
+
className?: string;
|
|
32
47
|
}
|
|
33
|
-
declare const Typography:
|
|
34
|
-
as:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
textTransform: string;
|
|
38
|
-
textDecoration: string;
|
|
39
|
-
lineHeight: string;
|
|
40
|
-
defaultMargin: string;
|
|
41
|
-
} & TypographyProps, "as" | "textDecoration" | "size" | "lineHeight" | "textTransform" | "weight" | "defaultMargin">;
|
|
48
|
+
export declare const Typography: {
|
|
49
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, ...rest }: TypographyProps): React.JSX.Element;
|
|
50
|
+
displayName: string;
|
|
51
|
+
};
|
|
42
52
|
export default Typography;
|
|
@@ -1,202 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
import { filterStyledSystemMarginProps, filterStyledSystemPaddingProps } from "../../style/utils";
|
|
6
|
+
import StyledTypography from "./typography.style";
|
|
6
7
|
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return "h1";
|
|
11
|
-
case "segment-header":
|
|
12
|
-
case "segment-header-small":
|
|
13
|
-
case "segment-subheader":
|
|
14
|
-
case "segment-subheader-alt":
|
|
15
|
-
return "h5";
|
|
16
|
-
case "big":
|
|
17
|
-
return "p";
|
|
18
|
-
default:
|
|
19
|
-
return variant;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const getSize = variant => {
|
|
23
|
-
switch (variant) {
|
|
24
|
-
case "h1-large":
|
|
25
|
-
return "32px";
|
|
26
|
-
case "h1":
|
|
27
|
-
return "24px";
|
|
28
|
-
case "h2":
|
|
29
|
-
return "22px";
|
|
30
|
-
case "h3":
|
|
31
|
-
case "segment-header":
|
|
32
|
-
return "20px";
|
|
33
|
-
case "h4":
|
|
34
|
-
case "segment-header-small":
|
|
35
|
-
return "18px";
|
|
36
|
-
case "h5":
|
|
37
|
-
case "segment-subheader":
|
|
38
|
-
case "big":
|
|
39
|
-
return "16px";
|
|
40
|
-
case "small":
|
|
41
|
-
case "sub":
|
|
42
|
-
case "sup":
|
|
43
|
-
return "13px";
|
|
44
|
-
case "segment-subheader-alt":
|
|
45
|
-
case "p":
|
|
46
|
-
case "b":
|
|
47
|
-
case "strong":
|
|
48
|
-
case "em":
|
|
49
|
-
default:
|
|
50
|
-
return "14px";
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const getLineHeight = variant => {
|
|
54
|
-
switch (variant) {
|
|
55
|
-
case "h1-large":
|
|
56
|
-
return "40px";
|
|
57
|
-
case "h1":
|
|
58
|
-
case "segment-subheader":
|
|
59
|
-
return "31px";
|
|
60
|
-
case "h2":
|
|
61
|
-
return "29px";
|
|
62
|
-
case "h3":
|
|
63
|
-
case "segment-header":
|
|
64
|
-
return "26px";
|
|
65
|
-
case "big":
|
|
66
|
-
return "24px";
|
|
67
|
-
case "h4":
|
|
68
|
-
case "segment-header-small":
|
|
69
|
-
return "23px";
|
|
70
|
-
case "small":
|
|
71
|
-
case "sub":
|
|
72
|
-
case "sup":
|
|
73
|
-
return "20px";
|
|
74
|
-
case "h5":
|
|
75
|
-
case "segment-subheader-alt":
|
|
76
|
-
case "p":
|
|
77
|
-
case "b":
|
|
78
|
-
case "strong":
|
|
79
|
-
case "em":
|
|
80
|
-
default:
|
|
81
|
-
return "21px";
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const getWeight = variant => {
|
|
85
|
-
switch (variant) {
|
|
86
|
-
case "h1-large":
|
|
87
|
-
case "h1":
|
|
88
|
-
case "segment-header":
|
|
89
|
-
case "segment-header-small":
|
|
90
|
-
return "900";
|
|
91
|
-
case "h2":
|
|
92
|
-
case "h3":
|
|
93
|
-
case "segment-subheader":
|
|
94
|
-
case "segment-subheader-alt":
|
|
95
|
-
case "b":
|
|
96
|
-
case "em":
|
|
97
|
-
case "strong":
|
|
98
|
-
return "700";
|
|
99
|
-
case "h4":
|
|
100
|
-
case "h5":
|
|
101
|
-
case "p":
|
|
102
|
-
case "small":
|
|
103
|
-
case "big":
|
|
104
|
-
case "sub":
|
|
105
|
-
case "sup":
|
|
106
|
-
default:
|
|
107
|
-
return "400";
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const getTransform = variant => {
|
|
111
|
-
if (variant === "segment-subheader-alt") {
|
|
112
|
-
return "uppercase";
|
|
113
|
-
}
|
|
114
|
-
return "none";
|
|
115
|
-
};
|
|
116
|
-
const getDecoration = variant => {
|
|
117
|
-
if (variant === "em") {
|
|
118
|
-
return "underline";
|
|
119
|
-
}
|
|
120
|
-
return "none";
|
|
121
|
-
};
|
|
122
|
-
let isDeprecationWarningTriggered = false;
|
|
123
|
-
const Typography = styled.span.attrs(({
|
|
124
|
-
variant,
|
|
8
|
+
export const Typography = ({
|
|
9
|
+
"data-component": dataComponent,
|
|
10
|
+
variant = "p",
|
|
125
11
|
as,
|
|
12
|
+
id,
|
|
126
13
|
fontSize,
|
|
127
14
|
fontWeight,
|
|
128
15
|
textTransform,
|
|
129
16
|
lineHeight,
|
|
130
|
-
textDecoration
|
|
131
|
-
}) => {
|
|
132
|
-
return {
|
|
133
|
-
as: as || getAs(variant),
|
|
134
|
-
size: fontSize || getSize(variant),
|
|
135
|
-
weight: fontWeight || getWeight(variant),
|
|
136
|
-
textTransform: textTransform || getTransform(variant),
|
|
137
|
-
textDecoration: textDecoration || getDecoration(variant),
|
|
138
|
-
lineHeight: lineHeight || getLineHeight(variant),
|
|
139
|
-
defaultMargin: variant === "p" ? "0 0 16px" : "0"
|
|
140
|
-
};
|
|
141
|
-
})`
|
|
142
|
-
${() => {
|
|
143
|
-
if (!isDeprecationWarningTriggered) {
|
|
144
|
-
isDeprecationWarningTriggered = true;
|
|
145
|
-
Logger.deprecate("Previous props that could be spread to the `Typography` component are being removed. Only props documented in the intefaces will be supported.");
|
|
146
|
-
}
|
|
147
|
-
return css``;
|
|
148
|
-
}}
|
|
149
|
-
${({
|
|
150
|
-
size,
|
|
151
|
-
weight,
|
|
152
|
-
textTransform,
|
|
153
|
-
lineHeight,
|
|
154
|
-
defaultMargin,
|
|
155
17
|
textDecoration,
|
|
156
18
|
display,
|
|
157
|
-
variant,
|
|
158
19
|
listStyleType,
|
|
159
20
|
whiteSpace,
|
|
160
21
|
wordWrap,
|
|
161
22
|
textOverflow,
|
|
162
|
-
truncate
|
|
163
|
-
|
|
164
|
-
font-style: normal;
|
|
165
|
-
font-size: ${size};
|
|
166
|
-
font-weight: ${weight};
|
|
167
|
-
text-transform: ${textTransform};
|
|
168
|
-
text-decoration: ${textDecoration};
|
|
169
|
-
line-height: ${lineHeight};
|
|
170
|
-
margin: ${defaultMargin};
|
|
171
|
-
padding: 0;
|
|
172
|
-
white-space: ${truncate ? "nowrap" : whiteSpace};
|
|
173
|
-
word-wrap: ${wordWrap};
|
|
174
|
-
text-overflow: ${truncate ? "ellipsis" : textOverflow};
|
|
175
|
-
${truncate && css`
|
|
176
|
-
overflow: hidden;
|
|
177
|
-
`};
|
|
178
|
-
${variant === "sup" && "vertical-align: super;"};
|
|
179
|
-
${variant === "sub" && "vertical-align: sub;"};
|
|
180
|
-
${display && `display: ${display};`};
|
|
181
|
-
${listStyleType && `list-style-type: ${listStyleType};`}; ;
|
|
182
|
-
`}
|
|
183
|
-
${space}
|
|
184
|
-
${({
|
|
185
|
-
color,
|
|
186
|
-
bg,
|
|
23
|
+
truncate,
|
|
24
|
+
color = "blackOpacity90",
|
|
187
25
|
backgroundColor,
|
|
188
|
-
...rest
|
|
189
|
-
}) => styledColor({
|
|
190
|
-
color,
|
|
191
26
|
bg,
|
|
192
|
-
|
|
27
|
+
opacity,
|
|
28
|
+
children,
|
|
29
|
+
className,
|
|
193
30
|
...rest
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
31
|
+
}) => {
|
|
32
|
+
return /*#__PURE__*/React.createElement(StyledTypography, _extends({
|
|
33
|
+
variant: variant,
|
|
34
|
+
as: as,
|
|
35
|
+
id: id,
|
|
36
|
+
fontSize: fontSize,
|
|
37
|
+
fontWeight: fontWeight,
|
|
38
|
+
textTransform: textTransform,
|
|
39
|
+
lineHeight: lineHeight,
|
|
40
|
+
textDecoration: textDecoration,
|
|
41
|
+
display: display,
|
|
42
|
+
listStyleType: listStyleType,
|
|
43
|
+
whiteSpace: whiteSpace,
|
|
44
|
+
wordWrap: wordWrap,
|
|
45
|
+
textOverflow: textOverflow,
|
|
46
|
+
truncate: truncate,
|
|
47
|
+
color: color,
|
|
48
|
+
backgroundColor: backgroundColor,
|
|
49
|
+
bg: bg,
|
|
50
|
+
opacity: opacity,
|
|
51
|
+
className: className
|
|
52
|
+
}, tagComponent(dataComponent, rest), filterStyledSystemMarginProps(rest), filterStyledSystemPaddingProps(rest)), children);
|
|
200
53
|
};
|
|
201
54
|
Typography.displayName = "Typography";
|
|
202
55
|
export default Typography;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TypographyProps } from "./typography.component";
|
|
3
|
+
declare const StyledTypography: import("styled-components").StyledComponent<"span", any, {
|
|
4
|
+
as: import("react").ElementType<any> | undefined;
|
|
5
|
+
size: string;
|
|
6
|
+
weight: string;
|
|
7
|
+
textTransform: string;
|
|
8
|
+
textDecoration: string;
|
|
9
|
+
lineHeight: string;
|
|
10
|
+
defaultMargin: string;
|
|
11
|
+
} & TypographyProps, "as" | "textDecoration" | "size" | "weight" | "textTransform" | "lineHeight" | "defaultMargin">;
|
|
12
|
+
export default StyledTypography;
|