uikit-react-public 0.21.8 → 0.22.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.
Files changed (30) hide show
  1. package/dist/components/Heading/Heading.d.ts +6 -4
  2. package/dist/components/Heading/Heading.stories.d.ts +8 -6
  3. package/dist/components/Paragraph/Paragraph.d.ts +5 -2
  4. package/dist/components/Paragraph/Paragraph.stories.d.ts +6 -3
  5. package/dist/components/Spinner/Spinner.d.ts +3 -2
  6. package/dist/components/Spinner/Spinner.stories.d.ts +1 -1
  7. package/dist/components/index.d.ts +6 -4
  8. package/dist/index.js +3712 -3783
  9. package/lib/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +5 -3
  10. package/lib/components/Field/Field.tsx +0 -3
  11. package/lib/components/Heading/Heading.stories.tsx +34 -41
  12. package/lib/components/Heading/Heading.tsx +180 -49
  13. package/lib/components/Heading/__tests__/__snapshots__/Heading.test.tsx.snap +4 -4
  14. package/lib/components/Paragraph/Paragraph.stories.tsx +29 -27
  15. package/lib/components/Paragraph/Paragraph.tsx +212 -81
  16. package/lib/components/Paragraph/__tests__/__snapshots__/Paragraph.test.tsx.snap +5 -5
  17. package/lib/components/Spinner/Spinner.tsx +69 -70
  18. package/lib/components/Spinner/__tests__/Spinner.test.tsx +33 -1
  19. package/lib/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap +20 -12
  20. package/lib/components/Table/improvements-tracking.md +25 -0
  21. package/lib/components/index.ts +7 -4
  22. package/package.json +2 -1
  23. package/dist/components/HeadingNew/Heading.d.ts +0 -13
  24. package/dist/components/HeadingNew/index.d.ts +0 -2
  25. package/dist/components/ParagraphNew/Paragraph.d.ts +0 -13
  26. package/dist/components/ParagraphNew/index.d.ts +0 -4
  27. package/lib/components/HeadingNew/Heading.tsx +0 -208
  28. package/lib/components/HeadingNew/index.ts +0 -2
  29. package/lib/components/ParagraphNew/Paragraph.tsx +0 -200
  30. package/lib/components/ParagraphNew/index.ts +0 -6
@@ -39,17 +39,19 @@ exports[`Button > snapshot: loading 1`] = `
39
39
  disabled=""
40
40
  >
41
41
  <svg
42
- class="ucl-uikit-spinner css-1izyex6"
42
+ aria-label="Loading"
43
+ class="ucl-uikit-spinner css-15f359x"
43
44
  data-testid="ucl-uikit-spinner"
44
45
  height="24"
46
+ role="progressbar"
45
47
  viewBox="0 0 50 50"
46
48
  width="24"
47
49
  >
48
50
  <g
49
- class="css-ypv7tf"
51
+ class="css-swia5b"
50
52
  >
51
53
  <circle
52
- class="css-1w5ipzg"
54
+ class="css-1iyl2x2"
53
55
  cx="25"
54
56
  cy="25"
55
57
  fill="none"
@@ -52,9 +52,6 @@ const Field = ({
52
52
  display: flex;
53
53
  flex-direction: column;
54
54
  gap: 8px;
55
- width: 100%;
56
- min-width: 50px;
57
- max-width: 660px;
58
55
  box-sizing: border-box;
59
56
  `;
60
57
 
@@ -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 Level1: Story = {
24
+ export const LevelXxl: Story = {
24
25
  args: {
25
- level: 1,
26
- children: 'Heading level 1',
26
+ level: 'xxl',
27
+ children: 'Heading level XXL',
27
28
  },
28
29
  };
29
30
 
30
- export const Level2: Story = {
31
+ export const LevelXl: Story = {
31
32
  args: {
32
- level: 2,
33
- children: 'Heading level 2',
33
+ level: 'xl',
34
+ children: 'Heading level XL',
34
35
  },
35
36
  };
36
37
 
37
- export const Level3: Story = {
38
+ export const LevelLg: Story = {
38
39
  args: {
39
- title: 'Heading Level 3',
40
- level: 3,
41
- children: 'Heading level 3',
40
+ level: 'lg',
41
+ children: 'Heading level LG',
42
42
  },
43
43
  };
44
44
 
45
- export const Level4: Story = {
45
+ export const LevelMd: Story = {
46
46
  args: {
47
- title: 'Heading Level 4',
48
- level: 4,
49
- children: 'Heading level 4',
47
+ level: 'md',
48
+ children: 'Heading level MD',
50
49
  },
51
50
  };
52
51
 
53
- export const Margins: Story = {
54
- name: 'Heading with margins',
52
+ export const LevelSm: Story = {
55
53
  args: {
56
- title: 'Heading with margins',
57
- margins: true,
58
- children: 'Heading with margins',
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: 'Heading without margins',
75
+ name: 'No margins',
83
76
  args: {
84
- title: 'Heading without margins',
85
- margins: false,
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, forwardRef } from 'react';
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
- margins?: boolean; // todo: deprecate
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
- export type Ref = HTMLHeadingElement;
17
-
18
- const Heading = forwardRef<Ref, HeadingProps>(
19
- ({ level = 1, margins = true, testId = NAME, className, ...props }, ref) => {
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
- font: { size, lineHeight },
34
+ typography: {
35
+ heading: { xxl, xl, lg, md, sm, xs },
36
+ },
24
37
  } = theme;
25
38
 
26
- const level1Style = css`
27
- font-size: ${size.f36};
28
- line-height: ${lineHeight.h130};
29
- @media screen and (min-width: ${theme.breakpoints.desktop}px) {
30
- font-size: ${size.f40};
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 level2Style = css`
35
- font-size: ${size.f28};
36
- line-height: ${lineHeight.h140};
37
- @media screen and (min-width: ${theme.breakpoints.desktop}px) {
38
- font-size: ${size.f32};
39
- line-height: ${lineHeight.h130};
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 level3Style = css`
44
- font-size: ${size.f20};
45
- line-height: ${lineHeight.h140};
46
- @media screen and (min-width: ${theme.breakpoints.desktop}px) {
47
- font-size: ${size.f24};
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 level4Style = css`
52
- font-size: ${size.f16};
53
- line-height: ${lineHeight.h150};
54
- @media screen and (min-width: ${theme.breakpoints.desktop}px) {
55
- font-size: ${size.f18};
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 baseStyle = css`
60
- font-family: ${theme.font.family.primary};
61
- font-weight: bold;
62
- color: ${theme.color.text.primary};
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 noMarginsStyle = css`
66
- margin: 0;
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
- marginsStyle(props, theme),
73
- level === 1 && level1Style,
74
- level === 2 && level2Style,
75
- level === 3 && level3Style,
76
- level === 4 && level4Style,
77
- margins === false && noMarginsStyle,
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 HeadingTag = `h${level}` as 'h1' | 'h2' | 'h3' | 'h4';
152
+ const headingTag = (as || defaultHeadingTag) as keyof JSX.IntrinsicElements;
82
153
 
83
154
  return (
84
- <HeadingTag
85
- ref={ref}
86
- className={style}
87
- data-testid={testId}
88
- {...props}
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 memo(Heading);
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-1bjykaw"
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-1bjykaw"
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-1bjykaw"
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-x9klp3"
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 WithMargins: Story = {
22
- name: 'With margins',
21
+ export const LevelLg: Story = {
23
22
  args: {
24
- margins: true,
25
- children: 'This is a paragraph with margins.',
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 WithoutMargins: Story = {
49
- name: 'Without margins',
50
+ export const NoMargins: Story = {
51
+ name: 'No margins',
50
52
  args: {
51
- margins: false,
52
- children: 'This is a paragraph without margins.',
53
+ noMargins: true,
54
+ children: 'This paragraph has no margins.',
53
55
  },
54
56
  decorators: [
55
57
  (Story) => (