uikit-react-public 0.21.8 → 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/dist/components/Heading/Heading.d.ts +6 -4
- package/dist/components/Heading/Heading.stories.d.ts +8 -6
- package/dist/components/Paragraph/Paragraph.d.ts +5 -2
- package/dist/components/Paragraph/Paragraph.stories.d.ts +6 -3
- package/dist/components/index.d.ts +4 -4
- package/dist/index.js +3852 -3952
- 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/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/index.ts +4 -4
- package/package.json +1 -1
- package/dist/components/HeadingNew/Heading.d.ts +0 -13
- package/dist/components/HeadingNew/index.d.ts +0 -2
- package/dist/components/ParagraphNew/Paragraph.d.ts +0 -13
- package/dist/components/ParagraphNew/index.d.ts +0 -4
- package/lib/components/HeadingNew/Heading.tsx +0 -208
- package/lib/components/HeadingNew/index.ts +0 -2
- package/lib/components/ParagraphNew/Paragraph.tsx +0 -200
- package/lib/components/ParagraphNew/index.ts +0 -6
|
@@ -16,73 +16,66 @@ type Story = StoryObj<typeof meta>;
|
|
|
16
16
|
|
|
17
17
|
export const Default: Story = {
|
|
18
18
|
args: {
|
|
19
|
+
level: 'md',
|
|
19
20
|
children: 'Default Heading',
|
|
20
21
|
},
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
export const
|
|
24
|
+
export const LevelXxl: Story = {
|
|
24
25
|
args: {
|
|
25
|
-
level:
|
|
26
|
-
children: 'Heading level
|
|
26
|
+
level: 'xxl',
|
|
27
|
+
children: 'Heading level XXL',
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
export const
|
|
31
|
+
export const LevelXl: Story = {
|
|
31
32
|
args: {
|
|
32
|
-
level:
|
|
33
|
-
children: 'Heading level
|
|
33
|
+
level: 'xl',
|
|
34
|
+
children: 'Heading level XL',
|
|
34
35
|
},
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
export const
|
|
38
|
+
export const LevelLg: Story = {
|
|
38
39
|
args: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
children: 'Heading level 3',
|
|
40
|
+
level: 'lg',
|
|
41
|
+
children: 'Heading level LG',
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
export const
|
|
45
|
+
export const LevelMd: Story = {
|
|
46
46
|
args: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
children: 'Heading level 4',
|
|
47
|
+
level: 'md',
|
|
48
|
+
children: 'Heading level MD',
|
|
50
49
|
},
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
export const
|
|
54
|
-
name: 'Heading with margins',
|
|
52
|
+
export const LevelSm: Story = {
|
|
55
53
|
args: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
level: 'sm',
|
|
55
|
+
children: 'Heading level SM',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const LevelXs: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
level: 'xs',
|
|
62
|
+
children: 'Heading level XS',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const AsSpan: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
as: 'span',
|
|
69
|
+
level: 'lg',
|
|
70
|
+
children: 'Heading rendered as span',
|
|
59
71
|
},
|
|
60
|
-
decorators: [
|
|
61
|
-
(Story) => (
|
|
62
|
-
<div>
|
|
63
|
-
<div
|
|
64
|
-
style={{
|
|
65
|
-
height: '16px',
|
|
66
|
-
backgroundColor: '#CA0007',
|
|
67
|
-
}}
|
|
68
|
-
/>
|
|
69
|
-
<Story />
|
|
70
|
-
<div
|
|
71
|
-
style={{
|
|
72
|
-
height: '16px',
|
|
73
|
-
backgroundColor: '#CA0007',
|
|
74
|
-
}}
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
),
|
|
78
|
-
],
|
|
79
72
|
};
|
|
80
73
|
|
|
81
74
|
export const NoMargins: Story = {
|
|
82
|
-
name: '
|
|
75
|
+
name: 'No margins',
|
|
83
76
|
args: {
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
noMargins: true,
|
|
78
|
+
level: 'md',
|
|
86
79
|
children: 'Heading without margins',
|
|
87
80
|
},
|
|
88
81
|
decorators: [
|
|
@@ -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
|
|
@@ -18,38 +18,40 @@ type Story = StoryObj<typeof meta>;
|
|
|
18
18
|
|
|
19
19
|
export const Default: Story = {};
|
|
20
20
|
|
|
21
|
-
export const
|
|
22
|
-
name: 'With margins',
|
|
21
|
+
export const LevelLg: Story = {
|
|
23
22
|
args: {
|
|
24
|
-
|
|
25
|
-
children: 'This is
|
|
23
|
+
level: 'lg',
|
|
24
|
+
children: 'This is large paragraph text.',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const LevelMd: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
level: 'md',
|
|
31
|
+
children: 'This is medium paragraph text.',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const LevelSm: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
level: 'sm',
|
|
38
|
+
children: 'This is small paragraph text.',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const AsSpan: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
as: 'span',
|
|
45
|
+
level: 'md-semibold',
|
|
46
|
+
children: 'This paragraph is rendered as a span.',
|
|
26
47
|
},
|
|
27
|
-
decorators: [
|
|
28
|
-
(Story) => (
|
|
29
|
-
<>
|
|
30
|
-
<div
|
|
31
|
-
style={{
|
|
32
|
-
height: '16px',
|
|
33
|
-
backgroundColor: '#CA0007',
|
|
34
|
-
}}
|
|
35
|
-
/>
|
|
36
|
-
<Story />
|
|
37
|
-
<div
|
|
38
|
-
style={{
|
|
39
|
-
height: '16px',
|
|
40
|
-
backgroundColor: '#CA0007',
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
</>
|
|
44
|
-
),
|
|
45
|
-
],
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
export const
|
|
49
|
-
name: '
|
|
50
|
+
export const NoMargins: Story = {
|
|
51
|
+
name: 'No margins',
|
|
50
52
|
args: {
|
|
51
|
-
|
|
52
|
-
children: 'This
|
|
53
|
+
noMargins: true,
|
|
54
|
+
children: 'This paragraph has no margins.',
|
|
53
55
|
},
|
|
54
56
|
decorators: [
|
|
55
57
|
(Story) => (
|