gooee 0.0.0-stage → 0.41.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 (247) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -2
  3. package/package.json +36 -4
  4. package/scripts/add.js +533 -0
  5. package/scripts/pro-components.json +82 -0
  6. package/src/base.css +39 -0
  7. package/src/components/Accordion/Accordion.module.css +90 -0
  8. package/src/components/Accordion/Accordion.tsx +125 -0
  9. package/src/components/Accordion/index.ts +1 -0
  10. package/src/components/Alert/Alert.module.css +121 -0
  11. package/src/components/Alert/Alert.tsx +90 -0
  12. package/src/components/Alert/index.ts +1 -0
  13. package/src/components/AlertDialog/AlertDialog.module.css +2 -0
  14. package/src/components/AlertDialog/AlertDialog.tsx +108 -0
  15. package/src/components/AlertDialog/index.ts +1 -0
  16. package/src/components/AnimatedNumber/AnimatedNumber.module.css +48 -0
  17. package/src/components/AnimatedNumber/AnimatedNumber.tsx +52 -0
  18. package/src/components/AnimatedNumber/index.ts +1 -0
  19. package/src/components/AspectRatio/AspectRatio.module.css +15 -0
  20. package/src/components/AspectRatio/AspectRatio.tsx +12 -0
  21. package/src/components/AspectRatio/index.ts +1 -0
  22. package/src/components/Avatar/Avatar.module.css +62 -0
  23. package/src/components/Avatar/Avatar.tsx +55 -0
  24. package/src/components/Avatar/index.ts +3 -0
  25. package/src/components/AvatarGroup/AvatarGroup.module.css +53 -0
  26. package/src/components/AvatarGroup/AvatarGroup.tsx +43 -0
  27. package/src/components/AvatarGroup/index.ts +1 -0
  28. package/src/components/Badge/Badge.module.css +69 -0
  29. package/src/components/Badge/Badge.tsx +25 -0
  30. package/src/components/Badge/index.ts +1 -0
  31. package/src/components/Breadcrumb/Breadcrumb.module.css +104 -0
  32. package/src/components/Breadcrumb/Breadcrumb.tsx +76 -0
  33. package/src/components/Breadcrumb/index.ts +1 -0
  34. package/src/components/Button/Button.module.css +191 -0
  35. package/src/components/Button/Button.tsx +148 -0
  36. package/src/components/Button/index.ts +1 -0
  37. package/src/components/ButtonGroup/ButtonGroup.module.css +59 -0
  38. package/src/components/ButtonGroup/ButtonGroup.tsx +45 -0
  39. package/src/components/ButtonGroup/index.ts +1 -0
  40. package/src/components/Card/Card.module.css +82 -0
  41. package/src/components/Card/Card.tsx +34 -0
  42. package/src/components/Card/index.ts +1 -0
  43. package/src/components/Center/Center.module.css +15 -0
  44. package/src/components/Center/Center.tsx +28 -0
  45. package/src/components/Center/index.ts +1 -0
  46. package/src/components/Checkbox/Checkbox.module.css +120 -0
  47. package/src/components/Checkbox/Checkbox.tsx +133 -0
  48. package/src/components/Checkbox/index.ts +1 -0
  49. package/src/components/CheckboxGroup/CheckboxGroup.module.css +30 -0
  50. package/src/components/CheckboxGroup/CheckboxGroup.tsx +88 -0
  51. package/src/components/CheckboxGroup/index.ts +1 -0
  52. package/src/components/Cluster/Cluster.module.css +25 -0
  53. package/src/components/Cluster/Cluster.tsx +26 -0
  54. package/src/components/Cluster/index.ts +1 -0
  55. package/src/components/CodeBlock/CodeBlock.module.css +74 -0
  56. package/src/components/CodeBlock/CodeBlock.tsx +53 -0
  57. package/src/components/CodeBlock/highlight.ts +73 -0
  58. package/src/components/CodeBlock/index.ts +1 -0
  59. package/src/components/Collapsible/Collapsible.module.css +75 -0
  60. package/src/components/Collapsible/Collapsible.tsx +71 -0
  61. package/src/components/Collapsible/index.ts +1 -0
  62. package/src/components/Container/Container.module.css +14 -0
  63. package/src/components/Container/Container.tsx +19 -0
  64. package/src/components/Container/index.ts +1 -0
  65. package/src/components/CopyButton/CopyButton.module.css +125 -0
  66. package/src/components/CopyButton/CopyButton.tsx +160 -0
  67. package/src/components/CopyButton/index.ts +1 -0
  68. package/src/components/Dial/Dial.module.css +344 -0
  69. package/src/components/Dial/Dial.tsx +332 -0
  70. package/src/components/Dial/index.ts +1 -0
  71. package/src/components/Dialog/Dialog.module.css +190 -0
  72. package/src/components/Dialog/Dialog.tsx +100 -0
  73. package/src/components/Dialog/index.ts +1 -0
  74. package/src/components/Divider/Divider.module.css +39 -0
  75. package/src/components/Divider/Divider.tsx +34 -0
  76. package/src/components/Divider/index.ts +1 -0
  77. package/src/components/DropdownMenu/DropdownMenu.module.css +134 -0
  78. package/src/components/DropdownMenu/DropdownMenu.tsx +215 -0
  79. package/src/components/DropdownMenu/index.ts +1 -0
  80. package/src/components/EmptyState/EmptyState.module.css +66 -0
  81. package/src/components/EmptyState/EmptyState.tsx +38 -0
  82. package/src/components/EmptyState/index.ts +1 -0
  83. package/src/components/Fab/Fab.module.css +176 -0
  84. package/src/components/Fab/Fab.tsx +117 -0
  85. package/src/components/Fab/index.ts +1 -0
  86. package/src/components/Fieldset/Fieldset.module.css +34 -0
  87. package/src/components/Fieldset/Fieldset.tsx +41 -0
  88. package/src/components/Fieldset/index.ts +1 -0
  89. package/src/components/FormField/FormField.module.css +62 -0
  90. package/src/components/FormField/FormField.tsx +91 -0
  91. package/src/components/FormField/index.ts +2 -0
  92. package/src/components/Grid/Grid.module.css +39 -0
  93. package/src/components/Grid/Grid.tsx +35 -0
  94. package/src/components/Grid/index.ts +1 -0
  95. package/src/components/HoldToConfirm/HoldToConfirm.module.css +175 -0
  96. package/src/components/HoldToConfirm/HoldToConfirm.tsx +334 -0
  97. package/src/components/HoldToConfirm/index.ts +1 -0
  98. package/src/components/IconButton/IconButton.module.css +78 -0
  99. package/src/components/IconButton/IconButton.tsx +35 -0
  100. package/src/components/IconButton/index.ts +1 -0
  101. package/src/components/Input/Input.module.css +157 -0
  102. package/src/components/Input/Input.tsx +133 -0
  103. package/src/components/Input/index.ts +1 -0
  104. package/src/components/InputGroup/InputGroup.module.css +146 -0
  105. package/src/components/InputGroup/InputGroup.tsx +90 -0
  106. package/src/components/InputGroup/index.ts +1 -0
  107. package/src/components/Kbd/Kbd.module.css +28 -0
  108. package/src/components/Kbd/Kbd.tsx +38 -0
  109. package/src/components/Kbd/index.ts +1 -0
  110. package/src/components/Link/Link.module.css +65 -0
  111. package/src/components/Link/Link.tsx +41 -0
  112. package/src/components/Link/index.ts +1 -0
  113. package/src/components/LivePill/LivePill.module.css +207 -0
  114. package/src/components/LivePill/LivePill.tsx +182 -0
  115. package/src/components/LivePill/index.ts +1 -0
  116. package/src/components/Meter/Meter.module.css +91 -0
  117. package/src/components/Meter/Meter.tsx +109 -0
  118. package/src/components/Meter/index.ts +1 -0
  119. package/src/components/MorphButton/MorphButton.module.css +152 -0
  120. package/src/components/MorphButton/MorphButton.tsx +203 -0
  121. package/src/components/MorphButton/index.ts +1 -0
  122. package/src/components/NumberInput/NumberInput.module.css +104 -0
  123. package/src/components/NumberInput/NumberInput.tsx +252 -0
  124. package/src/components/NumberInput/index.ts +2 -0
  125. package/src/components/Pagination/Pagination.module.css +88 -0
  126. package/src/components/Pagination/Pagination.tsx +126 -0
  127. package/src/components/Pagination/index.ts +1 -0
  128. package/src/components/PasswordInput/PasswordInput.module.css +64 -0
  129. package/src/components/PasswordInput/PasswordInput.tsx +63 -0
  130. package/src/components/PasswordInput/index.ts +2 -0
  131. package/src/components/PickerWheel/PickerWheel.module.css +123 -0
  132. package/src/components/PickerWheel/PickerWheel.tsx +326 -0
  133. package/src/components/PickerWheel/index.ts +1 -0
  134. package/src/components/Popover/Popover.module.css +78 -0
  135. package/src/components/Popover/Popover.tsx +117 -0
  136. package/src/components/Popover/index.ts +1 -0
  137. package/src/components/ProgressBar/ProgressBar.module.css +61 -0
  138. package/src/components/ProgressBar/ProgressBar.tsx +48 -0
  139. package/src/components/ProgressBar/index.ts +1 -0
  140. package/src/components/Prose/Prose.module.css +115 -0
  141. package/src/components/Prose/Prose.tsx +14 -0
  142. package/src/components/Prose/index.ts +1 -0
  143. package/src/components/Radio/Radio.module.css +106 -0
  144. package/src/components/Radio/Radio.tsx +115 -0
  145. package/src/components/Radio/index.ts +1 -0
  146. package/src/components/Retime/Retime.tsx +116 -0
  147. package/src/components/Retime/index.ts +1 -0
  148. package/src/components/RulerScrubber/RulerScrubber.module.css +146 -0
  149. package/src/components/RulerScrubber/RulerScrubber.tsx +209 -0
  150. package/src/components/RulerScrubber/index.ts +1 -0
  151. package/src/components/ScrollArea/ScrollArea.module.css +72 -0
  152. package/src/components/ScrollArea/ScrollArea.tsx +172 -0
  153. package/src/components/ScrollArea/index.ts +1 -0
  154. package/src/components/SearchInput/SearchInput.module.css +53 -0
  155. package/src/components/SearchInput/SearchInput.tsx +104 -0
  156. package/src/components/SearchInput/index.ts +2 -0
  157. package/src/components/SegmentedControl/SegmentedControl.module.css +150 -0
  158. package/src/components/SegmentedControl/SegmentedControl.tsx +169 -0
  159. package/src/components/SegmentedControl/index.ts +1 -0
  160. package/src/components/Select/Select.module.css +204 -0
  161. package/src/components/Select/Select.tsx +254 -0
  162. package/src/components/Select/index.ts +1 -0
  163. package/src/components/Sheet/Sheet.module.css +228 -0
  164. package/src/components/Sheet/Sheet.tsx +449 -0
  165. package/src/components/Sheet/index.ts +1 -0
  166. package/src/components/Skeleton/Skeleton.module.css +56 -0
  167. package/src/components/Skeleton/Skeleton.tsx +37 -0
  168. package/src/components/Skeleton/index.ts +1 -0
  169. package/src/components/Slider/Slider.module.css +155 -0
  170. package/src/components/Slider/Slider.tsx +200 -0
  171. package/src/components/Slider/index.ts +1 -0
  172. package/src/components/Spinner/Spinner.module.css +50 -0
  173. package/src/components/Spinner/Spinner.tsx +29 -0
  174. package/src/components/Spinner/index.ts +1 -0
  175. package/src/components/Split/Split.module.css +29 -0
  176. package/src/components/Split/Split.tsx +33 -0
  177. package/src/components/Split/index.ts +1 -0
  178. package/src/components/SplitFlap/SplitFlap.module.css +107 -0
  179. package/src/components/SplitFlap/SplitFlap.tsx +225 -0
  180. package/src/components/SplitFlap/index.ts +1 -0
  181. package/src/components/Stack/Stack.module.css +17 -0
  182. package/src/components/Stack/Stack.tsx +19 -0
  183. package/src/components/Stack/index.ts +1 -0
  184. package/src/components/SwipeDeck/SwipeDeck.module.css +250 -0
  185. package/src/components/SwipeDeck/SwipeDeck.tsx +350 -0
  186. package/src/components/SwipeDeck/index.ts +1 -0
  187. package/src/components/Switch/Switch.module.css +97 -0
  188. package/src/components/Switch/Switch.tsx +147 -0
  189. package/src/components/Switch/index.ts +1 -0
  190. package/src/components/Table/Table.module.css +369 -0
  191. package/src/components/Table/Table.tsx +368 -0
  192. package/src/components/Table/index.ts +1 -0
  193. package/src/components/TableOfContents/TableOfContents.module.css +107 -0
  194. package/src/components/TableOfContents/TableOfContents.tsx +93 -0
  195. package/src/components/TableOfContents/index.ts +1 -0
  196. package/src/components/Tabs/Tabs.module.css +101 -0
  197. package/src/components/Tabs/Tabs.tsx +190 -0
  198. package/src/components/Tabs/index.ts +1 -0
  199. package/src/components/Tag/Tag.module.css +120 -0
  200. package/src/components/Tag/Tag.tsx +109 -0
  201. package/src/components/Tag/index.ts +1 -0
  202. package/src/components/Textarea/Textarea.module.css +79 -0
  203. package/src/components/Textarea/Textarea.tsx +130 -0
  204. package/src/components/Textarea/index.ts +1 -0
  205. package/src/components/ThemeToggle/ThemeToggle.module.css +21 -0
  206. package/src/components/ThemeToggle/ThemeToggle.tsx +69 -0
  207. package/src/components/ThemeToggle/index.ts +1 -0
  208. package/src/components/Toast/Toast.module.css +202 -0
  209. package/src/components/Toast/Toast.tsx +473 -0
  210. package/src/components/Toast/index.ts +1 -0
  211. package/src/components/Toggle/Toggle.module.css +94 -0
  212. package/src/components/Toggle/Toggle.tsx +50 -0
  213. package/src/components/Toggle/index.ts +1 -0
  214. package/src/components/Tooltip/Tooltip.module.css +34 -0
  215. package/src/components/Tooltip/Tooltip.tsx +154 -0
  216. package/src/components/Tooltip/index.ts +1 -0
  217. package/src/components/VisuallyHidden/VisuallyHidden.module.css +13 -0
  218. package/src/components/VisuallyHidden/VisuallyHidden.tsx +12 -0
  219. package/src/components/VisuallyHidden/index.ts +1 -0
  220. package/src/internal/FieldMessage.module.css +49 -0
  221. package/src/internal/FieldMessage.tsx +44 -0
  222. package/src/internal/Portal.tsx +7 -0
  223. package/src/internal/Roll.module.css +31 -0
  224. package/src/internal/Roll.tsx +20 -0
  225. package/src/internal/cx.ts +3 -0
  226. package/src/internal/feel.ts +355 -0
  227. package/src/internal/fling.ts +118 -0
  228. package/src/internal/focus.ts +94 -0
  229. package/src/internal/icons.module.css +62 -0
  230. package/src/internal/icons.tsx +511 -0
  231. package/src/internal/keyboard.ts +62 -0
  232. package/src/internal/layers.ts +85 -0
  233. package/src/internal/liquid.ts +248 -0
  234. package/src/internal/liquidMatter.ts +168 -0
  235. package/src/internal/liquidMore.ts +686 -0
  236. package/src/internal/liquidPath.ts +519 -0
  237. package/src/internal/mergeRefs.ts +10 -0
  238. package/src/internal/motion.ts +37 -0
  239. package/src/internal/relativeTime.ts +26 -0
  240. package/src/internal/scrollFrame.ts +157 -0
  241. package/src/internal/softPress.ts +299 -0
  242. package/src/internal/space.ts +6 -0
  243. package/src/internal/useControllable.ts +21 -0
  244. package/src/internal/useFloating.ts +85 -0
  245. package/src/internal/usePresence.ts +15 -0
  246. package/src/internal/useScrub.ts +160 -0
  247. package/src/tokens.css +727 -0
@@ -0,0 +1,62 @@
1
+ .root {
2
+ --size: var(--gooee-avatar-md);
3
+ position: relative;
4
+ display: inline-grid;
5
+ place-items: center;
6
+ flex: none;
7
+ width: var(--size);
8
+ height: var(--size);
9
+ border-radius: var(--gooee-radius-full);
10
+ background: var(--gooee-color-surface-active);
11
+ color: var(--gooee-color-fg);
12
+ font-size: calc(var(--size) * 0.38);
13
+ font-weight: var(--gooee-weight-medium);
14
+ letter-spacing: var(--gooee-tracking-tight);
15
+ user-select: none;
16
+ }
17
+
18
+ .sm { --size: var(--gooee-avatar-sm); }
19
+ .lg { --size: var(--gooee-avatar-lg); }
20
+ .xl { --size: var(--gooee-avatar-xl); }
21
+
22
+ .fallback,
23
+ .img {
24
+ grid-area: 1 / 1;
25
+ }
26
+
27
+ .img {
28
+ width: 100%;
29
+ height: 100%;
30
+ border-radius: inherit;
31
+ object-fit: cover;
32
+ opacity: 0;
33
+ filter: blur(var(--gooee-blur-sm));
34
+ transform: scale(1.05);
35
+ transition:
36
+ opacity var(--gooee-motion-slow) var(--gooee-ease-out),
37
+ filter var(--gooee-motion-slow) var(--gooee-ease-out),
38
+ transform var(--gooee-motion-slow) var(--gooee-ease-out);
39
+ }
40
+
41
+ .img[data-loaded] {
42
+ opacity: 1;
43
+ filter: none;
44
+ transform: none;
45
+ }
46
+
47
+ .status {
48
+ position: absolute;
49
+ right: 0;
50
+ bottom: 0;
51
+ width: 28%;
52
+ height: 28%;
53
+ min-width: var(--gooee-space-3);
54
+ min-height: var(--gooee-space-3);
55
+ border: var(--gooee-line-focus) solid var(--gooee-color-bg);
56
+ border-radius: var(--gooee-radius-full);
57
+ background: var(--gooee-color-fg);
58
+ }
59
+
60
+ /* Without colour, status reads by fill: solid, half, hollow. */
61
+ .status[data-status="away"] { background: linear-gradient(90deg, var(--gooee-color-fg) 50%, var(--gooee-color-bg) 50%); box-shadow: inset 0 0 0 var(--gooee-line-thick) var(--gooee-color-fg); }
62
+ .status[data-status="offline"] { background: var(--gooee-color-bg); box-shadow: inset 0 0 0 var(--gooee-line-thick) var(--gooee-color-fg-muted); }
@@ -0,0 +1,55 @@
1
+ 'use client'
2
+
3
+ import { useState } from 'react'
4
+ import { cx } from '../../internal/cx'
5
+ import styles from './Avatar.module.css'
6
+
7
+ export type AvatarProps = {
8
+ /** Used for the alt text and the initials fallback. */
9
+ name: string
10
+ /** Image URL. Initials show while it loads and if it fails. */
11
+ src?: string
12
+ /** Diameter of the avatar. */
13
+ size?: 'sm' | 'md' | 'lg' | 'xl'
14
+ /** Shows a status dot and adds the status to the spoken name. */
15
+ status?: 'online' | 'away' | 'offline'
16
+ /** Extra class for the root element. */
17
+ className?: string
18
+ }
19
+
20
+ const initials = (name: string) =>
21
+ name
22
+ .trim()
23
+ .split(/\s+/)
24
+ .slice(0, 2)
25
+ .map((p) => p[0]?.toUpperCase() ?? '')
26
+ .join('')
27
+
28
+ export function Avatar({ name, src, size = 'md', status, className }: AvatarProps) {
29
+ const [state, setState] = useState<'loading' | 'loaded' | 'error'>(src ? 'loading' : 'error')
30
+ const [lastSrc, setLastSrc] = useState(src)
31
+ if (src !== lastSrc) {
32
+ setLastSrc(src)
33
+ setState(src ? 'loading' : 'error')
34
+ }
35
+ return (
36
+ <span className={cx(styles.root, styles[size], className)} role="img" aria-label={status ? `${name}, ${status}` : name}>
37
+ <span className={styles.fallback} aria-hidden="true">{initials(name)}</span>
38
+ {src && state !== 'error' && (
39
+ <img
40
+ className={styles.img}
41
+ src={src}
42
+ alt=""
43
+ data-loaded={state === 'loaded' || undefined}
44
+ // A server-rendered image can finish before React hydrates, so its load event is gone by then.
45
+ ref={(img) => {
46
+ if (img?.complete && state === 'loading') setState(img.naturalWidth ? 'loaded' : 'error')
47
+ }}
48
+ onLoad={() => setState('loaded')}
49
+ onError={() => setState('error')}
50
+ />
51
+ )}
52
+ {status && <span className={styles.status} data-status={status} aria-hidden="true" />}
53
+ </span>
54
+ )
55
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Avatar'
2
+ // AvatarGroup has its own folder now; this keeps old imports from Avatar working.
3
+ export { AvatarGroup, type AvatarGroupProps } from '../AvatarGroup'
@@ -0,0 +1,53 @@
1
+ .root {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ padding-left: var(--gooee-space-3);
5
+ }
6
+
7
+ /* The slot takes the hover and never moves; only the face inside lifts. A lifted slot would slide out
8
+ from under the pointer and drop back, and at an overlap two neighbours would take turns. */
9
+ .slot {
10
+ display: inline-flex;
11
+ margin-left: calc(var(--gooee-space-3) * -1);
12
+ border-radius: var(--gooee-radius-full);
13
+ animation: slotIn var(--gooee-motion-slow) var(--gooee-ease-spring) backwards;
14
+ animation-delay: calc(var(--i) * var(--gooee-motion-stagger) * 2);
15
+ transition: margin var(--gooee-motion-slow) var(--gooee-ease-spring);
16
+ }
17
+
18
+ .face {
19
+ display: inline-flex;
20
+ border-radius: var(--gooee-radius-full);
21
+ box-shadow: 0 0 0 var(--gooee-line-focus) var(--gooee-color-bg);
22
+ transition: transform var(--gooee-motion-base) var(--gooee-ease-spring);
23
+ }
24
+
25
+ @media (hover: hover) {
26
+ .root:hover .slot { margin-left: calc(var(--gooee-space-1) * -1); }
27
+ .slot:hover .face { transform: translateY(calc(var(--gooee-shift-sm) * -1)); }
28
+ }
29
+
30
+ .more {
31
+ --size: var(--gooee-avatar-md);
32
+ display: inline-grid;
33
+ place-items: center;
34
+ width: var(--size);
35
+ height: var(--size);
36
+ border-radius: var(--gooee-radius-full);
37
+ background: var(--gooee-color-surface);
38
+ box-shadow: inset 0 0 0 var(--gooee-line) var(--gooee-color-border-strong), 0 0 0 var(--gooee-line-focus) var(--gooee-color-bg);
39
+ color: var(--gooee-color-fg);
40
+ font-size: calc(var(--size) * 0.32);
41
+ font-weight: var(--gooee-weight-medium);
42
+ font-variant-numeric: tabular-nums;
43
+ letter-spacing: var(--gooee-tracking-tight);
44
+ user-select: none;
45
+ }
46
+
47
+ .sm { --size: var(--gooee-avatar-sm); }
48
+ .lg { --size: var(--gooee-avatar-lg); }
49
+ .xl { --size: var(--gooee-avatar-xl); }
50
+
51
+ @keyframes slotIn {
52
+ from { opacity: 0; transform: translateX(calc(var(--gooee-shift-md) * -1)) scale(0.8); }
53
+ }
@@ -0,0 +1,43 @@
1
+ import { Children, isValidElement, type ReactElement, type ReactNode } from 'react'
2
+ import { cx } from '../../internal/cx'
3
+ import type { AvatarProps } from '../Avatar'
4
+ import styles from './AvatarGroup.module.css'
5
+
6
+ export type AvatarGroupProps = {
7
+ /** The Avatar elements to stack, in order. */
8
+ children: ReactNode
9
+ /** Avatars shown before the "+N" counter. */
10
+ max?: number
11
+ /** Size of the "+N" counter. Set it to match the avatars inside. */
12
+ size?: AvatarProps['size']
13
+ /** What the people are, such as "Project members". Screen readers hear it with every name. */
14
+ label?: string
15
+ /** Extra class for the root element. */
16
+ className?: string
17
+ }
18
+
19
+ const list = (names: string[]) => (names.length < 2 ? names.join('') : `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`)
20
+
21
+ export function AvatarGroup({ children, max = 4, size = 'md', label, className }: AvatarGroupProps) {
22
+ const all = Children.toArray(children).filter(isValidElement) as ReactElement<AvatarProps>[]
23
+ const shown = all.slice(0, max)
24
+ const extra = all.length - shown.length
25
+ // The names of the hidden people too, so a screen reader hears everyone the "+N" stands for.
26
+ const everyone = list(all.map((a) => a.props.name))
27
+ return (
28
+ <div className={cx(styles.root, className)} role="group" aria-label={label ? `${label}: ${everyone}` : everyone}>
29
+ {shown.map((child, i) => (
30
+ <span key={child.key ?? i} className={styles.slot} style={{ ['--i' as string]: i }}>
31
+ <span className={styles.face}>{child}</span>
32
+ </span>
33
+ ))}
34
+ {extra > 0 && (
35
+ <span className={styles.slot} style={{ ['--i' as string]: shown.length }}>
36
+ <span className={cx(styles.face, styles.more, styles[size])} role="img" aria-label={`${extra} more`} title={list(all.slice(max).map((a) => a.props.name))}>
37
+ <span aria-hidden="true">+{extra}</span>
38
+ </span>
39
+ </span>
40
+ )}
41
+ </div>
42
+ )
43
+ }
@@ -0,0 +1 @@
1
+ export * from './AvatarGroup'
@@ -0,0 +1,69 @@
1
+ .root {
2
+ display: inline-flex;
3
+ width: fit-content;
4
+ align-items: center;
5
+ gap: var(--gooee-space-2);
6
+ max-width: 100%;
7
+ height: var(--gooee-badge-h);
8
+ padding: 0 var(--gooee-space-3);
9
+ border: var(--gooee-line) solid transparent;
10
+ border-radius: var(--gooee-radius-full);
11
+ font-size: var(--gooee-text-xs);
12
+ font-weight: var(--gooee-weight-medium);
13
+ line-height: 1;
14
+ white-space: nowrap;
15
+ font-variant-numeric: tabular-nums;
16
+ }
17
+
18
+ .solid { background: var(--gooee-color-inverse); color: var(--gooee-color-inverse-fg); }
19
+ .outline { border-color: var(--gooee-color-border-strong); color: var(--gooee-color-fg); }
20
+ .subtle { background: var(--gooee-color-surface-active); color: var(--gooee-color-fg); }
21
+
22
+ .root[data-tone="success"] { --tone: var(--gooee-color-success); --tone-soft: var(--gooee-color-success-soft); --tone-fill: var(--gooee-color-success); --tone-on: var(--gooee-color-inverse-fg); }
23
+ .root[data-tone="warning"] { --tone: var(--gooee-color-warning); --tone-soft: var(--gooee-color-warning-soft); --tone-fill: var(--gooee-color-warning); --tone-on: var(--gooee-color-inverse-fg); }
24
+ /* Danger fills with the solid red, because the dark theme's text red is too light for white text. */
25
+ .root[data-tone="danger"] { --tone: var(--gooee-color-danger); --tone-soft: var(--gooee-color-danger-soft); --tone-fill: var(--gooee-color-danger-solid); --tone-on: var(--gooee-color-on-danger); }
26
+
27
+ .solid[data-tone] { background: var(--tone-fill); color: var(--tone-on); }
28
+ .outline[data-tone] { border-color: var(--tone); color: var(--tone); }
29
+ .subtle[data-tone] { background: var(--tone-soft); color: var(--tone); }
30
+
31
+ /* Clip only the x axis: line-height is 1, so hiding y would cut descenders. */
32
+ .text {
33
+ display: inline-block;
34
+ min-width: 0;
35
+ overflow-x: clip;
36
+ text-overflow: ellipsis;
37
+ animation: pop var(--gooee-motion-slow) var(--gooee-ease-spring);
38
+ }
39
+
40
+ .dot {
41
+ position: relative;
42
+ flex: none;
43
+ width: var(--gooee-dot);
44
+ height: var(--gooee-dot);
45
+ border-radius: var(--gooee-radius-full);
46
+ background: currentColor;
47
+ }
48
+
49
+ .dot[data-pulse]::after {
50
+ content: "";
51
+ position: absolute;
52
+ inset: 0;
53
+ border-radius: inherit;
54
+ background: currentColor;
55
+ animation: pulse calc(var(--gooee-motion-slower) * 3) var(--gooee-ease-out) infinite;
56
+ }
57
+
58
+ @keyframes pop {
59
+ from { opacity: 0; transform: translateY(var(--gooee-shift-sm)) scale(0.8); }
60
+ }
61
+
62
+ @keyframes pulse {
63
+ 0% { transform: scale(1); opacity: 0.6; }
64
+ 70%, 100% { transform: scale(3); opacity: 0; }
65
+ }
66
+
67
+ @media (prefers-reduced-motion: reduce) {
68
+ .dot[data-pulse]::after { animation: none; }
69
+ }
@@ -0,0 +1,25 @@
1
+ import type { ComponentPropsWithRef } from 'react'
2
+ import { cx } from '../../internal/cx'
3
+ import styles from './Badge.module.css'
4
+
5
+ export type BadgeProps = ComponentPropsWithRef<'span'> & {
6
+ /** Visual weight: filled, outlined or a soft tint. */
7
+ variant?: 'solid' | 'outline' | 'subtle'
8
+ /** Status colour. Use it only for a real status, and keep a word in the badge. */
9
+ tone?: 'neutral' | 'success' | 'warning' | 'danger'
10
+ /** A small dot before the text. "pulse" makes it breathe, for live states. */
11
+ dot?: boolean | 'pulse'
12
+ }
13
+
14
+ export function Badge({ variant = 'subtle', tone = 'neutral', dot, className, children, ...rest }: BadgeProps) {
15
+ const plain = typeof children === 'string' || typeof children === 'number'
16
+ return (
17
+ <span className={cx(styles.root, styles[variant], className)} data-tone={tone === 'neutral' ? undefined : tone} {...rest}>
18
+ {dot && <span className={styles.dot} data-pulse={dot === 'pulse' || undefined} aria-hidden="true" />}
19
+ {/* Keyed on content, so a new value pops in instead of swapping silently. */}
20
+ <span key={plain ? String(children) : undefined} className={styles.text} title={plain && !rest.title ? String(children) : undefined}>
21
+ {children}
22
+ </span>
23
+ </span>
24
+ )
25
+ }
@@ -0,0 +1 @@
1
+ export * from './Badge'
@@ -0,0 +1,104 @@
1
+ .root { min-width: 0; }
2
+
3
+ .list {
4
+ display: flex;
5
+ flex-wrap: wrap;
6
+ align-items: center;
7
+ margin: 0;
8
+ padding: 0;
9
+ list-style: none;
10
+ font-size: var(--gooee-text-sm);
11
+ }
12
+
13
+ .item {
14
+ display: inline-flex;
15
+ align-items: center;
16
+ min-width: 0;
17
+ }
18
+
19
+ .item[data-revealed] {
20
+ animation: reveal var(--gooee-motion-slow) var(--gooee-ease-out) backwards;
21
+ animation-delay: calc(var(--i) * var(--gooee-motion-stagger));
22
+ }
23
+
24
+ .link,
25
+ .more {
26
+ position: relative;
27
+ display: inline-flex;
28
+ align-items: center;
29
+ min-height: var(--gooee-hit-min);
30
+ padding: 0 var(--gooee-space-2);
31
+ border-radius: var(--gooee-radius-sm);
32
+ color: var(--gooee-color-fg-muted);
33
+ text-decoration: none;
34
+ transition: color var(--gooee-motion-fast) var(--gooee-ease-out);
35
+ }
36
+
37
+ .link::after {
38
+ content: "";
39
+ position: absolute;
40
+ left: var(--gooee-space-2);
41
+ right: var(--gooee-space-2);
42
+ bottom: calc((var(--gooee-hit-min) - 1em) / 2 - var(--gooee-space-2));
43
+ height: var(--gooee-line);
44
+ background: currentColor;
45
+ transform: scaleX(0);
46
+ transform-origin: left;
47
+ transition: transform var(--gooee-motion-base) var(--gooee-ease-out);
48
+ }
49
+
50
+ @media (hover: hover) {
51
+ .link:hover { color: var(--gooee-color-fg); }
52
+ .link:hover::after { transform: scaleX(1); }
53
+ }
54
+
55
+ .link:focus-visible,
56
+ .more:focus-visible {
57
+ outline: none;
58
+ box-shadow: var(--gooee-focus-ring);
59
+ }
60
+
61
+ .button {
62
+ border: 0;
63
+ background: transparent;
64
+ font: inherit;
65
+ cursor: pointer;
66
+ }
67
+
68
+ .more {
69
+ justify-content: center;
70
+ border: 0;
71
+ background: transparent;
72
+ font-size: inherit;
73
+ cursor: pointer;
74
+ letter-spacing: var(--gooee-tracking-wide);
75
+ }
76
+
77
+ /* The dots alone are too narrow to tap. */
78
+ @media (pointer: coarse) {
79
+ .more { min-width: var(--gooee-hit-min); }
80
+ }
81
+
82
+ @media (hover: hover) {
83
+ .more:hover { color: var(--gooee-color-fg); background: var(--gooee-color-surface-hover); }
84
+ }
85
+
86
+ .current {
87
+ padding: 0 var(--gooee-space-2);
88
+ font-weight: var(--gooee-weight-medium);
89
+ color: var(--gooee-color-fg);
90
+ overflow: hidden;
91
+ text-overflow: ellipsis;
92
+ white-space: nowrap;
93
+ }
94
+
95
+ .sep {
96
+ flex: none;
97
+ width: var(--gooee-icon-sm);
98
+ height: var(--gooee-icon-sm);
99
+ color: var(--gooee-color-fg-subtle);
100
+ }
101
+
102
+ @keyframes reveal {
103
+ from { opacity: 0; transform: translateX(calc(var(--gooee-shift-sm) * -1)); }
104
+ }
@@ -0,0 +1,76 @@
1
+ 'use client'
2
+
3
+ import { Fragment, useLayoutEffect, useRef, useState, type MouseEvent } from 'react'
4
+ import { cx } from '../../internal/cx'
5
+ import { ChevronRightIcon } from '../../internal/icons'
6
+ import styles from './Breadcrumb.module.css'
7
+
8
+ export type BreadcrumbItem = {
9
+ /** Text of the item. */
10
+ label: string
11
+ /** Where the link goes. Without it, the item is a button. */
12
+ href?: string
13
+ /** Called on click with the event, so a link can call preventDefault for client routing. */
14
+ onClick?: (event: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void
15
+ }
16
+
17
+ export type BreadcrumbProps = {
18
+ /** Path from the top level down. The last item is the current page. */
19
+ items: BreadcrumbItem[]
20
+ /** Above this many items, the middle collapses into a "…" button. With 2 or less, only "…" and the current page show. */
21
+ maxItems?: number
22
+ /** Name of the nav landmark. */
23
+ label?: string
24
+ /** Screen reader name for the "…" button. */
25
+ expandLabel?: string
26
+ /** Extra class for the nav element. */
27
+ className?: string
28
+ }
29
+
30
+ export function Breadcrumb({ items, maxItems = 4, label = 'Breadcrumb', expandLabel = 'Show full path', className }: BreadcrumbProps) {
31
+ const [expanded, setExpanded] = useState(false)
32
+ const listRef = useRef<HTMLOListElement>(null)
33
+ const collapse = !expanded && items.length > maxItems
34
+ // Under 3 there is no room for the first item, so only "…" and the current page stay.
35
+ const head = maxItems < 3 ? 0 : 1
36
+ const tail = Math.max(1, maxItems - head - 1)
37
+ const visible = collapse ? [...items.slice(0, head), null, ...items.slice(-tail)] : items
38
+
39
+ // The "…" button is gone after expanding, so focus moves to the first link it revealed.
40
+ useLayoutEffect(() => {
41
+ if (!expanded) return
42
+ listRef.current?.querySelector<HTMLElement>(`:scope > li:nth-child(${head + 1}) > :is(a, button)`)?.focus()
43
+ }, [expanded, head])
44
+
45
+ return (
46
+ <nav aria-label={label} className={cx(styles.root, className)}>
47
+ <ol ref={listRef} className={styles.list}>
48
+ {visible.map((item, i) => {
49
+ const last = i === visible.length - 1
50
+ return (
51
+ <Fragment key={item ? `${item.label}-${i}` : 'more'}>
52
+ <li className={styles.item} style={{ ['--i' as string]: i }} data-revealed={expanded || undefined}>
53
+ {item === null ? (
54
+ <button type="button" className={styles.more} aria-label={expandLabel} onClick={() => setExpanded(true)}>
55
+ …
56
+ </button>
57
+ ) : last ? (
58
+ <span className={styles.current} aria-current="page" title={item.label}>{item.label}</span>
59
+ ) : item.href === undefined ? (
60
+ <button type="button" className={cx(styles.link, styles.button)} title={item.label} onClick={item.onClick}>
61
+ {item.label}
62
+ </button>
63
+ ) : (
64
+ <a className={styles.link} href={item.href} title={item.label} onClick={item.onClick}>
65
+ {item.label}
66
+ </a>
67
+ )}
68
+ {!last && <ChevronRightIcon className={styles.sep} />}
69
+ </li>
70
+ </Fragment>
71
+ )
72
+ })}
73
+ </ol>
74
+ </nav>
75
+ )
76
+ }
@@ -0,0 +1 @@
1
+ export * from './Breadcrumb'