@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.
Files changed (227) hide show
  1. package/.nvmrc +1 -0
  2. package/README.md +35 -0
  3. package/catalog-info.yaml +14 -0
  4. package/eslint.config.mjs +94 -0
  5. package/fonts/Inter-BoldItalic.woff +0 -0
  6. package/fonts/Inter-BoldItalic.woff2 +0 -0
  7. package/fonts/Inter-ExtraBold.woff +0 -0
  8. package/fonts/Inter-ExtraBold.woff2 +0 -0
  9. package/fonts/Inter-Italic.woff +0 -0
  10. package/fonts/Inter-Italic.woff2 +0 -0
  11. package/fonts/Inter-Regular.woff +0 -0
  12. package/fonts/Inter-Regular.woff2 +0 -0
  13. package/fonts/Inter-SemiBold.woff +0 -0
  14. package/fonts/Inter-SemiBold.woff2 +0 -0
  15. package/fonts/LICENSE.txt +92 -0
  16. package/fonts/SATSHeadline-Bold.woff +0 -0
  17. package/fonts/SATSHeadline-BoldItalic.woff +0 -0
  18. package/fonts/SATSHeadline-RegularItalic.woff +0 -0
  19. package/fonts/SATSHeadline-SemiBoldItalic.woff +0 -0
  20. package/logos/e-avatar.svg +3 -0
  21. package/logos/elixia-letter.svg +3 -0
  22. package/logos/elixia-small.svg +8 -0
  23. package/logos/elixia.svg +8 -0
  24. package/logos/s-avatar.svg +3 -0
  25. package/logos/sats-letter.svg +3 -0
  26. package/logos/sats-small.svg +3 -0
  27. package/logos/sats.svg +4 -0
  28. package/package.json +58 -0
  29. package/react/add-bem-modifiers.ts +51 -0
  30. package/react/badge/badge.scss +53 -0
  31. package/react/badge/badge.tsx +28 -0
  32. package/react/badge/badge.types.ts +34 -0
  33. package/react/badge/index.ts +2 -0
  34. package/react/banner/banner.scss +118 -0
  35. package/react/banner/banner.tsx +92 -0
  36. package/react/banner/banner.types.ts +10 -0
  37. package/react/banner/index.ts +2 -0
  38. package/react/bomb/bomb.scss +33 -0
  39. package/react/bomb/bomb.tsx +19 -0
  40. package/react/bomb/bomb.types.ts +1 -0
  41. package/react/bomb/index.ts +2 -0
  42. package/react/button/button.tsx +19 -0
  43. package/react/button/button.types.ts +3 -0
  44. package/react/button/index.ts +2 -0
  45. package/react/checkbox/checkbox.scss +218 -0
  46. package/react/checkbox/checkbox.tsx +176 -0
  47. package/react/checkbox/checkbox.types.ts +19 -0
  48. package/react/checkbox/index.ts +2 -0
  49. package/react/chip/chip.scss +46 -0
  50. package/react/chip/chip.tsx +37 -0
  51. package/react/chip/chip.types.ts +18 -0
  52. package/react/chip/index.ts +2 -0
  53. package/react/chip/remove.tsx +14 -0
  54. package/react/chip-selected/chip-selected.scss +47 -0
  55. package/react/chip-selected/chip-selected.tsx +102 -0
  56. package/react/chip-selected/chip-selected.types.ts +11 -0
  57. package/react/chip-selected/index.ts +2 -0
  58. package/react/confirmation/confirmation.scss +60 -0
  59. package/react/confirmation/confirmation.tsx +85 -0
  60. package/react/confirmation/confirmation.types.ts +24 -0
  61. package/react/confirmation/index.ts +2 -0
  62. package/react/context-menu/context-menu.scss +183 -0
  63. package/react/context-menu/context-menu.tsx +200 -0
  64. package/react/context-menu/context-menu.types.ts +71 -0
  65. package/react/context-menu/index.ts +2 -0
  66. package/react/cropped-image/cropped-image.scss +48 -0
  67. package/react/cropped-image/cropped-image.tsx +36 -0
  68. package/react/cropped-image/cropped-image.types.ts +26 -0
  69. package/react/cropped-image/index.ts +2 -0
  70. package/react/dropdown-list/dropdown-list.scss +170 -0
  71. package/react/dropdown-list/dropdown-list.tsx +116 -0
  72. package/react/dropdown-list/dropdown-list.types.ts +17 -0
  73. package/react/dropdown-list/index.ts +2 -0
  74. package/react/expander/expander.scss +115 -0
  75. package/react/expander/expander.tsx +167 -0
  76. package/react/expander/expander.types.ts +26 -0
  77. package/react/expander/index.ts +2 -0
  78. package/react/filter/filter.scss +94 -0
  79. package/react/filter/filter.tsx +99 -0
  80. package/react/filter/filter.types.ts +8 -0
  81. package/react/filter/index.ts +2 -0
  82. package/react/filter-wrapper/filter-wrapper.scss +46 -0
  83. package/react/filter-wrapper/filter-wrapper.tsx +24 -0
  84. package/react/filter-wrapper/filter-wrapper.types.ts +10 -0
  85. package/react/filter-wrapper/index.ts +2 -0
  86. package/react/flag/flag.scss +26 -0
  87. package/react/flag/flag.tsx +27 -0
  88. package/react/flag/flag.types.ts +17 -0
  89. package/react/flag/index.ts +2 -0
  90. package/react/form-content/checkbox-category.tsx +183 -0
  91. package/react/form-content/form-content.checkbox-list.tsx +126 -0
  92. package/react/form-content/form-content.checkbox-list.types.ts +36 -0
  93. package/react/form-content/form-content.radio-list.tsx +58 -0
  94. package/react/form-content/form-content.range.tsx +20 -0
  95. package/react/form-content/form-content.range.types.ts +14 -0
  96. package/react/form-content/form-content.scss +234 -0
  97. package/react/form-content/form-content.search.tsx +47 -0
  98. package/react/form-content/form-content.tsx +95 -0
  99. package/react/form-content/form-content.types.ts +55 -0
  100. package/react/form-content/index.ts +2 -0
  101. package/react/form-content/types/index.d.ts +1 -0
  102. package/react/hidden-input/hidden-input.tsx +9 -0
  103. package/react/hidden-input/hidden-input.types.ts +6 -0
  104. package/react/hidden-input/index.ts +2 -0
  105. package/react/hooks/focus-previous-element.ts +30 -0
  106. package/react/hooks/is-running-on-client.ts +1 -0
  107. package/react/hooks/use-click-outside.ts +23 -0
  108. package/react/hooks/use-escape.ts +18 -0
  109. package/react/hooks/use-event.ts +29 -0
  110. package/react/hooks/use-is-mounted.ts +11 -0
  111. package/react/hooks/use-toggle.ts +19 -0
  112. package/react/icons/16/close.tsx +12 -0
  113. package/react/icons/18/close.tsx +18 -0
  114. package/react/icons/24/arrow-down.tsx +14 -0
  115. package/react/icons/24/arrow-right.tsx +14 -0
  116. package/react/icons/24/arrow-up.tsx +14 -0
  117. package/react/icons/24/close.tsx +12 -0
  118. package/react/icons/24/remove.tsx +12 -0
  119. package/react/icons/24/search.tsx +10 -0
  120. package/react/icons/icons.md +3 -0
  121. package/react/indexed-access-type.ts +1 -0
  122. package/react/link/index.ts +2 -0
  123. package/react/link/link.scss +44 -0
  124. package/react/link/link.tsx +62 -0
  125. package/react/link/link.types.ts +37 -0
  126. package/react/link-button/index.ts +2 -0
  127. package/react/link-button/link-button.tsx +17 -0
  128. package/react/link-button/link-button.types.ts +5 -0
  129. package/react/link-card/index.ts +2 -0
  130. package/react/link-card/link-card.scss +37 -0
  131. package/react/link-card/link-card.tsx +24 -0
  132. package/react/link-card/link-card.types.ts +5 -0
  133. package/react/logos/e-avatar.tsx +12 -0
  134. package/react/logos/elixia-letter.tsx +12 -0
  135. package/react/logos/elixia-small.tsx +12 -0
  136. package/react/logos/elixia.tsx +12 -0
  137. package/react/logos/index.ts +8 -0
  138. package/react/logos/s-avatar.tsx +12 -0
  139. package/react/logos/sats-letter.tsx +12 -0
  140. package/react/logos/sats-small.tsx +12 -0
  141. package/react/logos/sats.tsx +12 -0
  142. package/react/message/hook/use-message.ts +22 -0
  143. package/react/message/index.ts +2 -0
  144. package/react/message/message.scss +92 -0
  145. package/react/message/message.tsx +60 -0
  146. package/react/message/message.types.ts +39 -0
  147. package/react/message/publish.ts +19 -0
  148. package/react/message-field/index.ts +2 -0
  149. package/react/message-field/message-field.scss +21 -0
  150. package/react/message-field/message-field.tsx +70 -0
  151. package/react/message-field/message-field.types.ts +24 -0
  152. package/react/modal/index.ts +2 -0
  153. package/react/modal/modal.scss +162 -0
  154. package/react/modal/modal.tsx +130 -0
  155. package/react/modal/modal.types.ts +36 -0
  156. package/react/modal/tab-trapper.tsx +68 -0
  157. package/react/progress-bar/index.ts +2 -0
  158. package/react/progress-bar/progress-bar.scss +71 -0
  159. package/react/progress-bar/progress-bar.tsx +81 -0
  160. package/react/progress-bar/progress-bar.types.ts +35 -0
  161. package/react/radio/index.ts +2 -0
  162. package/react/radio/radio.scss +142 -0
  163. package/react/radio/radio.tsx +87 -0
  164. package/react/radio/radio.types.ts +15 -0
  165. package/react/scale-bar/index.ts +2 -0
  166. package/react/scale-bar/scale-bar.scss +22 -0
  167. package/react/scale-bar/scale-bar.tsx +29 -0
  168. package/react/scale-bar/scale-bar.types.ts +4 -0
  169. package/react/search/index.ts +2 -0
  170. package/react/search/search.scss +207 -0
  171. package/react/search/search.tsx +255 -0
  172. package/react/search/search.types.ts +43 -0
  173. package/react/select/chevron-down.tsx +24 -0
  174. package/react/select/index.ts +2 -0
  175. package/react/select/select.scss +135 -0
  176. package/react/select/select.tsx +105 -0
  177. package/react/select/select.types.ts +19 -0
  178. package/react/select-option/README.md +3 -0
  179. package/react/select-option/index.ts +2 -0
  180. package/react/select-option/select-option.tsx +16 -0
  181. package/react/select-option/select-option.types.ts +8 -0
  182. package/react/tag/index.ts +2 -0
  183. package/react/tag/tag.scss +107 -0
  184. package/react/tag/tag.tsx +26 -0
  185. package/react/tag/tag.types.ts +30 -0
  186. package/react/text/index.ts +2 -0
  187. package/react/text/text.scss +109 -0
  188. package/react/text/text.tsx +40 -0
  189. package/react/text/text.types.ts +29 -0
  190. package/react/text-area/index.ts +2 -0
  191. package/react/text-area/text-area.scss +180 -0
  192. package/react/text-area/text-area.tsx +153 -0
  193. package/react/text-area/text-area.types.ts +24 -0
  194. package/react/text-input/index.ts +2 -0
  195. package/react/text-input/text-input.scss +233 -0
  196. package/react/text-input/text-input.tsx +106 -0
  197. package/react/text-input/text-input.types.ts +19 -0
  198. package/react/toggle/index.ts +2 -0
  199. package/react/toggle/toggle.scss +69 -0
  200. package/react/toggle/toggle.tsx +83 -0
  201. package/react/toggle/toggle.types.ts +11 -0
  202. package/react/toolbox/index.ts +2 -0
  203. package/react/toolbox/toolbox.scss +68 -0
  204. package/react/toolbox/toolbox.tsx +43 -0
  205. package/react/toolbox/toolbox.types.ts +39 -0
  206. package/react/ts/debounce.ts +12 -0
  207. package/react/types.ts +38 -0
  208. package/react/use-input-validation.ts +47 -0
  209. package/react/use-input-validation.types.ts +12 -0
  210. package/react/visually-button/index.ts +2 -0
  211. package/react/visually-button/visually-button.scss +470 -0
  212. package/react/visually-button/visually-button.tsx +130 -0
  213. package/react/visually-button/visually-button.types.ts +71 -0
  214. package/react/visually-hidden/index.ts +2 -0
  215. package/react/visually-hidden/visually-hidden.scss +6 -0
  216. package/react/visually-hidden/visually-hidden.tsx +10 -0
  217. package/tokens/corner-radius.scss +5 -0
  218. package/tokens/dark.scss +392 -0
  219. package/tokens/darkmode.scss +131 -0
  220. package/tokens/elevation.scss +57 -0
  221. package/tokens/font-faces.scss +62 -0
  222. package/tokens/font-names.scss +2 -0
  223. package/tokens/font-sizes.scss +95 -0
  224. package/tokens/light.scss +392 -0
  225. package/tokens/lightmode.scss +131 -0
  226. package/tokens/primitives.scss +137 -0
  227. package/tokens/spacing.scss +12 -0
@@ -0,0 +1,200 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ import Close from '../icons/18/close';
5
+ import HiddenInput from '../hidden-input';
6
+ import focusPreviousElement from '../hooks/focus-previous-element';
7
+ import TabTrapper from '../modal/tab-trapper';
8
+ import useClickOutside from '../hooks/use-click-outside';
9
+ import useEscape from '../hooks/use-escape';
10
+ import Button from '../button';
11
+ import Text from '../text';
12
+ import debounce from '../ts/debounce';
13
+
14
+ import {
15
+ ContextMenu as Props,
16
+ Types,
17
+ itemThemes,
18
+ positions,
19
+ } from './context-menu.types';
20
+
21
+ const ContextMenu: React.FunctionComponent<Props> & {
22
+ position: typeof positions;
23
+ itemTheme: typeof itemThemes;
24
+ } = ({
25
+ list,
26
+ isOpen,
27
+ onClose = () => {},
28
+ position = positions.right,
29
+ title,
30
+ close,
31
+ descriptions,
32
+ smallDescription,
33
+ }) => {
34
+ const modal = useRef<HTMLDivElement>(null);
35
+ const [windowSize, setWindowSize] = useState<number>();
36
+ useClickOutside(modal, onClose);
37
+ useEscape(onClose);
38
+
39
+ focusPreviousElement(modal, isOpen);
40
+
41
+ useEffect(() => {
42
+ if (!windowSize) setWindowSize(window.innerWidth);
43
+ const handleWindowResize = () => {
44
+ setWindowSize(window.innerWidth);
45
+ };
46
+ window.addEventListener('resize', debounce(handleWindowResize, 2000));
47
+
48
+ return () => window.addEventListener('resize', handleWindowResize);
49
+ });
50
+
51
+ const component = (
52
+ <div
53
+ className={classNames('context-menu', {
54
+ [`context-menu--${position}`]: position,
55
+ })}
56
+ ref={modal}
57
+ tabIndex={-1}
58
+ >
59
+ <div
60
+ className={classNames('context-menu__texts-wrapper', {
61
+ 'context-menu__texts-wrapper--center': !descriptions?.length,
62
+ })}
63
+ >
64
+ <div className="context-menu__texts">
65
+ <Text theme={Text.themes.emphasis} size={Text.sizes.small}>
66
+ {title}
67
+ </Text>
68
+
69
+ {descriptions
70
+ ? descriptions.map(description => (
71
+ <Text
72
+ size={Text.sizes.small}
73
+ className="context-menu__texts-description"
74
+ key={description}
75
+ >
76
+ {description}
77
+ </Text>
78
+ ))
79
+ : null}
80
+ {smallDescription ? (
81
+ <Text
82
+ size={Text.sizes.interface}
83
+ className="context-menu__texts-description"
84
+ key={smallDescription}
85
+ >
86
+ {smallDescription}
87
+ </Text>
88
+ ) : null}
89
+ </div>
90
+ <div>
91
+ <Button
92
+ {...close}
93
+ variant={Button.variants.tertiary}
94
+ size={Button.sizes.small}
95
+ leadingIcon={<Close />}
96
+ onClick={onClose}
97
+ />
98
+ </div>
99
+ </div>
100
+ <div className="context-menu__list-items">
101
+ {list.map(({ icon, item }, index) => (
102
+ <div key={item.props.text + index}>
103
+ {item.type === Types.Link ? (
104
+ <a
105
+ href={item.props.href}
106
+ className={classNames('context-menu__list-item-link', {
107
+ [`context-menu__list-item-link--theme-${item.props.theme}`]:
108
+ item.props.theme,
109
+ })}
110
+ data-testid={item.props.testId}
111
+ >
112
+ {icon ? (
113
+ <div
114
+ className={classNames('context-menu__list-icon', {
115
+ [`context-menu__list-icon--theme-${item.props.theme}`]:
116
+ item.props.theme,
117
+ })}
118
+ >
119
+ {icon}
120
+ </div>
121
+ ) : null}
122
+ <Text>{item.props.text}</Text>
123
+ </a>
124
+ ) : item.type === Types.Form ? (
125
+ <form
126
+ onSubmit={item.props.handleSubmit}
127
+ action={item.props.action}
128
+ method="POST"
129
+ className={classNames('context-menu__list-item-form', {
130
+ [`context-menu__list-item-form--theme-${item.props.theme}`]:
131
+ item.props.theme,
132
+ })}
133
+ >
134
+ <button
135
+ type="submit"
136
+ className={classNames('context-menu__list-item-form-button', {
137
+ [`context-menu__list-item-form-button--theme-${item.props.theme}`]:
138
+ item.props.theme,
139
+ })}
140
+ data-testid={item.props.testId}
141
+ >
142
+ {icon ? (
143
+ <div
144
+ className={classNames('context-menu__list-icon', {
145
+ [`context-menu__list-icon--theme-${item.props.theme}`]:
146
+ item.props.theme,
147
+ })}
148
+ >
149
+ {icon}
150
+ </div>
151
+ ) : null}
152
+ <Text>{item.props.text}</Text>
153
+ </button>
154
+ {item.props.hiddenInputs
155
+ ? item.props.hiddenInputs.map((input, index) => (
156
+ <HiddenInput key={input.name + index} {...input} />
157
+ ))
158
+ : null}
159
+ </form>
160
+ ) : item.type === Types.Button ? (
161
+ <button
162
+ className={classNames('context-menu__list-item-button', {
163
+ [`context-menu__list-item-button--theme-${item.props.theme}`]:
164
+ item.props.theme,
165
+ })}
166
+ {...item.props}
167
+ >
168
+ {icon ? (
169
+ <div
170
+ className={classNames('context-menu__list-icon', {
171
+ [`context-menu__list-icon--theme-${item.props.theme}`]:
172
+ item.props.theme,
173
+ })}
174
+ >
175
+ {icon}
176
+ </div>
177
+ ) : null}
178
+ <Text>{item.props.text}</Text>
179
+ </button>
180
+ ) : null}
181
+ </div>
182
+ ))}
183
+ </div>
184
+ </div>
185
+ );
186
+ return isOpen ? (
187
+ <>
188
+ <div className="context-menu__background-overlay"></div>
189
+ {windowSize && windowSize < 600 ? ( // 600 is the breakpoint for the component.
190
+ <TabTrapper isActive={isOpen}>{component}</TabTrapper>
191
+ ) : (
192
+ <div>{component}</div>
193
+ )}
194
+ </>
195
+ ) : null;
196
+ };
197
+
198
+ ContextMenu.position = positions;
199
+ ContextMenu.itemTheme = itemThemes;
200
+ export default ContextMenu;
@@ -0,0 +1,71 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import type { Button } from '../button/button.types';
4
+ import type { HiddenInput } from '../hidden-input/hidden-input.types';
5
+ import type { ButtonHtmlProps, ObjectValues } from '../types';
6
+
7
+ export const positions = {
8
+ top: 'top',
9
+ right: 'right',
10
+ bottom: 'bottom',
11
+ left: 'left',
12
+ topLeft: 'top-left',
13
+ topRight: 'top-right',
14
+ bottomRight: 'bottom-right',
15
+ bottomLeft: 'bottom-left',
16
+ } as const;
17
+
18
+ export enum Types {
19
+ Button = 'Button',
20
+ Form = 'Form',
21
+ Link = 'Link',
22
+ }
23
+
24
+ export const itemThemes = {
25
+ destructive: 'destructive',
26
+ } as const;
27
+
28
+ type CommonProps = {
29
+ theme?: ObjectValues<typeof itemThemes>;
30
+ };
31
+
32
+ type LinkMenuItem = {
33
+ type: Types.Link;
34
+ props: {
35
+ href: string;
36
+ text: string;
37
+ testId?: string;
38
+ } & CommonProps;
39
+ };
40
+
41
+ type FormMenuItem = {
42
+ type: Types.Form;
43
+ props: {
44
+ text: string;
45
+ action: string;
46
+ handleSubmit?: () => void;
47
+ hiddenInputs?: HiddenInput[];
48
+ testId?: string;
49
+ } & CommonProps;
50
+ };
51
+
52
+ type ButtonMenuitem = {
53
+ type: Types.Button;
54
+ props: { text: string } & ButtonHtmlProps & CommonProps;
55
+ };
56
+
57
+ type MenuItem = {
58
+ icon?: ReactNode;
59
+ item: LinkMenuItem | FormMenuItem | ButtonMenuitem;
60
+ };
61
+
62
+ export type ContextMenu = {
63
+ isOpen?: boolean;
64
+ onClose?: () => void;
65
+ list: MenuItem[];
66
+ position?: ObjectValues<typeof positions>;
67
+ close: Button;
68
+ title: string;
69
+ descriptions?: string[];
70
+ smallDescription?: string;
71
+ };
@@ -0,0 +1,2 @@
1
+ import ContextMenu from './context-menu';
2
+ export default ContextMenu;
@@ -0,0 +1,48 @@
1
+ @use 'sass:math';
2
+
3
+ .cropped-image {
4
+ position: relative;
5
+
6
+ &--square {
7
+ padding-bottom: 100%;
8
+ }
9
+
10
+ &--2-3 {
11
+ padding-bottom: math.div(3, 2) * 100%;
12
+ }
13
+
14
+ &--3-4 {
15
+ padding-bottom: math.div(4, 3) * 100%;
16
+ }
17
+
18
+ &--4-3 {
19
+ padding-bottom: math.div(3, 4) * 100%;
20
+ }
21
+
22
+ &--3-2 {
23
+ padding-bottom: math.div(2, 3) * 100%;
24
+ }
25
+
26
+ &--16-9 {
27
+ padding-bottom: math.div(9, 16) * 100%;
28
+ }
29
+
30
+ &--9-18 {
31
+ padding-bottom: math.div(18, 9) * 100%;
32
+ }
33
+
34
+ &--9-16 {
35
+ padding-bottom: math.div(16, 9) * 100%;
36
+ }
37
+
38
+ &__element {
39
+ display: block;
40
+ height: 100%;
41
+ left: 0;
42
+ object-fit: cover;
43
+ object-position: center;
44
+ position: absolute;
45
+ top: 0;
46
+ width: 100%;
47
+ }
48
+ }
@@ -0,0 +1,36 @@
1
+ import cn from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import {
5
+ aspectRatios,
6
+ loadings,
7
+ CroppedImage as Props,
8
+ } from './cropped-image.types';
9
+
10
+ const CroppedImage: React.FunctionComponent<Props> & {
11
+ aspectRatios: typeof aspectRatios;
12
+ loadings: typeof loadings;
13
+ } = ({
14
+ alt,
15
+ aspectRatio = aspectRatios.sixteenNine,
16
+ className,
17
+ loading = loadings.lazy,
18
+ src,
19
+ srcQuery = '',
20
+ ...rest
21
+ }) => (
22
+ <div className={cn('cropped-image', aspectRatio, className)}>
23
+ <img
24
+ className="cropped-image__element"
25
+ alt={alt}
26
+ loading={loading}
27
+ src={`${src}${srcQuery}`}
28
+ {...rest}
29
+ />
30
+ </div>
31
+ );
32
+
33
+ CroppedImage.aspectRatios = aspectRatios;
34
+ CroppedImage.loadings = loadings;
35
+
36
+ export default CroppedImage;
@@ -0,0 +1,26 @@
1
+ import { ImageHtmlProps, ObjectValues } from '../types';
2
+
3
+ export const aspectRatios = {
4
+ square: 'cropped-image--square',
5
+ twoThree: 'cropped-image--2-3',
6
+ fourThree: 'cropped-image--4-3',
7
+ threeTwo: 'cropped-image--3-2',
8
+ threeFour: 'cropped-image--3-4',
9
+ nineSixteen: 'cropped-image--9-16',
10
+ nineEighteen: 'cropped-image--9-18',
11
+ sixteenNine: 'cropped-image--16-9',
12
+ } as const;
13
+
14
+ export const loadings = {
15
+ eager: 'eager',
16
+ lazy: 'lazy',
17
+ } as const;
18
+
19
+ export type CroppedImage = ImageHtmlProps & {
20
+ alt: string;
21
+ aspectRatio?: ObjectValues<typeof aspectRatios>;
22
+ className?: string;
23
+ loading?: ObjectValues<typeof loadings>;
24
+ src: string;
25
+ srcQuery?: string;
26
+ };
@@ -0,0 +1,2 @@
1
+ import CroppedImage from './cropped-image';
2
+ export default CroppedImage;
@@ -0,0 +1,170 @@
1
+ @use '../../tokens/corner-radius';
2
+ @use '../../tokens/spacing';
3
+ @use '../../tokens/light';
4
+
5
+ .dropdown-list {
6
+ $breakpoint: 900px;
7
+ min-width: 280px;
8
+
9
+
10
+ &__wrapper {
11
+ border-radius: corner-radius.$s;
12
+ border: 1px solid light.$ge-divider-default;
13
+ background-color: light.$surface-primary-default;
14
+ margin-top: spacing.$xxs;
15
+ min-width: 180px;
16
+
17
+ @media (min-width: $breakpoint) {
18
+ position: relative;
19
+ }
20
+
21
+ &--theme-light {
22
+ &-clicked {
23
+ background-color: light.$surface-primary-hover;
24
+ }
25
+
26
+ &-disabled {
27
+ border-color: light.$surface-primary-default;
28
+ }
29
+
30
+ @media (hover: hover) {
31
+ &:hover {
32
+ background-color: light.$surface-primary-hover;
33
+ }
34
+
35
+ &-disabled {
36
+ &:hover {
37
+ background-color: light.$surface-primary-default;
38
+ border-color: light.$surface-primary-default;
39
+ }
40
+ }
41
+ }
42
+
43
+ @media (hover: none) {
44
+ &:hover {
45
+ background-color: light.$surface-primary-default;
46
+ border-color: light.$surface-primary-default;
47
+ }
48
+ }
49
+ }
50
+
51
+ &--theme-dark {
52
+ background-color: light.$fixed-surface-secondary-default;
53
+ border-color: light.$fixed-surface-secondary-default;
54
+
55
+ &-clicked {
56
+ background-color: light.$fixed-surface-secondary-hover;
57
+ border-color: light.$fixed-surface-secondary-hover;
58
+ }
59
+
60
+ &-disabled {
61
+ background-color: light.$fixed-surface-secondary-default;
62
+ border-color: light.$fixed-surface-secondary-default;
63
+ }
64
+
65
+ @media (hover: hover) {
66
+ &:hover {
67
+ background-color: light.$fixed-surface-secondary-hover;
68
+ border-color: light.$fixed-surface-secondary-hover;
69
+ }
70
+
71
+ &-disabled {
72
+ &:hover {
73
+ background-color: light.$fixed-surface-secondary-default;
74
+ border-color: light.$fixed-surface-secondary-default;
75
+ }
76
+ }
77
+ }
78
+
79
+ @media (hover: none) {
80
+ &:hover {
81
+ background-color: light.$fixed-surface-secondary-default;
82
+ border-color: light.$fixed-surface-secondary-default;
83
+ }
84
+ }
85
+ }
86
+ }
87
+
88
+ &__buttons {
89
+ position: relative;
90
+ }
91
+
92
+ &__button {
93
+ cursor: pointer;
94
+ display: flex;
95
+ justify-content: space-between;
96
+ text-align: left;
97
+ background-color: transparent;
98
+ border: none;
99
+ width: 100%;
100
+ height: 100%;
101
+ box-shadow: none;
102
+ font: inherit;
103
+ overflow: hidden;
104
+ padding: spacing.$xs spacing.$s;
105
+
106
+ &--theme-light {
107
+ &-disabled {
108
+ cursor: not-allowed;
109
+ color: light.$on-surface-primary-disabled;
110
+ }
111
+ }
112
+
113
+ &--theme-dark {
114
+ color: light.$on-fixed-surface-secondary-default;
115
+
116
+ &-disabled {
117
+ color: light.$on-fixed-surface-secondary-disabled;
118
+ cursor: not-allowed;
119
+ }
120
+
121
+ &-clicked {
122
+ color: light.$on-fixed-surface-secondary-default;
123
+ }
124
+ }
125
+ }
126
+
127
+ &__text-wrap {
128
+ display: flex;
129
+ flex-direction: column;
130
+ gap: spacing.$xxs;
131
+ }
132
+
133
+ &__icon {
134
+ margin-left: spacing.$xs;
135
+ display: block;
136
+ align-self: center;
137
+ }
138
+
139
+ &__information {
140
+ &--theme-light {
141
+ color: light.$on-surface-primary-alternate;
142
+
143
+ &-disabled {
144
+ color: light.$on-surface-primary-disabled;
145
+ }
146
+ }
147
+
148
+ &--theme-dark {
149
+ color: light.$on-fixed-surface-secondary-alternate;
150
+
151
+ &-disabled {
152
+ color: light.$on-fixed-surface-secondary-disabled;
153
+ }
154
+ }
155
+ }
156
+
157
+ &__label {
158
+ &--theme-light {
159
+ &-disabled {
160
+ color: light.$on-surface-primary-disabled;
161
+ }
162
+ }
163
+ &--theme-dark {
164
+ color: light.$on-fixed-surface-primary-default;
165
+ &-disabled {
166
+ color: light.$on-fixed-background-primary-disabled;
167
+ }
168
+ }
169
+ }
170
+ }
@@ -0,0 +1,116 @@
1
+ import * as React from 'react';
2
+ import FormContent from '../form-content';
3
+
4
+ import Text from '../text';
5
+
6
+ import { DropdownList as Props, themes } from './dropdown-list.types';
7
+ import ChevronUp from '../icons/24/arrow-up';
8
+ import ChevronDown from '../icons/24/arrow-down';
9
+ import useToggle from '../hooks/use-toggle';
10
+ import useClickOutside from '../hooks/use-click-outside';
11
+ import useEscape from '../hooks/use-escape';
12
+ import classNames from 'classnames';
13
+
14
+ const DropdownList: React.FC<React.PropsWithChildren<Props>> & {
15
+ themes: typeof themes;
16
+ } = ({
17
+ description,
18
+ disabled,
19
+ formContentOptions,
20
+ label,
21
+ selectedOptions,
22
+ header,
23
+ theme = themes.light,
24
+ }) => {
25
+ const modal = React.useRef(null);
26
+ const [isOpen, toggle, , close] = useToggle(false);
27
+
28
+ useClickOutside(modal, close);
29
+ useEscape(close);
30
+
31
+ return (
32
+ <div className="dropdown-list">
33
+ <Text
34
+ theme={Text.themes.emphasis}
35
+ className={classNames(
36
+ 'dropdown-list__label',
37
+ `dropdown-list__label--theme-${theme}`,
38
+ {
39
+ [`dropdown-list__label--theme-${theme}-disabled`]: disabled,
40
+ },
41
+ )}
42
+ >
43
+ {label}
44
+ </Text>
45
+ <div
46
+ className={classNames(
47
+ 'dropdown-list__wrapper',
48
+ `dropdown-list__wrapper--theme-${theme}`,
49
+ {
50
+ [`dropdown-list__wrapper--theme-${theme}-disabled`]: disabled,
51
+ [`dropdown-list__wrapper--theme-${theme}-clicked`]: isOpen,
52
+ },
53
+ )}
54
+ ref={modal}
55
+ >
56
+ <div className="dropdown-list__buttons">
57
+ <button
58
+ type="button"
59
+ className={classNames(
60
+ 'dropdown-list__button',
61
+ `dropdown-list__button--theme-${theme}`,
62
+ {
63
+ [`dropdown-list__button--theme-${theme}-disabled`]: disabled,
64
+ [`dropdown-list__button--theme-${theme}-clicked`]: isOpen,
65
+ },
66
+ )}
67
+ onClick={toggle}
68
+ disabled={disabled}
69
+ data-test-dropdown-button
70
+ >
71
+ <div className="dropdown-list__text-wrap">
72
+ <Text theme={Text.themes.normal} size={Text.sizes.basic}>
73
+ {header}
74
+ </Text>
75
+
76
+ <Text size={Text.sizes.small}>
77
+ {selectedOptions ? (
78
+ selectedOptions
79
+ ) : (
80
+ <Text
81
+ elementName="span"
82
+ size={Text.sizes.small}
83
+ className={classNames(
84
+ 'dropdown-list__information',
85
+ `dropdown-list__information--theme-${theme}`,
86
+ {
87
+ [`dropdown-list__information--theme-${theme}-disabled`]:
88
+ disabled,
89
+ },
90
+ )}
91
+ >
92
+ {description}
93
+ </Text>
94
+ )}
95
+ </Text>
96
+ </div>
97
+
98
+ <div className="dropdown-list__icon">
99
+ {isOpen ? <ChevronUp /> : <ChevronDown />}
100
+ </div>
101
+ </button>
102
+ </div>
103
+ <FormContent
104
+ {...formContentOptions}
105
+ isOpen={isOpen}
106
+ close={close}
107
+ onSubmit={toggle}
108
+ />
109
+ </div>
110
+ </div>
111
+ );
112
+ };
113
+
114
+ DropdownList.themes = themes;
115
+
116
+ export default DropdownList;
@@ -0,0 +1,17 @@
1
+ import type { FormContentDropdownList } from '../form-content/form-content.types';
2
+ import type { ObjectValues } from '../types';
3
+
4
+ export const themes = {
5
+ dark: 'dark',
6
+ light: 'light',
7
+ } as const;
8
+
9
+ export type DropdownList = {
10
+ label?: string;
11
+ header: string;
12
+ description: string;
13
+ formContentOptions: FormContentDropdownList;
14
+ selectedOptions?: string;
15
+ disabled?: boolean;
16
+ theme?: ObjectValues<typeof themes>;
17
+ };
@@ -0,0 +1,2 @@
1
+ import DropdownList from './dropdown-list';
2
+ export default DropdownList;