@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 Chevron from '../../internal/Chevron.svelte';
6
6
  import Collapse from '../../internal/Collapse.svelte';
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 { setSidebarFold } from './fold.js';
11
11
 
@@ -32,18 +32,21 @@
32
32
  children?: Snippet | undefined;
33
33
  };
34
34
 
35
+ /** A length at the window's density (`density` in the tokens). */
36
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
37
+
35
38
  const styles = stylex.create({
36
- group: { display: 'flex', flexDirection: 'column', paddingTop: '0.75rem' },
39
+ group: { display: 'flex', flexDirection: 'column', paddingTop: d('0.75rem') },
37
40
  // Rows with no label over them start closer to what is above
38
- bare: { paddingTop: '0.375rem' },
41
+ bare: { paddingTop: d('0.375rem') },
39
42
  head: {
40
43
  display: 'flex',
41
44
  alignItems: 'center',
42
- gap: '0.25rem',
43
- minHeight: '1.75rem',
45
+ gap: d('0.25rem'),
46
+ minHeight: d('1.75rem'),
44
47
  // The rows' own inset at both ends: the label starts where their titles do, and the
45
48
  // actions end where their trailing column does
46
- paddingInline: '0.5rem'
49
+ paddingInline: d('0.5rem')
47
50
  },
48
51
  label: {
49
52
  display: 'inline-flex',
@@ -82,7 +85,7 @@
82
85
  '--narvi-icon-flush': 1,
83
86
  display: 'flex',
84
87
  alignItems: 'center',
85
- gap: '0.25rem',
88
+ gap: d('0.25rem'),
86
89
  flexShrink: 0
87
90
  },
88
91
  list: {
@@ -91,7 +94,7 @@
91
94
  gap: '1px',
92
95
  margin: 0,
93
96
  padding: 0,
94
- paddingTop: '0.125rem',
97
+ paddingTop: d('0.125rem'),
95
98
  listStyleType: 'none'
96
99
  }
97
100
  });
@@ -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';
@@ -15,18 +16,22 @@
15
16
  children?: Snippet | undefined;
16
17
  };
17
18
 
19
+ /** A length at the window's density (`density` in the tokens). */
20
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
21
+
18
22
  const styles = stylex.create({
19
23
  header: {
20
24
  display: 'flex',
21
25
  alignItems: 'center',
22
- gap: '0.25rem',
26
+ gap: d('0.25rem'),
23
27
  boxSizing: 'border-box',
24
28
  flexShrink: 0,
25
29
  // The same height as AppShell.Header, so the columns' heads sit on one line
26
30
  height: '3rem',
27
- // The usual edge, or clear of the traffic lights in a shell with no bar
28
- paddingInlineStart: 'max(1rem, calc(var(--narvi-inset-sidebar, 0px) + 0.5rem))',
29
- paddingInlineEnd: '0.5rem',
31
+ // The usual edge, which follows the rows' inset, or clear of the traffic lights in a
32
+ // shell with no bar
33
+ paddingInlineStart: `max(${d('1rem')}, calc(var(--narvi-inset-sidebar, 0px) + 0.5rem))`,
34
+ paddingInlineEnd: d('0.5rem'),
30
35
  whiteSpace: 'nowrap'
31
36
  }
32
37
  });
@@ -17,7 +17,7 @@
17
17
  import type { HTMLAnchorAttributes, HTMLAttributes } from 'svelte/elements';
18
18
  import { sidebarItemMarker } from '../../internal/markers.stylex.js';
19
19
  import { attrs, type Sx } from '../../internal/sx.js';
20
- import { colors, font, motion, radius } from '../../tokens.stylex.js';
20
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
21
21
  import { media } from '../../media.stylex.js';
22
22
  import { visuallyHidden } from '../../visually-hidden.js';
23
23
  import { getSidebarDepth } from './depth.js';
@@ -80,16 +80,19 @@
80
80
  const LIT =
81
81
  ':is([data-state="open"], :has([data-slot="sidebar-item-actions"] [aria-expanded="true"]))';
82
82
 
83
+ /** A length at the window's density (`density` in the tokens). */
84
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
85
+
83
86
  const styles = stylex.create({
84
87
  item: {
85
88
  position: 'relative',
86
89
  listStyleType: 'none',
87
90
  contentVisibility: 'auto',
88
- // Two lines: 50px
89
- containIntrinsicSize: 'auto 3.125rem'
91
+ // Two lines: 50px, of which 12px is padding
92
+ containIntrinsicSize: `auto calc(2.375rem + ${d('0.75rem')})`
90
93
  },
91
94
  // One line: 30px
92
- itemOneLine: { containIntrinsicSize: 'auto 1.875rem' },
95
+ itemOneLine: { containIntrinsicSize: `auto calc(1.125rem + ${d('0.75rem')})` },
93
96
  // Its group or folder is folded, and this is not the open row
94
97
  foldedAway: { display: 'none' },
95
98
  row: {
@@ -105,17 +108,19 @@
105
108
  rowGap: '0.125rem',
106
109
  width: '100%',
107
110
  margin: 0,
108
- paddingBlock: '0.375rem',
109
- paddingInline: '0.5rem',
110
- // In a folder, the title starts where the folder's name does
111
- paddingInlineStart: 'calc(0.5rem + var(--narvi-sidebar-depth, 0) * 1.5rem)',
111
+ paddingBlock: d('0.375rem'),
112
+ paddingInline: d('0.5rem'),
113
+ // In a folder, the title starts where the folder's name does. The step is an icon and
114
+ // its gap, which keep their size.
115
+ paddingInlineStart: `calc(${d('0.5rem')} + var(--narvi-sidebar-depth, 0) * 1.5rem)`,
112
116
  borderWidth: 0,
113
117
  borderRadius: radius.control,
114
118
  backgroundColor: 'transparent',
115
119
  color: colors.text,
116
120
  fontFamily: 'inherit',
117
121
  fontSize: font.sizeMeta,
118
- // A whole number of pixels, so every row is 30px and none sits between pixels
122
+ // A whole number of pixels, so at the default density every row is 30px and none
123
+ // sits between pixels
119
124
  lineHeight: '1.125rem',
120
125
  textAlign: 'start',
121
126
  textDecoration: 'none',
@@ -12,7 +12,7 @@
12
12
  import Glyph from '../../internal/Glyph.svelte';
13
13
  import { attrs, type Sx } from '../../internal/sx.js';
14
14
  import Button, { type ButtonProps, type ButtonShape } from '../button/Button.svelte';
15
- import { colors, space } from '../../tokens.stylex.js';
15
+ import { colors, density, space } from '../../tokens.stylex.js';
16
16
  import * as Menu from '../menu/index.js';
17
17
 
18
18
  export type SplitButtonProps = Omit<
@@ -66,6 +66,9 @@
66
66
  children?: Snippet | undefined;
67
67
  };
68
68
 
69
+ /** A length at the window's density (`density` in the tokens). */
70
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
71
+
69
72
  const styles = stylex.create({
70
73
  group: {
71
74
  display: 'inline-flex',
@@ -104,7 +107,7 @@
104
107
  }
105
108
  },
106
109
  // The chevron's button is a little narrower than a square: it is the lesser half
107
- moreWidth: { paddingInline: '0.375rem' }
110
+ moreWidth: { paddingInline: d('0.375rem') }
108
111
  });
109
112
  </script>
110
113
 
@@ -4,7 +4,7 @@
4
4
  import type { HTMLButtonAttributes } 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, motion, radius } from '../../tokens.stylex.js';
7
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
8
8
  import { media } from '../../media.stylex.js';
9
9
  import { getSuggestionsContext } from './context.js';
10
10
 
@@ -27,15 +27,18 @@
27
27
  to: { opacity: 1 }
28
28
  });
29
29
 
30
+ /** A length at the window's density (`density` in the tokens). */
31
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
32
+
30
33
  const styles = stylex.create({
31
34
  item: {
32
35
  display: 'inline-flex',
33
36
  alignItems: 'center',
34
37
  flexShrink: 0,
35
38
  gap: '0.375rem',
36
- minHeight: '2rem',
39
+ minHeight: d('2rem'),
37
40
  margin: 0,
38
- paddingInline: '0.75rem',
41
+ paddingInline: d('0.75rem'),
39
42
  borderWidth: 0,
40
43
  borderRadius: `calc(${radius.card} * 4 / 3)`,
41
44
  backgroundColor: {
@@ -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 { attrs, type Sx } from '../../internal/sx.js';
@@ -23,13 +24,16 @@
23
24
  children?: Snippet | undefined;
24
25
  };
25
26
 
27
+ /** A length at the window's density (`density` in the tokens). */
28
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
29
+
26
30
  const styles = stylex.create({
27
31
  root: {
28
32
  display: 'flex',
29
33
  // Pills keep their own height, however tall the space they are placed in
30
34
  alignItems: 'flex-start',
31
35
  alignContent: 'flex-start',
32
- gap: '0.5rem',
36
+ gap: d('0.5rem'),
33
37
  minWidth: 0
34
38
  },
35
39
  wrap: {
@@ -25,7 +25,7 @@
25
25
  import * as Menu from '../menu/index.js';
26
26
  import { TabDragging, tabOffset } from './drag.svelte.js';
27
27
  import { attrs, type Sx } from '../../internal/sx.js';
28
- import { colors, font, motion, radius } from '../../tokens.stylex.js';
28
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
29
29
  import { media } from '../../media.stylex.js';
30
30
 
31
31
  export type TabStripTab = {
@@ -109,12 +109,15 @@
109
109
  // One key for every hover, so the catalog can show it without a pointer
110
110
  const HOVER = ':is(:hover, [data-preview~="hover"])';
111
111
 
112
+ /** A length at the window's density (`density` in the tokens). */
113
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
114
+
112
115
  const styles = stylex.create({
113
116
  root: {
114
117
  display: 'flex',
115
118
  alignItems: 'center',
116
119
  // The button to add one stands a little apart from the last tab
117
- gap: '0.375rem',
120
+ gap: d('0.375rem'),
118
121
  minWidth: 0,
119
122
  fontFamily: font.body
120
123
  },
@@ -122,7 +125,7 @@
122
125
  list: {
123
126
  display: 'flex',
124
127
  alignItems: 'center',
125
- gap: '0.125rem',
128
+ gap: d('0.125rem'),
126
129
  minWidth: 0,
127
130
  overflowX: 'auto',
128
131
  overscrollBehaviorX: 'contain',
@@ -185,11 +188,11 @@
185
188
  gap: '0.4375rem',
186
189
  flexGrow: 1,
187
190
  minWidth: 0,
188
- height: '1.75rem',
191
+ height: d('1.75rem'),
189
192
  margin: 0,
190
193
  paddingBlock: 0,
191
- paddingInlineStart: '0.625rem',
192
- paddingInlineEnd: '0.625rem',
194
+ paddingInlineStart: d('0.625rem'),
195
+ paddingInlineEnd: d('0.625rem'),
193
196
  borderWidth: 0,
194
197
  borderRadius: 'inherit',
195
198
  backgroundColor: 'transparent',
@@ -206,8 +209,9 @@
206
209
  outlineColor: colors.focusRing,
207
210
  outlineOffset: '0px'
208
211
  },
209
- // A tab that can be closed keeps room at its end for the button
210
- closable: { paddingInlineEnd: '1.625rem' },
212
+ // A tab that can be closed keeps room at its end for the button: its inset, which follows the
213
+ // density, then the button and a gap, which keep their size
214
+ closable: { paddingInlineEnd: `calc(${d('0.25rem')} + 1.375rem)` },
211
215
  // With buttons of its own, the room for the close button is kept after them
212
216
  buttonBeforeTrailing: { paddingInlineEnd: '0.375rem' },
213
217
  trailing: {
@@ -215,9 +219,9 @@
215
219
  alignItems: 'center',
216
220
  gap: '0.125rem',
217
221
  flexShrink: 0,
218
- paddingInlineEnd: '0.25rem'
222
+ paddingInlineEnd: d('0.25rem')
219
223
  },
220
- trailingBeforeEnd: { paddingInlineEnd: '1.5rem' },
224
+ trailingBeforeEnd: { paddingInlineEnd: `calc(${d('0.25rem')} + 1.25rem)` },
221
225
  // The name, typed in place
222
226
  rename: {
223
227
  boxSizing: 'border-box',
@@ -225,8 +229,8 @@
225
229
  width: '8rem',
226
230
  minWidth: 0,
227
231
  height: '1.25rem',
228
- marginInline: '0.25rem',
229
- paddingInline: '0.375rem',
232
+ marginInline: d('0.25rem'),
233
+ paddingInline: d('0.375rem'),
230
234
  borderWidth: 0,
231
235
  borderRadius: radius.item,
232
236
  backgroundColor: colors.bgRaised,
@@ -264,9 +268,10 @@
264
268
  }
265
269
  },
266
270
  leadMark: { gridArea: '1 / 1' },
271
+ // Centred on the leading icon, which starts after the tab's padding
267
272
  start: {
268
273
  position: 'absolute',
269
- insetInlineStart: '0.5rem',
274
+ insetInlineStart: `calc(${d('0.625rem')} - 0.125rem)`,
270
275
  top: '50%',
271
276
  translate: '0 -50%',
272
277
  display: 'grid',
@@ -291,7 +296,7 @@
291
296
  // with focus inside; until then a mark may stand there.
292
297
  end: {
293
298
  position: 'absolute',
294
- insetInlineEnd: '0.25rem',
299
+ insetInlineEnd: d('0.25rem'),
295
300
  top: '50%',
296
301
  translate: '0 -50%',
297
302
  display: 'grid',
@@ -350,8 +355,8 @@
350
355
  display: 'grid',
351
356
  placeItems: 'center',
352
357
  flexShrink: 0,
353
- width: '1.75rem',
354
- height: '1.75rem',
358
+ width: d('1.75rem'),
359
+ height: d('1.75rem'),
355
360
  margin: 0,
356
361
  padding: 0,
357
362
  borderWidth: 0,
@@ -8,7 +8,7 @@
8
8
  import * as Tooltip from '../tooltip/index.js';
9
9
  import TooltipScope from '../../internal/TooltipScope.svelte';
10
10
  import { attrs, type Sx } from '../../internal/sx.js';
11
- import { colors, font, motion, radius } from '../../tokens.stylex.js';
11
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
12
12
  import { media } from '../../media.stylex.js';
13
13
 
14
14
  export type TabItem = {
@@ -37,6 +37,9 @@
37
37
  children?: Snippet<[string]> | undefined;
38
38
  };
39
39
 
40
+ /** A length at the window's density (`density` in the tokens). */
41
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
42
+
40
43
  const styles = stylex.create({
41
44
  root: {
42
45
  minWidth: 0,
@@ -45,7 +48,7 @@
45
48
  list: {
46
49
  WebkitAppRegion: 'no-drag',
47
50
  display: 'flex',
48
- gap: '1.25rem',
51
+ gap: d('1.25rem'),
49
52
  borderBottomWidth: '1px',
50
53
  borderBottomStyle: 'solid',
51
54
  borderBottomColor: colors.border
@@ -57,7 +60,7 @@
57
60
  alignItems: 'center',
58
61
  gap: '0.375rem',
59
62
  flexShrink: 0,
60
- minHeight: '2.125rem',
63
+ minHeight: d('2.125rem'),
61
64
  margin: 0,
62
65
  padding: 0,
63
66
  borderWidth: 0,
@@ -103,7 +106,7 @@
103
106
  fontVariantNumeric: 'tabular-nums'
104
107
  },
105
108
  panel: {
106
- paddingTop: '0.875rem',
109
+ paddingTop: d('0.875rem'),
107
110
  outlineStyle: 'solid',
108
111
  outlineWidth: { default: 0, ':focus-visible': '2px' },
109
112
  outlineColor: colors.focusRing,
@@ -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 { HTMLTextareaAttributes } from 'svelte/elements';
4
5
  import { control } from '../../internal/control.js';
5
6
  import { attrs, type Sx } from '../../internal/sx.js';
@@ -14,11 +15,14 @@
14
15
  ref?: HTMLTextAreaElement | null | undefined;
15
16
  };
16
17
 
18
+ /** A length at the window's density (`density` in the tokens). */
19
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
20
+
17
21
  const styles = stylex.create({
18
22
  base: {
19
23
  minHeight: '5rem',
20
- paddingBlock: '0.5rem',
21
- paddingInline: '0.625rem',
24
+ paddingBlock: d('0.5rem'),
25
+ paddingInline: d('0.625rem'),
22
26
  resize: 'vertical'
23
27
  },
24
28
  autosize: {
@@ -3,7 +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 { colors } from '../../tokens.stylex.js';
6
+ import { colors, density, space } from '../../tokens.stylex.js';
7
7
 
8
8
  export type ThemeScheme = 'light' | 'dark' | 'system';
9
9
 
@@ -25,12 +25,38 @@
25
25
  children?: Snippet | undefined;
26
26
  };
27
27
 
28
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
29
+
30
+ /**
31
+ * The spacing scale, declared again here. A custom property is worked out where it is
32
+ * declared, so the scale on `:root` keeps the root's density; declared again on this
33
+ * element, it takes a density theme passed to this `Theme`. The values are the tokens' own,
34
+ * so without one nothing changes, and a space theme passed in replaces it, as StyleX keeps
35
+ * the last theme of a group.
36
+ */
37
+ const spaceAtDensity = stylex.createTheme(space, {
38
+ x1: d('0.25rem'),
39
+ x1_5: d('0.375rem'),
40
+ x2: d('0.5rem'),
41
+ x3: d('0.75rem'),
42
+ x4: d('1rem'),
43
+ x5: d('1.25rem'),
44
+ x6: d('1.5rem'),
45
+ x8: d('2rem'),
46
+ x10: d('2.5rem'),
47
+ x12: d('3rem'),
48
+ x16: d('4rem')
49
+ });
50
+
28
51
  const styles = stylex.create({
29
52
  // `display: contents` keeps the wrapper out of layout, while the inherited
30
53
  // `color-scheme` and `color` still reach its children.
31
54
  base: {
32
55
  display: 'contents',
33
- color: colors.text
56
+ color: colors.text,
57
+ // base.css draws the scrollbars from these: set here, they take this theme's tokens
58
+ '--narvi-scrollbar-thumb': colors.borderStrong,
59
+ '--narvi-scrollbar-thumb-hover': colors.borderControl
34
60
  },
35
61
  light: { colorScheme: 'light' },
36
62
  dark: { colorScheme: 'dark' },
@@ -44,6 +70,9 @@
44
70
  const themes = $derived(theme === undefined ? [] : Array.isArray(theme) ? theme : [theme]);
45
71
  </script>
46
72
 
47
- <div {...rest} {...attrs([styles.base, scheme && styles[scheme], ...themes, sx], className)}>
73
+ <div
74
+ {...rest}
75
+ {...attrs([styles.base, spaceAtDensity, scheme && styles[scheme], ...themes, sx], className)}
76
+ >
48
77
  {@render children?.()}
49
78
  </div>
@@ -7,7 +7,7 @@
7
7
  -->
8
8
  <script lang="ts" module>
9
9
  import * as stylex from '@stylexjs/stylex';
10
- import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
10
+ import { colors, density, font, motion, radius, space } from '../../tokens.stylex.js';
11
11
  import { media } from '../../media.stylex.js';
12
12
  import Glyph from '../../internal/Glyph.svelte';
13
13
  import Button from '../button/Button.svelte';
@@ -21,6 +21,9 @@
21
21
  label?: string | undefined;
22
22
  };
23
23
 
24
+ /** A length at the window's density (`density` in the tokens). */
25
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
26
+
24
27
  const styles = stylex.create({
25
28
  // The top layer brings the browser's popover styles; these undo them
26
29
  region: {
@@ -45,9 +48,9 @@
45
48
  gridTemplateColumns: 'auto minmax(0, 1fr) auto',
46
49
  alignItems: 'start',
47
50
  gap: '0.625rem',
48
- paddingBlock: '0.75rem',
49
- paddingInlineStart: '0.875rem',
50
- paddingInlineEnd: '0.5rem',
51
+ paddingBlock: d('0.75rem'),
52
+ paddingInlineStart: d('0.875rem'),
53
+ paddingInlineEnd: d('0.5rem'),
51
54
  borderRadius: radius.card,
52
55
  backgroundColor: colors.bgRaised,
53
56
  boxShadow: `inset 0 0 0 1px ${colors.borderStrong}, 0 16px 40px -12px ${colors.shadow}`,
@@ -97,7 +100,13 @@
97
100
  userSelect: 'text',
98
101
  overflowWrap: 'anywhere'
99
102
  },
100
- actions: { display: 'flex', alignItems: 'center', gap: '0.25rem', marginTop: '-0.25rem' }
103
+ // Its small buttons are centred on the title's line, about 20px, at any density
104
+ actions: {
105
+ display: 'flex',
106
+ alignItems: 'center',
107
+ gap: d('0.25rem'),
108
+ marginTop: `calc((1.25rem - ${d('1.75rem')}) / 2)`
109
+ }
101
110
  });
102
111
  </script>
103
112
 
@@ -1,6 +1,7 @@
1
1
  <script lang="ts" module>
2
2
  import { ToggleGroup } from 'bits-ui';
3
3
  import * as stylex from '@stylexjs/stylex';
4
+ import { density } from '../../tokens.stylex.js';
4
5
  import type { Snippet } from 'svelte';
5
6
  import type { Loose } from '../../internal/loose.js';
6
7
  import { attrs, type Sx } from '../../internal/sx.js';
@@ -48,11 +49,14 @@
48
49
  }
49
50
  );
50
51
 
52
+ /** A length at the window's density (`density` in the tokens). */
53
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
54
+
51
55
  const styles = stylex.create({
52
56
  root: {
53
57
  display: 'inline-flex',
54
58
  alignItems: 'center',
55
- gap: '0.25rem'
59
+ gap: d('0.25rem')
56
60
  },
57
61
  vertical: { flexDirection: 'column', alignItems: 'stretch' }
58
62
  });
@@ -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 Collapse from '../../internal/Collapse.svelte';
@@ -12,16 +13,19 @@
12
13
  children?: Snippet | undefined;
13
14
  };
14
15
 
16
+ /** A length at the window's density (`density` in the tokens). */
17
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
18
+
15
19
  const styles = stylex.create({
16
20
  // Input and output are set in under the icon, in line with the title
17
21
  body: {
18
22
  display: 'flex',
19
23
  flexDirection: 'column',
20
- gap: '0.75rem',
21
- marginTop: '0.5rem',
22
- marginBottom: '0.25rem',
24
+ gap: d('0.75rem'),
25
+ marginTop: d('0.5rem'),
26
+ marginBottom: d('0.25rem'),
23
27
  paddingInlineStart: '1.625rem',
24
- paddingBlock: '0.125rem'
28
+ paddingBlock: d('0.125rem')
25
29
  }
26
30
  });
27
31
  </script>
@@ -10,7 +10,7 @@
10
10
  import { flatEntries } from '../../internal/json.js';
11
11
  import { shared } from '../../internal/shared.js';
12
12
  import { attrs, type Sx } from '../../internal/sx.js';
13
- import { colors, font, radius } from '../../tokens.stylex.js';
13
+ import { colors, density, font, radius } from '../../tokens.stylex.js';
14
14
 
15
15
  export type ToolSectionProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
16
16
  label: string;
@@ -23,6 +23,9 @@
23
23
  children?: Snippet | undefined;
24
24
  };
25
25
 
26
+ /** A length at the window's density (`density` in the tokens). */
27
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
28
+
26
29
  const styles = stylex.create({
27
30
  section: {
28
31
  display: 'flex',
@@ -36,10 +39,10 @@
36
39
  display: 'grid',
37
40
  gridTemplateColumns: 'max-content minmax(0, 1fr)',
38
41
  columnGap: '1rem',
39
- rowGap: '0.3125rem',
42
+ rowGap: d('0.3125rem'),
40
43
  margin: 0,
41
- paddingBlock: '0.5625rem',
42
- paddingInline: '0.75rem',
44
+ paddingBlock: d('0.5625rem'),
45
+ paddingInline: d('0.75rem'),
43
46
  borderRadius: radius.control,
44
47
  backgroundColor: colors.fillSunken,
45
48
  fontFamily: font.mono,
@@ -7,7 +7,7 @@
7
7
  import { KIND_GLYPHS } from '../../internal/kinds.js';
8
8
  import { attrs, type Sx } from '../../internal/sx.js';
9
9
  import Tile, { type TileTone } from '../../internal/Tile.svelte';
10
- import { colors, font, motion, radius } from '../../tokens.stylex.js';
10
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
11
11
  import { media } from '../../media.stylex.js';
12
12
  import Shimmer from '../shimmer/Shimmer.svelte';
13
13
  import { getToolContext, type ToolState } from './context.js';
@@ -28,6 +28,9 @@
28
28
  error: 'danger'
29
29
  };
30
30
 
31
+ /** A length at the window's density (`density` in the tokens). */
32
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
33
+
31
34
  const styles = stylex.create({
32
35
  // A row of the turn, like thinking and activity: an icon, then the words
33
36
  trigger: {
@@ -36,7 +39,7 @@
36
39
  alignSelf: 'flex-start',
37
40
  gap: '0.625rem',
38
41
  maxWidth: '100%',
39
- minHeight: '1.75rem',
42
+ minHeight: d('1.75rem'),
40
43
  margin: 0,
41
44
  padding: 0,
42
45
  borderWidth: 0,