@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,118 @@
|
|
|
1
|
+
@use '../../tokens/corner-radius';
|
|
2
|
+
@use '../../tokens/light';
|
|
3
|
+
@use '../../tokens/spacing';
|
|
4
|
+
|
|
5
|
+
.banner {
|
|
6
|
+
border: 1px solid;
|
|
7
|
+
border-radius: corner-radius.$s;
|
|
8
|
+
display: grid;
|
|
9
|
+
padding: spacing.$m;
|
|
10
|
+
|
|
11
|
+
&--layout {
|
|
12
|
+
&-dismissable {
|
|
13
|
+
grid-template-columns: 1fr min-content;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&-icon {
|
|
17
|
+
grid-template-columns: min-content 1fr;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&-single {
|
|
21
|
+
grid-template-columns: 1fr;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&-triple {
|
|
25
|
+
grid-template-columns: min-content 1fr min-content;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&--nested {
|
|
30
|
+
border: 0;
|
|
31
|
+
border-radius: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&--type {
|
|
35
|
+
&-error {
|
|
36
|
+
background-color: light.$signal-surface-error;
|
|
37
|
+
border-color: light.$on-signal-surface-error-alternate;
|
|
38
|
+
|
|
39
|
+
.banner__anchor,
|
|
40
|
+
.banner__disimsser,
|
|
41
|
+
.banner__icon {
|
|
42
|
+
color: light.$on-signal-surface-error-alternate;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&-information {
|
|
47
|
+
background-color: light.$signal-surface-information;
|
|
48
|
+
border-color: light.$on-signal-surface-information-alternate;
|
|
49
|
+
|
|
50
|
+
.banner__anchor,
|
|
51
|
+
.banner__disimsser,
|
|
52
|
+
.banner__icon {
|
|
53
|
+
color: light.$on-signal-surface-information-alternate;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&-success {
|
|
58
|
+
background-color: light.$signal-surface-success;
|
|
59
|
+
border-color: light.$on-signal-surface-success-alternate;
|
|
60
|
+
|
|
61
|
+
.banner__anchor,
|
|
62
|
+
.banner__disimsser,
|
|
63
|
+
.banner__icon {
|
|
64
|
+
color: light.$on-signal-surface-success-alternate;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&-warning {
|
|
69
|
+
background-color: light.$signal-surface-warning;
|
|
70
|
+
border-color: light.$on-signal-surface-warning-alternate;
|
|
71
|
+
|
|
72
|
+
.banner__anchor,
|
|
73
|
+
.banner__disimsser,
|
|
74
|
+
.banner__icon {
|
|
75
|
+
color: light.$on-signal-surface-warning-alternate;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&__icon {
|
|
81
|
+
margin-right: spacing.$m;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__title {
|
|
85
|
+
margin-bottom: spacing.$s;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&__list {
|
|
89
|
+
margin-bottom: 0;
|
|
90
|
+
margin-top: spacing.$xs;
|
|
91
|
+
padding: 0 0 0 1.2em;
|
|
92
|
+
|
|
93
|
+
li::marker {
|
|
94
|
+
font-size: inherit;
|
|
95
|
+
font-size: inherit;
|
|
96
|
+
line-height: inherit;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&__link {
|
|
101
|
+
margin-top: spacing.$m;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&__secondary {
|
|
105
|
+
margin: (-(spacing.$m)) (-(spacing.$m)) 0 spacing.$xs;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&__dismisser {
|
|
109
|
+
background: transparent;
|
|
110
|
+
border: 0;
|
|
111
|
+
display: grid;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
height: 48px;
|
|
114
|
+
padding: 0;
|
|
115
|
+
place-items: center;
|
|
116
|
+
width: 48px;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import Close from '@sats-group/icons/18/close';
|
|
2
|
+
import Confirm from '@sats-group/icons/18/confirm';
|
|
3
|
+
import Error from '@sats-group/icons/18/error';
|
|
4
|
+
import Info from '@sats-group/icons/18/info';
|
|
5
|
+
import WarningSign from '@sats-group/icons/18/warning-sign';
|
|
6
|
+
import cn from 'classnames';
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import Text from '../text';
|
|
10
|
+
import VisuallyHidden from '../visually-hidden';
|
|
11
|
+
|
|
12
|
+
import type { Banner as Props } from './banner.types';
|
|
13
|
+
|
|
14
|
+
const typeIcon = {
|
|
15
|
+
error: <Error />,
|
|
16
|
+
information: <Info />,
|
|
17
|
+
success: <Confirm />,
|
|
18
|
+
warning: <WarningSign />,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const Banner: React.FunctionComponent<Props> = ({
|
|
22
|
+
dismiss,
|
|
23
|
+
icon,
|
|
24
|
+
link,
|
|
25
|
+
list,
|
|
26
|
+
nested,
|
|
27
|
+
text,
|
|
28
|
+
title,
|
|
29
|
+
type,
|
|
30
|
+
}) => {
|
|
31
|
+
const [isDismissed, setDismissed] = useState(false);
|
|
32
|
+
if (isDismissed) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const handleClick = () => setDismissed(true);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className={cn('banner', {
|
|
41
|
+
'banner--layout-dismissable': !icon && dismiss,
|
|
42
|
+
'banner--layout-icon': icon && !dismiss,
|
|
43
|
+
'banner--layout-single': !icon && !dismiss,
|
|
44
|
+
'banner--layout-triple': icon && dismiss,
|
|
45
|
+
'banner--nested': nested,
|
|
46
|
+
[`banner--type-${type}`]: type,
|
|
47
|
+
})}
|
|
48
|
+
>
|
|
49
|
+
{icon ? <div className="banner__icon">{typeIcon[type]}</div> : null}
|
|
50
|
+
<div className="banner__primary">
|
|
51
|
+
{title ? (
|
|
52
|
+
<div className="banner__title">
|
|
53
|
+
<Text theme={Text.themes.emphasis} tight>
|
|
54
|
+
{title}
|
|
55
|
+
</Text>
|
|
56
|
+
</div>
|
|
57
|
+
) : null}
|
|
58
|
+
<Text className="banner__text" size={Text.sizes.small}>
|
|
59
|
+
{text}
|
|
60
|
+
</Text>
|
|
61
|
+
{list.length ? (
|
|
62
|
+
<Text
|
|
63
|
+
elementName="ol"
|
|
64
|
+
className="banner__list"
|
|
65
|
+
size={Text.sizes.small}
|
|
66
|
+
>
|
|
67
|
+
{list.map(item => (
|
|
68
|
+
<li key={item}>{item}</li>
|
|
69
|
+
))}
|
|
70
|
+
</Text>
|
|
71
|
+
) : null}
|
|
72
|
+
{link ? (
|
|
73
|
+
<Text className="banner__link">
|
|
74
|
+
<a className="banner__anchor" href={link.href}>
|
|
75
|
+
{link.text}
|
|
76
|
+
</a>
|
|
77
|
+
</Text>
|
|
78
|
+
) : null}
|
|
79
|
+
</div>
|
|
80
|
+
{dismiss ? (
|
|
81
|
+
<div className="banner__secondary">
|
|
82
|
+
<button className="banner__dismisser" onClick={handleClick}>
|
|
83
|
+
<VisuallyHidden>{dismiss}</VisuallyHidden>
|
|
84
|
+
<Close />
|
|
85
|
+
</button>
|
|
86
|
+
</div>
|
|
87
|
+
) : null}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default Banner;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@use '../../tokens/elevation';
|
|
2
|
+
@use '../../tokens/light';
|
|
3
|
+
@use '../../tokens/spacing';
|
|
4
|
+
|
|
5
|
+
.bomb {
|
|
6
|
+
$border-inset: 3px;
|
|
7
|
+
$border-thickness: 2px;
|
|
8
|
+
|
|
9
|
+
@include elevation.level(1);
|
|
10
|
+
aspect-ratio: 1/1; // NOTE: Needs fallback for perfect roundness in older browsers. Worth it?
|
|
11
|
+
background: light.$buttons-cta-default;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
color: light.$on-buttons-on-cta-default;
|
|
14
|
+
display: grid;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
padding: spacing.$l;
|
|
17
|
+
place-items: center;
|
|
18
|
+
position: relative;
|
|
19
|
+
width: max-content;
|
|
20
|
+
|
|
21
|
+
&::before {
|
|
22
|
+
border-radius: 50%;
|
|
23
|
+
border: $border-thickness solid light.$on-buttons-on-cta-default;
|
|
24
|
+
bottom: $border-inset;
|
|
25
|
+
content: '';
|
|
26
|
+
display: block;
|
|
27
|
+
left: $border-inset;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
position: absolute;
|
|
30
|
+
right: $border-inset;
|
|
31
|
+
top: $border-inset;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Text from '../text';
|
|
3
|
+
|
|
4
|
+
import { Bomb as Props } from './bomb.types';
|
|
5
|
+
|
|
6
|
+
const Bomb: React.FC<Props> = ({ label, price }) => (
|
|
7
|
+
<div className="bomb">
|
|
8
|
+
<div className="bomb__content">
|
|
9
|
+
<Text size={Text.sizes.small} theme={Text.themes.normal}>
|
|
10
|
+
{label}
|
|
11
|
+
</Text>
|
|
12
|
+
<Text size={Text.sizes.large} theme={Text.themes['emphasis']}>
|
|
13
|
+
{price}
|
|
14
|
+
</Text>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export default Bomb;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Bomb = { label: string; price: string };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button as Props } from './button.types';
|
|
4
|
+
|
|
5
|
+
import VisuallyButton from '../visually-button';
|
|
6
|
+
|
|
7
|
+
const Button: React.FunctionComponent<Props> & {
|
|
8
|
+
sizes: typeof VisuallyButton.sizes;
|
|
9
|
+
themes: typeof VisuallyButton.themes;
|
|
10
|
+
variants: typeof VisuallyButton.variants;
|
|
11
|
+
} = ({ type = 'button', ...rest }) => (
|
|
12
|
+
<VisuallyButton elementName="button" type={type} {...rest} />
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
Button.sizes = VisuallyButton.sizes;
|
|
16
|
+
Button.themes = VisuallyButton.themes;
|
|
17
|
+
Button.variants = VisuallyButton.variants;
|
|
18
|
+
|
|
19
|
+
export default Button;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
@use '../../tokens/light';
|
|
2
|
+
@use '../../tokens/spacing';
|
|
3
|
+
|
|
4
|
+
.checkbox {
|
|
5
|
+
$block: &;
|
|
6
|
+
$size: 20px;
|
|
7
|
+
|
|
8
|
+
&__asterisk {
|
|
9
|
+
color: light.$on-surface-featured;
|
|
10
|
+
margin-left: spacing.$xs;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&:focus-within {
|
|
14
|
+
.checkbox__icon {
|
|
15
|
+
outline: 4px solid light.$ge-selector-primary-unselected-default;
|
|
16
|
+
outline-offset: 2px;
|
|
17
|
+
|
|
18
|
+
&--light {
|
|
19
|
+
outline-color: light.$ge-fixed-selector-unselected-default;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&--underline {
|
|
25
|
+
padding-bottom: spacing.$s;
|
|
26
|
+
border-bottom: 1px solid light.$ge-divider-default;
|
|
27
|
+
|
|
28
|
+
&--light {
|
|
29
|
+
border-color: light.$ge-divider-default;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&--intermediate {
|
|
34
|
+
.checkbox__icon {
|
|
35
|
+
border-color: light.$ge-selector-primary-selected-default;
|
|
36
|
+
background-color: light.$ge-selector-primary-selected-default;
|
|
37
|
+
|
|
38
|
+
svg {
|
|
39
|
+
color: light.$on-ge-on-selector-primary-selected-default;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.checkbox__check {
|
|
43
|
+
opacity: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.checkbox__intermediate {
|
|
47
|
+
opacity: 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&--light {
|
|
51
|
+
border-color: light.$ge-fixed-selector-selected-default;
|
|
52
|
+
background-color: light.$ge-fixed-selector-selected-default;
|
|
53
|
+
|
|
54
|
+
svg {
|
|
55
|
+
color: light.$on-ge-on-fixed-selector-selected-default;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&--blue {
|
|
60
|
+
border-color: light.$on-background-primary-default;
|
|
61
|
+
background-color: light.$on-background-primary-default;
|
|
62
|
+
|
|
63
|
+
svg {
|
|
64
|
+
color: light.$on-ge-on-selector-primary-selected-default;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&--error {
|
|
71
|
+
.checkbox__icon {
|
|
72
|
+
border-color: light.$ge-signal-border-error;
|
|
73
|
+
|
|
74
|
+
&--light {
|
|
75
|
+
border-color: light.$ge-signal-border-error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&__main {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
position: relative;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&__main-top {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
gap: spacing.$xs;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&__input {
|
|
93
|
+
position: absolute;
|
|
94
|
+
height: $size;
|
|
95
|
+
width: $size;
|
|
96
|
+
margin: 0;
|
|
97
|
+
opacity: 0;
|
|
98
|
+
z-index: 1;
|
|
99
|
+
|
|
100
|
+
&:not(:checked) {
|
|
101
|
+
+ .checkbox__icon {
|
|
102
|
+
svg {
|
|
103
|
+
opacity: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&--intermediate {
|
|
107
|
+
.checkbox__intermediate {
|
|
108
|
+
opacity: 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&:checked + .checkbox__icon {
|
|
115
|
+
background-color: light.$ge-selector-primary-selected-default;
|
|
116
|
+
border-color: light.$ge-selector-primary-selected-default;
|
|
117
|
+
|
|
118
|
+
svg {
|
|
119
|
+
color: light.$on-ge-on-selector-primary-selected-default;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.checkbox__check {
|
|
123
|
+
opacity: 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.checkbox__intermediate {
|
|
127
|
+
opacity: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&--light {
|
|
131
|
+
background-color: light.$ge-fixed-selector-selected-default;
|
|
132
|
+
border-color: light.$ge-fixed-selector-selected-default;
|
|
133
|
+
|
|
134
|
+
svg {
|
|
135
|
+
color: light.$on-ge-on-fixed-selector-selected-default;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&--blue {
|
|
140
|
+
background-color: light.$on-background-primary-default;
|
|
141
|
+
border-color: light.$on-background-primary-default;
|
|
142
|
+
|
|
143
|
+
svg {
|
|
144
|
+
color: light.$on-ge-on-selector-primary-selected-default;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&:disabled + .checkbox__icon {
|
|
150
|
+
opacity: 0.4;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&__content {
|
|
155
|
+
display: flex;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&__icon {
|
|
159
|
+
border-radius: 4px;
|
|
160
|
+
border: 2px solid light.$ge-selector-primary-unselected-default;
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
height: $size;
|
|
163
|
+
position: relative;
|
|
164
|
+
width: $size;
|
|
165
|
+
margin-top: 2px;
|
|
166
|
+
flex-shrink: 0;
|
|
167
|
+
|
|
168
|
+
svg {
|
|
169
|
+
display: block;
|
|
170
|
+
left: 50%;
|
|
171
|
+
position: absolute;
|
|
172
|
+
top: 50%;
|
|
173
|
+
transform: translate(-50%, -50%);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&--light {
|
|
177
|
+
border-color: light.$ge-fixed-selector-unselected-default;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&__description {
|
|
182
|
+
color: light.$on-surface-primary-alternate;
|
|
183
|
+
margin-left: $size + (spacing.$xs);
|
|
184
|
+
&--light {
|
|
185
|
+
color: light.$on-fixed-surface-neutral;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&--disabled {
|
|
189
|
+
color: light.$on-surface-primary-disabled;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&__label {
|
|
194
|
+
color: light.$on-surface-primary-default;
|
|
195
|
+
|
|
196
|
+
&--light {
|
|
197
|
+
color: light.$on-fixed-surface-primary-default;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
&--disabled {
|
|
201
|
+
color: light.$on-surface-primary-default;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&__extra {
|
|
206
|
+
margin-top: spacing.$s;
|
|
207
|
+
margin-left: 28px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
&__error {
|
|
211
|
+
color: light.$ge-signal-error;
|
|
212
|
+
margin-top: 4px;
|
|
213
|
+
|
|
214
|
+
&--light {
|
|
215
|
+
color: light.$ge-signal-error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import useInputValidation from '../use-input-validation';
|
|
5
|
+
import Text from '../text';
|
|
6
|
+
|
|
7
|
+
import { Checkbox as Props, themes } from './checkbox.types';
|
|
8
|
+
|
|
9
|
+
const RefCheckbox = React.forwardRef<
|
|
10
|
+
HTMLInputElement,
|
|
11
|
+
React.PropsWithChildren<Props>
|
|
12
|
+
>(
|
|
13
|
+
(
|
|
14
|
+
{
|
|
15
|
+
children,
|
|
16
|
+
disabled,
|
|
17
|
+
description,
|
|
18
|
+
extra,
|
|
19
|
+
intermediate,
|
|
20
|
+
isLabelVisible = true,
|
|
21
|
+
label,
|
|
22
|
+
name,
|
|
23
|
+
showCustomError = true,
|
|
24
|
+
theme,
|
|
25
|
+
value = '',
|
|
26
|
+
isUnderlined,
|
|
27
|
+
required,
|
|
28
|
+
...restProps
|
|
29
|
+
},
|
|
30
|
+
ref,
|
|
31
|
+
) => {
|
|
32
|
+
const [onChange, onInvalid, error] = useInputValidation();
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
className={cn('checkbox', {
|
|
37
|
+
'checkbox--error': error,
|
|
38
|
+
'checkbox--intermediate': intermediate,
|
|
39
|
+
[`checkbox--${theme}`]: theme,
|
|
40
|
+
})}
|
|
41
|
+
>
|
|
42
|
+
<label
|
|
43
|
+
className={cn('checkbox__content', {
|
|
44
|
+
'checkbox--underline': isUnderlined,
|
|
45
|
+
})}
|
|
46
|
+
>
|
|
47
|
+
<div className="checkbox__main">
|
|
48
|
+
<div className="checkbox__main-top">
|
|
49
|
+
<div>
|
|
50
|
+
<input
|
|
51
|
+
aria-label={isLabelVisible ? undefined : label}
|
|
52
|
+
className="checkbox__input"
|
|
53
|
+
type="checkbox"
|
|
54
|
+
name={name}
|
|
55
|
+
onChange={e => {
|
|
56
|
+
// NOTE: If props specify an `onChange`, we need to call that too
|
|
57
|
+
if (restProps.onChange) restProps.onChange(e);
|
|
58
|
+
onChange(e);
|
|
59
|
+
}}
|
|
60
|
+
onInvalid={e => {
|
|
61
|
+
// NOTE: If props specify an `onInvalid`, we need to call that too
|
|
62
|
+
if (restProps.onInvalid) restProps.onInvalid(e);
|
|
63
|
+
onInvalid(e);
|
|
64
|
+
}}
|
|
65
|
+
ref={ref}
|
|
66
|
+
value={value}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
required={required}
|
|
69
|
+
{...restProps}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<div
|
|
73
|
+
className={cn('checkbox__icon', {
|
|
74
|
+
'checkbox__icon--intermediate': intermediate,
|
|
75
|
+
[`checkbox__icon--${theme}`]: theme,
|
|
76
|
+
})}
|
|
77
|
+
>
|
|
78
|
+
<svg
|
|
79
|
+
className="checkbox__intermediate"
|
|
80
|
+
width="10"
|
|
81
|
+
height="10"
|
|
82
|
+
viewBox="0 0 10 10"
|
|
83
|
+
fill="none"
|
|
84
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
85
|
+
>
|
|
86
|
+
<line
|
|
87
|
+
x1="0"
|
|
88
|
+
y1="5"
|
|
89
|
+
x2="10"
|
|
90
|
+
y2="5"
|
|
91
|
+
stroke="currentColor"
|
|
92
|
+
strokeWidth="2"
|
|
93
|
+
/>
|
|
94
|
+
</svg>
|
|
95
|
+
<svg
|
|
96
|
+
className="checkbox__check"
|
|
97
|
+
width="12"
|
|
98
|
+
height="10"
|
|
99
|
+
viewBox="0 0 12 10"
|
|
100
|
+
fill="none"
|
|
101
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
102
|
+
>
|
|
103
|
+
<path
|
|
104
|
+
d="M4.76123 9.0605L0.700729 5L1.76123 3.9395L4.76123 6.9395L10.7612 0.939501L11.8217 2L4.76123 9.0605Z"
|
|
105
|
+
fill="currentColor"
|
|
106
|
+
/>
|
|
107
|
+
</svg>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
{isLabelVisible ? (
|
|
111
|
+
<>
|
|
112
|
+
{label ? (
|
|
113
|
+
<Text
|
|
114
|
+
className={cn('checkbox__label', {
|
|
115
|
+
[`checkbox__label--${theme}`]: theme,
|
|
116
|
+
'checkbox__label--disabled': disabled,
|
|
117
|
+
})}
|
|
118
|
+
size={Text.sizes.basic}
|
|
119
|
+
>
|
|
120
|
+
{label}
|
|
121
|
+
</Text>
|
|
122
|
+
) : (
|
|
123
|
+
<div
|
|
124
|
+
className={cn('checkbox__label', {
|
|
125
|
+
[`checkbox__label--${theme}`]: theme,
|
|
126
|
+
'checkbox__label--disabled': disabled,
|
|
127
|
+
})}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
</>
|
|
133
|
+
) : null}
|
|
134
|
+
{required ? <span className="checkbox__asterisk">*</span> : null}
|
|
135
|
+
</div>
|
|
136
|
+
{description && (
|
|
137
|
+
<Text
|
|
138
|
+
className={cn('checkbox__description', {
|
|
139
|
+
[`checkbox__label--${theme}`]: theme,
|
|
140
|
+
'checkbox__label--disabled': disabled,
|
|
141
|
+
})}
|
|
142
|
+
size={Text.sizes.small}
|
|
143
|
+
>
|
|
144
|
+
{description}
|
|
145
|
+
</Text>
|
|
146
|
+
)}
|
|
147
|
+
</div>
|
|
148
|
+
</label>
|
|
149
|
+
|
|
150
|
+
{/* NOTE: This is aria-hidden because reporting of validation errors is handled by the browser */}
|
|
151
|
+
{error && showCustomError && (
|
|
152
|
+
<div
|
|
153
|
+
aria-hidden="true"
|
|
154
|
+
className={cn('checkbox__error', {
|
|
155
|
+
[`checkbox__error--${theme}`]: theme,
|
|
156
|
+
})}
|
|
157
|
+
>
|
|
158
|
+
{error}
|
|
159
|
+
</div>
|
|
160
|
+
)}
|
|
161
|
+
|
|
162
|
+
{extra && <span className="checkbox__extra">{extra}</span>}
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// NOTE: If this isn't set, stack traces say "forwardRef" instead of "Checkbox"
|
|
169
|
+
RefCheckbox.displayName = 'Checkbox';
|
|
170
|
+
|
|
171
|
+
// NOTE: The component is redeclared here because TypeScript doesn't accept assigning extra properties to `RefComponent` when it's declared
|
|
172
|
+
const Checkbox: typeof RefCheckbox & {
|
|
173
|
+
themes: typeof themes;
|
|
174
|
+
} = Object.assign(RefCheckbox, { themes });
|
|
175
|
+
|
|
176
|
+
export default Checkbox;
|