uikit-react-public 0.45.0 → 0.45.2
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/Paragraph/Paragraph.d.ts +1 -1
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/Text/__tests__/Text.test.d.ts +1 -0
- package/dist/index.js +5472 -5378
- package/lib/components/Button/Button.tsx +1 -1
- package/lib/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +8 -8
- package/lib/components/FeedbackDialog/FeedbackDialog.tsx +7 -1
- package/lib/components/Input/Input.tsx +1 -0
- package/lib/components/Input/__tests__/__snapshots__/Input.test.tsx.snap +4 -4
- package/lib/components/Paragraph/Paragraph.tsx +13 -1
- package/lib/components/Paragraph/__tests__/Paragraph.test.tsx +24 -0
- package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +2 -2
- package/lib/components/Text/Text.tsx +13 -0
- package/lib/components/Text/__tests__/Text.test.tsx +41 -0
- package/lib/components/Textarea/Textarea.tsx +2 -3
- package/lib/components/Textarea/__tests__/__snapshots__/Textarea.test.tsx.snap +4 -4
- package/lib/theme/common/themeCommon.ts +305 -327
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`Button > maps legacy destructive prop to destructive variants 1`] = `
|
|
4
4
|
<button
|
|
5
5
|
aria-disabled="false"
|
|
6
|
-
class="ucl-uikit-button css-
|
|
6
|
+
class="ucl-uikit-button css-ijdex1"
|
|
7
7
|
data-testid="ucl-uikit-button"
|
|
8
8
|
>
|
|
9
9
|
Delete
|
|
@@ -13,7 +13,7 @@ exports[`Button > maps legacy destructive prop to destructive variants 1`] = `
|
|
|
13
13
|
exports[`Button > maps legacy size default to medium 1`] = `
|
|
14
14
|
<button
|
|
15
15
|
aria-disabled="false"
|
|
16
|
-
class="ucl-uikit-button css-
|
|
16
|
+
class="ucl-uikit-button css-ijdex1"
|
|
17
17
|
data-testid="ucl-uikit-button"
|
|
18
18
|
>
|
|
19
19
|
Legacy default size
|
|
@@ -23,7 +23,7 @@ exports[`Button > maps legacy size default to medium 1`] = `
|
|
|
23
23
|
exports[`Button > snapshot: 'as' prop with 'a' 1`] = `
|
|
24
24
|
<a
|
|
25
25
|
aria-disabled="false"
|
|
26
|
-
class="ucl-uikit-button css-
|
|
26
|
+
class="ucl-uikit-button css-ijdex1"
|
|
27
27
|
data-testid="ucl-uikit-button"
|
|
28
28
|
href="https://ucl.ac.uk"
|
|
29
29
|
>
|
|
@@ -34,7 +34,7 @@ exports[`Button > snapshot: 'as' prop with 'a' 1`] = `
|
|
|
34
34
|
exports[`Button > snapshot: loading 1`] = `
|
|
35
35
|
<button
|
|
36
36
|
aria-disabled="false"
|
|
37
|
-
class="ucl-uikit-button css-
|
|
37
|
+
class="ucl-uikit-button css-1ram5ew"
|
|
38
38
|
data-testid="ucl-uikit-button"
|
|
39
39
|
disabled=""
|
|
40
40
|
>
|
|
@@ -67,7 +67,7 @@ exports[`Button > snapshot: loading 1`] = `
|
|
|
67
67
|
exports[`Button > snapshot: no props 1`] = `
|
|
68
68
|
<button
|
|
69
69
|
aria-disabled="false"
|
|
70
|
-
class="ucl-uikit-button css-
|
|
70
|
+
class="ucl-uikit-button css-1v2bqw7"
|
|
71
71
|
data-testid="ucl-uikit-button"
|
|
72
72
|
/>
|
|
73
73
|
`;
|
|
@@ -75,7 +75,7 @@ exports[`Button > snapshot: no props 1`] = `
|
|
|
75
75
|
exports[`Button > snapshot: testId prop 1`] = `
|
|
76
76
|
<button
|
|
77
77
|
aria-disabled="false"
|
|
78
|
-
class="ucl-uikit-button css-
|
|
78
|
+
class="ucl-uikit-button css-1v2bqw7"
|
|
79
79
|
data-testid="test123"
|
|
80
80
|
/>
|
|
81
81
|
`;
|
|
@@ -91,7 +91,7 @@ exports[`Button > snapshot: variant prop 1`] = `
|
|
|
91
91
|
exports[`Button > snapshot: with icon 1`] = `
|
|
92
92
|
<button
|
|
93
93
|
aria-disabled="false"
|
|
94
|
-
class="ucl-uikit-button css-
|
|
94
|
+
class="ucl-uikit-button css-ijdex1"
|
|
95
95
|
data-testid="ucl-uikit-button"
|
|
96
96
|
>
|
|
97
97
|
<svg
|
|
@@ -119,7 +119,7 @@ exports[`Button > snapshot: with icon 1`] = `
|
|
|
119
119
|
exports[`Button > snapshot: with icon and iconPosition right 1`] = `
|
|
120
120
|
<button
|
|
121
121
|
aria-disabled="false"
|
|
122
|
-
class="ucl-uikit-button css-
|
|
122
|
+
class="ucl-uikit-button css-ijdex1"
|
|
123
123
|
data-testid="ucl-uikit-button"
|
|
124
124
|
>
|
|
125
125
|
Download
|
|
@@ -28,6 +28,8 @@ const FeedbackDialog = ({
|
|
|
28
28
|
children,
|
|
29
29
|
...props
|
|
30
30
|
}: FeedbackDialogProps) => {
|
|
31
|
+
const isText = typeof children === 'string';
|
|
32
|
+
|
|
31
33
|
const [theme] = useTheme();
|
|
32
34
|
|
|
33
35
|
const {
|
|
@@ -112,7 +114,11 @@ const FeedbackDialog = ({
|
|
|
112
114
|
>
|
|
113
115
|
{heading}
|
|
114
116
|
</Dialog.Header>
|
|
115
|
-
|
|
117
|
+
{isText ? (
|
|
118
|
+
<Paragraph className={textStyle}>{children}</Paragraph>
|
|
119
|
+
) : (
|
|
120
|
+
<div className={textStyle}>{children}</div>
|
|
121
|
+
)}
|
|
116
122
|
<Dialog.Footer
|
|
117
123
|
className={footerStyle}
|
|
118
124
|
primaryButton={buttonLabel}
|
|
@@ -60,6 +60,7 @@ const Input = forwardRef<Ref, InputProps>(
|
|
|
60
60
|
color: ${theme.colour.text.default};
|
|
61
61
|
background-color: ${theme.colour.fill.inverse};
|
|
62
62
|
border: ${theme.border.b1} solid ${theme.colour.speciality.inputDefault};
|
|
63
|
+
border-radius: ${theme.radius.r4};
|
|
63
64
|
outline: none;
|
|
64
65
|
|
|
65
66
|
&::placeholder {
|
|
@@ -5,7 +5,7 @@ exports[`Input > snapshot: no props 1`] = `
|
|
|
5
5
|
class="ucl-uikit-input css-1bpb1dw"
|
|
6
6
|
>
|
|
7
7
|
<input
|
|
8
|
-
class="ucl-uikit-input__input css-
|
|
8
|
+
class="ucl-uikit-input__input css-i99dnf"
|
|
9
9
|
data-testid="ucl-uikit-input"
|
|
10
10
|
id=""
|
|
11
11
|
/>
|
|
@@ -17,7 +17,7 @@ exports[`Input > snapshot: placeholder prop 1`] = `
|
|
|
17
17
|
class="ucl-uikit-input css-1bpb1dw"
|
|
18
18
|
>
|
|
19
19
|
<input
|
|
20
|
-
class="ucl-uikit-input__input css-
|
|
20
|
+
class="ucl-uikit-input__input css-i99dnf"
|
|
21
21
|
data-testid="ucl-uikit-input"
|
|
22
22
|
id=""
|
|
23
23
|
placeholder="Type your value..."
|
|
@@ -30,7 +30,7 @@ exports[`Input > snapshot: testId prop 1`] = `
|
|
|
30
30
|
class="ucl-uikit-input css-1bpb1dw"
|
|
31
31
|
>
|
|
32
32
|
<input
|
|
33
|
-
class="ucl-uikit-input__input css-
|
|
33
|
+
class="ucl-uikit-input__input css-i99dnf"
|
|
34
34
|
data-testid="test123"
|
|
35
35
|
id=""
|
|
36
36
|
/>
|
|
@@ -42,7 +42,7 @@ exports[`Input > snapshot: value prop 1`] = `
|
|
|
42
42
|
class="ucl-uikit-input css-1bpb1dw"
|
|
43
43
|
>
|
|
44
44
|
<input
|
|
45
|
-
class="ucl-uikit-input__input css-
|
|
45
|
+
class="ucl-uikit-input__input css-i99dnf"
|
|
46
46
|
data-testid="ucl-uikit-input"
|
|
47
47
|
id=""
|
|
48
48
|
value="abc"
|
|
@@ -13,7 +13,7 @@ export type ParagraphLevel =
|
|
|
13
13
|
| 'md'
|
|
14
14
|
| 'md-medium'
|
|
15
15
|
| 'md-semibold'
|
|
16
|
-
| 'md-
|
|
16
|
+
| 'md-numeric'
|
|
17
17
|
| 'md-medium-numeric'
|
|
18
18
|
| 'sm'
|
|
19
19
|
| 'sm-medium'
|
|
@@ -57,6 +57,7 @@ const Paragraph = ({
|
|
|
57
57
|
md,
|
|
58
58
|
mdMedium,
|
|
59
59
|
mdSemibold,
|
|
60
|
+
mdNumeric,
|
|
60
61
|
mdMediumNumeric,
|
|
61
62
|
sm,
|
|
62
63
|
smMedium,
|
|
@@ -134,7 +135,17 @@ const Paragraph = ({
|
|
|
134
135
|
line-height: ${mdSemibold.lineHeight}%;
|
|
135
136
|
`;
|
|
136
137
|
|
|
138
|
+
const mdNumericStyle = css`
|
|
139
|
+
font-family: ${mdNumeric.fontFamily};
|
|
140
|
+
font-feature-settings: ${mdNumeric.fontSettings};
|
|
141
|
+
font-size: ${mdNumeric.fontSize}px;
|
|
142
|
+
font-weight: ${mdNumeric.fontWeight};
|
|
143
|
+
line-height: ${mdNumeric.lineHeight}%;
|
|
144
|
+
`;
|
|
145
|
+
|
|
137
146
|
const mdMediumNumericStyle = css`
|
|
147
|
+
font-family: ${mdMediumNumeric.fontFamily};
|
|
148
|
+
font-feature-settings: ${mdMediumNumeric.fontSettings};
|
|
138
149
|
font-size: ${mdMediumNumeric.fontSize}px;
|
|
139
150
|
font-weight: ${mdMediumNumeric.fontWeight};
|
|
140
151
|
line-height: ${mdMediumNumeric.lineHeight}%;
|
|
@@ -180,6 +191,7 @@ const Paragraph = ({
|
|
|
180
191
|
mappedLevel === 'md' && mdStyle,
|
|
181
192
|
mappedLevel === 'md-medium' && mdMediumStyle,
|
|
182
193
|
mappedLevel === 'md-semibold' && mdSemiboldStyle,
|
|
194
|
+
mappedLevel === 'md-numeric' && mdNumericStyle,
|
|
183
195
|
mappedLevel === 'md-medium-numeric' && mdMediumNumericStyle,
|
|
184
196
|
mappedLevel === 'sm' && smStyle,
|
|
185
197
|
mappedLevel === 'sm-medium' && smMediumStyle,
|
|
@@ -73,4 +73,28 @@ describe('Paragraph', () => {
|
|
|
73
73
|
const paragraph = screen.getByTestId('custom-test-id');
|
|
74
74
|
expect(paragraph).toBeDefined();
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
test('md-numeric uses mono font family', () => {
|
|
78
|
+
render(
|
|
79
|
+
<ThemeContextProvider>
|
|
80
|
+
<Paragraph level='md-numeric'>0123456789</Paragraph>
|
|
81
|
+
</ThemeContextProvider>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(document.head.textContent).toContain(
|
|
85
|
+
'font-family:DM Mono;font-size:16px;font-weight:400;line-height:150%;'
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('md-medium-numeric uses mono font family', () => {
|
|
90
|
+
render(
|
|
91
|
+
<ThemeContextProvider>
|
|
92
|
+
<Paragraph level='md-medium-numeric'>0123456789</Paragraph>
|
|
93
|
+
</ThemeContextProvider>
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
expect(document.head.textContent).toContain(
|
|
97
|
+
'font-family:DM Mono;font-size:16px;font-weight:450;line-height:150%;'
|
|
98
|
+
);
|
|
99
|
+
});
|
|
76
100
|
});
|
|
@@ -8,7 +8,7 @@ exports[`Search > snapshot: no props 1`] = `
|
|
|
8
8
|
class="ucl-uikit-input css-1bpb1dw"
|
|
9
9
|
>
|
|
10
10
|
<input
|
|
11
|
-
class="ucl-uikit-input__input css-
|
|
11
|
+
class="ucl-uikit-input__input css-q3oxlx"
|
|
12
12
|
data-testid="ucl-uikit-search"
|
|
13
13
|
id=""
|
|
14
14
|
placeholder=""
|
|
@@ -87,7 +87,7 @@ exports[`Search > snapshot: testId prop 1`] = `
|
|
|
87
87
|
class="ucl-uikit-input css-1bpb1dw"
|
|
88
88
|
>
|
|
89
89
|
<input
|
|
90
|
-
class="ucl-uikit-input__input css-
|
|
90
|
+
class="ucl-uikit-input__input css-q3oxlx"
|
|
91
91
|
data-testid="test123"
|
|
92
92
|
id=""
|
|
93
93
|
placeholder=""
|
|
@@ -12,6 +12,7 @@ export type TextLevel =
|
|
|
12
12
|
| 'md'
|
|
13
13
|
| 'md-medium'
|
|
14
14
|
| 'md-semibold'
|
|
15
|
+
| 'md-numeric'
|
|
15
16
|
| 'md-medium-numeric'
|
|
16
17
|
| 'sm'
|
|
17
18
|
| 'sm-medium'
|
|
@@ -44,6 +45,7 @@ const Text = ({
|
|
|
44
45
|
md,
|
|
45
46
|
mdMedium,
|
|
46
47
|
mdSemibold,
|
|
48
|
+
mdNumeric,
|
|
47
49
|
mdMediumNumeric,
|
|
48
50
|
sm,
|
|
49
51
|
smMedium,
|
|
@@ -103,7 +105,17 @@ const Text = ({
|
|
|
103
105
|
line-height: ${mdSemibold.lineHeight}%;
|
|
104
106
|
`;
|
|
105
107
|
|
|
108
|
+
const mdNumericStyle = css`
|
|
109
|
+
font-family: ${mdNumeric.fontFamily};
|
|
110
|
+
font-feature-settings: ${mdNumeric.fontSettings};
|
|
111
|
+
font-size: ${mdNumeric.fontSize}px;
|
|
112
|
+
font-weight: ${mdNumeric.fontWeight};
|
|
113
|
+
line-height: ${mdNumeric.lineHeight}%;
|
|
114
|
+
`;
|
|
115
|
+
|
|
106
116
|
const mdMediumNumericStyle = css`
|
|
117
|
+
font-family: ${mdMediumNumeric.fontFamily};
|
|
118
|
+
font-feature-settings: ${mdMediumNumeric.fontSettings};
|
|
107
119
|
font-size: ${mdMediumNumeric.fontSize}px;
|
|
108
120
|
font-weight: ${mdMediumNumeric.fontWeight};
|
|
109
121
|
line-height: ${mdMediumNumeric.lineHeight}%;
|
|
@@ -149,6 +161,7 @@ const Text = ({
|
|
|
149
161
|
level === 'md' && mdStyle,
|
|
150
162
|
level === 'md-medium' && mdMediumStyle,
|
|
151
163
|
level === 'md-semibold' && mdSemiboldStyle,
|
|
164
|
+
level === 'md-numeric' && mdNumericStyle,
|
|
152
165
|
level === 'md-medium-numeric' && mdMediumNumericStyle,
|
|
153
166
|
level === 'sm' && smStyle,
|
|
154
167
|
level === 'sm-medium' && smMediumStyle,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import Text from '../Text';
|
|
4
|
+
import { ThemeContextProvider } from '../../../theme/useTheme';
|
|
5
|
+
|
|
6
|
+
describe('Text', () => {
|
|
7
|
+
test('Test ID: Default', () => {
|
|
8
|
+
render(
|
|
9
|
+
<ThemeContextProvider>
|
|
10
|
+
<Text>This is a test</Text>
|
|
11
|
+
</ThemeContextProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const text = screen.getByTestId('ucl-uikit-text');
|
|
15
|
+
expect(text).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('md-numeric uses mono font family', () => {
|
|
19
|
+
render(
|
|
20
|
+
<ThemeContextProvider>
|
|
21
|
+
<Text level='md-numeric'>0123456789</Text>
|
|
22
|
+
</ThemeContextProvider>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(document.head.textContent).toContain(
|
|
26
|
+
'font-family:DM Mono;font-size:16px;font-weight:400;line-height:150%;'
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('md-medium-numeric uses mono font family', () => {
|
|
31
|
+
render(
|
|
32
|
+
<ThemeContextProvider>
|
|
33
|
+
<Text level='md-medium-numeric'>0123456789</Text>
|
|
34
|
+
</ThemeContextProvider>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
expect(document.head.textContent).toContain(
|
|
38
|
+
'font-family:DM Mono;font-size:16px;font-weight:450;line-height:150%;'
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -41,21 +41,20 @@ const Textarea = forwardRef<Ref, TextareaProps>(
|
|
|
41
41
|
}, [value, setCharCount]);
|
|
42
42
|
|
|
43
43
|
const baseStyle = css`
|
|
44
|
-
line-height: 150%;
|
|
45
44
|
box-sizing: border-box;
|
|
46
45
|
padding: ${theme.padding.p16};
|
|
47
46
|
font-family: ${md.fontFamily};
|
|
48
47
|
font-feature-settings: ${md.fontSettings};
|
|
49
48
|
font-size: ${md.fontSize}px;
|
|
50
49
|
font-weight: ${md.fontWeight};
|
|
50
|
+
line-height: ${md.lineHeight}%;
|
|
51
51
|
color: ${theme.colour.text.default};
|
|
52
52
|
background-color: ${theme.colour.fill.inverse};
|
|
53
53
|
border: ${theme.border.b1} solid ${theme.colour.speciality.inputDefault};
|
|
54
|
+
border-radius: ${theme.radius.r4};
|
|
54
55
|
outline: none;
|
|
55
56
|
box-sizing: border-box;
|
|
56
57
|
width: 100%;
|
|
57
|
-
min-width: 50px;
|
|
58
|
-
max-width: 660px;
|
|
59
58
|
height: 106px;
|
|
60
59
|
min-height: 64px;
|
|
61
60
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Textarea > snapshot: Disabled 1`] = `
|
|
4
4
|
<textarea
|
|
5
|
-
class="ucl-uikit-textarea css-
|
|
5
|
+
class="ucl-uikit-textarea css-dbajsl"
|
|
6
6
|
data-testid="ucl-uikit-textarea"
|
|
7
7
|
disabled=""
|
|
8
8
|
id=""
|
|
@@ -11,7 +11,7 @@ exports[`Textarea > snapshot: Disabled 1`] = `
|
|
|
11
11
|
|
|
12
12
|
exports[`Textarea > snapshot: Placeholder 1`] = `
|
|
13
13
|
<textarea
|
|
14
|
-
class="ucl-uikit-textarea css-
|
|
14
|
+
class="ucl-uikit-textarea css-elmoey"
|
|
15
15
|
data-testid="ucl-uikit-textarea"
|
|
16
16
|
id=""
|
|
17
17
|
placeholder="test"
|
|
@@ -20,7 +20,7 @@ exports[`Textarea > snapshot: Placeholder 1`] = `
|
|
|
20
20
|
|
|
21
21
|
exports[`Textarea > snapshot: custom test id 1`] = `
|
|
22
22
|
<textarea
|
|
23
|
-
class="ucl-uikit-textarea css-
|
|
23
|
+
class="ucl-uikit-textarea css-elmoey"
|
|
24
24
|
data-testid="custom-test-id"
|
|
25
25
|
id=""
|
|
26
26
|
/>
|
|
@@ -28,7 +28,7 @@ exports[`Textarea > snapshot: custom test id 1`] = `
|
|
|
28
28
|
|
|
29
29
|
exports[`Textarea > snapshot: minimal props 1`] = `
|
|
30
30
|
<textarea
|
|
31
|
-
class="ucl-uikit-textarea css-
|
|
31
|
+
class="ucl-uikit-textarea css-elmoey"
|
|
32
32
|
data-testid="ucl-uikit-textarea"
|
|
33
33
|
id=""
|
|
34
34
|
/>
|