@noxlovette/material 0.3.3 → 0.4.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 (288) hide show
  1. package/README.md +1 -0
  2. package/dist/actions/index.d.ts +1 -0
  3. package/dist/actions/index.js +1 -0
  4. package/dist/actions/rovingFocusGroup.d.ts +20 -0
  5. package/dist/actions/rovingFocusGroup.js +82 -0
  6. package/dist/components/badge/theme.d.ts +8 -8
  7. package/dist/components/buttons/button-group/ButtonGroup.stories.svelte +83 -0
  8. package/dist/components/buttons/button-group/ButtonGroup.stories.svelte.d.ts +19 -0
  9. package/dist/components/buttons/button-group/ButtonGroup.svelte +10 -29
  10. package/dist/components/buttons/button-group/ButtonGroup.svelte.d.ts +7 -3
  11. package/dist/components/buttons/button-group/index.d.ts +0 -1
  12. package/dist/components/buttons/button-group/index.js +3 -1
  13. package/dist/components/buttons/button-group/theme.d.ts +17 -103
  14. package/dist/components/buttons/button-group/theme.js +7 -35
  15. package/dist/components/buttons/button-group/types.d.ts +9 -20
  16. package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte +118 -0
  17. package/dist/components/buttons/connected/ConnectedButtonGroup.stories.svelte.d.ts +19 -0
  18. package/dist/components/buttons/connected/ConnectedButtonGroup.svelte +52 -0
  19. package/dist/components/buttons/connected/ConnectedButtonGroup.svelte.d.ts +12 -0
  20. package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte +37 -0
  21. package/dist/components/buttons/connected/ConnectedButtonGroupItem.svelte.d.ts +9 -0
  22. package/dist/components/buttons/connected/index.d.ts +3 -1
  23. package/dist/components/buttons/connected/index.js +3 -1
  24. package/dist/components/buttons/connected/theme.d.ts +125 -0
  25. package/dist/components/buttons/connected/theme.js +38 -0
  26. package/dist/components/buttons/connected/types.d.ts +32 -13
  27. package/dist/components/buttons/index.d.ts +1 -0
  28. package/dist/components/buttons/index.js +1 -0
  29. package/dist/components/buttons/split-button/SplitButton.stories.svelte +103 -0
  30. package/dist/components/buttons/split-button/SplitButton.stories.svelte.d.ts +19 -0
  31. package/dist/components/buttons/split-button/SplitButton.svelte +104 -0
  32. package/dist/components/buttons/split-button/SplitButton.svelte.d.ts +19 -0
  33. package/dist/components/buttons/split-button/index.d.ts +3 -0
  34. package/dist/components/{containers/panes → buttons/split-button}/index.js +1 -3
  35. package/dist/components/buttons/split-button/theme.d.ts +35 -0
  36. package/dist/components/buttons/split-button/theme.js +26 -0
  37. package/dist/components/buttons/split-button/types.d.ts +33 -0
  38. package/dist/components/buttons/theme.d.ts +142 -142
  39. package/dist/components/buttons/theme.js +2 -2
  40. package/dist/components/cards/Card.stories.svelte +58 -0
  41. package/dist/components/cards/Card.stories.svelte.d.ts +2 -17
  42. package/dist/components/cards/Card.svelte +76 -8
  43. package/dist/components/cards/theme.d.ts +26 -14
  44. package/dist/components/cards/theme.js +5 -1
  45. package/dist/components/cards/types.d.ts +39 -1
  46. package/dist/components/chips/Chip.stories.svelte +64 -0
  47. package/dist/components/chips/Chip.stories.svelte.d.ts +19 -0
  48. package/dist/components/chips/Chip.svelte +115 -0
  49. package/dist/components/chips/Chip.svelte.d.ts +14 -0
  50. package/dist/components/chips/index.d.ts +3 -0
  51. package/dist/components/{containers/merger → chips}/index.js +2 -1
  52. package/dist/components/chips/theme.d.ts +78 -0
  53. package/dist/components/chips/theme.js +72 -0
  54. package/dist/components/chips/types.d.ts +43 -0
  55. package/dist/components/containers/action-rail/ActionRail.stories.svelte +36 -0
  56. package/dist/components/containers/{panes/SinglePane.stories.svelte.d.ts → action-rail/ActionRail.stories.svelte.d.ts} +4 -4
  57. package/dist/components/containers/action-rail/ActionRail.svelte +35 -0
  58. package/dist/components/containers/action-rail/ActionRail.svelte.d.ts +17 -0
  59. package/dist/components/containers/action-rail/index.d.ts +3 -0
  60. package/dist/components/containers/action-rail/index.js +6 -0
  61. package/dist/components/containers/action-rail/theme.d.ts +45 -0
  62. package/dist/components/containers/action-rail/theme.js +26 -0
  63. package/dist/components/containers/action-rail/types.d.ts +20 -0
  64. package/dist/components/containers/action-rail/types.js +1 -0
  65. package/dist/components/containers/app/App.svelte +6 -6
  66. package/dist/components/containers/app/App.svelte.d.ts +4 -2
  67. package/dist/components/containers/app/theme.d.ts +1 -1
  68. package/dist/components/containers/app/types.d.ts +9 -4
  69. package/dist/components/containers/bottom-sheet/BottomSheet.stories.svelte +1 -1
  70. package/dist/components/containers/bottom-sheet/BottomSheet.svelte +1 -1
  71. package/dist/components/containers/context-menu/ContextMenu.stories.svelte +44 -0
  72. package/dist/components/containers/context-menu/ContextMenu.svelte +21 -5
  73. package/dist/components/containers/context-menu/ContextMenu.svelte.d.ts +11 -0
  74. package/dist/components/containers/context-menu/theme.d.ts +20 -2
  75. package/dist/components/containers/context-menu/theme.js +31 -8
  76. package/dist/components/containers/context-menu/types.d.ts +14 -2
  77. package/dist/components/containers/dialogue/theme.d.ts +20 -20
  78. package/dist/components/containers/divider/theme.d.ts +17 -17
  79. package/dist/components/containers/index.d.ts +2 -3
  80. package/dist/components/containers/index.js +2 -3
  81. package/dist/components/containers/link-preview/theme.d.ts +11 -11
  82. package/dist/components/containers/list/theme.d.ts +14 -14
  83. package/dist/components/containers/list/theme.js +1 -1
  84. package/dist/components/containers/menu/Menu.stories.svelte +105 -3
  85. package/dist/components/containers/menu/Menu.stories.svelte.d.ts +2 -17
  86. package/dist/components/containers/menu/Menu.svelte +9 -7
  87. package/dist/components/containers/menu/MenuCheckboxItem.svelte +55 -0
  88. package/dist/components/containers/menu/MenuCheckboxItem.svelte.d.ts +25 -0
  89. package/dist/components/containers/menu/MenuGroup.svelte +43 -0
  90. package/dist/components/containers/menu/MenuGroup.svelte.d.ts +28 -0
  91. package/dist/components/containers/menu/MenuRadioGroup.svelte +39 -0
  92. package/dist/components/containers/menu/MenuRadioGroup.svelte.d.ts +27 -0
  93. package/dist/components/containers/menu/MenuRadioItem.svelte +49 -0
  94. package/dist/components/containers/menu/MenuRadioItem.svelte.d.ts +17 -0
  95. package/dist/components/containers/menu/MenuSub.svelte +91 -0
  96. package/dist/components/containers/menu/MenuSub.svelte.d.ts +29 -0
  97. package/dist/components/containers/menu/index.d.ts +7 -0
  98. package/dist/components/containers/menu/index.js +8 -0
  99. package/dist/components/containers/menu/menu-item/MenuItem.svelte +71 -0
  100. package/dist/components/containers/{menu-item → menu/menu-item}/MenuItem.svelte.d.ts +2 -1
  101. package/dist/components/containers/{menu-item → menu/menu-item}/types.d.ts +5 -1
  102. package/dist/components/containers/menu/menu-item/types.js +1 -0
  103. package/dist/components/containers/menu/theme.d.ts +68 -0
  104. package/dist/components/containers/menu/theme.js +36 -0
  105. package/dist/components/containers/menu/types.d.ts +113 -2
  106. package/dist/components/containers/pane/DraggablePane.stories.svelte +199 -0
  107. package/dist/components/containers/pane/DraggablePane.stories.svelte.d.ts +4 -0
  108. package/dist/components/containers/pane/DraggablePane.svelte +533 -0
  109. package/dist/components/containers/pane/DraggablePane.svelte.d.ts +29 -0
  110. package/dist/components/containers/pane/Pane.stories.svelte +104 -0
  111. package/dist/components/containers/pane/Pane.stories.svelte.d.ts +19 -0
  112. package/dist/components/containers/pane/Pane.svelte +78 -0
  113. package/dist/components/containers/pane/Pane.svelte.d.ts +18 -0
  114. package/dist/components/containers/pane/PaneGrid.stories.svelte +134 -0
  115. package/dist/components/containers/pane/PaneGrid.stories.svelte.d.ts +19 -0
  116. package/dist/components/containers/pane/PaneGrid.svelte +43 -0
  117. package/dist/components/containers/pane/PaneGrid.svelte.d.ts +13 -0
  118. package/dist/components/containers/pane/PaneHandle.svelte +90 -0
  119. package/dist/components/containers/pane/PaneHandle.svelte.d.ts +12 -0
  120. package/dist/components/containers/pane/dragStore.svelte.d.ts +16 -0
  121. package/dist/components/containers/pane/dragStore.svelte.js +38 -0
  122. package/dist/components/containers/pane/index.d.ts +8 -0
  123. package/dist/components/containers/pane/index.js +11 -0
  124. package/dist/components/containers/pane/resizeStore.svelte.d.ts +10 -0
  125. package/dist/components/containers/pane/resizeStore.svelte.js +30 -0
  126. package/dist/components/containers/pane/theme.d.ts +571 -0
  127. package/dist/components/containers/pane/theme.js +211 -0
  128. package/dist/components/containers/pane/types.d.ts +249 -0
  129. package/dist/components/containers/pane/types.js +1 -0
  130. package/dist/components/containers/popover/Popover.stories.svelte +4 -4
  131. package/dist/components/containers/popover/Popover.svelte +3 -1
  132. package/dist/components/containers/popover/theme.d.ts +20 -20
  133. package/dist/components/containers/popover/types.d.ts +6 -2
  134. package/dist/components/containers/scroll-area/theme.d.ts +2 -2
  135. package/dist/components/containers/side-sheet/SideSheet.stories.svelte +16 -24
  136. package/dist/components/containers/side-sheet/SideSheet.svelte +73 -7
  137. package/dist/components/containers/side-sheet/SideSheet.svelte.d.ts +5 -0
  138. package/dist/components/containers/stack/theme.d.ts +44 -44
  139. package/dist/components/date/DateField.stories.svelte +57 -0
  140. package/dist/components/{containers/panes/SplitPane.stories.svelte.d.ts → date/DateField.stories.svelte.d.ts} +4 -4
  141. package/dist/components/date/DateField.svelte +11 -2
  142. package/dist/components/date/DateRangeField.stories.svelte +53 -0
  143. package/dist/components/{containers/panes/SupportingPane.stories.svelte.d.ts → date/DateRangeField.stories.svelte.d.ts} +4 -4
  144. package/dist/components/date/DateRangeField.svelte +2 -1
  145. package/dist/components/date/theme.d.ts +73 -4
  146. package/dist/components/date/theme.js +95 -26
  147. package/dist/components/date/types.d.ts +5 -0
  148. package/dist/components/forms/checkbox/Checkbox.svelte +7 -9
  149. package/dist/components/forms/checkbox/theme.d.ts +8 -8
  150. package/dist/components/forms/checkbox/theme.js +31 -9
  151. package/dist/components/forms/command/theme.d.ts +35 -35
  152. package/dist/components/forms/pin/theme.d.ts +2 -2
  153. package/dist/components/forms/radio-group/theme.d.ts +2 -2
  154. package/dist/components/forms/search/theme.d.ts +8 -8
  155. package/dist/components/forms/select/Select.svelte +3 -2
  156. package/dist/components/forms/select/theme.d.ts +26 -2
  157. package/dist/components/forms/select/theme.js +56 -22
  158. package/dist/components/forms/slider/theme.d.ts +20 -20
  159. package/dist/components/forms/switch/theme.d.ts +2 -2
  160. package/dist/components/forms/textfield/Textfield.stories.svelte +22 -0
  161. package/dist/components/forms/textfield/Textfield.svelte +10 -1
  162. package/dist/components/forms/textfield/theme.d.ts +44 -2
  163. package/dist/components/forms/textfield/theme.js +56 -16
  164. package/dist/components/forms/toggle-group/ToggleGroup.svelte +2 -2
  165. package/dist/components/forms/toggle-group/ToggleGroup.svelte.d.ts +2 -2
  166. package/dist/components/forms/toggle-group/ToggleGroupItem.svelte +1 -1
  167. package/dist/components/forms/toggle-group/ToggleGroupItem.svelte.d.ts +1 -1
  168. package/dist/components/forms/toggle-group/theme.d.ts +16 -16
  169. package/dist/components/forms/toggle-group/types.d.ts +2 -2
  170. package/dist/components/forms/tooltip/Tooltip.svelte +1 -1
  171. package/dist/components/forms/tooltip/theme.d.ts +2 -2
  172. package/dist/components/index.d.ts +1 -0
  173. package/dist/components/index.js +1 -0
  174. package/dist/components/misc/Avatar.stories.svelte +8 -0
  175. package/dist/components/misc/Avatar.svelte +35 -10
  176. package/dist/components/misc/DicebearAvatarBuilder.d.ts +59 -0
  177. package/dist/components/misc/DicebearAvatarBuilder.js +115 -0
  178. package/dist/components/misc/ThemeSettings.svelte +1 -1
  179. package/dist/components/misc/ThemeSwitcher.svelte +2 -2
  180. package/dist/components/misc/dicebearStyles.d.ts +21 -0
  181. package/dist/components/misc/dicebearStyles.js +169 -0
  182. package/dist/components/misc/index.d.ts +3 -0
  183. package/dist/components/misc/index.js +3 -0
  184. package/dist/components/misc/materialAvatarPalette.d.ts +6 -0
  185. package/dist/components/misc/materialAvatarPalette.js +44 -0
  186. package/dist/components/misc/theme.d.ts +20 -2
  187. package/dist/components/misc/theme.js +7 -1
  188. package/dist/components/misc/types.d.ts +20 -2
  189. package/dist/components/nav/appbar/AppBar.stories.svelte +1 -1
  190. package/dist/components/nav/appbar/AppBar.svelte +46 -15
  191. package/dist/components/nav/appbar/AppBar.svelte.d.ts +5 -0
  192. package/dist/components/nav/appbar/theme.d.ts +20 -14
  193. package/dist/components/nav/appbar/theme.js +11 -7
  194. package/dist/components/nav/appbar/types.d.ts +3 -1
  195. package/dist/components/nav/breadcrumb/Breadcrumb.stories.svelte +50 -0
  196. package/dist/components/nav/breadcrumb/Breadcrumb.stories.svelte.d.ts +19 -0
  197. package/dist/components/nav/breadcrumb/Breadcrumb.svelte +46 -0
  198. package/dist/components/nav/breadcrumb/Breadcrumb.svelte.d.ts +13 -0
  199. package/dist/components/nav/breadcrumb/index.d.ts +3 -0
  200. package/dist/components/nav/breadcrumb/index.js +6 -0
  201. package/dist/components/nav/breadcrumb/theme.d.ts +84 -0
  202. package/dist/components/nav/breadcrumb/theme.js +35 -0
  203. package/dist/components/nav/breadcrumb/types.d.ts +14 -0
  204. package/dist/components/nav/breadcrumb/types.js +1 -0
  205. package/dist/components/nav/index.d.ts +1 -0
  206. package/dist/components/nav/index.js +1 -0
  207. package/dist/components/nav/navbar/theme.d.ts +19 -19
  208. package/dist/components/nav/rail/Rail.stories.svelte +1 -5
  209. package/dist/components/nav/rail/Rail.svelte +3 -25
  210. package/dist/components/nav/rail/theme.d.ts +4 -4
  211. package/dist/components/nav/rail/types.d.ts +0 -5
  212. package/dist/components/nav/tabs/TabHolder.svelte +2 -1
  213. package/dist/components/nav/tabs/theme.d.ts +21 -21
  214. package/dist/components/nav/tabs/theme.js +6 -0
  215. package/dist/components/nav/tabs/types.d.ts +2 -2
  216. package/dist/components/pill/theme.d.ts +35 -35
  217. package/dist/components/snackbar/theme.d.ts +8 -8
  218. package/dist/components/table/Table.stories.svelte +267 -0
  219. package/dist/components/table/Table.stories.svelte.d.ts +19 -0
  220. package/dist/components/table/Table.svelte +1 -1
  221. package/dist/components/table/TableBody.svelte +16 -3
  222. package/dist/components/table/TableBody.svelte.d.ts +5 -1
  223. package/dist/components/table/TableRow.svelte +1 -1
  224. package/dist/components/table/theme.d.ts +2 -2
  225. package/dist/components/table/theme.js +2 -2
  226. package/dist/components/table/types.d.ts +7 -0
  227. package/dist/components/time/theme.d.ts +29 -29
  228. package/dist/components/toolbar/Toolbar.stories.svelte +71 -0
  229. package/dist/components/toolbar/Toolbar.stories.svelte.d.ts +19 -0
  230. package/dist/components/toolbar/Toolbar.svelte +19 -3
  231. package/dist/components/toolbar/Toolbar.svelte.d.ts +8 -2
  232. package/dist/components/toolbar/ToolbarButton.svelte +28 -4
  233. package/dist/components/toolbar/ToolbarDivider.svelte +4 -3
  234. package/dist/components/toolbar/ToolbarGroup.svelte +7 -2
  235. package/dist/components/toolbar/ToolbarGroupItem.svelte +29 -4
  236. package/dist/components/toolbar/ToolbarSection.svelte +35 -0
  237. package/dist/components/toolbar/ToolbarSection.svelte.d.ts +9 -0
  238. package/dist/components/toolbar/ToolbarSpacer.svelte +18 -0
  239. package/dist/components/toolbar/ToolbarSpacer.svelte.d.ts +9 -0
  240. package/dist/components/toolbar/index.d.ts +2 -0
  241. package/dist/components/toolbar/index.js +2 -0
  242. package/dist/components/toolbar/theme.d.ts +36 -21
  243. package/dist/components/toolbar/theme.js +27 -11
  244. package/dist/components/toolbar/types.d.ts +37 -4
  245. package/dist/components/typography/body/theme.d.ts +14 -14
  246. package/dist/components/typography/display/theme.d.ts +14 -14
  247. package/dist/components/typography/headline/theme.d.ts +14 -14
  248. package/dist/components/typography/kbd/Kbd.stories.svelte +1 -1
  249. package/dist/components/typography/kbd/theme.d.ts +8 -8
  250. package/dist/components/typography/label/theme.d.ts +14 -14
  251. package/dist/components/typography/title/theme.d.ts +14 -14
  252. package/dist/styles/component.css +126 -4
  253. package/dist/styles/motion.css +6 -3
  254. package/dist/utils/Layer.svelte +7 -3
  255. package/dist/utils/Theme.svelte +20 -20
  256. package/dist/utils/ThemeScript.svelte +1 -1
  257. package/dist/utils/icon/theme.d.ts +14 -14
  258. package/package.json +38 -37
  259. package/bin/install-skill.js +0 -29
  260. package/dist/components/buttons/button-group/ButtonGroupItem.svelte +0 -41
  261. package/dist/components/buttons/button-group/ButtonGroupItem.svelte.d.ts +0 -8
  262. package/dist/components/buttons/connected/ConnectedButtons.svelte +0 -14
  263. package/dist/components/buttons/connected/ConnectedButtons.svelte.d.ts +0 -8
  264. package/dist/components/containers/menu-item/MenuItem.svelte +0 -74
  265. package/dist/components/containers/merger/InputMerger.svelte +0 -24
  266. package/dist/components/containers/merger/InputMerger.svelte.d.ts +0 -14
  267. package/dist/components/containers/merger/index.d.ts +0 -2
  268. package/dist/components/containers/merger/theme.d.ts +0 -1
  269. package/dist/components/containers/merger/theme.js +0 -4
  270. package/dist/components/containers/panes/SinglePane.stories.svelte +0 -67
  271. package/dist/components/containers/panes/SinglePane.svelte +0 -32
  272. package/dist/components/containers/panes/SinglePane.svelte.d.ts +0 -5
  273. package/dist/components/containers/panes/SplitPane.stories.svelte +0 -124
  274. package/dist/components/containers/panes/SplitPane.svelte +0 -144
  275. package/dist/components/containers/panes/SplitPane.svelte.d.ts +0 -8
  276. package/dist/components/containers/panes/SupportingPane.stories.svelte +0 -113
  277. package/dist/components/containers/panes/SupportingPane.svelte +0 -175
  278. package/dist/components/containers/panes/SupportingPane.svelte.d.ts +0 -9
  279. package/dist/components/containers/panes/index.d.ts +0 -5
  280. package/dist/components/containers/panes/theme.d.ts +0 -490
  281. package/dist/components/containers/panes/theme.js +0 -185
  282. package/dist/components/containers/panes/types.d.ts +0 -108
  283. package/dist/components/nav/rail/RailNavContext.svelte +0 -14
  284. package/dist/components/nav/rail/RailNavContext.svelte.d.ts +0 -8
  285. /package/dist/components/{containers/menu-item → buttons/split-button}/types.js +0 -0
  286. /package/dist/components/{containers/panes → chips}/types.js +0 -0
  287. /package/dist/components/containers/{menu-item → menu/menu-item}/index.d.ts +0 -0
  288. /package/dist/components/containers/{menu-item → menu/menu-item}/index.js +0 -0
@@ -53,3 +53,11 @@
53
53
  <Story name="Clickable" asChild>
54
54
  <Avatar seed="clickable" onclick={() => console.log('Avatar clicked')} />
55
55
  </Story>
56
+
57
+ <Story name="Animated" asChild>
58
+ <div class="flex items-end gap-4">
59
+ <Avatar seed="alice" dicebearStyle="gaze" tags={['animation']} />
60
+ <Avatar seed="bob" dicebearStyle="shapes" tags={['animation']} />
61
+ <Avatar seed="carol" dicebearStyle="blobs" tags={['animation']} />
62
+ </div>
63
+ </Story>
@@ -8,6 +8,8 @@ Avatars can be used to represent people or objects.
8
8
  import { Avatar as AvatarPrimitive } from 'bits-ui';
9
9
  import { Layer } from '../../utils/index.js';
10
10
  import { avatar } from './theme.js';
11
+ import { DicebearAvatarBuilder } from './DicebearAvatarBuilder.js';
12
+ import { getMaterialAvatarPalette } from './materialAvatarPalette.js';
11
13
  import type { AvatarProps } from './types.js';
12
14
 
13
15
  let {
@@ -15,6 +17,8 @@ Avatars can be used to represent people or objects.
15
17
  alt = 'User avatar',
16
18
  seed = 'ogonek',
17
19
  dicebearStyle = 'shapes',
20
+ backgroundColor,
21
+ tags,
18
22
  size = 'lg',
19
23
  loadingStatus = $bindable('loading'),
20
24
  class: className,
@@ -22,23 +26,40 @@ Avatars can be used to represent people or objects.
22
26
  ...rest
23
27
  }: AvatarProps = $props();
24
28
 
25
- const materialPalette = ['e8f0fe', 'e8f5e9', 'fff7e6', 'fde7ec', 'e3f2fd'];
26
29
  const sizeMap = {
30
+ xxs: 20,
31
+ xs: 32,
27
32
  sm: 48,
28
33
  md: 72,
29
34
  lg: 96
30
35
  } as const;
31
36
 
32
- const generatedAvatar = $derived.by(() => {
37
+ let generatedAvatar = $state('');
38
+
39
+ $effect(() => {
33
40
  const sizePx = sizeMap[size ?? 'lg'] ?? 96;
34
- const params = new URLSearchParams({
35
- seed,
36
- size: String(sizePx),
37
- radius: '50',
38
- backgroundColor: materialPalette.join(',')
41
+ const currentSeed = seed;
42
+ const currentStyle = dicebearStyle ?? 'shapes';
43
+ const palette = backgroundColor ?? getMaterialAvatarPalette();
44
+ const currentTags = tags;
45
+ let cancelled = false;
46
+
47
+ const builder = new DicebearAvatarBuilder(currentStyle)
48
+ .seed(currentSeed)
49
+ .size(sizePx)
50
+ .borderRadius(50)
51
+ .background(palette);
52
+
53
+ if (currentTags) builder.tags(currentTags);
54
+
55
+ builder.toDataUri().then((uri) => {
56
+ if (cancelled) return;
57
+ generatedAvatar = uri;
39
58
  });
40
59
 
41
- return `https://api.dicebear.com/9.x/${dicebearStyle}/svg?${params.toString()}`;
60
+ return () => {
61
+ cancelled = true;
62
+ };
42
63
  });
43
64
 
44
65
  const { root, image, fallback, button } = $derived(avatar({ size }));
@@ -54,7 +75,9 @@ Avatars can be used to represent people or objects.
54
75
  <AvatarPrimitive.Image {src} {alt} class={image()} />
55
76
  {/if}
56
77
  <AvatarPrimitive.Fallback class={fallback()}>
57
- <img src={generatedAvatar} {alt} class={image()} />
78
+ {#if generatedAvatar}
79
+ <img src={generatedAvatar} {alt} class={image()} />
80
+ {/if}
58
81
  </AvatarPrimitive.Fallback>
59
82
  </AvatarPrimitive.Root>
60
83
  </button>
@@ -64,7 +87,9 @@ Avatars can be used to represent people or objects.
64
87
  <AvatarPrimitive.Image {src} {alt} class={image()} />
65
88
  {/if}
66
89
  <AvatarPrimitive.Fallback class={fallback()}>
67
- <img src={generatedAvatar} {alt} class={image()} />
90
+ {#if generatedAvatar}
91
+ <img src={generatedAvatar} {alt} class={image()} />
92
+ {/if}
68
93
  </AvatarPrimitive.Fallback>
69
94
  </AvatarPrimitive.Root>
70
95
  {/if}
@@ -0,0 +1,59 @@
1
+ import { Avatar as DicebearAvatar } from '@dicebear/core';
2
+ import type { DicebearStyleName } from './dicebearStyles.js';
3
+ export type DicebearFlip = 'none' | 'horizontal' | 'vertical' | 'both';
4
+ export type DicebearColorFill = 'solid' | 'linear' | 'radial';
5
+ export type DicebearColorOrder = 'random' | 'fixed';
6
+ /** The raw options bag passed to DiceBear's `Avatar` constructor. */
7
+ export type DicebearAvatarOptions = Record<string, unknown>;
8
+ /**
9
+ * Fluent builder around DiceBear's `Style` + `Avatar` SDK classes
10
+ * (https://www.dicebear.com/customize/options/). The style definition is only
11
+ * lazily imported once a terminal method (`build`/`toDataUri`/`toSvg`) is called.
12
+ *
13
+ * Covers the generic options every style accepts (seed, transform, background,
14
+ * typography) as named methods; use `.option()`/`.options()` for options specific
15
+ * to the chosen style's own components (e.g. `hairColor`, `eyesVariant`), which
16
+ * can't be named generically — see the selected style's `OptionsDescriptor`.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const uri = await new DicebearAvatarBuilder('lorelei')
21
+ * .seed('alice')
22
+ * .size(96)
23
+ * .background(['b6e3f4', 'c0aede'])
24
+ * .option('hairColor', ['2c1b18'])
25
+ * .toDataUri();
26
+ * ```
27
+ */
28
+ export declare class DicebearAvatarBuilder {
29
+ #private;
30
+ constructor(styleName: DicebearStyleName);
31
+ seed(seed: string): this;
32
+ size(px: number): this;
33
+ idRandomization(enabled?: boolean): this;
34
+ title(text: string): this;
35
+ font(family: string | string[], weight?: number): this;
36
+ flip(value: DicebearFlip): this;
37
+ rotate(degrees: number): this;
38
+ scale(factor: number): this;
39
+ borderRadius(radius: number): this;
40
+ translate(x: number, y: number): this;
41
+ background(colors: string[], fill?: DicebearColorFill, order?: DicebearColorOrder): this;
42
+ backgroundGradient(stops: number, angle: number): this;
43
+ /**
44
+ * Filters which variant a style picks by tag — currently DiceBear's only tag is
45
+ * `'animation'`, which opts a supporting style (e.g. `gaze`, `shapes`, `blobs`) into its
46
+ * animated variants; prefix with `!` (e.g. `'!animation'`) to force the static variant
47
+ * instead. A no-op for styles that don't define the tag.
48
+ * @see https://www.dicebear.com/guides/filter-variants-with-tags
49
+ */
50
+ tags(tags: string[]): this;
51
+ /** Escape hatch for an option specific to the chosen style (e.g. `hairColor`, `eyesVariant`). */
52
+ option(key: string, value: unknown): this;
53
+ /** Merges an arbitrary options object in, e.g. one collected from user input. */
54
+ options(values: DicebearAvatarOptions): this;
55
+ /** Resolves the style definition and constructs the underlying `Avatar` instance. */
56
+ build(): Promise<DicebearAvatar>;
57
+ toDataUri(): Promise<string>;
58
+ toSvg(): Promise<string>;
59
+ }
@@ -0,0 +1,115 @@
1
+ import { Avatar as DicebearAvatar } from '@dicebear/core';
2
+ import { loadDicebearStyle } from './dicebearStyles.js';
3
+ /**
4
+ * Fluent builder around DiceBear's `Style` + `Avatar` SDK classes
5
+ * (https://www.dicebear.com/customize/options/). The style definition is only
6
+ * lazily imported once a terminal method (`build`/`toDataUri`/`toSvg`) is called.
7
+ *
8
+ * Covers the generic options every style accepts (seed, transform, background,
9
+ * typography) as named methods; use `.option()`/`.options()` for options specific
10
+ * to the chosen style's own components (e.g. `hairColor`, `eyesVariant`), which
11
+ * can't be named generically — see the selected style's `OptionsDescriptor`.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const uri = await new DicebearAvatarBuilder('lorelei')
16
+ * .seed('alice')
17
+ * .size(96)
18
+ * .background(['b6e3f4', 'c0aede'])
19
+ * .option('hairColor', ['2c1b18'])
20
+ * .toDataUri();
21
+ * ```
22
+ */
23
+ export class DicebearAvatarBuilder {
24
+ #styleName;
25
+ #options = {};
26
+ constructor(styleName) {
27
+ this.#styleName = styleName;
28
+ }
29
+ seed(seed) {
30
+ this.#options.seed = seed;
31
+ return this;
32
+ }
33
+ size(px) {
34
+ this.#options.size = px;
35
+ return this;
36
+ }
37
+ idRandomization(enabled = true) {
38
+ this.#options.idRandomization = enabled;
39
+ return this;
40
+ }
41
+ title(text) {
42
+ this.#options.title = text;
43
+ return this;
44
+ }
45
+ font(family, weight) {
46
+ this.#options.fontFamily = Array.isArray(family) ? family : [family];
47
+ if (weight !== undefined)
48
+ this.#options.fontWeight = weight;
49
+ return this;
50
+ }
51
+ flip(value) {
52
+ this.#options.flip = value;
53
+ return this;
54
+ }
55
+ rotate(degrees) {
56
+ this.#options.rotate = degrees;
57
+ return this;
58
+ }
59
+ scale(factor) {
60
+ this.#options.scale = factor;
61
+ return this;
62
+ }
63
+ borderRadius(radius) {
64
+ this.#options.borderRadius = radius;
65
+ return this;
66
+ }
67
+ translate(x, y) {
68
+ this.#options.translateX = x;
69
+ this.#options.translateY = y;
70
+ return this;
71
+ }
72
+ background(colors, fill = 'solid', order = 'random') {
73
+ this.#options.backgroundColor = colors;
74
+ this.#options.backgroundColorFill = fill;
75
+ this.#options.backgroundColorOrder = order;
76
+ return this;
77
+ }
78
+ backgroundGradient(stops, angle) {
79
+ this.#options.backgroundColorFillStops = stops;
80
+ this.#options.backgroundColorAngle = angle;
81
+ return this;
82
+ }
83
+ /**
84
+ * Filters which variant a style picks by tag — currently DiceBear's only tag is
85
+ * `'animation'`, which opts a supporting style (e.g. `gaze`, `shapes`, `blobs`) into its
86
+ * animated variants; prefix with `!` (e.g. `'!animation'`) to force the static variant
87
+ * instead. A no-op for styles that don't define the tag.
88
+ * @see https://www.dicebear.com/guides/filter-variants-with-tags
89
+ */
90
+ tags(tags) {
91
+ this.#options.tags = tags;
92
+ return this;
93
+ }
94
+ /** Escape hatch for an option specific to the chosen style (e.g. `hairColor`, `eyesVariant`). */
95
+ option(key, value) {
96
+ this.#options[key] = value;
97
+ return this;
98
+ }
99
+ /** Merges an arbitrary options object in, e.g. one collected from user input. */
100
+ options(values) {
101
+ Object.assign(this.#options, values);
102
+ return this;
103
+ }
104
+ /** Resolves the style definition and constructs the underlying `Avatar` instance. */
105
+ async build() {
106
+ const style = await loadDicebearStyle(this.#styleName);
107
+ return new DicebearAvatar(style, this.#options);
108
+ }
109
+ async toDataUri() {
110
+ return (await this.build()).toDataUri();
111
+ }
112
+ async toSvg() {
113
+ return (await this.build()).toString();
114
+ }
115
+ }
@@ -55,7 +55,7 @@
55
55
  type="file"
56
56
  accept="image/*"
57
57
  onchange={handleImageUpload}
58
- class="file:bg-md-sys-color-primary-container file:text-md-sys-color-on-primary-container hover:file:bg-md-sys-color-primary-container/80 md-sys-typescale-body-medium file:mr-4 file:rounded-full file:border-0 file:px-4 file:py-2 file:md-sys-typescale-label-large"
58
+ class="file:bg-md-sys-color-primary-container file:text-md-sys-color-on-primary-container hover:file:bg-md-sys-color-primary-container/80 md-sys-typescale-body-medium file:md-sys-typescale-label-large file:mr-4 file:rounded-full file:border-0 file:px-4 file:py-2"
59
59
  />
60
60
  </div>
61
61
  </div>
@@ -8,8 +8,8 @@
8
8
 
9
9
  <div class="fixed right-4 bottom-4 z-50 hidden md:block">
10
10
  <Popover bind:open title="Theme Settings" side="top" align="end" sideOffset={16}>
11
- {#snippet trigger()}
12
- <FAB iconProps={{ name: 'palette' }} config="primary" />
11
+ {#snippet trigger(triggerProps)}
12
+ <FAB iconProps={{ name: 'palette' }} config="primary" {...triggerProps} />
13
13
  {/snippet}
14
14
 
15
15
  <div
@@ -0,0 +1,21 @@
1
+ import { OptionsDescriptor, Style } from '@dicebear/core';
2
+ /**
3
+ * `@dicebear/core` does not publicly export its `Descriptor`/`FieldDescriptor` types (only
4
+ * the `OptionsDescriptor` class itself), so they're recovered structurally from its `toJSON()`
5
+ * return type instead of being duplicated by hand.
6
+ */
7
+ export type DicebearDescriptor = ReturnType<InstanceType<typeof OptionsDescriptor>['toJSON']>;
8
+ export type DicebearFieldDescriptor = DicebearDescriptor[string];
9
+ /**
10
+ * Every style shipped by `@dicebear/styles` (v10). Kept as the single source of
11
+ * truth for the `DicebearStyle` type in `types.ts` — extend this list first when
12
+ * DiceBear adds a new style, everything else derives from it.
13
+ */
14
+ export declare const DICEBEAR_STYLES: readonly ["adventurer", "adventurer-neutral", "avataaars", "avataaars-neutral", "big-ears", "big-ears-neutral", "big-smile", "blobs", "bottts", "bottts-neutral", "cameo", "clay", "constellation", "critters", "croodles", "croodles-neutral", "cutouts", "disco", "dylan", "fun-emoji", "gaze", "glass", "glyphs", "icons", "identicon", "initial-face", "initials", "landscape", "line-face", "loops", "lorelei", "lorelei-neutral", "marbles", "micah", "miniavs", "moods", "notionists", "notionists-neutral", "open-peeps", "patchwork", "personas", "pixel-art", "pixel-art-neutral", "pixelbot", "planets", "rings", "shadows", "shape-grid", "shapes", "slice", "sprouts", "squircles", "stack", "stripes", "thumbs", "toon-head", "triangles", "voxel-art", "voxel-bot", "waves", "weave"];
15
+ export type DicebearStyleName = (typeof DICEBEAR_STYLES)[number];
16
+ /** Lazily imports and validates a style definition, caching the resulting `Style` instance. */
17
+ export declare function loadDicebearStyle(name: DicebearStyleName): Promise<Style>;
18
+ /** Lazily builds the `OptionsDescriptor` JSON for a style, describing every option it accepts. */
19
+ export declare function loadDicebearOptionsDescriptor(name: DicebearStyleName): Promise<DicebearDescriptor>;
20
+ /** Turns a style name like `big-ears-neutral` into `Big Ears Neutral`. */
21
+ export declare function formatDicebearStyleLabel(name: string): string;
@@ -0,0 +1,169 @@
1
+ import { OptionsDescriptor, Style } from '@dicebear/core';
2
+ /**
3
+ * Every style shipped by `@dicebear/styles` (v10). Kept as the single source of
4
+ * truth for the `DicebearStyle` type in `types.ts` — extend this list first when
5
+ * DiceBear adds a new style, everything else derives from it.
6
+ */
7
+ export const DICEBEAR_STYLES = [
8
+ 'adventurer',
9
+ 'adventurer-neutral',
10
+ 'avataaars',
11
+ 'avataaars-neutral',
12
+ 'big-ears',
13
+ 'big-ears-neutral',
14
+ 'big-smile',
15
+ 'blobs',
16
+ 'bottts',
17
+ 'bottts-neutral',
18
+ 'cameo',
19
+ 'clay',
20
+ 'constellation',
21
+ 'critters',
22
+ 'croodles',
23
+ 'croodles-neutral',
24
+ 'cutouts',
25
+ 'disco',
26
+ 'dylan',
27
+ 'fun-emoji',
28
+ 'gaze',
29
+ 'glass',
30
+ 'glyphs',
31
+ 'icons',
32
+ 'identicon',
33
+ 'initial-face',
34
+ 'initials',
35
+ 'landscape',
36
+ 'line-face',
37
+ 'loops',
38
+ 'lorelei',
39
+ 'lorelei-neutral',
40
+ 'marbles',
41
+ 'micah',
42
+ 'miniavs',
43
+ 'moods',
44
+ 'notionists',
45
+ 'notionists-neutral',
46
+ 'open-peeps',
47
+ 'patchwork',
48
+ 'personas',
49
+ 'pixel-art',
50
+ 'pixel-art-neutral',
51
+ 'pixelbot',
52
+ 'planets',
53
+ 'rings',
54
+ 'shadows',
55
+ 'shape-grid',
56
+ 'shapes',
57
+ 'slice',
58
+ 'sprouts',
59
+ 'squircles',
60
+ 'stack',
61
+ 'stripes',
62
+ 'thumbs',
63
+ 'toon-head',
64
+ 'triangles',
65
+ 'voxel-art',
66
+ 'voxel-bot',
67
+ 'waves',
68
+ 'weave'
69
+ ];
70
+ /**
71
+ * One dynamic `import()` per style, written out literally (not a template
72
+ * expression) so every bundler — Vite, Rollup, webpack, esbuild — can
73
+ * statically analyze and code-split each style into its own lazily-loaded
74
+ * chunk. A generated/templated import here would defeat that analysis.
75
+ */
76
+ // Not annotated with an explicit `StyleDefinition` return type: TS widens the enum-like string
77
+ // literals inside each imported JSON module (e.g. element `type`) to `string`, which doesn't
78
+ // structurally satisfy `StyleDefinition`'s literal unions. `Style` is happy to accept the
79
+ // as-imported shape directly (it validates the real JSON against DiceBear's schema at runtime).
80
+ const styleLoaders = {
81
+ adventurer: () => import('@dicebear/styles/adventurer.json'),
82
+ 'adventurer-neutral': () => import('@dicebear/styles/adventurer-neutral.json'),
83
+ avataaars: () => import('@dicebear/styles/avataaars.json'),
84
+ 'avataaars-neutral': () => import('@dicebear/styles/avataaars-neutral.json'),
85
+ 'big-ears': () => import('@dicebear/styles/big-ears.json'),
86
+ 'big-ears-neutral': () => import('@dicebear/styles/big-ears-neutral.json'),
87
+ 'big-smile': () => import('@dicebear/styles/big-smile.json'),
88
+ blobs: () => import('@dicebear/styles/blobs.json'),
89
+ bottts: () => import('@dicebear/styles/bottts.json'),
90
+ 'bottts-neutral': () => import('@dicebear/styles/bottts-neutral.json'),
91
+ cameo: () => import('@dicebear/styles/cameo.json'),
92
+ clay: () => import('@dicebear/styles/clay.json'),
93
+ constellation: () => import('@dicebear/styles/constellation.json'),
94
+ critters: () => import('@dicebear/styles/critters.json'),
95
+ croodles: () => import('@dicebear/styles/croodles.json'),
96
+ 'croodles-neutral': () => import('@dicebear/styles/croodles-neutral.json'),
97
+ cutouts: () => import('@dicebear/styles/cutouts.json'),
98
+ disco: () => import('@dicebear/styles/disco.json'),
99
+ dylan: () => import('@dicebear/styles/dylan.json'),
100
+ 'fun-emoji': () => import('@dicebear/styles/fun-emoji.json'),
101
+ gaze: () => import('@dicebear/styles/gaze.json'),
102
+ glass: () => import('@dicebear/styles/glass.json'),
103
+ glyphs: () => import('@dicebear/styles/glyphs.json'),
104
+ icons: () => import('@dicebear/styles/icons.json'),
105
+ identicon: () => import('@dicebear/styles/identicon.json'),
106
+ 'initial-face': () => import('@dicebear/styles/initial-face.json'),
107
+ initials: () => import('@dicebear/styles/initials.json'),
108
+ landscape: () => import('@dicebear/styles/landscape.json'),
109
+ 'line-face': () => import('@dicebear/styles/line-face.json'),
110
+ loops: () => import('@dicebear/styles/loops.json'),
111
+ lorelei: () => import('@dicebear/styles/lorelei.json'),
112
+ 'lorelei-neutral': () => import('@dicebear/styles/lorelei-neutral.json'),
113
+ marbles: () => import('@dicebear/styles/marbles.json'),
114
+ micah: () => import('@dicebear/styles/micah.json'),
115
+ miniavs: () => import('@dicebear/styles/miniavs.json'),
116
+ moods: () => import('@dicebear/styles/moods.json'),
117
+ notionists: () => import('@dicebear/styles/notionists.json'),
118
+ 'notionists-neutral': () => import('@dicebear/styles/notionists-neutral.json'),
119
+ 'open-peeps': () => import('@dicebear/styles/open-peeps.json'),
120
+ patchwork: () => import('@dicebear/styles/patchwork.json'),
121
+ personas: () => import('@dicebear/styles/personas.json'),
122
+ 'pixel-art': () => import('@dicebear/styles/pixel-art.json'),
123
+ 'pixel-art-neutral': () => import('@dicebear/styles/pixel-art-neutral.json'),
124
+ pixelbot: () => import('@dicebear/styles/pixelbot.json'),
125
+ planets: () => import('@dicebear/styles/planets.json'),
126
+ rings: () => import('@dicebear/styles/rings.json'),
127
+ shadows: () => import('@dicebear/styles/shadows.json'),
128
+ 'shape-grid': () => import('@dicebear/styles/shape-grid.json'),
129
+ shapes: () => import('@dicebear/styles/shapes.json'),
130
+ slice: () => import('@dicebear/styles/slice.json'),
131
+ sprouts: () => import('@dicebear/styles/sprouts.json'),
132
+ squircles: () => import('@dicebear/styles/squircles.json'),
133
+ stack: () => import('@dicebear/styles/stack.json'),
134
+ stripes: () => import('@dicebear/styles/stripes.json'),
135
+ thumbs: () => import('@dicebear/styles/thumbs.json'),
136
+ 'toon-head': () => import('@dicebear/styles/toon-head.json'),
137
+ triangles: () => import('@dicebear/styles/triangles.json'),
138
+ 'voxel-art': () => import('@dicebear/styles/voxel-art.json'),
139
+ 'voxel-bot': () => import('@dicebear/styles/voxel-bot.json'),
140
+ waves: () => import('@dicebear/styles/waves.json'),
141
+ weave: () => import('@dicebear/styles/weave.json')
142
+ };
143
+ const styleCache = new Map();
144
+ /** Lazily imports and validates a style definition, caching the resulting `Style` instance. */
145
+ export function loadDicebearStyle(name) {
146
+ let cached = styleCache.get(name);
147
+ if (!cached) {
148
+ cached = styleLoaders[name]().then((mod) => new Style(mod.default));
149
+ styleCache.set(name, cached);
150
+ }
151
+ return cached;
152
+ }
153
+ const descriptorCache = new Map();
154
+ /** Lazily builds the `OptionsDescriptor` JSON for a style, describing every option it accepts. */
155
+ export function loadDicebearOptionsDescriptor(name) {
156
+ let cached = descriptorCache.get(name);
157
+ if (!cached) {
158
+ cached = loadDicebearStyle(name).then((style) => new OptionsDescriptor(style).toJSON());
159
+ descriptorCache.set(name, cached);
160
+ }
161
+ return cached;
162
+ }
163
+ /** Turns a style name like `big-ears-neutral` into `Big Ears Neutral`. */
164
+ export function formatDicebearStyleLabel(name) {
165
+ return name
166
+ .split('-')
167
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
168
+ .join(' ');
169
+ }
@@ -1,3 +1,6 @@
1
+ export * from './DicebearAvatarBuilder.js';
2
+ export * from './dicebearStyles.js';
3
+ export * from './materialAvatarPalette.js';
1
4
  export * from './theme.js';
2
5
  export * from './types.js';
3
6
  export { default as Avatar } from './Avatar.svelte';
@@ -1,5 +1,8 @@
1
1
  // THIS FILE IS AUTO-GENERATED BY scripts/generate-components-index.ts - DO NOT EDIT MANUALLY
2
2
  // re-export TS/JS modules from this folder
3
+ export * from './DicebearAvatarBuilder.js';
4
+ export * from './dicebearStyles.js';
5
+ export * from './materialAvatarPalette.js';
3
6
  export * from './theme.js';
4
7
  export * from './types.js';
5
8
  // default exports for components in this folder
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Reads the current app's resolved container-tier color tokens as hex strings, for use as
3
+ * DiceBear's `backgroundColor` option. Falls back to a neutral default outside the browser
4
+ * (SSR) or before the theme stylesheet has painted.
5
+ */
6
+ export declare function getMaterialAvatarPalette(): string[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Container-tier M3 color roles (see `styles/theme/*.css`) used as a generated avatar's
3
+ * background. Deliberately NOT a fixed hex list: every consuming app picks its own source
4
+ * color (`ThemeConfig.sourceColor` in `theme.svelte.ts`), which the M3 dynamic color
5
+ * algorithm expands into these tokens as real `--color-md-sys-color-*` custom properties on
6
+ * `:root` — reading them live is what makes the avatar match that app's actual palette
7
+ * instead of this library's own hardcoded pastel.
8
+ */
9
+ const CONTAINER_TOKENS = [
10
+ '--color-md-sys-color-primary-container',
11
+ '--color-md-sys-color-secondary-container',
12
+ '--color-md-sys-color-tertiary-container',
13
+ '--color-md-sys-color-error-container',
14
+ '--color-md-sys-color-surface-container-highest'
15
+ ];
16
+ /** Used server-side, or if a token hasn't been painted yet (styles not loaded). */
17
+ const FALLBACK_PALETTE = ['e9ddff', 'e8def8', 'ffd9e3', 'ffdad6', 'e6e0e9'];
18
+ /** Converts the `rgb(r g b)` (or `rgb(r, g, b)`) format these tokens are always defined in to hex. */
19
+ function rgbStringToHex(value) {
20
+ const channels = value.match(/\d+(?:\.\d+)?/g);
21
+ if (!channels || channels.length < 3)
22
+ return undefined;
23
+ return channels
24
+ .slice(0, 3)
25
+ .map((n) => Math.round(Math.max(0, Math.min(255, parseFloat(n))))
26
+ .toString(16)
27
+ .padStart(2, '0'))
28
+ .join('');
29
+ }
30
+ /**
31
+ * Reads the current app's resolved container-tier color tokens as hex strings, for use as
32
+ * DiceBear's `backgroundColor` option. Falls back to a neutral default outside the browser
33
+ * (SSR) or before the theme stylesheet has painted.
34
+ */
35
+ export function getMaterialAvatarPalette() {
36
+ if (typeof window === 'undefined')
37
+ return FALLBACK_PALETTE;
38
+ const styles = getComputedStyle(document.documentElement);
39
+ const palette = CONTAINER_TOKENS.map((token) => {
40
+ const raw = styles.getPropertyValue(token).trim();
41
+ return raw ? rgbStringToHex(raw) : undefined;
42
+ }).filter((hex) => Boolean(hex));
43
+ return palette.length > 0 ? palette : FALLBACK_PALETTE;
44
+ }
@@ -1,5 +1,11 @@
1
1
  export declare const avatar: import("tailwind-variants").TVReturnType<{
2
2
  size: {
3
+ xxs: {
4
+ root: string;
5
+ };
6
+ xs: {
7
+ root: string;
8
+ };
3
9
  sm: {
4
10
  root: string;
5
11
  };
@@ -17,6 +23,12 @@ export declare const avatar: import("tailwind-variants").TVReturnType<{
17
23
  button: string;
18
24
  }, undefined, {
19
25
  size: {
26
+ xxs: {
27
+ root: string;
28
+ };
29
+ xs: {
30
+ root: string;
31
+ };
20
32
  sm: {
21
33
  root: string;
22
34
  };
@@ -32,8 +44,14 @@ export declare const avatar: import("tailwind-variants").TVReturnType<{
32
44
  image: string;
33
45
  fallback: string;
34
46
  button: string;
35
- }, import("tailwind-variants").TVReturnType<{
47
+ }, import("tailwind-variants").TVReturnTypeLike<{
36
48
  size: {
49
+ xxs: {
50
+ root: string;
51
+ };
52
+ xs: {
53
+ root: string;
54
+ };
37
55
  sm: {
38
56
  root: string;
39
57
  };
@@ -49,4 +67,4 @@ export declare const avatar: import("tailwind-variants").TVReturnType<{
49
67
  image: string;
50
68
  fallback: string;
51
69
  button: string;
52
- }, undefined, unknown, unknown, undefined>>;
70
+ }>>;
@@ -8,6 +8,12 @@ export const avatar = tv({
8
8
  },
9
9
  variants: {
10
10
  size: {
11
+ xxs: {
12
+ root: 'size-5'
13
+ },
14
+ xs: {
15
+ root: 'size-8'
16
+ },
11
17
  sm: {
12
18
  root: 'size-12'
13
19
  },
@@ -20,6 +26,6 @@ export const avatar = tv({
20
26
  }
21
27
  },
22
28
  defaultVariants: {
23
- size: 'lg'
29
+ size: 'md'
24
30
  }
25
31
  });
@@ -1,9 +1,13 @@
1
1
  import type { Avatar as AvatarPrimitive } from 'bits-ui';
2
2
  import type { VariantProps } from 'tailwind-variants';
3
+ import type { DicebearStyleName } from './dicebearStyles.js';
3
4
  import type { avatar } from './theme.js';
4
5
  export type AvatarVariants = VariantProps<typeof avatar>;
5
- /** Dicebear (https://www.dicebear.com) avatar styles available for the generated fallback avatar. */
6
- export type DicebearStyle = 'shapes' | 'adventurer' | 'adventurer-neutral' | 'avataaars' | 'avataaars-neutral' | 'big-ears' | 'big-ears-neutral' | 'big-smile' | 'bottts' | 'bottts-neutral' | 'croodles' | 'croodles-neutral' | 'dylan' | 'fun-emoji' | 'glass' | 'icons' | 'identicon' | 'initials' | 'lorelei' | 'lorelei-neutral' | 'micah' | 'miniavs' | 'notionists' | 'notionists-neutral' | 'open-peeps' | 'personas' | 'pixel-art' | 'pixel-art-neutral' | 'rings' | 'thumbs';
6
+ /**
7
+ * Dicebear (https://www.dicebear.com) avatar styles available for the generated fallback
8
+ * avatar. Derived from `DICEBEAR_STYLES` in `dicebearStyles.ts` — extend the list there.
9
+ */
10
+ export type DicebearStyle = DicebearStyleName;
7
11
  export type AvatarProps = AvatarPrimitive.RootProps & {
8
12
  /** The URL of the avatar image. If null or undefined, a generated avatar will be used. */
9
13
  src?: string | null;
@@ -13,6 +17,20 @@ export type AvatarProps = AvatarPrimitive.RootProps & {
13
17
  seed?: string;
14
18
  /** The Dicebear style used for the generated fallback avatar. @default 'shapes' */
15
19
  dicebearStyle?: DicebearStyle;
20
+ /**
21
+ * Hex background colors (no `#`) for the generated fallback avatar. Defaults to the
22
+ * current app's own M3 container-tier tokens (`getMaterialAvatarPalette()`), read live
23
+ * from CSS custom properties — every app's tokens differ since they derive from that
24
+ * app's own chosen source color, so the fallback isn't a fixed palette.
25
+ */
26
+ backgroundColor?: string[];
27
+ /**
28
+ * DiceBear variant tags for the generated fallback avatar, e.g. `['animation']` to opt a
29
+ * supporting style (`gaze`, `shapes`, `blobs`, …) into its animated variants, or
30
+ * `['!animation']` to force the static one. A no-op for styles without that tag.
31
+ * @see https://www.dicebear.com/guides/filter-variants-with-tags
32
+ */
33
+ tags?: string[];
16
34
  /** The loading status of the avatar image. */
17
35
  loadingStatus?: 'loading' | 'loaded' | 'error';
18
36
  /** Callback for when the avatar is clicked. If provided, the avatar is wrapped in a button. */