@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,115 @@
1
+ @use '../../tokens/light';
2
+ @use '../../tokens/spacing';
3
+
4
+ .expander {
5
+ @mixin break {
6
+ @media (min-width: 800px) {
7
+ @content;
8
+ }
9
+ }
10
+
11
+ display: grid;
12
+ gap: spacing.$m;
13
+ width: 100%;
14
+
15
+ &__header {
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: spacing.$s;
19
+ }
20
+
21
+ &__trigger {
22
+ align-items: center;
23
+ background: transparent;
24
+ border: 0;
25
+ border-bottom: 1px solid light.$ge-divider-default;
26
+ cursor: pointer;
27
+ display: flex;
28
+ gap: spacing.$xs;
29
+ justify-items: flex-end;
30
+ padding: spacing.$s spacing.$xs;
31
+ transition: background-color 0.2s ease-in-out;
32
+ width: 100%;
33
+
34
+ &--triggered {
35
+ background: light.$background-primary-default;
36
+ }
37
+
38
+ @include break {
39
+ gap: spacing.$s;
40
+ padding: spacing.$l spacing.$m;
41
+ }
42
+
43
+ @media (hover: hover) {
44
+ &:hover {
45
+ background: light.$surface-primary-hover;
46
+ }
47
+ }
48
+ }
49
+
50
+ &__trigger-title {
51
+ margin-right: auto;
52
+ text-align: left;
53
+ }
54
+
55
+ &__icon {
56
+ display: grid;
57
+ place-items: center;
58
+ transition: transform 0.4s;
59
+
60
+ &--flipped {
61
+ transform: rotate(-180deg);
62
+ }
63
+ }
64
+
65
+ &__drawer {
66
+ background: light.$surface-primary-default;
67
+ }
68
+
69
+ &__content {
70
+ border-bottom: 1px solid light.$ge-divider-default;
71
+ border-top: 1px solid light.$ge-divider-default;
72
+ display: grid;
73
+ gap: spacing.$m;
74
+ padding: 20px; // NOTE: Magic number 20px as designed
75
+
76
+ @media (min-resolution: 2dppx) {
77
+ border-bottom-width: 0.5px;
78
+ border-top-width: 0.5px;
79
+ }
80
+ }
81
+
82
+ &__actions {
83
+ display: flex;
84
+ flex-wrap: wrap;
85
+ gap: spacing.$s;
86
+ }
87
+
88
+ &__metadata {
89
+ display: grid;
90
+ gap: spacing.$xs;
91
+ }
92
+
93
+ &__meta-content {
94
+ display: flex;
95
+ justify-content: space-between;
96
+ }
97
+
98
+ &__meta-text {
99
+ color: light.$on-surface-primary-alternate;
100
+ }
101
+
102
+ &__divider {
103
+ background: light.$ge-divider-default;
104
+ border: 0;
105
+ height: 1px;
106
+ margin: 0;
107
+ width: 100%;
108
+ }
109
+
110
+ &__links {
111
+ display: flex;
112
+ flex-wrap: wrap;
113
+ gap: spacing.$s;
114
+ }
115
+ }
@@ -0,0 +1,167 @@
1
+ import cn from 'classnames';
2
+ import React, { useState } from 'react';
3
+ import Collapse from 'react-tiny-collapse';
4
+
5
+ import ArrowDown from '../icons/24/arrow-down';
6
+ import LinkButton from '../link-button';
7
+ import Text from '../text';
8
+
9
+ import type { Expander as Props } from './expander.types';
10
+ import Badge from '../badge';
11
+ import { Types } from '../badge/badge.types';
12
+ import Link from '../link';
13
+
14
+ const ExpanderListItem: React.FC<
15
+ React.PropsWithChildren<Props<unknown>['items'][number]['listItemProps']>
16
+ > = ({
17
+ actions,
18
+ defaultOpen = false,
19
+ faq,
20
+ icon,
21
+ id,
22
+ links,
23
+ children,
24
+ metadata,
25
+ title,
26
+ value,
27
+ }) => {
28
+ const [isOpen, setIsOpen] = useState(defaultOpen);
29
+
30
+ const toggle = () => setIsOpen(!isOpen);
31
+
32
+ return (
33
+ <div
34
+ className="expander__list-item"
35
+ key={id}
36
+ itemScope={faq ? faq : undefined}
37
+ itemProp={faq ? 'mainEntity' : undefined}
38
+ itemType={faq ? 'https://schema.org/Question' : undefined}
39
+ >
40
+ <button
41
+ aria-controls={id}
42
+ aria-expanded={isOpen}
43
+ className={cn('expander__trigger', {
44
+ 'expander__trigger--triggered': isOpen,
45
+ 'expander__trigger--w-value': value,
46
+ })}
47
+ onClick={toggle}
48
+ >
49
+ {icon ? <div className="expander__icon">{icon}</div> : null}
50
+ <div className="expander__trigger-title">
51
+ <Text elementName="h3" itemProp={faq ? 'name' : undefined} tight>
52
+ {title}
53
+ </Text>
54
+ </div>
55
+ {value ? (
56
+ <Badge
57
+ content={{ content: value, type: Types.Numerical }}
58
+ variant={Badge.variants.secondary}
59
+ />
60
+ ) : null}
61
+ <div
62
+ className={cn('expander__icon', {
63
+ 'expander__icon--flipped': isOpen,
64
+ })}
65
+ >
66
+ <ArrowDown />
67
+ </div>
68
+ </button>
69
+ <div
70
+ className={cn('expander__drawer', {
71
+ 'expander__drawer--open': isOpen,
72
+ })}
73
+ id={id}
74
+ >
75
+ <Collapse isOpen={isOpen}>
76
+ <div
77
+ className="expander__content"
78
+ itemScope={faq ? faq : undefined}
79
+ itemProp={faq ? 'acceptedAnswer' : undefined}
80
+ itemType={faq ? 'https://schema.org/Answer' : undefined}
81
+ >
82
+ <div
83
+ className="expander__children"
84
+ itemProp={faq ? 'text' : undefined}
85
+ >
86
+ {children}
87
+ </div>
88
+ {actions.length ? (
89
+ <div className="expander__actions">
90
+ {actions.map(action => (
91
+ <div className="expander__action" key={action.href}>
92
+ <LinkButton {...action} />
93
+ </div>
94
+ ))}
95
+ </div>
96
+ ) : null}
97
+ {metadata || (links && links.length) ? (
98
+ <div className="expander__metadata">
99
+ <hr className="expander__divider" />
100
+ <div className="expander__meta-content">
101
+ {metadata ? (
102
+ <div className="expander__meta-text">
103
+ <Text elementName="span" size={Text.sizes.small}>
104
+ {metadata}
105
+ </Text>
106
+ </div>
107
+ ) : null}
108
+ {links && links.length ? (
109
+ <div className="expander__links">
110
+ {links.map(link => (
111
+ <div className="expander__link" key={link.href}>
112
+ <Link {...link} size={Link.sizes.small} />
113
+ </div>
114
+ ))}
115
+ </div>
116
+ ) : null}
117
+ </div>
118
+ </div>
119
+ ) : null}
120
+ </div>
121
+ </Collapse>
122
+ </div>
123
+ </div>
124
+ );
125
+ };
126
+
127
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
128
+ const Expander = <T extends {}>({
129
+ description,
130
+ faq,
131
+ itemRenderer,
132
+ items,
133
+ title,
134
+ }: Props<T> & { itemRenderer: React.FC<T> }) => (
135
+ <div className="expander">
136
+ {title || description ? (
137
+ <div className="expander__header">
138
+ {title ? (
139
+ <Text
140
+ elementName="h2"
141
+ size={Text.sizes.headline2}
142
+ theme={Text.themes.emphasis}
143
+ tight
144
+ >
145
+ {title}
146
+ </Text>
147
+ ) : null}
148
+ {description ? (
149
+ <Text size={Text.sizes.basic}>{description}</Text>
150
+ ) : null}
151
+ </div>
152
+ ) : null}
153
+ <div>
154
+ {items.map(item => (
155
+ <ExpanderListItem
156
+ key={item.listItemProps.id}
157
+ {...item.listItemProps}
158
+ faq={faq}
159
+ >
160
+ {React.createElement(itemRenderer, item.props)}
161
+ </ExpanderListItem>
162
+ ))}
163
+ </div>
164
+ </div>
165
+ );
166
+
167
+ export default Expander;
@@ -0,0 +1,26 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import type { Link } from '../link/link.types';
4
+ import type { LinkButton } from '../link-button/link-button.types';
5
+
6
+ type ExpanderListItem = {
7
+ actions: LinkButton[];
8
+ defaultOpen?: boolean;
9
+ faq?: boolean;
10
+ icon?: ReactNode;
11
+ id: string;
12
+ links?: Pick<Link, 'href' | 'testId' | 'text'>[];
13
+ metadata?: string;
14
+ title: string;
15
+ value?: number;
16
+ };
17
+
18
+ export type Expander<T> = {
19
+ description?: string;
20
+ faq?: boolean;
21
+ items: {
22
+ listItemProps: ExpanderListItem;
23
+ props: T;
24
+ }[];
25
+ title?: string;
26
+ };
@@ -0,0 +1,2 @@
1
+ import Expander from './expander';
2
+ export default Expander;
@@ -0,0 +1,94 @@
1
+ @use '../../tokens/corner-radius';
2
+ @use '../../tokens/light.scss';
3
+ @use '../../tokens/spacing';
4
+
5
+ .filter {
6
+ $breakpoint: 900px;
7
+ $breakpointSmall: 500px;
8
+
9
+ border-radius: corner-radius.$s;
10
+ background-color: light.$surface-primary-default;
11
+ border: 1px solid light.$ge-divider-default;
12
+ min-width: 180px;
13
+ display: flex;
14
+ flex-direction: column;
15
+ justify-content: center;
16
+
17
+ @media (max-width: $breakpointSmall) {
18
+ border-radius: corner-radius.$none;
19
+ border-left: 0;
20
+ border-right: 0;
21
+ border-bottom: 0;
22
+ width: 100%;
23
+
24
+ &:last-of-type {
25
+ border-bottom: 1px solid light.$ge-divider-default;
26
+ }
27
+ }
28
+
29
+ @media (hover: hover) {
30
+ &:hover {
31
+ background-color: light.$surface-primary-hover;
32
+ border-color: light.$ge-divider-alternate;
33
+ }
34
+ }
35
+
36
+ &--clicked {
37
+ background-color: light.$surface-primary-hover;
38
+ border-color: light.$ge-divider-alternate;
39
+ }
40
+
41
+ @media (min-width: $breakpoint) {
42
+ position: relative;
43
+ flex-shrink: 0;
44
+ }
45
+
46
+ &__buttons {
47
+ position: relative;
48
+ }
49
+
50
+ &__button,
51
+ &__loading-button {
52
+ cursor: pointer;
53
+ display: flex;
54
+ justify-content: space-between;
55
+ align-items: center;
56
+ background-color: transparent;
57
+ border: none;
58
+ width: 100%;
59
+ height: 100%;
60
+ box-shadow: none;
61
+ font: inherit;
62
+ overflow: hidden;
63
+ padding: spacing.$s;
64
+ color: inherit;
65
+ gap: spacing.$s;
66
+ }
67
+
68
+ &__loading-icon {
69
+ color: light.$on-surface-primary-disabled;
70
+ }
71
+
72
+ &__button-text {
73
+ word-break: break-all;
74
+ text-align: left;
75
+ }
76
+
77
+ &__button-inner-right {
78
+ display: flex;
79
+ align-items: center;
80
+ gap: spacing.$xs;
81
+ }
82
+
83
+ &__selected-options {
84
+ box-sizing: border-box;
85
+ border-radius: corner-radius.$l;
86
+ color: light.$on-ge-on-badge-secondary;
87
+ background: light.$ge-badge-secondary;
88
+ display: flex;
89
+ justify-content: center;
90
+ align-items: center;
91
+ padding: 3px spacing.$xs; // NOTE: The spacings on this padding are slightly custom due to their tiny size.
92
+ min-width: 29px; // NOTE: Magic width that makes the background round in correlation with the padding when the selected options are less than 10
93
+ }
94
+ }
@@ -0,0 +1,99 @@
1
+ import * as React from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ import useToggle from '../hooks/use-toggle';
5
+ import useClickOutside from '../hooks/use-click-outside';
6
+ import useEscape from '../hooks/use-escape';
7
+ import { useIsMounted } from '../hooks/use-is-mounted';
8
+ import FormContent from '../form-content';
9
+ import ChevronUp from '../icons/24/arrow-up';
10
+ import ChevronDown from '../icons/24/arrow-down';
11
+ import Text from '../text';
12
+
13
+ import { Filter as Props } from './filter.types';
14
+
15
+ const Filter: React.FunctionComponent<Props> = ({
16
+ formContentOptions,
17
+ selectedOptionsCount,
18
+ testTags,
19
+ title,
20
+ }) => {
21
+ const isMounted = useIsMounted();
22
+ const modal = React.useRef(null);
23
+ const [isOpen, toggle, , close] = useToggle(false);
24
+
25
+ useClickOutside(modal, close);
26
+ useEscape(close);
27
+
28
+ return (
29
+ <div
30
+ className={classNames('filter', {
31
+ 'filter--clicked': isOpen,
32
+ })}
33
+ ref={modal}
34
+ {...testTags}
35
+ >
36
+ {isMounted ? (
37
+ <div className="filter__buttons">
38
+ <button
39
+ type="button"
40
+ className="filter__button"
41
+ onClick={toggle}
42
+ data-test-dropdown-button
43
+ >
44
+ <Text
45
+ size={Text.sizes.basic}
46
+ theme={Text.themes.emphasis}
47
+ className="filter__button-text"
48
+ >
49
+ {title}
50
+ </Text>
51
+
52
+ <div className="filter__button-inner-right">
53
+ {selectedOptionsCount ? (
54
+ <Text
55
+ className="filter__selected-options"
56
+ theme={Text.themes.emphasis}
57
+ size={Text.sizes.small}
58
+ >
59
+ {selectedOptionsCount}
60
+ </Text>
61
+ ) : null}
62
+
63
+ {isOpen ? <ChevronUp /> : <ChevronDown />}
64
+ </div>
65
+ </button>
66
+ </div>
67
+ ) : (
68
+ <div className="filter__loading-button">
69
+ <div className="filter__loading-placeholder">
70
+ <svg
71
+ xmlns="http://www.w3.org/2000/svg"
72
+ width="112"
73
+ height="22"
74
+ viewBox="0 0 112 22"
75
+ fill="none"
76
+ >
77
+ <path
78
+ d="M0 4.5C0 2.29086 1.79086 0.5 4 0.5H108C110.209 0.5 112 2.29086 112 4.5V17.5C112 19.7091 110.209 21.5 108 21.5H4C1.79086 21.5 0 19.7091 0 17.5V4.5Z"
79
+ fill="#DCDEE0"
80
+ />
81
+ </svg>
82
+ </div>
83
+ <div className="filter__loading-icon">
84
+ <ChevronDown />
85
+ </div>
86
+ </div>
87
+ )}
88
+
89
+ <FormContent
90
+ {...formContentOptions}
91
+ isOpen={isOpen}
92
+ close={close}
93
+ onSubmit={toggle}
94
+ />
95
+ </div>
96
+ );
97
+ };
98
+
99
+ export default Filter;
@@ -0,0 +1,8 @@
1
+ import type { FormContentFilter } from '../form-content/form-content.types';
2
+
3
+ export type Filter = {
4
+ title: string;
5
+ formContentOptions: FormContentFilter;
6
+ selectedOptionsCount?: number;
7
+ testTags?: { [key: string]: boolean };
8
+ };
@@ -0,0 +1,2 @@
1
+ import Filter from './filter';
2
+ export default Filter;
@@ -0,0 +1,46 @@
1
+ @use '../../tokens/spacing';
2
+
3
+ .filter-wrapper {
4
+ $breakpointLarge: 1100px;
5
+ $breakpointMedium: 850px;
6
+ $breakpointSmall: 500px;
7
+ width: 100%;
8
+
9
+ display: grid;
10
+ gap: spacing.$s;
11
+ width: 100%;
12
+
13
+ &--wide {
14
+ @media (min-width: $breakpointLarge) {
15
+ grid-template-columns: repeat(
16
+ auto-fit,
17
+ [col-start] minmax(180px, 1fr) [col-end]
18
+ );
19
+ }
20
+ }
21
+
22
+ &--medium {
23
+ &--single {
24
+ > * + * {
25
+ max-width: 430px;
26
+ width: 100%;
27
+ }
28
+ }
29
+ @media (min-width: $breakpointMedium) {
30
+ grid-template-columns: repeat(
31
+ auto-fit,
32
+ [col-start] minmax(180px, 1fr) [col-end]
33
+ );
34
+ }
35
+ }
36
+
37
+ @media (max-width: $breakpointSmall) {
38
+ gap: 0;
39
+ }
40
+
41
+ &--single {
42
+ > * {
43
+ width: 430px;
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,24 @@
1
+ import classNames from 'classnames';
2
+ import React from 'react';
3
+ import Filter from '../filter/filter';
4
+
5
+ import {
6
+ FilterWrapper as Props,
7
+ BreakAtElements,
8
+ } from './filter-wrapper.types';
9
+
10
+ const FilterWrapper: React.FunctionComponent<Props> = ({ filters }) => (
11
+ <div
12
+ className={classNames('filter-wrapper', {
13
+ [`filter-wrapper--medium`]: filters.length <= BreakAtElements.medium,
14
+ [`filter-wrapper--wide`]: filters.length >= BreakAtElements.wide,
15
+ [`filter-wrapper--single`]: filters.length === 1,
16
+ })}
17
+ >
18
+ {filters.map((filter, i) => (
19
+ <Filter {...filter} key={i} />
20
+ ))}
21
+ </div>
22
+ );
23
+
24
+ export default FilterWrapper;
@@ -0,0 +1,10 @@
1
+ import { Filter } from '../filter/filter.types';
2
+
3
+ export enum BreakAtElements {
4
+ 'wide' = 3,
5
+ 'medium' = 4,
6
+ }
7
+
8
+ export type FilterWrapper = {
9
+ filters: Filter[];
10
+ };
@@ -0,0 +1,2 @@
1
+ import FilterWrapper from './filter-wrapper';
2
+ export default FilterWrapper;
@@ -0,0 +1,26 @@
1
+ @use '../../tokens/light';
2
+ @use '../../tokens/spacing';
3
+
4
+ .flag {
5
+ border-top-left-radius: 8px;
6
+ clip-path: polygon(0 0, 100% 0, calc(100% - #{spacing.$s}) 100%, 0 100%);
7
+ color: light.$on-ge-on-tags-featured-default;
8
+ padding: spacing.$xxs (spacing.$s * 2) spacing.$xxs spacing.$s;
9
+ text-transform: uppercase;
10
+
11
+ &--theme-inline-block {
12
+ display: inline-block;
13
+ }
14
+
15
+ &--theme-block {
16
+ display: block;
17
+ }
18
+
19
+ &--variant-featured {
20
+ background: light.$ge-tags-featured;
21
+ }
22
+
23
+ &--variant-primary {
24
+ background: light.$ge-tags-primary;
25
+ }
26
+ }
@@ -0,0 +1,27 @@
1
+ import cn from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import Text from '../text';
5
+
6
+ import { Flag as Props, themes, variants } from './flag.types';
7
+
8
+ const Flag: React.FunctionComponent<Props> & {
9
+ themes: typeof themes;
10
+ variants: typeof variants;
11
+ } = ({ text, theme = themes['inline-block'], variant = variants.featured }) => (
12
+ <div
13
+ className={cn('flag', {
14
+ [`flag--theme-${theme}`]: theme,
15
+ [`flag--variant-${variant}`]: variant,
16
+ })}
17
+ >
18
+ <Text size={Text.sizes.interface} theme={Text.themes.emphasis}>
19
+ {text}
20
+ </Text>
21
+ </div>
22
+ );
23
+
24
+ Flag.themes = themes;
25
+ Flag.variants = variants;
26
+
27
+ export default Flag;
@@ -0,0 +1,17 @@
1
+ import { ObjectValues } from '../types';
2
+
3
+ export const themes = {
4
+ block: 'block',
5
+ 'inline-block': 'inline-block',
6
+ } as const;
7
+
8
+ export const variants = {
9
+ featured: 'featured',
10
+ primary: 'primary',
11
+ } as const;
12
+
13
+ export type Flag = {
14
+ text: string;
15
+ theme?: ObjectValues<typeof themes>;
16
+ variant?: ObjectValues<typeof variants>;
17
+ };
@@ -0,0 +1,2 @@
1
+ import Flag from './flag';
2
+ export default Flag;