@sats-group/ui-lib 75.4.0 → 75.5.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/package.json +1 -1
- package/react/select/select.scss +16 -7
- package/react/select/select.tsx +20 -4
- package/react/select/select.types.ts +6 -0
- package/react/text-input/text-input.scss +25 -8
- package/react/text-input/text-input.tsx +10 -4
- package/react/text-input/text-input.types.ts +7 -1
- package/tokens/font-sizes.scss +21 -17
- package/react/select-option/README.md +0 -3
package/package.json
CHANGED
package/react/select/select.scss
CHANGED
|
@@ -41,23 +41,32 @@
|
|
|
41
41
|
transform: translateY(-50%);
|
|
42
42
|
pointer-events: none;
|
|
43
43
|
display: flex;
|
|
44
|
-
align-items: center
|
|
44
|
+
align-items: center;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
@include font-sizes.normal(
|
|
47
|
+
&__select {
|
|
48
|
+
@include font-sizes.normal(input);
|
|
49
49
|
color: light.$on-surface-primary-default;
|
|
50
50
|
appearance: none;
|
|
51
51
|
background-color: transparent;
|
|
52
52
|
border: 1px solid light.$ge-border-default;
|
|
53
53
|
display: block;
|
|
54
|
-
padding-top: clamp(spacing.$xs, 2vw, spacing.$s);
|
|
55
|
-
padding-bottom: clamp(spacing.$xs, 2vw, spacing.$s);
|
|
56
|
-
padding-left: clamp(spacing.$s, 2vw, spacing.$m);
|
|
57
|
-
padding-right: spacing.$l; // NOTE: Space for chevron icon
|
|
58
54
|
position: relative;
|
|
59
55
|
width: 100%;
|
|
60
56
|
border-radius: corner-radius.$s;
|
|
57
|
+
padding-right: spacing.$l;
|
|
58
|
+
|
|
59
|
+
&--variant-small {
|
|
60
|
+
padding-top: spacing.$xs;
|
|
61
|
+
padding-bottom: spacing.$xs;
|
|
62
|
+
padding-left: spacing.$s;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&--variant-large {
|
|
66
|
+
padding-top: spacing.$s;
|
|
67
|
+
padding-bottom: spacing.$s;
|
|
68
|
+
padding-left: spacing.$m;
|
|
69
|
+
}
|
|
61
70
|
|
|
62
71
|
@media (hover: hover) {
|
|
63
72
|
&:hover {
|
package/react/select/select.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import Option from '../select-option/select-option';
|
|
|
7
7
|
import Text from '../text';
|
|
8
8
|
import SvgArrowDown from '@sats-group/icons/18/arrow-down';
|
|
9
9
|
|
|
10
|
-
import { labelPositions, Select as Props } from './select.types';
|
|
10
|
+
import { labelPositions, Select as Props, variants } from './select.types';
|
|
11
11
|
|
|
12
12
|
// NOTE: `onChangeOption` works like `onChange` but returns the props for that option instead of an event object.
|
|
13
13
|
const RefSelect = React.forwardRef<
|
|
@@ -26,6 +26,7 @@ const RefSelect = React.forwardRef<
|
|
|
26
26
|
onChangeOption = () => {},
|
|
27
27
|
options = [],
|
|
28
28
|
required,
|
|
29
|
+
variant = variants.large,
|
|
29
30
|
...restProps
|
|
30
31
|
},
|
|
31
32
|
ref,
|
|
@@ -49,7 +50,12 @@ const RefSelect = React.forwardRef<
|
|
|
49
50
|
>
|
|
50
51
|
{isLabelVisible && (label || children) ? (
|
|
51
52
|
<div className="select__label">
|
|
52
|
-
<Text
|
|
53
|
+
<Text
|
|
54
|
+
size={
|
|
55
|
+
variant === variants.small ? Text.sizes.small : Text.sizes.basic
|
|
56
|
+
}
|
|
57
|
+
theme={Text.themes.emphasis}
|
|
58
|
+
>
|
|
53
59
|
{label}
|
|
54
60
|
</Text>
|
|
55
61
|
{required ? <span className="select__asterisk">*</span> : null}
|
|
@@ -61,6 +67,10 @@ const RefSelect = React.forwardRef<
|
|
|
61
67
|
|
|
62
68
|
<div className="select__native-wrapper">
|
|
63
69
|
<select
|
|
70
|
+
className={cn('select__select', {
|
|
71
|
+
'select__select--variant-small': variant === variants.small,
|
|
72
|
+
'select__select--variant-large': variant === variants.large,
|
|
73
|
+
})}
|
|
64
74
|
name={name}
|
|
65
75
|
ref={ref}
|
|
66
76
|
onChange={onInputChange}
|
|
@@ -97,8 +107,14 @@ const RefSelect = React.forwardRef<
|
|
|
97
107
|
RefSelect.displayName = 'Select';
|
|
98
108
|
|
|
99
109
|
// NOTE: Since `React.forwardRef` props aren't generic, the component is cast so that generics work as intended. See https://stackoverflow.com/a/58473012
|
|
100
|
-
const
|
|
101
|
-
props: Props<OptionExtra> & {
|
|
110
|
+
const SelectComponent = RefSelect as <OptionExtra>(
|
|
111
|
+
props: Props<OptionExtra> & {
|
|
112
|
+
ref?: React.Ref<HTMLSelectElement>;
|
|
113
|
+
},
|
|
102
114
|
) => React.ReactElement;
|
|
103
115
|
|
|
116
|
+
const Select: typeof SelectComponent & {
|
|
117
|
+
variants: typeof variants;
|
|
118
|
+
} = Object.assign(SelectComponent, { variants });
|
|
119
|
+
|
|
104
120
|
export default Select;
|
|
@@ -7,6 +7,11 @@ export const labelPositions = {
|
|
|
7
7
|
stacked: 'stacked',
|
|
8
8
|
} as const;
|
|
9
9
|
|
|
10
|
+
export const variants = {
|
|
11
|
+
small: 'small',
|
|
12
|
+
large: 'large',
|
|
13
|
+
};
|
|
14
|
+
|
|
10
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
16
|
export type Select<OptionExtra = any> = {
|
|
12
17
|
isLabelVisible?: boolean;
|
|
@@ -15,4 +20,5 @@ export type Select<OptionExtra = any> = {
|
|
|
15
20
|
name: string;
|
|
16
21
|
onChangeOption?: (option?: SelectOption<OptionExtra>) => void;
|
|
17
22
|
options?: SelectOption<OptionExtra>[];
|
|
23
|
+
variant?: ObjectValues<typeof variants>;
|
|
18
24
|
} & SelectHtmlProps;
|
|
@@ -6,10 +6,31 @@
|
|
|
6
6
|
|
|
7
7
|
.text-input {
|
|
8
8
|
$block: &;
|
|
9
|
-
$vertical-padding: 13px;
|
|
10
9
|
$line-height: 1;
|
|
11
10
|
$icon-width: 24px;
|
|
12
11
|
$icon-spacing: spacing.$xs;
|
|
12
|
+
$vertical-padding-xs: spacing.$xs;
|
|
13
|
+
$vertical-padding-s: spacing.$s;
|
|
14
|
+
|
|
15
|
+
&--variant-small {
|
|
16
|
+
#{$block}__input {
|
|
17
|
+
padding: $vertical-padding-xs spacing.$s;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#{$block}__icon {
|
|
21
|
+
bottom: $vertical-padding-xs;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&--variant-large {
|
|
26
|
+
#{$block}__input {
|
|
27
|
+
padding: $vertical-padding-s spacing.$m;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#{$block}__icon {
|
|
31
|
+
bottom: $vertical-padding-s;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
13
34
|
|
|
14
35
|
&__wrapper {
|
|
15
36
|
position: relative;
|
|
@@ -18,12 +39,9 @@
|
|
|
18
39
|
}
|
|
19
40
|
|
|
20
41
|
&__input {
|
|
21
|
-
font-
|
|
22
|
-
font-family: font-names.$brand, sans-serif;
|
|
42
|
+
@include font-sizes.normal(input);
|
|
23
43
|
border: 1px solid light.$ge-divider-default;
|
|
24
44
|
border-radius: corner-radius.$s;
|
|
25
|
-
padding: clamp(spacing.$xs, 2vw, spacing.$s)
|
|
26
|
-
clamp(spacing.$s, 2vw, spacing.$m);
|
|
27
45
|
line-height: $line-height;
|
|
28
46
|
background-color: light.$surface-primary-default;
|
|
29
47
|
color: light.$on-surface-primary-default;
|
|
@@ -71,7 +89,6 @@
|
|
|
71
89
|
}
|
|
72
90
|
|
|
73
91
|
&__icon {
|
|
74
|
-
bottom: $vertical-padding;
|
|
75
92
|
color: light.$on-surface-primary-disabled;
|
|
76
93
|
left: $icon-spacing;
|
|
77
94
|
height: $icon-width;
|
|
@@ -88,7 +105,7 @@
|
|
|
88
105
|
|
|
89
106
|
&--moving-label {
|
|
90
107
|
#{$block}__input {
|
|
91
|
-
padding:
|
|
108
|
+
padding: spacing.$s spacing.$m;
|
|
92
109
|
}
|
|
93
110
|
|
|
94
111
|
#{$block}__label {
|
|
@@ -97,7 +114,7 @@
|
|
|
97
114
|
top: 0;
|
|
98
115
|
margin: 0;
|
|
99
116
|
padding: 0 6px;
|
|
100
|
-
transform: translate(10px,
|
|
117
|
+
transform: translate(10px, spacing.$s);
|
|
101
118
|
transition: transform 0.1s cubic-bezier(0.22, 0.57, 0.25, 1);
|
|
102
119
|
transform-origin: left center;
|
|
103
120
|
max-width: calc(100% - 25px);
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import Text from '../text';
|
|
5
5
|
import useInputValidation from '../use-input-validation';
|
|
6
6
|
|
|
7
|
-
import { themes, TextInput as Props } from './text-input.types';
|
|
7
|
+
import { themes, variants, TextInput as Props } from './text-input.types';
|
|
8
8
|
|
|
9
9
|
const RefTextInput = React.forwardRef<HTMLInputElement, Props>(
|
|
10
10
|
(
|
|
@@ -24,6 +24,7 @@ const RefTextInput = React.forwardRef<HTMLInputElement, Props>(
|
|
|
24
24
|
required,
|
|
25
25
|
theme,
|
|
26
26
|
type = 'text',
|
|
27
|
+
variant = variants.large,
|
|
27
28
|
...restProps
|
|
28
29
|
},
|
|
29
30
|
ref,
|
|
@@ -40,6 +41,8 @@ const RefTextInput = React.forwardRef<HTMLInputElement, Props>(
|
|
|
40
41
|
'text-input--error': error || hasError,
|
|
41
42
|
'text-input--moving-label': icon ? false : hasMovingLabel,
|
|
42
43
|
'text-input--icon': icon,
|
|
44
|
+
'text-input--variant-small': variant === variants.small,
|
|
45
|
+
'text-input--variant-large': variant === variants.large,
|
|
43
46
|
})}
|
|
44
47
|
>
|
|
45
48
|
<div className="text-input__wrapper">
|
|
@@ -70,7 +73,9 @@ const RefTextInput = React.forwardRef<HTMLInputElement, Props>(
|
|
|
70
73
|
<Text
|
|
71
74
|
className="text-input__label"
|
|
72
75
|
theme={Text.themes.emphasis}
|
|
73
|
-
size={
|
|
76
|
+
size={
|
|
77
|
+
variant === variants.small ? Text.sizes.small : Text.sizes.basic
|
|
78
|
+
}
|
|
74
79
|
>
|
|
75
80
|
{label}
|
|
76
81
|
{required ? (
|
|
@@ -88,7 +93,7 @@ const RefTextInput = React.forwardRef<HTMLInputElement, Props>(
|
|
|
88
93
|
{/* NOTE: This is aria-hidden because reporting of validation errors is handled by the browser */}
|
|
89
94
|
{error ? (
|
|
90
95
|
<div aria-hidden="true" className="text-input__error">
|
|
91
|
-
<Text>{error}</Text>
|
|
96
|
+
<Text size={Text.sizes.interface}>{error}</Text>
|
|
92
97
|
</div>
|
|
93
98
|
) : null}
|
|
94
99
|
</label>
|
|
@@ -101,6 +106,7 @@ RefTextInput.displayName = 'TextInput';
|
|
|
101
106
|
|
|
102
107
|
const TextInput: typeof RefTextInput & {
|
|
103
108
|
themes: typeof themes;
|
|
104
|
-
|
|
109
|
+
variants: typeof variants;
|
|
110
|
+
} = Object.assign(RefTextInput, { themes, variants });
|
|
105
111
|
|
|
106
112
|
export default TextInput;
|
|
@@ -6,8 +6,12 @@ export const themes = {
|
|
|
6
6
|
light: 'light',
|
|
7
7
|
} as const;
|
|
8
8
|
|
|
9
|
+
export const variants = {
|
|
10
|
+
small: 'small',
|
|
11
|
+
large: 'large',
|
|
12
|
+
};
|
|
13
|
+
|
|
9
14
|
export type TextInput = {
|
|
10
|
-
theme?: ObjectValues<typeof themes>;
|
|
11
15
|
customErrorMessages?: Messages;
|
|
12
16
|
hasError?: boolean;
|
|
13
17
|
hasMovingLabel?: boolean;
|
|
@@ -16,4 +20,6 @@ export type TextInput = {
|
|
|
16
20
|
icon?: React.ReactNode;
|
|
17
21
|
label: string;
|
|
18
22
|
name: string;
|
|
23
|
+
theme?: ObjectValues<typeof themes>;
|
|
24
|
+
variant?: ObjectValues<typeof variants>;
|
|
19
25
|
} & InputHtmlProps;
|
package/tokens/font-sizes.scss
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use 'sass:map';
|
|
2
2
|
@use './font-names';
|
|
3
3
|
|
|
4
4
|
$headline: (
|
|
5
5
|
headline1: (
|
|
6
6
|
fallBack: 64px,
|
|
7
|
-
clamp: clamp(36px, 4vw, 64px)
|
|
7
|
+
clamp: clamp(36px, 4vw, 64px),
|
|
8
8
|
),
|
|
9
9
|
headline2: (
|
|
10
10
|
fallBack: 38px,
|
|
11
|
-
clamp: clamp(24px, 4vw, 38px)
|
|
11
|
+
clamp: clamp(24px, 4vw, 38px),
|
|
12
12
|
),
|
|
13
13
|
headline3: (
|
|
14
14
|
fallBack: 30px,
|
|
15
|
-
clamp: clamp(19px, 4vw, 30px)
|
|
15
|
+
clamp: clamp(19px, 4vw, 30px),
|
|
16
16
|
),
|
|
17
17
|
large: (
|
|
18
18
|
fallBack: 21px,
|
|
19
|
-
clamp: clamp(16px, 4vw, 21px)
|
|
19
|
+
clamp: clamp(16px, 4vw, 21px),
|
|
20
20
|
),
|
|
21
21
|
basic: (
|
|
22
22
|
fallBack: 18px,
|
|
23
|
-
clamp: clamp(14px, 4vw, 18px)
|
|
23
|
+
clamp: clamp(14px, 4vw, 18px),
|
|
24
24
|
),
|
|
25
25
|
small: (
|
|
26
26
|
fallBack: 16px,
|
|
27
|
-
clamp: clamp(12px, 4vw, 16px)
|
|
27
|
+
clamp: clamp(12px, 4vw, 16px),
|
|
28
28
|
),
|
|
29
29
|
interface: (
|
|
30
30
|
fallBack: 14px,
|
|
31
|
-
clamp: clamp(10px, 4vw, 14px)
|
|
31
|
+
clamp: clamp(10px, 4vw, 14px),
|
|
32
32
|
),
|
|
33
33
|
button: (
|
|
34
34
|
fallBack: 16px,
|
|
35
|
-
clamp: clamp(14px, 4vw, 16px)
|
|
35
|
+
clamp: clamp(14px, 4vw, 16px),
|
|
36
36
|
),
|
|
37
37
|
);
|
|
38
38
|
|
|
@@ -51,35 +51,39 @@ $headline: (
|
|
|
51
51
|
$normal: (
|
|
52
52
|
headline1: (
|
|
53
53
|
fallBack: 36px,
|
|
54
|
-
clamp: clamp(28px, 4vw, 36px)
|
|
54
|
+
clamp: clamp(28px, 4vw, 36px),
|
|
55
55
|
),
|
|
56
56
|
headline2: (
|
|
57
57
|
fallBack: 28px,
|
|
58
|
-
clamp: clamp(24px, 4vw, 28px)
|
|
58
|
+
clamp: clamp(24px, 4vw, 28px),
|
|
59
59
|
),
|
|
60
60
|
headline3: (
|
|
61
61
|
fallBack: 24px,
|
|
62
|
-
clamp: clamp(19px, 4vw, 24px)
|
|
62
|
+
clamp: clamp(19px, 4vw, 24px),
|
|
63
63
|
),
|
|
64
64
|
large: (
|
|
65
65
|
fallBack: 21px,
|
|
66
|
-
clamp: clamp(16px, 3vw, 21px)
|
|
66
|
+
clamp: clamp(16px, 3vw, 21px),
|
|
67
67
|
),
|
|
68
68
|
basic: (
|
|
69
69
|
fallBack: 18px,
|
|
70
|
-
clamp: clamp(14px, 3vw, 18px)
|
|
70
|
+
clamp: clamp(14px, 3vw, 18px),
|
|
71
71
|
),
|
|
72
72
|
small: (
|
|
73
73
|
fallBack: 16px,
|
|
74
|
-
clamp: clamp(12px, 3vw, 16px)
|
|
74
|
+
clamp: clamp(12px, 3vw, 16px),
|
|
75
75
|
),
|
|
76
76
|
interface: (
|
|
77
77
|
fallBack: 14px,
|
|
78
|
-
clamp: clamp(10px, 3vw, 14px)
|
|
78
|
+
clamp: clamp(10px, 3vw, 14px),
|
|
79
79
|
),
|
|
80
80
|
section: (
|
|
81
81
|
fallBack: 20px,
|
|
82
|
-
clamp: clamp(16px, 3vw, 20px)
|
|
82
|
+
clamp: clamp(16px, 3vw, 20px),
|
|
83
|
+
),
|
|
84
|
+
input: (
|
|
85
|
+
fallBack: 16px,
|
|
86
|
+
clamp: clamp(16px, 3vw, 18px),
|
|
83
87
|
),
|
|
84
88
|
);
|
|
85
89
|
|