@diegopluna/narvi 0.3.13 → 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 (63) hide show
  1. package/dist/components/app-shell/AppShellHeader.svelte +15 -2
  2. package/dist/components/app-shell/AppShellStrip.svelte +41 -0
  3. package/dist/components/app-shell/AppShellStrip.svelte.d.ts +10 -0
  4. package/dist/components/app-shell/index.d.ts +3 -1
  5. package/dist/components/app-shell/index.js +2 -1
  6. package/dist/components/approval/Approval.svelte +147 -13
  7. package/dist/components/approval/Approval.svelte.d.ts +22 -0
  8. package/dist/components/avatar/AvatarFallback.svelte +2 -1
  9. package/dist/components/avatar/AvatarRoot.svelte +9 -6
  10. package/dist/components/composer/ComposerTray.svelte +150 -10
  11. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -3
  12. package/dist/components/heading/Heading.svelte +2 -1
  13. package/dist/components/markdown/MarkdownHtml.svelte +7 -3
  14. package/dist/components/markdown/MarkdownTable.svelte +19 -5
  15. package/dist/components/markdown/styles.d.ts +0 -17
  16. package/dist/components/markdown/styles.js +4 -20
  17. package/dist/components/plan/Plan.svelte +146 -28
  18. package/dist/components/plan/Plan.svelte.d.ts +17 -2
  19. package/dist/components/queued-message/QueuedMessage.svelte +178 -49
  20. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +25 -4
  21. package/dist/components/tab-strip/TabStrip.svelte +120 -12
  22. package/dist/components/tab-strip/TabStrip.svelte.d.ts +17 -0
  23. package/dist/components/table/TableBody.svelte +27 -0
  24. package/dist/components/table/TableBody.svelte.d.ts +10 -0
  25. package/dist/components/table/TableCell.svelte +54 -0
  26. package/dist/components/table/TableCell.svelte.d.ts +17 -0
  27. package/dist/components/table/TableFoot.svelte +39 -0
  28. package/dist/components/table/TableFoot.svelte.d.ts +10 -0
  29. package/dist/components/table/TableHead.svelte +33 -0
  30. package/dist/components/table/TableHead.svelte.d.ts +10 -0
  31. package/dist/components/table/TableHeaderCell.svelte +61 -0
  32. package/dist/components/table/TableHeaderCell.svelte.d.ts +17 -0
  33. package/dist/components/table/TableRoot.svelte +144 -0
  34. package/dist/components/table/TableRoot.svelte.d.ts +22 -0
  35. package/dist/components/table/TableRow.svelte +59 -0
  36. package/dist/components/table/TableRow.svelte.d.ts +12 -0
  37. package/dist/components/table/context.d.ts +14 -0
  38. package/dist/components/table/context.js +15 -0
  39. package/dist/components/table/index.d.ts +16 -0
  40. package/dist/components/table/index.js +8 -0
  41. package/dist/components/table/styles.d.ts +56 -0
  42. package/dist/components/table/styles.js +44 -0
  43. package/dist/components/text/Text.svelte +19 -4
  44. package/dist/components/text/Text.svelte.d.ts +4 -2
  45. package/dist/components/work-fold/WorkFold.svelte +26 -1
  46. package/dist/components/work-fold/WorkFold.svelte.d.ts +5 -0
  47. package/dist/index.d.ts +4 -1
  48. package/dist/index.js +7 -1
  49. package/dist/internal/markers.stylex.d.ts +4 -0
  50. package/dist/internal/markers.stylex.js +2 -0
  51. package/dist/internal/table.d.ts +29 -0
  52. package/dist/internal/table.js +34 -0
  53. package/dist/tokens.stylex.d.ts +2 -0
  54. package/dist/tokens.stylex.js +9 -3
  55. package/dist/typography.d.ts +40 -1
  56. package/dist/typography.js +42 -2
  57. package/package.json +1 -1
  58. package/skills/building-ui/SKILL.md +22 -22
  59. package/skills/building-ui/references/components.md +196 -42
  60. package/skills/markdown/SKILL.md +1 -1
  61. package/skills/setup/SKILL.md +1 -1
  62. package/skills/styling/SKILL.md +21 -5
  63. package/skills/theming/SKILL.md +1 -1
@@ -1,12 +1,15 @@
1
1
  <!--
2
2
  The head of a column of the sheet: the page's title and its actions, or a
3
3
  panel's tabs. Every column's head is the same height, so they sit on one line.
4
+ Its parts are centred on that line; an AppShell.Strip in it runs its full
5
+ height, for a notch TabStrip that meets the page under it.
4
6
  -->
5
7
  <script lang="ts" module>
6
8
  import * as stylex from '@stylexjs/stylex';
7
9
  import type { Snippet } from 'svelte';
8
10
  import type { HTMLAttributes } from 'svelte/elements';
9
11
  import { shared } from '../../internal/shared.js';
12
+ import { appShellStripMarker } from '../../internal/markers.stylex.js';
10
13
  import { attrs, type Sx } from '../../internal/sx.js';
11
14
  import { colors, density, font } from '../../tokens.stylex.js';
12
15
 
@@ -42,10 +45,20 @@
42
45
  // room are kept at any density.
43
46
  paddingInlineStart: `max(${d('1rem')}, calc(var(--narvi-inset-page, 0px) + 0.5rem))`,
44
47
  paddingInlineEnd: d('0.625rem'),
45
- fontSize: font.sizeBody
48
+ fontSize: font.sizeBody,
49
+ // Holding an AppShell.Strip, it is a band a step from the page's colour, which the
50
+ // strip's open tab, in the page's colour, runs down into
51
+ backgroundColor: {
52
+ default: null,
53
+ [stylex.when.descendant('[data-slot="app-shell-strip"]', appShellStripMarker)]: colors.bg
54
+ }
46
55
  },
47
56
  divider: {
48
- borderBottomWidth: '1px',
57
+ // Holding an AppShell.Strip, the open tab joins it to the page: no line between
58
+ borderBottomWidth: {
59
+ default: '1px',
60
+ [stylex.when.descendant('[data-slot="app-shell-strip"]', appShellStripMarker)]: 0
61
+ },
49
62
  borderBottomStyle: 'solid',
50
63
  borderBottomColor: colors.border
51
64
  }
@@ -0,0 +1,41 @@
1
+ <!--
2
+ Within AppShell.Header, what runs the header's full height and takes the room
3
+ left in it: a TabStrip with `variant="notch"`, whose open tab runs down into
4
+ the page under the header. The header's other parts stay centred on its line.
5
+ A header that holds one is a band of the window's colour, a step from the
6
+ page's, with no line under it, so the open tab is what joins the two.
7
+ -->
8
+ <script lang="ts" module>
9
+ import * as stylex from '@stylexjs/stylex';
10
+ import type { Snippet } from 'svelte';
11
+ import type { HTMLAttributes } from 'svelte/elements';
12
+ import { appShellStripMarker } from '../../internal/markers.stylex.js';
13
+ import { attrs, type Sx } from '../../internal/sx.js';
14
+
15
+ export type AppShellStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
16
+ sx?: Sx | undefined;
17
+ children?: Snippet | undefined;
18
+ };
19
+
20
+ const styles = stylex.create({
21
+ strip: {
22
+ display: 'flex',
23
+ alignItems: 'stretch',
24
+ alignSelf: 'stretch',
25
+ flexGrow: 1,
26
+ minWidth: 0
27
+ }
28
+ });
29
+ </script>
30
+
31
+ <script lang="ts">
32
+ let { sx, class: className, children, ...rest }: AppShellStripProps = $props();
33
+ </script>
34
+
35
+ <div
36
+ data-slot="app-shell-strip"
37
+ {...rest}
38
+ {...attrs([styles.strip, appShellStripMarker, sx], className)}
39
+ >
40
+ {@render children?.()}
41
+ </div>
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type AppShellStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
+ sx?: Sx | undefined;
6
+ children?: Snippet | undefined;
7
+ };
8
+ declare const AppShellStrip: import("svelte").Component<AppShellStripProps, {}, "">;
9
+ type AppShellStrip = ReturnType<typeof AppShellStrip>;
10
+ export default AppShellStrip;
@@ -7,8 +7,9 @@ import Rail from './AppShellRail.svelte';
7
7
  import Root from './AppShellRoot.svelte';
8
8
  import Sheet from './AppShellSheet.svelte';
9
9
  import Sidebar from './AppShellSidebar.svelte';
10
+ import Strip from './AppShellStrip.svelte';
10
11
  import Toggle from './AppShellToggle.svelte';
11
- export { Root, Bar, Rail, Panes, Sheet, Sidebar, Main, Header, Panel, Toggle };
12
+ export { Root, Bar, Rail, Panes, Sheet, Sidebar, Main, Header, Strip, Panel, Toggle };
12
13
  export { getAppShellContext } from './context.js';
13
14
  export type { AppShellContext } from './context.js';
14
15
  export type { AppShellBarProps } from './AppShellBar.svelte';
@@ -20,4 +21,5 @@ export type { AppShellRailProps } from './AppShellRail.svelte';
20
21
  export type { AppShellRootProps } from './AppShellRoot.svelte';
21
22
  export type { AppShellSheetProps } from './AppShellSheet.svelte';
22
23
  export type { AppShellSidebarProps } from './AppShellSidebar.svelte';
24
+ export type { AppShellStripProps } from './AppShellStrip.svelte';
23
25
  export type { AppShellToggleProps } from './AppShellToggle.svelte';
@@ -7,6 +7,7 @@ import Rail from './AppShellRail.svelte';
7
7
  import Root from './AppShellRoot.svelte';
8
8
  import Sheet from './AppShellSheet.svelte';
9
9
  import Sidebar from './AppShellSidebar.svelte';
10
+ import Strip from './AppShellStrip.svelte';
10
11
  import Toggle from './AppShellToggle.svelte';
11
- export { Root, Bar, Rail, Panes, Sheet, Sidebar, Main, Header, Panel, Toggle };
12
+ export { Root, Bar, Rail, Panes, Sheet, Sidebar, Main, Header, Strip, Panel, Toggle };
12
13
  export { getAppShellContext } from './context.js';
@@ -3,12 +3,18 @@
3
3
  choices; once answered, the card folds into one line that says what was
4
4
  decided. Focus is kept: when the buttons go, it moves to that line, not to
5
5
  the top of the page. (From Eregion, 2b566c1f.)
6
+
7
+ Several waiting at once show one at a time, saying where this one is among
8
+ them ("2 of 3"), with buttons to the others. In the composer's tray it can
9
+ be `compact`, so the tray leaves the conversation its room.
6
10
  -->
7
11
  <script lang="ts" module>
8
12
  import * as stylex from '@stylexjs/stylex';
9
13
  import { onMount, tick, type Snippet } from 'svelte';
10
14
  import Glyph from '../../internal/Glyph.svelte';
15
+ import { shared } from '../../internal/shared.js';
11
16
  import { attrs, type Sx } from '../../internal/sx.js';
17
+ import { visuallyHidden } from '../../visually-hidden.js';
12
18
  import { colors, density, font, motion, radius, space } from '../../tokens.stylex.js';
13
19
  import { media } from '../../media.stylex.js';
14
20
  import Button from '../button/Button.svelte';
@@ -70,6 +76,28 @@
70
76
  busy?: boolean | undefined;
71
77
  /** What the folded line names after the answer, such as the command. */
72
78
  subject?: string | undefined;
79
+ /**
80
+ * Tighter, for the composer's tray: less room in and around its parts, the command on
81
+ * one line that scrolls sideways, the files run on in one paragraph, smaller buttons.
82
+ */
83
+ compact?: boolean | undefined;
84
+ /**
85
+ * Where this approval is among those waiting, counted from 0, with `count`. With more
86
+ * than one waiting, the card says "2 of 3" beside its title.
87
+ */
88
+ index?: number | undefined;
89
+ /** How many approvals are waiting, this one among them. */
90
+ count?: number | undefined;
91
+ /**
92
+ * Asks for another of those waiting. Given, the card has buttons to the one before and
93
+ * the one after, wrapping round at the ends; show the approval at the index it is called
94
+ * with.
95
+ */
96
+ onindexchange?: ((index: number) => void) | undefined;
97
+ /** How the position is said, from the index counted from 0: "2 of 3". */
98
+ positionLabel?: ((index: number, count: number) => string) | undefined;
99
+ /** Names of the buttons to the others. */
100
+ labels?: Partial<Record<'previous' | 'next', string>> | undefined;
73
101
  /** More detail inside the card. */
74
102
  children?: Snippet | undefined;
75
103
  sx?: Sx | undefined;
@@ -96,13 +124,27 @@
96
124
  transitionDuration: motion.slow,
97
125
  transitionTimingFunction: motion.easeOut
98
126
  },
99
- title: { margin: 0, fontSize: font.sizeBody, fontWeight: font.weightSemibold },
127
+ compact: { gap: space.x2, padding: d('0.625rem') },
128
+ head: { display: 'flex', alignItems: 'center', gap: space.x2, minWidth: 0 },
129
+ title: {
130
+ flexGrow: 1,
131
+ minWidth: 0,
132
+ margin: 0,
133
+ fontSize: font.sizeBody,
134
+ fontWeight: font.weightSemibold
135
+ },
136
+ position: { flexShrink: 0 },
137
+ // Tight to the position, as one control; they take no more height than the title
138
+ nav: { display: 'flex', flexShrink: 0, marginBlock: d('-0.25rem') },
139
+ previous: { display: 'grid', rotate: { default: '90deg', ':dir(rtl)': '-90deg' } },
140
+ next: { display: 'grid', rotate: { default: '-90deg', ':dir(rtl)': '90deg' } },
100
141
  reason: {
101
142
  margin: 0,
102
143
  color: colors.textMuted,
103
144
  fontSize: font.sizeBody,
104
145
  lineHeight: font.leadingNormal
105
146
  },
147
+ reasonCompact: { fontSize: font.sizeMeta, lineHeight: font.leadingSnug },
106
148
  command: {
107
149
  margin: 0,
108
150
  paddingBlock: d('0.5rem'),
@@ -116,6 +158,13 @@
116
158
  overflowWrap: 'anywhere',
117
159
  userSelect: 'text'
118
160
  },
161
+ // One line that scrolls sideways, rather than a block that grows
162
+ commandCompact: {
163
+ paddingBlock: d('0.3125rem'),
164
+ paddingInline: d('0.5rem'),
165
+ whiteSpace: 'pre',
166
+ overflowWrap: 'normal'
167
+ },
119
168
  prompt: { color: colors.textSubtle, userSelect: 'none' },
120
169
  files: {
121
170
  margin: 0,
@@ -126,7 +175,18 @@
126
175
  fontSize: font.sizeCaption,
127
176
  lineHeight: 1.7
128
177
  },
178
+ // The files run on, set apart by room, rather than a line each
179
+ filesCompact: {
180
+ display: 'flex',
181
+ flexWrap: 'wrap',
182
+ columnGap: space.x3,
183
+ paddingInlineStart: 0,
184
+ listStyleType: 'none',
185
+ lineHeight: font.leadingSnug
186
+ },
187
+ file: { minWidth: 0, overflowWrap: 'anywhere' },
129
188
  actions: { display: 'flex', flexWrap: 'wrap', gap: space.x2 },
189
+ actionsCompact: { gap: space.x1 },
130
190
  answered: {
131
191
  display: 'flex',
132
192
  alignItems: 'center',
@@ -153,6 +213,22 @@
153
213
  fontSize: font.sizeCaption
154
214
  }
155
215
  });
216
+
217
+ /**
218
+ * Whether the person has typed something where a key was pressed: a textarea or an input
219
+ * with words in it, or an editor of the app's own (ProseMirror, Lexical, a contenteditable),
220
+ * whose words are its editing host's text. An editor's placeholder is drawn by CSS or an
221
+ * attribute, so an empty editor has none.
222
+ */
223
+ function hasTypedWords(target: EventTarget | null): boolean {
224
+ if (target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement) {
225
+ return target.value.trim() !== '';
226
+ }
227
+ if (!(target instanceof HTMLElement) || !target.isContentEditable) return false;
228
+ let host = target;
229
+ while (host.parentElement?.isContentEditable) host = host.parentElement;
230
+ return (host.textContent ?? '').trim() !== '';
231
+ }
156
232
  </script>
157
233
 
158
234
  <script lang="ts">
@@ -166,6 +242,12 @@
166
242
  answer,
167
243
  busy = false,
168
244
  subject,
245
+ compact = false,
246
+ index = 0,
247
+ count = 1,
248
+ onindexchange,
249
+ positionLabel = (index, count) => `${index + 1} of ${count}`,
250
+ labels,
169
251
  children,
170
252
  sx,
171
253
  class: className
@@ -178,6 +260,16 @@
178
260
  // The choice last made, which spins while the answer is on its way
179
261
  let chosen = $state<string>();
180
262
 
263
+ const several = $derived(count > 1);
264
+ const position = $derived(positionLabel(index, count));
265
+ // Once the buttons have shown another, where it went and what it asks is read out
266
+ let moved = $state(false);
267
+
268
+ function show(step: -1 | 1) {
269
+ moved = true;
270
+ onindexchange?.((((index + step) % count) + count) % count);
271
+ }
272
+
181
273
  function choose(value: string) {
182
274
  if (busy) return;
183
275
  // The buttons are about to go; focus follows to what replaces them
@@ -205,10 +297,7 @@
205
297
  const mod = event.metaKey || event.ctrlKey;
206
298
  const inside = card.contains(document.activeElement);
207
299
  // Words already typed are being sent: the key is the field's, not the card's
208
- const target = event.target;
209
- const typed =
210
- (target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement) &&
211
- target.value.trim() !== '';
300
+ const typed = hasTypedWords(event.target);
212
301
  const choice = choices.find((choice) => {
213
302
  if (!choice.shortcut || event.key !== KEY[choice.shortcut]) return false;
214
303
  return choice.shortcut.startsWith('mod+') ? mod && !typed : !mod && inside;
@@ -253,27 +342,72 @@
253
342
  bind:this={card}
254
343
  role="group"
255
344
  aria-labelledby="{uid}-title"
345
+ aria-describedby={several ? `${uid}-position` : undefined}
256
346
  data-slot="approval"
347
+ data-compact={compact || undefined}
257
348
  aria-busy={busy || undefined}
258
349
  data-shortcuts={choices.some((choice) => choice.shortcut) || undefined}
259
- {...attrs([styles.card, sx], className)}
350
+ {...attrs([styles.card, compact && styles.compact, sx], className)}
260
351
  >
261
- <p id="{uid}-title" {...stylex.attrs(styles.title)}>{title}</p>
262
- {#if reason}<p {...stylex.attrs(styles.reason)}>{reason}</p>{/if}
352
+ <div {...stylex.attrs(styles.head)}>
353
+ <p id="{uid}-title" {...stylex.attrs(styles.title)}>{title}</p>
354
+ {#if several}
355
+ <span
356
+ id="{uid}-position"
357
+ data-slot="approval-position"
358
+ {...stylex.attrs(shared.eyebrow, styles.position)}>{position}</span
359
+ >
360
+ {#if onindexchange}
361
+ {@const previous = labels?.previous ?? 'Previous approval'}
362
+ {@const next = labels?.next ?? 'Next approval'}
363
+ <span {...stylex.attrs(styles.nav)}>
364
+ <Button
365
+ variant="ghost"
366
+ size="xs"
367
+ iconOnly
368
+ aria-label={previous}
369
+ tooltip={previous}
370
+ onclick={() => show(-1)}
371
+ >
372
+ <span {...stylex.attrs(styles.previous)}><Glyph name="chevron" /></span>
373
+ </Button>
374
+ <Button
375
+ variant="ghost"
376
+ size="xs"
377
+ iconOnly
378
+ aria-label={next}
379
+ tooltip={next}
380
+ onclick={() => show(1)}
381
+ >
382
+ <span {...stylex.attrs(styles.next)}><Glyph name="chevron" /></span>
383
+ </Button>
384
+ </span>
385
+ {/if}
386
+ {/if}
387
+ </div>
388
+ {#if several && onindexchange}
389
+ <span role="status" {...stylex.attrs(visuallyHidden)}
390
+ >{moved ? `${position}, ${title}` : ''}</span
391
+ >
392
+ {/if}
393
+ {#if reason}<p {...stylex.attrs(styles.reason, compact && styles.reasonCompact)}>
394
+ {reason}
395
+ </p>{/if}
263
396
  {#if command}
264
- <pre {...stylex.attrs(styles.command)}><span {...stylex.attrs(styles.prompt)}
397
+ <pre {...stylex.attrs(styles.command, compact && styles.commandCompact)}><span
398
+ {...stylex.attrs(styles.prompt)}
265
399
  >$ </span>{command}</pre>
266
400
  {/if}
267
401
  {#if files?.length}
268
- <ul {...stylex.attrs(styles.files)}>
269
- {#each files as file (file)}<li>{file}</li>{/each}
402
+ <ul {...stylex.attrs(styles.files, compact && styles.filesCompact)}>
403
+ {#each files as file (file)}<li {...stylex.attrs(styles.file)}>{file}</li>{/each}
270
404
  </ul>
271
405
  {/if}
272
406
  {@render children?.()}
273
- <div {...stylex.attrs(styles.actions)}>
407
+ <div {...stylex.attrs(styles.actions, compact && styles.actionsCompact)}>
274
408
  {#each choices as choice (choice.value)}
275
409
  <Button
276
- size="sm"
410
+ size={compact ? 'xs' : 'sm'}
277
411
  variant={choice.primary
278
412
  ? 'primary'
279
413
  : choice.tone === 'danger'
@@ -40,6 +40,28 @@ export type ApprovalProps = {
40
40
  busy?: boolean | undefined;
41
41
  /** What the folded line names after the answer, such as the command. */
42
42
  subject?: string | undefined;
43
+ /**
44
+ * Tighter, for the composer's tray: less room in and around its parts, the command on
45
+ * one line that scrolls sideways, the files run on in one paragraph, smaller buttons.
46
+ */
47
+ compact?: boolean | undefined;
48
+ /**
49
+ * Where this approval is among those waiting, counted from 0, with `count`. With more
50
+ * than one waiting, the card says "2 of 3" beside its title.
51
+ */
52
+ index?: number | undefined;
53
+ /** How many approvals are waiting, this one among them. */
54
+ count?: number | undefined;
55
+ /**
56
+ * Asks for another of those waiting. Given, the card has buttons to the one before and
57
+ * the one after, wrapping round at the ends; show the approval at the index it is called
58
+ * with.
59
+ */
60
+ onindexchange?: ((index: number) => void) | undefined;
61
+ /** How the position is said, from the index counted from 0: "2 of 3". */
62
+ positionLabel?: ((index: number, count: number) => string) | undefined;
63
+ /** Names of the buttons to the others. */
64
+ labels?: Partial<Record<'previous' | 'next', string>> | undefined;
43
65
  /** More detail inside the card. */
44
66
  children?: Snippet | undefined;
45
67
  sx?: Sx | undefined;
@@ -3,6 +3,7 @@
3
3
  import type { Snippet } from 'svelte';
4
4
  import type { HTMLAttributes } from 'svelte/elements';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
+ import { monogram } from '../../typography.js';
6
7
  import { getAvatarContext } from './context.js';
7
8
 
8
9
  export type AvatarFallbackProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
@@ -44,7 +45,7 @@
44
45
  <span
45
46
  data-slot="avatar-fallback"
46
47
  {...rest}
47
- {...attrs([styles.fallback, children && styles.initials, sx], className)}
48
+ {...attrs([styles.fallback, monogram.letter, children && styles.initials, sx], className)}
48
49
  >
49
50
  {#if children}
50
51
  {@render children()}
@@ -4,6 +4,7 @@
4
4
  import type { HTMLAttributes } from 'svelte/elements';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
6
  import { font, radius } from '../../tokens.stylex.js';
7
+ import { monogram } from '../../typography.js';
7
8
  import { setAvatarContext, type AvatarImageStatus } from './context.js';
8
9
 
9
10
  /** 20, 24, 28, 36 and 56px. */
@@ -58,13 +59,15 @@
58
59
  }
59
60
  });
60
61
 
62
+ // The initials are sized from the avatar's own box (`monogram`), not from a role:
63
+ // 9, 10, 11, 13 and 18px
61
64
  const sizes = stylex.create({
62
65
  // Beside a line of meta text, as in a row of who is in a thread
63
- xs: { width: '1.25rem', height: '1.25rem', fontSize: '0.5625rem' },
64
- sm: { width: '1.5rem', height: '1.5rem', fontSize: '0.625rem' },
65
- md: { width: '1.75rem', height: '1.75rem', fontSize: font.sizeMicro },
66
- lg: { width: '2.25rem', height: '2.25rem', fontSize: font.sizeMeta },
67
- xl: { width: '3.5rem', height: '3.5rem', fontSize: '1.125rem' }
66
+ xs: { width: '1.25rem', height: '1.25rem' },
67
+ sm: { width: '1.5rem', height: '1.5rem' },
68
+ md: { width: '1.75rem', height: '1.75rem' },
69
+ lg: { width: '2.25rem', height: '2.25rem' },
70
+ xl: { width: '3.5rem', height: '3.5rem' }
68
71
  });
69
72
 
70
73
  // Blue through violet to teal: every hue sits comfortably beside the silver-blue accent.
@@ -114,7 +117,7 @@
114
117
  data-slot="avatar"
115
118
  data-status={status}
116
119
  {...rest}
117
- {...attrs([styles.root, sizes[size], sx], className)}
120
+ {...attrs([styles.root, monogram.mark, sizes[size], sx], className)}
118
121
  style:--narvi-avatar-hue={name ? hueOf(name) : undefined}
119
122
  >
120
123
  {@render children?.()}