@sats-group/ui-lib 74.2.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/.nvmrc +1 -0
- package/README.md +35 -0
- package/catalog-info.yaml +14 -0
- package/eslint.config.mjs +94 -0
- package/fonts/Inter-BoldItalic.woff +0 -0
- package/fonts/Inter-BoldItalic.woff2 +0 -0
- package/fonts/Inter-ExtraBold.woff +0 -0
- package/fonts/Inter-ExtraBold.woff2 +0 -0
- package/fonts/Inter-Italic.woff +0 -0
- package/fonts/Inter-Italic.woff2 +0 -0
- package/fonts/Inter-Regular.woff +0 -0
- package/fonts/Inter-Regular.woff2 +0 -0
- package/fonts/Inter-SemiBold.woff +0 -0
- package/fonts/Inter-SemiBold.woff2 +0 -0
- package/fonts/LICENSE.txt +92 -0
- package/fonts/SATSHeadline-Bold.woff +0 -0
- package/fonts/SATSHeadline-BoldItalic.woff +0 -0
- package/fonts/SATSHeadline-RegularItalic.woff +0 -0
- package/fonts/SATSHeadline-SemiBoldItalic.woff +0 -0
- package/logos/e-avatar.svg +3 -0
- package/logos/elixia-letter.svg +3 -0
- package/logos/elixia-small.svg +8 -0
- package/logos/elixia.svg +8 -0
- package/logos/s-avatar.svg +3 -0
- package/logos/sats-letter.svg +3 -0
- package/logos/sats-small.svg +3 -0
- package/logos/sats.svg +4 -0
- package/package.json +58 -0
- package/react/add-bem-modifiers.ts +51 -0
- package/react/badge/badge.scss +53 -0
- package/react/badge/badge.tsx +28 -0
- package/react/badge/badge.types.ts +34 -0
- package/react/badge/index.ts +2 -0
- package/react/banner/banner.scss +118 -0
- package/react/banner/banner.tsx +92 -0
- package/react/banner/banner.types.ts +10 -0
- package/react/banner/index.ts +2 -0
- package/react/bomb/bomb.scss +33 -0
- package/react/bomb/bomb.tsx +19 -0
- package/react/bomb/bomb.types.ts +1 -0
- package/react/bomb/index.ts +2 -0
- package/react/button/button.tsx +19 -0
- package/react/button/button.types.ts +3 -0
- package/react/button/index.ts +2 -0
- package/react/checkbox/checkbox.scss +218 -0
- package/react/checkbox/checkbox.tsx +176 -0
- package/react/checkbox/checkbox.types.ts +19 -0
- package/react/checkbox/index.ts +2 -0
- package/react/chip/chip.scss +46 -0
- package/react/chip/chip.tsx +37 -0
- package/react/chip/chip.types.ts +18 -0
- package/react/chip/index.ts +2 -0
- package/react/chip/remove.tsx +14 -0
- package/react/chip-selected/chip-selected.scss +47 -0
- package/react/chip-selected/chip-selected.tsx +102 -0
- package/react/chip-selected/chip-selected.types.ts +11 -0
- package/react/chip-selected/index.ts +2 -0
- package/react/confirmation/confirmation.scss +60 -0
- package/react/confirmation/confirmation.tsx +85 -0
- package/react/confirmation/confirmation.types.ts +24 -0
- package/react/confirmation/index.ts +2 -0
- package/react/context-menu/context-menu.scss +183 -0
- package/react/context-menu/context-menu.tsx +200 -0
- package/react/context-menu/context-menu.types.ts +71 -0
- package/react/context-menu/index.ts +2 -0
- package/react/cropped-image/cropped-image.scss +48 -0
- package/react/cropped-image/cropped-image.tsx +36 -0
- package/react/cropped-image/cropped-image.types.ts +26 -0
- package/react/cropped-image/index.ts +2 -0
- package/react/dropdown-list/dropdown-list.scss +170 -0
- package/react/dropdown-list/dropdown-list.tsx +116 -0
- package/react/dropdown-list/dropdown-list.types.ts +17 -0
- package/react/dropdown-list/index.ts +2 -0
- package/react/expander/expander.scss +115 -0
- package/react/expander/expander.tsx +167 -0
- package/react/expander/expander.types.ts +26 -0
- package/react/expander/index.ts +2 -0
- package/react/filter/filter.scss +94 -0
- package/react/filter/filter.tsx +99 -0
- package/react/filter/filter.types.ts +8 -0
- package/react/filter/index.ts +2 -0
- package/react/filter-wrapper/filter-wrapper.scss +46 -0
- package/react/filter-wrapper/filter-wrapper.tsx +24 -0
- package/react/filter-wrapper/filter-wrapper.types.ts +10 -0
- package/react/filter-wrapper/index.ts +2 -0
- package/react/flag/flag.scss +26 -0
- package/react/flag/flag.tsx +27 -0
- package/react/flag/flag.types.ts +17 -0
- package/react/flag/index.ts +2 -0
- package/react/form-content/checkbox-category.tsx +183 -0
- package/react/form-content/form-content.checkbox-list.tsx +126 -0
- package/react/form-content/form-content.checkbox-list.types.ts +36 -0
- package/react/form-content/form-content.radio-list.tsx +58 -0
- package/react/form-content/form-content.range.tsx +20 -0
- package/react/form-content/form-content.range.types.ts +14 -0
- package/react/form-content/form-content.scss +234 -0
- package/react/form-content/form-content.search.tsx +47 -0
- package/react/form-content/form-content.tsx +95 -0
- package/react/form-content/form-content.types.ts +55 -0
- package/react/form-content/index.ts +2 -0
- package/react/form-content/types/index.d.ts +1 -0
- package/react/hidden-input/hidden-input.tsx +9 -0
- package/react/hidden-input/hidden-input.types.ts +6 -0
- package/react/hidden-input/index.ts +2 -0
- package/react/hooks/focus-previous-element.ts +30 -0
- package/react/hooks/is-running-on-client.ts +1 -0
- package/react/hooks/use-click-outside.ts +23 -0
- package/react/hooks/use-escape.ts +18 -0
- package/react/hooks/use-event.ts +29 -0
- package/react/hooks/use-is-mounted.ts +11 -0
- package/react/hooks/use-toggle.ts +19 -0
- package/react/icons/16/close.tsx +12 -0
- package/react/icons/18/close.tsx +18 -0
- package/react/icons/24/arrow-down.tsx +14 -0
- package/react/icons/24/arrow-right.tsx +14 -0
- package/react/icons/24/arrow-up.tsx +14 -0
- package/react/icons/24/close.tsx +12 -0
- package/react/icons/24/remove.tsx +12 -0
- package/react/icons/24/search.tsx +10 -0
- package/react/icons/icons.md +3 -0
- package/react/indexed-access-type.ts +1 -0
- package/react/link/index.ts +2 -0
- package/react/link/link.scss +44 -0
- package/react/link/link.tsx +62 -0
- package/react/link/link.types.ts +37 -0
- package/react/link-button/index.ts +2 -0
- package/react/link-button/link-button.tsx +17 -0
- package/react/link-button/link-button.types.ts +5 -0
- package/react/link-card/index.ts +2 -0
- package/react/link-card/link-card.scss +37 -0
- package/react/link-card/link-card.tsx +24 -0
- package/react/link-card/link-card.types.ts +5 -0
- package/react/logos/e-avatar.tsx +12 -0
- package/react/logos/elixia-letter.tsx +12 -0
- package/react/logos/elixia-small.tsx +12 -0
- package/react/logos/elixia.tsx +12 -0
- package/react/logos/index.ts +8 -0
- package/react/logos/s-avatar.tsx +12 -0
- package/react/logos/sats-letter.tsx +12 -0
- package/react/logos/sats-small.tsx +12 -0
- package/react/logos/sats.tsx +12 -0
- package/react/message/hook/use-message.ts +22 -0
- package/react/message/index.ts +2 -0
- package/react/message/message.scss +92 -0
- package/react/message/message.tsx +60 -0
- package/react/message/message.types.ts +39 -0
- package/react/message/publish.ts +19 -0
- package/react/message-field/index.ts +2 -0
- package/react/message-field/message-field.scss +21 -0
- package/react/message-field/message-field.tsx +70 -0
- package/react/message-field/message-field.types.ts +24 -0
- package/react/modal/index.ts +2 -0
- package/react/modal/modal.scss +162 -0
- package/react/modal/modal.tsx +130 -0
- package/react/modal/modal.types.ts +36 -0
- package/react/modal/tab-trapper.tsx +68 -0
- package/react/progress-bar/index.ts +2 -0
- package/react/progress-bar/progress-bar.scss +71 -0
- package/react/progress-bar/progress-bar.tsx +81 -0
- package/react/progress-bar/progress-bar.types.ts +35 -0
- package/react/radio/index.ts +2 -0
- package/react/radio/radio.scss +142 -0
- package/react/radio/radio.tsx +87 -0
- package/react/radio/radio.types.ts +15 -0
- package/react/scale-bar/index.ts +2 -0
- package/react/scale-bar/scale-bar.scss +22 -0
- package/react/scale-bar/scale-bar.tsx +29 -0
- package/react/scale-bar/scale-bar.types.ts +4 -0
- package/react/search/index.ts +2 -0
- package/react/search/search.scss +207 -0
- package/react/search/search.tsx +255 -0
- package/react/search/search.types.ts +43 -0
- package/react/select/chevron-down.tsx +24 -0
- package/react/select/index.ts +2 -0
- package/react/select/select.scss +135 -0
- package/react/select/select.tsx +105 -0
- package/react/select/select.types.ts +19 -0
- package/react/select-option/README.md +3 -0
- package/react/select-option/index.ts +2 -0
- package/react/select-option/select-option.tsx +16 -0
- package/react/select-option/select-option.types.ts +8 -0
- package/react/tag/index.ts +2 -0
- package/react/tag/tag.scss +107 -0
- package/react/tag/tag.tsx +26 -0
- package/react/tag/tag.types.ts +30 -0
- package/react/text/index.ts +2 -0
- package/react/text/text.scss +109 -0
- package/react/text/text.tsx +40 -0
- package/react/text/text.types.ts +29 -0
- package/react/text-area/index.ts +2 -0
- package/react/text-area/text-area.scss +180 -0
- package/react/text-area/text-area.tsx +153 -0
- package/react/text-area/text-area.types.ts +24 -0
- package/react/text-input/index.ts +2 -0
- package/react/text-input/text-input.scss +233 -0
- package/react/text-input/text-input.tsx +106 -0
- package/react/text-input/text-input.types.ts +19 -0
- package/react/toggle/index.ts +2 -0
- package/react/toggle/toggle.scss +69 -0
- package/react/toggle/toggle.tsx +83 -0
- package/react/toggle/toggle.types.ts +11 -0
- package/react/toolbox/index.ts +2 -0
- package/react/toolbox/toolbox.scss +68 -0
- package/react/toolbox/toolbox.tsx +43 -0
- package/react/toolbox/toolbox.types.ts +39 -0
- package/react/ts/debounce.ts +12 -0
- package/react/types.ts +38 -0
- package/react/use-input-validation.ts +47 -0
- package/react/use-input-validation.types.ts +12 -0
- package/react/visually-button/index.ts +2 -0
- package/react/visually-button/visually-button.scss +470 -0
- package/react/visually-button/visually-button.tsx +130 -0
- package/react/visually-button/visually-button.types.ts +71 -0
- package/react/visually-hidden/index.ts +2 -0
- package/react/visually-hidden/visually-hidden.scss +6 -0
- package/react/visually-hidden/visually-hidden.tsx +10 -0
- package/tokens/corner-radius.scss +5 -0
- package/tokens/dark.scss +392 -0
- package/tokens/darkmode.scss +131 -0
- package/tokens/elevation.scss +57 -0
- package/tokens/font-faces.scss +62 -0
- package/tokens/font-names.scss +2 -0
- package/tokens/font-sizes.scss +95 -0
- package/tokens/light.scss +392 -0
- package/tokens/lightmode.scss +131 -0
- package/tokens/primitives.scss +137 -0
- package/tokens/spacing.scss +12 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
@use '../../tokens/corner-radius';
|
|
2
|
+
@use '../../tokens/light';
|
|
3
|
+
@use '../../tokens/spacing';
|
|
4
|
+
|
|
5
|
+
.tag {
|
|
6
|
+
border-radius: corner-radius.$xs;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: spacing.$xxs;
|
|
10
|
+
padding: spacing.$xxs spacing.$xs;
|
|
11
|
+
border: 1px solid;
|
|
12
|
+
|
|
13
|
+
&--variant-primary {
|
|
14
|
+
background: light.$ge-tags-primary;
|
|
15
|
+
border-color: light.$ge-tags-primary;
|
|
16
|
+
color: light.$on-ge-on-tags-primary-default;
|
|
17
|
+
|
|
18
|
+
&-border {
|
|
19
|
+
background: transparent;
|
|
20
|
+
color: light.$ge-tags-primary;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&--variant-secondary {
|
|
25
|
+
background: light.$ge-tags-secondary;
|
|
26
|
+
border-color: light.$ge-tags-secondary;
|
|
27
|
+
color: light.$on-ge-on-tags-secondary-default;
|
|
28
|
+
|
|
29
|
+
&-border {
|
|
30
|
+
background: transparent;
|
|
31
|
+
border-color: light.$ge-tags-secondary;
|
|
32
|
+
color: light.$on-ge-on-tags-secondary-default;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&--variant-tertiary {
|
|
37
|
+
background: light.$ge-tags-featured;
|
|
38
|
+
border-color: light.$ge-tags-featured;
|
|
39
|
+
color: light.$on-ge-on-tags-featured-default;
|
|
40
|
+
|
|
41
|
+
&-border {
|
|
42
|
+
background: transparent;
|
|
43
|
+
border-color: light.$ge-tags-featured;
|
|
44
|
+
color: light.$ge-tags-featured;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&--variant-positive {
|
|
49
|
+
background: light.$ge-indicator-tags-positive-alternate;
|
|
50
|
+
border-color: light.$ge-indicator-tags-positive-alternate;
|
|
51
|
+
color: light.$on-ge-on-indicator-tags-positive-alternate;
|
|
52
|
+
|
|
53
|
+
&-border {
|
|
54
|
+
border-color: light.$on-ge-on-indicator-tags-positive-alternate;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&--variant-attention {
|
|
59
|
+
background: light.$ge-indicator-tags-attention-alternate;
|
|
60
|
+
border-color: light.$ge-indicator-tags-attention-alternate;
|
|
61
|
+
color: light.$on-ge-on-indicator-tags-attention-alternate;
|
|
62
|
+
|
|
63
|
+
&-border {
|
|
64
|
+
border-color: light.$on-ge-on-indicator-tags-attention-alternate;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&--variant-negative {
|
|
69
|
+
background: light.$ge-indicator-tags-negative-alternate;
|
|
70
|
+
border-color: light.$ge-indicator-tags-negative-alternate;
|
|
71
|
+
color: light.$on-ge-on-indicator-tags-negative-alternate;
|
|
72
|
+
|
|
73
|
+
&-border {
|
|
74
|
+
border-color: light.$on-ge-on-indicator-tags-negative-alternate;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&--variant-neutral {
|
|
79
|
+
background: light.$ge-indicator-tags-neutral-alternate;
|
|
80
|
+
border-color: light.$ge-indicator-tags-neutral-alternate;
|
|
81
|
+
color: light.$on-ge-on-indicator-tags-neutral-alternate;
|
|
82
|
+
|
|
83
|
+
&-border {
|
|
84
|
+
border-color: light.$on-ge-on-indicator-tags-neutral-alternate;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&--variant-information {
|
|
89
|
+
background: light.$ge-indicator-tags-information-alternate;
|
|
90
|
+
border-color: light.$ge-indicator-tags-information-alternate;
|
|
91
|
+
color: light.$on-ge-on-indicator-tags-information-alternate;
|
|
92
|
+
|
|
93
|
+
&-border {
|
|
94
|
+
border-color: light.$on-ge-on-indicator-tags-information-alternate;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&--variant-featured {
|
|
99
|
+
background: light.$ge-indicator-tags-featured-alternate;
|
|
100
|
+
border-color: light.$ge-indicator-tags-featured-alternate;
|
|
101
|
+
color: light.$on-ge-on-indicator-tags-featured-alternate;
|
|
102
|
+
|
|
103
|
+
&-border {
|
|
104
|
+
border-color: light.$on-ge-on-indicator-tags-featured-alternate;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Text from '../text';
|
|
4
|
+
|
|
5
|
+
import { Tag as Props, variants, sizes } from './tag.types';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
|
|
8
|
+
const Tag: React.FunctionComponent<Props> & {
|
|
9
|
+
sizes: typeof sizes;
|
|
10
|
+
variants: typeof variants;
|
|
11
|
+
} = ({ text, icon, border, size = sizes.m, variant = variants.primary }) => (
|
|
12
|
+
<Text
|
|
13
|
+
size={size}
|
|
14
|
+
tight
|
|
15
|
+
className={classNames('tag', `tag--variant-${variant}`, {
|
|
16
|
+
[`tag--variant-${variant}-border`]: border,
|
|
17
|
+
})}
|
|
18
|
+
>
|
|
19
|
+
{icon ? icon : null}
|
|
20
|
+
{text}
|
|
21
|
+
</Text>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
Tag.sizes = sizes;
|
|
25
|
+
Tag.variants = variants;
|
|
26
|
+
export default Tag;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ObjectValues } from '../types';
|
|
2
|
+
import { sizes as TextSizes } from '../text/text.types';
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
export const sizes = {
|
|
6
|
+
xs: TextSizes.interface,
|
|
7
|
+
s: TextSizes.small,
|
|
8
|
+
m: TextSizes.basic,
|
|
9
|
+
l: TextSizes.large,
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export const variants = {
|
|
13
|
+
primary: 'primary',
|
|
14
|
+
secondary: 'secondary',
|
|
15
|
+
tertiary: 'tertiary',
|
|
16
|
+
positive: 'positive',
|
|
17
|
+
attention: 'attention',
|
|
18
|
+
negative: 'negative',
|
|
19
|
+
neutral: 'neutral',
|
|
20
|
+
information: 'information',
|
|
21
|
+
featured: 'featured',
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
export type Tag = {
|
|
25
|
+
text: string;
|
|
26
|
+
border?: boolean;
|
|
27
|
+
size?: ObjectValues<typeof sizes>;
|
|
28
|
+
variant?: ObjectValues<typeof variants>;
|
|
29
|
+
icon?: ReactElement;
|
|
30
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
@use '../../tokens/font-names';
|
|
3
|
+
@use '../../tokens/font-sizes';
|
|
4
|
+
|
|
5
|
+
.text {
|
|
6
|
+
$block: &;
|
|
7
|
+
|
|
8
|
+
&--italic {
|
|
9
|
+
font-style: italic;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&--tight {
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&--theme-normal {
|
|
17
|
+
&#{$block}--size-section {
|
|
18
|
+
// NOTE: Only normal can be section
|
|
19
|
+
@include font-sizes.normal(section);
|
|
20
|
+
font-weight: 600;
|
|
21
|
+
line-height: 1.15;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&--size-headline1 {
|
|
26
|
+
@include font-sizes.normal(headline1);
|
|
27
|
+
line-height: 1.1;
|
|
28
|
+
letter-spacing: -0.02em;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&--size-headline2 {
|
|
32
|
+
@include font-sizes.normal(headline2);
|
|
33
|
+
line-height: 1.1;
|
|
34
|
+
letter-spacing: -0.02em;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&--size-headline3 {
|
|
38
|
+
@include font-sizes.normal(headline3);
|
|
39
|
+
line-height: 1.1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&--size-large {
|
|
43
|
+
@include font-sizes.normal(large);
|
|
44
|
+
line-height: math.div(30, 21);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&--size-basic {
|
|
48
|
+
@include font-sizes.normal(basic);
|
|
49
|
+
line-height: math.div(26, 18);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&--size-small {
|
|
53
|
+
@include font-sizes.normal(small);
|
|
54
|
+
line-height: math.div(23, 16);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&--size-interface {
|
|
58
|
+
@include font-sizes.normal(interface);
|
|
59
|
+
line-height: math.div(20, 14);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
&--theme-emphasis {
|
|
64
|
+
font-family: font-names.$brand, sans-serif;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
|
|
67
|
+
&#{$block}--size-headline1 {
|
|
68
|
+
font-weight: 800;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&#{$block}--size-headline2 {
|
|
72
|
+
font-weight: 800;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&#{$block}--size-headline3 {
|
|
76
|
+
font-weight: 800;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&#{$block}--italic {
|
|
80
|
+
// NOTE: Emphasis doesn't have an italic version
|
|
81
|
+
font-style: normal;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&--theme-headline {
|
|
86
|
+
&#{$block}--size-headline1 {
|
|
87
|
+
@include font-sizes.headline(headline1);
|
|
88
|
+
letter-spacing: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&#{$block}--size-headline2 {
|
|
92
|
+
@include font-sizes.headline(headline2);
|
|
93
|
+
letter-spacing: 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&#{$block}--size-headline3 {
|
|
97
|
+
@include font-sizes.headline(headline3);
|
|
98
|
+
letter-spacing: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&#{$block}--size-button {
|
|
102
|
+
// NOTE: Only headline can be button
|
|
103
|
+
@include font-sizes.headline(button);
|
|
104
|
+
letter-spacing: 1.03;
|
|
105
|
+
line-height: 1.2;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { sizes, themes, Text as Props } from './text.types';
|
|
5
|
+
|
|
6
|
+
const Text: React.FunctionComponent<React.PropsWithChildren<Props>> & {
|
|
7
|
+
sizes: typeof sizes;
|
|
8
|
+
themes: typeof themes;
|
|
9
|
+
} = ({
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
elementName = 'div',
|
|
13
|
+
italic,
|
|
14
|
+
size = sizes.basic,
|
|
15
|
+
theme = themes.normal,
|
|
16
|
+
tight,
|
|
17
|
+
...restProps
|
|
18
|
+
}) =>
|
|
19
|
+
React.createElement(
|
|
20
|
+
elementName,
|
|
21
|
+
{
|
|
22
|
+
className: cn(
|
|
23
|
+
'text',
|
|
24
|
+
{
|
|
25
|
+
'text--italic': italic,
|
|
26
|
+
[`text--size-${size}`]: size ? sizes[size] : undefined,
|
|
27
|
+
[`text--theme-${theme}`]: theme ? themes[theme] : undefined,
|
|
28
|
+
'text--tight': tight,
|
|
29
|
+
},
|
|
30
|
+
className,
|
|
31
|
+
),
|
|
32
|
+
...restProps,
|
|
33
|
+
},
|
|
34
|
+
children,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
Text.sizes = sizes;
|
|
38
|
+
Text.themes = themes;
|
|
39
|
+
|
|
40
|
+
export default Text;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ObjectValues } from '../types';
|
|
2
|
+
|
|
3
|
+
export const sizes = {
|
|
4
|
+
headline1: 'headline1',
|
|
5
|
+
headline2: 'headline2',
|
|
6
|
+
headline3: 'headline3',
|
|
7
|
+
large: 'large',
|
|
8
|
+
basic: 'basic',
|
|
9
|
+
small: 'small',
|
|
10
|
+
interface: 'interface',
|
|
11
|
+
button: 'button',
|
|
12
|
+
section: 'section',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export const themes = {
|
|
16
|
+
normal: 'normal',
|
|
17
|
+
emphasis: 'emphasis',
|
|
18
|
+
headline: 'headline',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
// NOTE: The type of the rest spread properties is generic because `elementName` can be _any_ HTML element which we can't type the props for
|
|
22
|
+
export type Text = {
|
|
23
|
+
className?: string;
|
|
24
|
+
elementName?: string;
|
|
25
|
+
italic?: boolean;
|
|
26
|
+
size?: ObjectValues<typeof sizes>;
|
|
27
|
+
theme?: ObjectValues<typeof themes>;
|
|
28
|
+
tight?: boolean;
|
|
29
|
+
} & { [key: string]: unknown };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
@use '../../tokens/corner-radius';
|
|
2
|
+
@use '../../tokens/font-names';
|
|
3
|
+
@use '../../tokens/light';
|
|
4
|
+
@use '../../tokens/dark';
|
|
5
|
+
@use '../../tokens/spacing';
|
|
6
|
+
|
|
7
|
+
.text-area {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
width: 100%;
|
|
11
|
+
|
|
12
|
+
&__wrapper {
|
|
13
|
+
position: relative;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__header {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__label {
|
|
24
|
+
&--theme-light {
|
|
25
|
+
&-disabled {
|
|
26
|
+
color: light.$on-background-primary-disabled;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
&--theme-dark {
|
|
30
|
+
color: light.$on-fixed-background-primary-default;
|
|
31
|
+
&-disabled {
|
|
32
|
+
color: light.$on-fixed-background-primary-disabled;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&__max {
|
|
38
|
+
color: light.$on-background-primary-alternate;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&__input {
|
|
42
|
+
width: 100%;
|
|
43
|
+
border: 0.5px solid light.$ge-border-default;
|
|
44
|
+
border-radius: corner-radius.$xs;
|
|
45
|
+
|
|
46
|
+
font-family: font-names.$brand, sans-serif;
|
|
47
|
+
font-size: 16px;
|
|
48
|
+
line-height: 1.2;
|
|
49
|
+
|
|
50
|
+
overflow: auto;
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
|
|
53
|
+
min-height: 95px;
|
|
54
|
+
min-width: 150px;
|
|
55
|
+
|
|
56
|
+
&--size-default {
|
|
57
|
+
padding: spacing.$s spacing.$m;
|
|
58
|
+
&-short {
|
|
59
|
+
min-height: 45px;
|
|
60
|
+
max-height: 120px;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&--size-small {
|
|
65
|
+
padding: spacing.$xs spacing.$s;
|
|
66
|
+
&-short {
|
|
67
|
+
min-height: 35px; // NOTE: Magic number to get to correct height with padding
|
|
68
|
+
max-height: 110px;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&--theme-light {
|
|
73
|
+
background-color: light.$surface-primary-default;
|
|
74
|
+
color: light.$on-surface-primary-default;
|
|
75
|
+
&:focus {
|
|
76
|
+
outline: 1px solid light.$ge-border-focused;
|
|
77
|
+
outline-offset: -1px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&:hover {
|
|
81
|
+
background-color: light.$surface-primary-hover;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&::placeholder {
|
|
85
|
+
color: light.$on-surface-primary-alternate;
|
|
86
|
+
opacity: 1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:disabled {
|
|
90
|
+
background-color: light.$surface-primary-disabled;
|
|
91
|
+
&::placeholder {
|
|
92
|
+
color: light.$on-surface-primary-disabled;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&-error {
|
|
97
|
+
border-color: light.$ge-signal-border-error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&--theme-dark {
|
|
102
|
+
background-color: light.$fixed-surface-secondary-default;
|
|
103
|
+
color: light.$on-fixed-surface-primary-default;
|
|
104
|
+
&:focus {
|
|
105
|
+
background: light.$fixed-surface-primary-hover;
|
|
106
|
+
outline: 2px solid light.$ge-border-focused;
|
|
107
|
+
outline-offset: -2px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&:hover {
|
|
111
|
+
background-color: light.$fixed-surface-primary-hover;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&::placeholder {
|
|
115
|
+
color: light.$on-fixed-surface-primary-alternate;
|
|
116
|
+
opacity: 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&:disabled {
|
|
120
|
+
background-color: light.$fixed-surface-primary-selected;
|
|
121
|
+
border: 0;
|
|
122
|
+
&::placeholder {
|
|
123
|
+
color: light.$on-fixed-surface-secondary-disabled;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&-error {
|
|
128
|
+
border-color: light.$on-fixed-surface-error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&__asterisk {
|
|
134
|
+
margin-left: spacing.$xs;
|
|
135
|
+
|
|
136
|
+
&--theme-light {
|
|
137
|
+
color: light.$on-surface-featured;
|
|
138
|
+
&-disabled {
|
|
139
|
+
|
|
140
|
+
color: light.$on-surface-primary-disabled;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
&--theme-dark {
|
|
144
|
+
color: light.$on-fixed-surface-featured;
|
|
145
|
+
&-disabled {
|
|
146
|
+
color: light.$on-fixed-background-primary-disabled;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&__error {
|
|
153
|
+
color: light.$on-surface-error;
|
|
154
|
+
margin-top: spacing.$xxs;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&__help {
|
|
158
|
+
margin-top: spacing.$xxs;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&__help-text {
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
gap: spacing.$xs;
|
|
165
|
+
|
|
166
|
+
&--theme-light {
|
|
167
|
+
color: light.$on-background-primary-disabled;
|
|
168
|
+
&--error {
|
|
169
|
+
color: light.$on-surface-error;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
&--theme-dark {
|
|
174
|
+
color: light.$on-fixed-background-primary-disabled;
|
|
175
|
+
&--error {
|
|
176
|
+
color: light.$on-fixed-surface-error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import Text from '../text';
|
|
5
|
+
import useInputValidation from '../use-input-validation';
|
|
6
|
+
|
|
7
|
+
import { TextArea as Props, themes, sizes } from './text-area.types';
|
|
8
|
+
|
|
9
|
+
const RefTextArea = React.forwardRef<
|
|
10
|
+
HTMLTextAreaElement,
|
|
11
|
+
React.PropsWithChildren<Props>
|
|
12
|
+
>(
|
|
13
|
+
(
|
|
14
|
+
{
|
|
15
|
+
children,
|
|
16
|
+
helpText,
|
|
17
|
+
label,
|
|
18
|
+
name,
|
|
19
|
+
placeholder,
|
|
20
|
+
disabled,
|
|
21
|
+
required,
|
|
22
|
+
isLabelVisible = true,
|
|
23
|
+
helpIcon,
|
|
24
|
+
size = sizes.default,
|
|
25
|
+
theme = themes.light,
|
|
26
|
+
isShort,
|
|
27
|
+
maxLength,
|
|
28
|
+
defaultValue,
|
|
29
|
+
...restProps
|
|
30
|
+
},
|
|
31
|
+
ref,
|
|
32
|
+
) => {
|
|
33
|
+
const [onChange, onInvalid, error] = useInputValidation();
|
|
34
|
+
const [count, setCount] = React.useState(0);
|
|
35
|
+
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (defaultValue) {
|
|
38
|
+
if (typeof defaultValue === 'string') {
|
|
39
|
+
setCount(defaultValue.length);
|
|
40
|
+
} else if (typeof defaultValue === 'number') {
|
|
41
|
+
setCount(defaultValue);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, [restProps]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<label className="text-area">
|
|
48
|
+
<div className="text-area__wrapper">
|
|
49
|
+
{isLabelVisible ? (
|
|
50
|
+
<div className="text-area__header">
|
|
51
|
+
<Text
|
|
52
|
+
theme={Text.themes.emphasis}
|
|
53
|
+
size={
|
|
54
|
+
size === sizes.default ? Text.sizes.basic : Text.sizes.small
|
|
55
|
+
}
|
|
56
|
+
className={cn('text-area__label', {
|
|
57
|
+
[`text-area__label--theme-${theme}-disabled`]: disabled,
|
|
58
|
+
[`text-area__label--theme-${theme}`]: theme,
|
|
59
|
+
})}
|
|
60
|
+
>
|
|
61
|
+
{label}
|
|
62
|
+
{required ? (
|
|
63
|
+
<span
|
|
64
|
+
className={cn('text-area__asterisk', {
|
|
65
|
+
[`text-area__asterisk--theme-${theme}-disabled`]:
|
|
66
|
+
disabled,
|
|
67
|
+
[`text-area__asterisk--theme-${theme}`]: theme,
|
|
68
|
+
})}
|
|
69
|
+
>
|
|
70
|
+
*
|
|
71
|
+
</span>
|
|
72
|
+
) : null}
|
|
73
|
+
{children}
|
|
74
|
+
</Text>
|
|
75
|
+
{maxLength ? (
|
|
76
|
+
<Text className="text-area__max" size={Text.sizes.small}>
|
|
77
|
+
{count}/{maxLength}
|
|
78
|
+
</Text>
|
|
79
|
+
) : null}
|
|
80
|
+
</div>
|
|
81
|
+
) : null}
|
|
82
|
+
<textarea
|
|
83
|
+
className={cn('text-area__input', {
|
|
84
|
+
[`text-area__input--theme-${theme}`]: theme,
|
|
85
|
+
[`text-area__input--theme-${theme}-error`]: error,
|
|
86
|
+
[`text-area__input--size-${size}-short`]: isShort,
|
|
87
|
+
[`text-area__input--size-${size}`]: size,
|
|
88
|
+
})}
|
|
89
|
+
aria-label={isLabelVisible ? label : undefined}
|
|
90
|
+
name={name}
|
|
91
|
+
maxLength={maxLength}
|
|
92
|
+
ref={ref}
|
|
93
|
+
cols={1}
|
|
94
|
+
required={required}
|
|
95
|
+
defaultValue={defaultValue}
|
|
96
|
+
rows={isShort ? 1 : 2}
|
|
97
|
+
onChange={e => {
|
|
98
|
+
// NOTE: To not break compatibility
|
|
99
|
+
if (restProps.onChange) {
|
|
100
|
+
restProps.onChange(e);
|
|
101
|
+
}
|
|
102
|
+
onChange(e);
|
|
103
|
+
if (maxLength) {
|
|
104
|
+
setCount(e.target.value.length);
|
|
105
|
+
}
|
|
106
|
+
}}
|
|
107
|
+
onInvalid={e => {
|
|
108
|
+
// NOTE: To not break compatibility
|
|
109
|
+
if (restProps.onInvalid) restProps.onInvalid(e);
|
|
110
|
+
onInvalid(e);
|
|
111
|
+
}}
|
|
112
|
+
placeholder={placeholder}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
{...restProps}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
{helpText ? (
|
|
119
|
+
<div className="text-area__help">
|
|
120
|
+
<Text
|
|
121
|
+
size={Text.sizes.interface}
|
|
122
|
+
className={cn('text-area__help-text', {
|
|
123
|
+
[`text-area__help-text--theme-${theme}-error`]: error,
|
|
124
|
+
[`text-area__help-text--theme-${theme}`]: theme,
|
|
125
|
+
})}
|
|
126
|
+
>
|
|
127
|
+
{helpIcon ? helpIcon : null}
|
|
128
|
+
{helpText}
|
|
129
|
+
</Text>
|
|
130
|
+
</div>
|
|
131
|
+
) : null}
|
|
132
|
+
|
|
133
|
+
{/* NOTE: This is aria-hidden because reporting of validation errors is handled by the browser */}
|
|
134
|
+
{error && (
|
|
135
|
+
<div aria-hidden="true" className="text-area__error">
|
|
136
|
+
<Text>{error}</Text>
|
|
137
|
+
</div>
|
|
138
|
+
)}
|
|
139
|
+
</label>
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// NOTE: If this isn't set, stack traces say "forwardRef" instead of "TextArea"
|
|
145
|
+
RefTextArea.displayName = 'TextArea';
|
|
146
|
+
// NOTE: The component is redeclared here because TypeScript doesn't accept assigning extra properties to `RefComponent` when it's declared
|
|
147
|
+
|
|
148
|
+
const TextArea: typeof RefTextArea & {
|
|
149
|
+
themes: typeof themes;
|
|
150
|
+
sizes: typeof sizes;
|
|
151
|
+
} = Object.assign(RefTextArea, { themes, sizes });
|
|
152
|
+
|
|
153
|
+
export default TextArea;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { ObjectValues, TextAreaHtmlProps } from '../types';
|
|
3
|
+
|
|
4
|
+
export const themes = {
|
|
5
|
+
light: 'light',
|
|
6
|
+
dark: 'dark',
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export const sizes = {
|
|
10
|
+
default: 'default',
|
|
11
|
+
small: 'small',
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
export type TextArea = {
|
|
15
|
+
helpText?: string;
|
|
16
|
+
label: string;
|
|
17
|
+
theme?: ObjectValues<typeof themes>;
|
|
18
|
+
size?: ObjectValues<typeof sizes>;
|
|
19
|
+
isLabelVisible?: boolean;
|
|
20
|
+
helpIcon?: ReactElement;
|
|
21
|
+
isShort?: boolean;
|
|
22
|
+
name: string;
|
|
23
|
+
defaultValue?: string;
|
|
24
|
+
} & TextAreaHtmlProps;
|