@diegopluna/narvi 0.3.10 → 0.3.12

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 (107) hide show
  1. package/dist/base.css +38 -0
  2. package/dist/components/activity/ActivityContent.svelte +7 -3
  3. package/dist/components/activity/ActivityStep.svelte +28 -11
  4. package/dist/components/activity/ActivityStep.svelte.d.ts +6 -0
  5. package/dist/components/activity/ActivityTrigger.svelte +5 -2
  6. package/dist/components/app-shell/AppShellBar.svelte +9 -4
  7. package/dist/components/app-shell/AppShellHeader.svelte +9 -5
  8. package/dist/components/approval/Approval.svelte +7 -4
  9. package/dist/components/button/Button.svelte +50 -26
  10. package/dist/components/card/Card.svelte +5 -2
  11. package/dist/components/changes-summary/ChangesSummary.svelte +11 -8
  12. package/dist/components/choice-cards/ChoiceCards.svelte +5 -2
  13. package/dist/components/collapsible/CollapsibleTrigger.svelte +5 -2
  14. package/dist/components/color-field/ColorField.svelte +397 -0
  15. package/dist/components/color-field/ColorField.svelte.d.ts +41 -0
  16. package/dist/components/command/styles.d.ts +8 -9
  17. package/dist/components/command/styles.js +11 -10
  18. package/dist/components/composer/ComposerAttachment.svelte +7 -3
  19. package/dist/components/composer/ComposerAttachments.svelte +5 -1
  20. package/dist/components/composer/ComposerModelPicker.svelte +37 -35
  21. package/dist/components/composer/ComposerRoot.svelte +9 -5
  22. package/dist/components/composer/ComposerTextarea.svelte +9 -6
  23. package/dist/components/composer/ComposerToggle.svelte +7 -4
  24. package/dist/components/composer/ComposerToolbar.svelte +5 -1
  25. package/dist/components/composer/ComposerTray.svelte +10 -7
  26. package/dist/components/conversation/ConversationContent.svelte +0 -2
  27. package/dist/components/conversation/ConversationRoot.svelte +124 -27
  28. package/dist/components/conversation/ConversationScrollButton.svelte +10 -7
  29. package/dist/components/conversation/scrolling.d.ts +18 -4
  30. package/dist/components/conversation/scrolling.js +28 -6
  31. package/dist/components/dialog/ConfirmDialog.svelte +5 -2
  32. package/dist/components/dialog/styles.d.ts +3 -4
  33. package/dist/components/dialog/styles.js +7 -6
  34. package/dist/components/frame/Frame.svelte +8 -5
  35. package/dist/components/hover-card/HoverCardContent.svelte +5 -1
  36. package/dist/components/input/Input.svelte +12 -8
  37. package/dist/components/markdown/MarkdownCode.svelte +0 -1
  38. package/dist/components/markdown/MarkdownDiagram.svelte +1 -2
  39. package/dist/components/markdown/styles.d.ts +0 -2
  40. package/dist/components/markdown/styles.js +0 -2
  41. package/dist/components/message/MessageActions.svelte +8 -4
  42. package/dist/components/message/MessageContent.svelte +6 -2
  43. package/dist/components/message/MessagePending.svelte +5 -2
  44. package/dist/components/message/MessageRoot.svelte +10 -4
  45. package/dist/components/message/MessageTime.svelte +5 -2
  46. package/dist/components/message/styles.d.ts +2 -2
  47. package/dist/components/message/styles.js +5 -3
  48. package/dist/components/notice/Notice.svelte +13 -4
  49. package/dist/components/plan/Plan.svelte +13 -10
  50. package/dist/components/popover/PopoverContent.svelte +8 -1
  51. package/dist/components/questionnaire/Questionnaire.svelte +12 -9
  52. package/dist/components/queued-message/QueuedMessage.svelte +14 -7
  53. package/dist/components/rail/RailItem.svelte +16 -7
  54. package/dist/components/rail/RailRoot.svelte +9 -4
  55. package/dist/components/rail/RailSeparator.svelte +5 -2
  56. package/dist/components/reasoning/ReasoningContent.svelte +6 -3
  57. package/dist/components/reasoning/ReasoningTrigger.svelte +5 -2
  58. package/dist/components/resize-handle/ResizeHandle.svelte +11 -7
  59. package/dist/components/search-button/SearchButton.svelte +6 -3
  60. package/dist/components/segmented/SegmentedControl.svelte +6 -3
  61. package/dist/components/settings-group/SettingsGroup.svelte +5 -2
  62. package/dist/components/sidebar/SidebarContent.svelte +8 -9
  63. package/dist/components/sidebar/SidebarFolder.svelte +8 -5
  64. package/dist/components/sidebar/SidebarFooter.svelte +5 -2
  65. package/dist/components/sidebar/SidebarGroup.svelte +11 -8
  66. package/dist/components/sidebar/SidebarHeader.svelte +9 -4
  67. package/dist/components/sidebar/SidebarItem.svelte +14 -9
  68. package/dist/components/split-button/SplitButton.svelte +5 -2
  69. package/dist/components/suggestions/SuggestionsItem.svelte +6 -3
  70. package/dist/components/suggestions/SuggestionsRoot.svelte +5 -1
  71. package/dist/components/tab-strip/TabStrip.svelte +21 -16
  72. package/dist/components/tabs/Tabs.svelte +7 -4
  73. package/dist/components/textarea/Textarea.svelte +6 -2
  74. package/dist/components/theme/Theme.svelte +32 -3
  75. package/dist/components/toast/Toaster.svelte +14 -5
  76. package/dist/components/toggle-group/ToggleGroupRoot.svelte +5 -1
  77. package/dist/components/tool/ToolContent.svelte +8 -4
  78. package/dist/components/tool/ToolSection.svelte +7 -4
  79. package/dist/components/tool/ToolTrigger.svelte +5 -2
  80. package/dist/components/tooltip/TooltipContent.svelte +7 -4
  81. package/dist/components/work-fold/WorkFold.svelte +9 -6
  82. package/dist/index.d.ts +2 -0
  83. package/dist/index.js +1 -0
  84. package/dist/internal/Code.svelte +6 -4
  85. package/dist/internal/Glyph.svelte +23 -2
  86. package/dist/internal/Glyph.svelte.d.ts +4 -1
  87. package/dist/internal/control.d.ts +6 -6
  88. package/dist/internal/control.js +9 -7
  89. package/dist/internal/hsv.d.ts +18 -0
  90. package/dist/internal/hsv.js +63 -0
  91. package/dist/internal/kinds.d.ts +1 -1
  92. package/dist/internal/kinds.js +3 -3
  93. package/dist/internal/layer.d.ts +10 -11
  94. package/dist/internal/layer.js +14 -13
  95. package/dist/internal/toggle.d.ts +8 -8
  96. package/dist/internal/toggle.js +22 -10
  97. package/dist/preset.d.ts +12 -3
  98. package/dist/preset.js +18 -4
  99. package/dist/tokens.stylex.d.ts +13 -3
  100. package/dist/tokens.stylex.js +25 -14
  101. package/package.json +1 -1
  102. package/skills/building-ui/SKILL.md +1 -1
  103. package/skills/building-ui/references/components.md +24 -0
  104. package/skills/markdown/SKILL.md +1 -1
  105. package/skills/setup/SKILL.md +9 -3
  106. package/skills/styling/SKILL.md +5 -2
  107. package/skills/theming/SKILL.md +48 -4
@@ -5,7 +5,7 @@
5
5
  import Glyph from '../../internal/Glyph.svelte';
6
6
  import { shared } from '../../internal/shared.js';
7
7
  import { attrs, type Sx } from '../../internal/sx.js';
8
- import { colors, font, motion, radius } from '../../tokens.stylex.js';
8
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
9
9
  import { media } from '../../media.stylex.js';
10
10
  import { useConversation } from './context.js';
11
11
 
@@ -18,21 +18,24 @@
18
18
  children?: Snippet | undefined;
19
19
  };
20
20
 
21
+ /** A length at the window's density (`density` in the tokens). */
22
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
23
+
21
24
  const styles = stylex.create({
22
25
  button: {
23
26
  position: 'absolute',
24
27
  insetInline: 0,
25
- bottom: '1rem',
28
+ bottom: d('1rem'),
26
29
  zIndex: 1,
27
30
  display: 'inline-flex',
28
31
  alignItems: 'center',
29
32
  justifyContent: 'center',
30
33
  gap: '0.375rem',
31
34
  width: 'fit-content',
32
- height: '2rem',
33
- minWidth: '2rem',
35
+ height: d('2rem'),
36
+ minWidth: d('2rem'),
34
37
  marginInline: 'auto',
35
- paddingInline: '0.5rem',
38
+ paddingInline: d('0.5rem'),
36
39
  borderWidth: 0,
37
40
  borderRadius: radius.pill,
38
41
  backgroundColor: colors.bgRaised,
@@ -60,8 +63,8 @@
60
63
  transitionTimingFunction: motion.easeOut
61
64
  },
62
65
  withText: {
63
- paddingInlineStart: '0.625rem',
64
- paddingInlineEnd: '0.75rem'
66
+ paddingInlineStart: d('0.625rem'),
67
+ paddingInlineEnd: d('0.75rem')
65
68
  },
66
69
  hidden: {
67
70
  opacity: 0,
@@ -4,13 +4,20 @@
4
4
  * Content arriving, a code block folding open or the window resizing all move
5
5
  * scrollTop too, and none of them should stop the conversation following. Only
6
6
  * a gesture that means "take me up" does: a wheel or a swipe upward, the keys
7
- * that scroll up, or a drag of the scrollbar. These rules come from Eregion,
7
+ * that scroll up, or a drag of the scrollbar. The gesture lets go on its own,
8
+ * as it happens, not in the scroll it causes: while an agent streams, the
9
+ * conversation moves itself with every chunk, and a scroll that had to wait for
10
+ * a quiet moment never got one. These rules come from Eregion and T3 Code,
8
11
  * where each one fixed a reported jump.
9
12
  */
10
- /** How long a gesture counts as the person's, after they make it. */
13
+ /**
14
+ * How long after an upward gesture the conversation holds off following again, unless the
15
+ * person comes back down: a wheel turned up leaves the view at the end for a frame or more
16
+ * before it moves.
17
+ */
11
18
  export declare const INTENT_WINDOW = 1500;
12
- /** How long after the conversation moves itself its own scroll events are ignored. */
13
- export declare const SELF_SCROLL_WINDOW = 180;
19
+ /** How long after a fold's toggle is pressed the toggle is kept where it was. */
20
+ export declare const TOGGLE_WINDOW = 600;
14
21
  /** How near the end, in pixels, counts as at the end: following picks up again there. */
15
22
  export declare const FOLLOW_BAND = 40;
16
23
  /**
@@ -21,5 +28,12 @@ export declare const FOLLOW_BAND = 40;
21
28
  export declare function scrollsInside(target: EventTarget | null, viewport: HTMLElement, deltaY: number): boolean;
22
29
  /** Whether a key press asks the conversation to scroll up. */
23
30
  export declare function isUpKey(event: KeyboardEvent): boolean;
31
+ /**
32
+ * Whether the pointer or the focus is in a frame inside the conversation, such as a page an agent
33
+ * showed. A frame takes the wheel, so a scroll it passes on comes with no wheel event to read.
34
+ */
35
+ export declare function frameHasInput(viewport: HTMLElement): boolean;
36
+ /** The toggle a click pressed, if it opens or shuts something in place: not a menu's button. */
37
+ export declare function toggleOf(target: EventTarget | null): HTMLElement | null;
24
38
  /** Whether a press landed on the viewport's own scrollbar rather than its content. */
25
39
  export declare function onScrollbar(event: PointerEvent, viewport: HTMLElement): boolean;
@@ -4,15 +4,22 @@
4
4
  * Content arriving, a code block folding open or the window resizing all move
5
5
  * scrollTop too, and none of them should stop the conversation following. Only
6
6
  * a gesture that means "take me up" does: a wheel or a swipe upward, the keys
7
- * that scroll up, or a drag of the scrollbar. These rules come from Eregion,
7
+ * that scroll up, or a drag of the scrollbar. The gesture lets go on its own,
8
+ * as it happens, not in the scroll it causes: while an agent streams, the
9
+ * conversation moves itself with every chunk, and a scroll that had to wait for
10
+ * a quiet moment never got one. These rules come from Eregion and T3 Code,
8
11
  * where each one fixed a reported jump.
9
12
  */
10
- /** Keys that scroll a page up. Shift+Space is handled on its own. */
13
+ /** Keys that scroll a page up, with ⌘ or Ctrl too (⌘↑, Ctrl+Home). Shift+Space on its own. */
11
14
  const UP_KEYS = new Set(['ArrowUp', 'PageUp', 'Home']);
12
- /** How long a gesture counts as the person's, after they make it. */
15
+ /**
16
+ * How long after an upward gesture the conversation holds off following again, unless the
17
+ * person comes back down: a wheel turned up leaves the view at the end for a frame or more
18
+ * before it moves.
19
+ */
13
20
  export const INTENT_WINDOW = 1500;
14
- /** How long after the conversation moves itself its own scroll events are ignored. */
15
- export const SELF_SCROLL_WINDOW = 180;
21
+ /** How long after a fold's toggle is pressed the toggle is kept where it was. */
22
+ export const TOGGLE_WINDOW = 600;
16
23
  /** How near the end, in pixels, counts as at the end: following picks up again there. */
17
24
  export const FOLLOW_BAND = 40;
18
25
  /**
@@ -46,7 +53,22 @@ export function isUpKey(event) {
46
53
  return false;
47
54
  if (event.key === ' ')
48
55
  return event.shiftKey;
49
- return UP_KEYS.has(event.key) && !event.altKey && !event.metaKey && !event.ctrlKey;
56
+ return UP_KEYS.has(event.key);
57
+ }
58
+ /**
59
+ * Whether the pointer or the focus is in a frame inside the conversation, such as a page an agent
60
+ * showed. A frame takes the wheel, so a scroll it passes on comes with no wheel event to read.
61
+ */
62
+ export function frameHasInput(viewport) {
63
+ const focused = document.activeElement;
64
+ return (viewport.querySelector('iframe:hover') !== null ||
65
+ (focused instanceof HTMLIFrameElement && viewport.contains(focused)));
66
+ }
67
+ /** The toggle a click pressed, if it opens or shuts something in place: not a menu's button. */
68
+ export function toggleOf(target) {
69
+ return target instanceof Element
70
+ ? target.closest('[aria-expanded]:not([aria-haspopup])')
71
+ : null;
50
72
  }
51
73
  /** Whether a press landed on the viewport's own scrollbar rather than its content. */
52
74
  export function onScrollbar(event, viewport) {
@@ -11,7 +11,7 @@
11
11
  import { AlertDialog } from 'bits-ui';
12
12
  import * as stylex from '@stylexjs/stylex';
13
13
  import type { Snippet } from 'svelte';
14
- import { colors, font, space } from '../../tokens.stylex.js';
14
+ import { colors, density, font, space } from '../../tokens.stylex.js';
15
15
  import Button from '../button/Button.svelte';
16
16
  import Notice from '../notice/Notice.svelte';
17
17
  import { dialog } from './styles.js';
@@ -47,6 +47,9 @@
47
47
  children?: Snippet | undefined;
48
48
  };
49
49
 
50
+ /** A length at the window's density (`density` in the tokens). */
51
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
52
+
50
53
  const styles = stylex.create({
51
54
  content: { maxWidth: '26rem' },
52
55
  // No close button in the corner, so no room kept for one
@@ -55,7 +58,7 @@
55
58
  empty: { display: 'none' },
56
59
  note: {
57
60
  margin: 0,
58
- marginTop: '0.25rem',
61
+ marginTop: d('0.25rem'),
59
62
  fontSize: font.sizeMeta,
60
63
  lineHeight: font.leadingSnug
61
64
  },
@@ -60,7 +60,7 @@ export declare const dialog: Readonly<{
60
60
  readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 0>;
61
61
  readonly paddingTop: stylex.StyleXClassNameFor<"paddingTop", string>;
62
62
  readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
63
- readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "3.5rem">;
63
+ readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", string>;
64
64
  }>;
65
65
  readonly title: Readonly<{
66
66
  readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
@@ -82,7 +82,6 @@ export declare const dialog: Readonly<{
82
82
  readonly overscrollBehavior: stylex.StyleXClassNameFor<"overscrollBehavior", "contain">;
83
83
  readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", string>;
84
84
  readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
85
- readonly scrollbarWidth: stylex.StyleXClassNameFor<"scrollbarWidth", "thin">;
86
85
  }>;
87
86
  readonly footer: Readonly<{
88
87
  readonly display: stylex.StyleXClassNameFor<"display", "flex">;
@@ -96,7 +95,7 @@ export declare const dialog: Readonly<{
96
95
  }>;
97
96
  readonly close: Readonly<{
98
97
  readonly position: stylex.StyleXClassNameFor<"position", "absolute">;
99
- readonly top: stylex.StyleXClassNameFor<"top", "0.875rem">;
100
- readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", "0.875rem">;
98
+ readonly top: stylex.StyleXClassNameFor<"top", string>;
99
+ readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", string>;
101
100
  }>;
102
101
  }>;
@@ -1,7 +1,9 @@
1
1
  import * as stylex from '@stylexjs/stylex';
2
- import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
2
+ import { colors, density, font, motion, radius, space } from '../../tokens.stylex.js';
3
3
  import { media } from '../../media.stylex.js';
4
4
  const CLOSED = ':is([data-state="closed"])';
5
+ /** A length at the window's density (`density` in the tokens). */
6
+ const d = (rem) => `calc(${rem} * ${density.factor})`;
5
7
  export const dialog = stylex.create({
6
8
  overlay: {
7
9
  position: 'fixed',
@@ -62,7 +64,7 @@ export const dialog = stylex.create({
62
64
  paddingTop: space.x6,
63
65
  paddingInline: space.x6,
64
66
  // Room for the close button in the corner
65
- paddingInlineEnd: '3.5rem'
67
+ paddingInlineEnd: d('3.5rem')
66
68
  },
67
69
  title: {
68
70
  margin: 0,
@@ -83,8 +85,7 @@ export const dialog = stylex.create({
83
85
  overflowY: 'auto',
84
86
  overscrollBehavior: 'contain',
85
87
  paddingBlock: space.x4,
86
- paddingInline: space.x6,
87
- scrollbarWidth: 'thin'
88
+ paddingInline: space.x6
88
89
  },
89
90
  footer: {
90
91
  display: 'flex',
@@ -98,7 +99,7 @@ export const dialog = stylex.create({
98
99
  },
99
100
  close: {
100
101
  position: 'absolute',
101
- top: '0.875rem',
102
- insetInlineEnd: '0.875rem'
102
+ top: d('0.875rem'),
103
+ insetInlineEnd: d('0.875rem')
103
104
  }
104
105
  });
@@ -4,7 +4,7 @@
4
4
  import type { HTMLAttributes } from 'svelte/elements';
5
5
  import { shared } from '../../internal/shared.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
- import { colors, font, radius } from '../../tokens.stylex.js';
7
+ import { colors, density, font, radius } from '../../tokens.stylex.js';
8
8
 
9
9
  export type FrameProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'title'> & {
10
10
  /** Element to render. */
@@ -20,6 +20,9 @@
20
20
  children?: Snippet | undefined;
21
21
  };
22
22
 
23
+ /** A length at the window's density (`density` in the tokens). */
24
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
25
+
23
26
  const styles = stylex.create({
24
27
  // A tray around an inset panel: a flat fill, so the panel's own edge is the only line.
25
28
  // Its radius is the Card's radius plus this padding.
@@ -37,10 +40,10 @@
37
40
  header: {
38
41
  display: 'flex',
39
42
  alignItems: 'center',
40
- gap: '0.625rem',
41
- paddingTop: '0.6875rem',
42
- paddingBottom: '0.75rem',
43
- paddingInline: '0.75rem'
43
+ gap: d('0.625rem'),
44
+ paddingTop: d('0.6875rem'),
45
+ paddingBottom: d('0.75rem'),
46
+ paddingInline: d('0.75rem')
44
47
  },
45
48
  title: {
46
49
  flexGrow: 1,
@@ -2,6 +2,7 @@
2
2
  import type { Loose } from '../../internal/loose.js';
3
3
  import { LinkPreview } from 'bits-ui';
4
4
  import * as stylex from '@stylexjs/stylex';
5
+ import { density } from '../../tokens.stylex.js';
5
6
  import type { Snippet } from 'svelte';
6
7
  import { layer } from '../../internal/layer.js';
7
8
  import { attrs, type Sx } from '../../internal/sx.js';
@@ -17,12 +18,15 @@
17
18
  }
18
19
  >;
19
20
 
21
+ /** A length at the window's density (`density` in the tokens). */
22
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
23
+
20
24
  const styles = stylex.create({
21
25
  // A card of its own content: a preview of a thread, a file, a person
22
26
  card: {
23
27
  width: '20rem',
24
28
  minWidth: 0,
25
- padding: '0.75rem'
29
+ padding: d('0.75rem')
26
30
  },
27
31
  bare: { padding: 0 }
28
32
  });
@@ -3,7 +3,7 @@
3
3
  import type { Snippet } from 'svelte';
4
4
  import type { ClassValue, HTMLInputAttributes } from 'svelte/elements';
5
5
  import '../../internal/icons.css';
6
- import { colors } from '../../tokens.stylex.js';
6
+ import { colors, density } from '../../tokens.stylex.js';
7
7
  import { control, type ControlSize } from '../../internal/control.js';
8
8
  import { attrs, type Sx } from '../../internal/sx.js';
9
9
  import { getFieldContext } from '../field/context.js';
@@ -31,6 +31,9 @@
31
31
  ref?: HTMLInputElement | null | undefined;
32
32
  };
33
33
 
34
+ /** A length at the window's density (`density` in the tokens). */
35
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
36
+
34
37
  const styles = stylex.create({
35
38
  frame: { position: 'relative', display: 'block', width: '100%', minWidth: 0 },
36
39
  // In the field's start padding, where the pointer passes through to the field
@@ -42,13 +45,14 @@
42
45
  color: colors.textSubtle,
43
46
  pointerEvents: 'none'
44
47
  },
45
- iconSm: { '--narvi-icon-size': '0.875rem', insetInlineStart: '8px' },
46
- iconMd: { '--narvi-icon-size': '1rem', insetInlineStart: '10px' },
47
- iconLg: { '--narvi-icon-size': '1rem', insetInlineStart: '12px' },
48
- // The text starts after the icon: its inset, its size and a gap of 6px
49
- besideSm: { paddingInlineStart: '28px' },
50
- besideMd: { paddingInlineStart: '32px' },
51
- besideLg: { paddingInlineStart: '34px' }
48
+ iconSm: { '--narvi-icon-size': '0.875rem', insetInlineStart: d('0.5rem') },
49
+ iconMd: { '--narvi-icon-size': '1rem', insetInlineStart: d('0.625rem') },
50
+ iconLg: { '--narvi-icon-size': '1rem', insetInlineStart: d('0.75rem') },
51
+ // The text starts after the icon: its inset, which follows the density, then its size and a
52
+ // gap of 6px, which keep theirs
53
+ besideSm: { paddingInlineStart: `calc(${d('0.5rem')} + 1.25rem)` },
54
+ besideMd: { paddingInlineStart: `calc(${d('0.625rem')} + 1.375rem)` },
55
+ besideLg: { paddingInlineStart: `calc(${d('0.75rem')} + 1.375rem)` }
52
56
  });
53
57
 
54
58
  const iconStyles = { sm: styles.iconSm, md: styles.iconMd, lg: styles.iconLg };
@@ -79,7 +79,6 @@
79
79
  lineHeight: 1.6,
80
80
  tabSize: 2,
81
81
  whiteSpace: 'pre',
82
- scrollbarWidth: 'thin',
83
82
  // Code that is off the screen is not laid out until it comes near. Code is most of
84
83
  // the elements of a reply that has any, and a long reply is mostly off the screen.
85
84
  // Until then the block is as tall as its lines make it, which is known without
@@ -136,8 +136,7 @@
136
136
  justifyContent: 'safe center',
137
137
  paddingBlockEnd: '0.75rem',
138
138
  paddingInline: '0.75rem',
139
- overflowX: 'auto',
140
- scrollbarWidth: 'thin'
139
+ overflowX: 'auto'
141
140
  },
142
141
  hidden: { display: 'none' },
143
142
  actions: { display: 'inline-flex', gap: '0.125rem' },
@@ -210,7 +210,6 @@ export declare const prose: Readonly<{
210
210
  readonly overflowY: stylex.StyleXClassNameFor<"overflowY", "hidden">;
211
211
  readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", "0.25em">;
212
212
  readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "center">;
213
- readonly scrollbarWidth: stylex.StyleXClassNameFor<"scrollbarWidth", "thin">;
214
213
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
215
214
  readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
216
215
  readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", 0 | "2px">;
@@ -238,7 +237,6 @@ export declare const prose: Readonly<{
238
237
  readonly overflowY: stylex.StyleXClassNameFor<"overflowY", "hidden">;
239
238
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
240
239
  readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", `inset 0 0 0 1px ${stylex.StyleXVar<string>}`>;
241
- readonly scrollbarWidth: stylex.StyleXClassNameFor<"scrollbarWidth", "thin">;
242
240
  readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
243
241
  readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "1px">;
244
242
  readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", "transparent">;
@@ -187,7 +187,6 @@ export const prose = stylex.create({
187
187
  overflowY: 'hidden',
188
188
  paddingBlock: '0.25em',
189
189
  textAlign: 'center',
190
- scrollbarWidth: 'thin',
191
190
  borderRadius: radius.chip,
192
191
  outlineStyle: 'solid',
193
192
  outlineWidth: { default: 0, ':focus-visible': '2px' },
@@ -218,7 +217,6 @@ export const prose = stylex.create({
218
217
  overflowY: 'hidden',
219
218
  borderRadius: radius.control,
220
219
  boxShadow: `inset 0 0 0 1px ${colors.border}`,
221
- scrollbarWidth: 'thin',
222
220
  outlineStyle: 'solid',
223
221
  outlineWidth: '1px',
224
222
  outlineColor: 'transparent',
@@ -4,7 +4,7 @@
4
4
  import type { HTMLAttributes } from 'svelte/elements';
5
5
  import { messageMarker } from '../../internal/markers.stylex.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
- import { motion } from '../../tokens.stylex.js';
7
+ import { density, motion } from '../../tokens.stylex.js';
8
8
  import { media } from '../../media.stylex.js';
9
9
  import { getMessageContext } from './context.js';
10
10
 
@@ -22,14 +22,18 @@
22
22
  children?: Snippet | undefined;
23
23
  };
24
24
 
25
+ /** A length at the window's density (`density` in the tokens). */
26
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
27
+
25
28
  const styles = stylex.create({
26
29
  actions: {
27
30
  display: 'flex',
28
31
  alignItems: 'center',
29
- gap: '2px'
32
+ gap: d('0.125rem')
30
33
  },
31
- // The buttons' icons line up with the edge of the text above them
32
- assistant: { marginInlineStart: '-6px' },
34
+ // The buttons' icons line up with the edge of the text above them. The buttons follow the
35
+ // density and their 14px icons do not, so the room around an icon changes with it.
36
+ assistant: { marginInlineStart: `calc((0.875rem - ${d('1.75rem')}) / 2 + 1px)` },
33
37
  user: { marginInlineEnd: '-2px' },
34
38
  // Revealed on hover. The space stays, so nothing shifts when they appear.
35
39
  hover: {
@@ -1,5 +1,6 @@
1
1
  <script lang="ts" module>
2
2
  import * as stylex from '@stylexjs/stylex';
3
+ import { density } from '../../tokens.stylex.js';
3
4
  import type { Snippet } from 'svelte';
4
5
  import type { HTMLAttributes } from 'svelte/elements';
5
6
  import { shared } from '../../internal/shared.js';
@@ -20,12 +21,15 @@
20
21
  children?: Snippet | undefined;
21
22
  };
22
23
 
24
+ /** A length at the window's density (`density` in the tokens). */
25
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
26
+
23
27
  const styles = stylex.create({
24
28
  content: {
25
29
  boxSizing: 'border-box',
26
30
  display: 'flex',
27
31
  flexDirection: 'column',
28
- gap: '0.75rem',
32
+ gap: d('0.75rem'),
29
33
  minWidth: 0,
30
34
  overflowWrap: 'break-word'
31
35
  },
@@ -33,7 +37,7 @@
33
37
  around: {
34
38
  alignItems: 'flex-end',
35
39
  alignSelf: 'stretch',
36
- gap: '0.5rem'
40
+ gap: d('0.5rem')
37
41
  },
38
42
  assistant: {
39
43
  width: '100%'
@@ -8,7 +8,7 @@
8
8
  import type { HTMLAttributes } from 'svelte/elements';
9
9
  import { attrs, type Sx } from '../../internal/sx.js';
10
10
  import Tile from '../../internal/Tile.svelte';
11
- import { colors, font, motion } from '../../tokens.stylex.js';
11
+ import { colors, density, font, motion } from '../../tokens.stylex.js';
12
12
  import Shimmer from '../shimmer/Shimmer.svelte';
13
13
 
14
14
  export type MessagePendingProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
@@ -17,12 +17,15 @@
17
17
  sx?: Sx | undefined;
18
18
  };
19
19
 
20
+ /** A length at the window's density (`density` in the tokens). */
21
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
22
+
20
23
  const styles = stylex.create({
21
24
  row: {
22
25
  display: 'flex',
23
26
  alignItems: 'center',
24
27
  gap: '0.625rem',
25
- minHeight: '1.75rem',
28
+ minHeight: d('1.75rem'),
26
29
  color: colors.textMuted,
27
30
  fontSize: font.sizeBody,
28
31
  lineHeight: 1,
@@ -4,7 +4,7 @@
4
4
  import type { HTMLAttributes } from 'svelte/elements';
5
5
  import { messageMarker } from '../../internal/markers.stylex.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
- import { colors, font } from '../../tokens.stylex.js';
7
+ import { colors, density, font } from '../../tokens.stylex.js';
8
8
  import { media } from '../../media.stylex.js';
9
9
  import { setMessageContext, type MessageFrom } from './context.js';
10
10
  import type { MessageTextSize } from './styles.js';
@@ -31,11 +31,14 @@
31
31
  children?: Snippet | undefined;
32
32
  };
33
33
 
34
+ /** A length at the window's density (`density` in the tokens). */
35
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
36
+
34
37
  const styles = stylex.create({
35
38
  root: {
36
39
  display: 'flex',
37
40
  flexDirection: 'column',
38
- gap: '0.375rem',
41
+ gap: d('0.375rem'),
39
42
  minWidth: 0,
40
43
  color: colors.text,
41
44
  fontFamily: font.body
@@ -50,8 +53,11 @@
50
53
  default: 'column',
51
54
  [media.hover]: { default: 'row-reverse', [HOLDS_MORE]: 'column' }
52
55
  },
53
- gap: { default: '0.375rem', [media.hover]: { default: '0.25rem', [HOLDS_MORE]: '0.375rem' } },
54
- marginBlockStart: { default: '1.5rem', ':first-child': 0 }
56
+ gap: {
57
+ default: d('0.375rem'),
58
+ [media.hover]: { default: d('0.25rem'), [HOLDS_MORE]: d('0.375rem') }
59
+ },
60
+ marginBlockStart: { default: d('1.5rem'), ':first-child': 0 }
55
61
  },
56
62
  assistant: { alignItems: 'stretch' }
57
63
  });
@@ -6,7 +6,7 @@
6
6
  import * as stylex from '@stylexjs/stylex';
7
7
  import { messageMarker } from '../../internal/markers.stylex.js';
8
8
  import { attrs, type Sx } from '../../internal/sx.js';
9
- import { colors, font, motion } from '../../tokens.stylex.js';
9
+ import { colors, density, font, motion } from '../../tokens.stylex.js';
10
10
  import { media } from '../../media.stylex.js';
11
11
 
12
12
  export type MessageTimeProps = {
@@ -18,9 +18,12 @@
18
18
  class?: string | undefined;
19
19
  };
20
20
 
21
+ /** A length at the window's density (`density` in the tokens). */
22
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
23
+
21
24
  const styles = stylex.create({
22
25
  time: {
23
- paddingInline: '0.375rem',
26
+ paddingInline: d('0.375rem'),
24
27
  color: colors.textSubtle,
25
28
  fontSize: font.sizeCaption,
26
29
  fontVariantNumeric: 'tabular-nums',
@@ -20,8 +20,8 @@ export declare const bubble: Readonly<{
20
20
  readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
21
21
  readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "min(85%, 36rem)">;
22
22
  readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
23
- readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", "0.5625rem">;
24
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.875rem">;
23
+ readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", string>;
24
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
25
25
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
26
26
  readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
27
27
  readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "pre-wrap">;
@@ -3,7 +3,9 @@
3
3
  * they are read at, and the person's bubble.
4
4
  */
5
5
  import * as stylex from '@stylexjs/stylex';
6
- import { colors, font, radius } from '../../tokens.stylex.js';
6
+ import { colors, density, font, radius } from '../../tokens.stylex.js';
7
+ /** A length at the window's density (`density` in the tokens). */
8
+ const d = (rem) => `calc(${rem} * ${density.factor})`;
7
9
  export const text = stylex.create({
8
10
  reading: { fontSize: font.sizeReading, lineHeight: font.leadingNormal },
9
11
  body: { fontSize: font.sizeBody, lineHeight: font.leadingNormal }
@@ -14,8 +16,8 @@ export const bubble = stylex.create({
14
16
  boxSizing: 'border-box',
15
17
  maxWidth: 'min(85%, 36rem)',
16
18
  minWidth: 0,
17
- paddingBlock: '0.5625rem',
18
- paddingInline: '0.875rem',
19
+ paddingBlock: d('0.5625rem'),
20
+ paddingInline: d('0.875rem'),
19
21
  borderRadius: radius.frame,
20
22
  backgroundColor: colors.fillMuted,
21
23
  whiteSpace: 'pre-wrap',
@@ -9,7 +9,7 @@
9
9
  import Glyph from '../../internal/Glyph.svelte';
10
10
  import { shared } from '../../internal/shared.js';
11
11
  import { attrs, type Sx } from '../../internal/sx.js';
12
- import { colors, font, radius } from '../../tokens.stylex.js';
12
+ import { colors, density, font, radius } from '../../tokens.stylex.js';
13
13
  import Spinner from '../spinner/Spinner.svelte';
14
14
 
15
15
  export type NoticeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
@@ -39,14 +39,17 @@
39
39
  children?: Snippet | undefined;
40
40
  };
41
41
 
42
+ /** A length at the window's density (`density` in the tokens). */
43
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
44
+
42
45
  const styles = stylex.create({
43
46
  notice: {
44
47
  display: 'grid',
45
48
  gridTemplateColumns: 'auto minmax(0, 1fr) auto',
46
49
  alignItems: 'start',
47
50
  columnGap: '0.625rem',
48
- paddingBlock: '0.625rem',
49
- paddingInline: '0.75rem',
51
+ paddingBlock: d('0.625rem'),
52
+ paddingInline: d('0.75rem'),
50
53
  borderRadius: radius.panel,
51
54
  fontSize: font.sizeBody,
52
55
  lineHeight: font.leadingSnug
@@ -86,7 +89,13 @@
86
89
  userSelect: 'text',
87
90
  overflowWrap: 'anywhere'
88
91
  },
89
- actions: { display: 'flex', alignItems: 'center', gap: '0.25rem', marginBlock: '-0.25rem' }
92
+ // Small buttons take no more room than the first line, about 20px, at any density
93
+ actions: {
94
+ display: 'flex',
95
+ alignItems: 'center',
96
+ gap: d('0.25rem'),
97
+ marginBlock: `calc((1.25rem - ${d('1.75rem')}) / 2)`
98
+ }
90
99
  });
91
100
  </script>
92
101