@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
package/dist/base.css CHANGED
@@ -23,6 +23,12 @@
23
23
  /* The page, on the root rather than the body, so overscroll shows it too */
24
24
  background-color: light-dark(#f3f4f5, #151618); /* colors.bg */
25
25
  color: light-dark(#16181c, #eaedf2); /* colors.text */
26
+ /* The scrollbar's thumb. Theme sets both again from its tokens, so a preset reaches the
27
+ scrollbars inside it. */
28
+ /* prettier-ignore */
29
+ --narvi-scrollbar-thumb: light-dark(rgb(22 24 28 / 0.2), rgb(255 255 255 / 0.16)); /* colors.borderStrong */
30
+ /* prettier-ignore */
31
+ --narvi-scrollbar-thumb-hover: light-dark(#8b8d92, #67696e); /* colors.borderControl */
26
32
  /* Narvi's interface text inherits the page's face: set your own on the root */
27
33
  font-family:
28
34
  system-ui,
@@ -41,6 +47,38 @@
41
47
  margin: 0;
42
48
  }
43
49
 
50
+ /* Every scrollbar: 6px, no track, a thumb with round ends. Chromium drops these for an element
51
+ that sets scrollbar-width or scrollbar-color (121 and later), so Narvi's parts set neither,
52
+ save scrollbar-width: none where a scrollbar is hidden on purpose. Not on an iframe's own
53
+ element, where WebKit lays its page out again and again: webkit.org/b/324485. */
54
+ :where(:not(iframe))::-webkit-scrollbar {
55
+ width: 6px;
56
+ height: 6px;
57
+ background: transparent;
58
+ }
59
+
60
+ :where(:not(iframe))::-webkit-scrollbar-thumb {
61
+ border-radius: 3px;
62
+ background-color: var(--narvi-scrollbar-thumb);
63
+ }
64
+
65
+ :where(:not(iframe))::-webkit-scrollbar-thumb:hover {
66
+ background-color: var(--narvi-scrollbar-thumb-hover);
67
+ }
68
+
69
+ :where(:not(iframe))::-webkit-scrollbar-track,
70
+ :where(:not(iframe))::-webkit-scrollbar-corner {
71
+ background: transparent;
72
+ }
73
+
74
+ /* Firefox, which has no ::-webkit-scrollbar, takes the standard properties instead */
75
+ @supports not selector(::-webkit-scrollbar) {
76
+ :where(*) {
77
+ scrollbar-width: thin;
78
+ scrollbar-color: var(--narvi-scrollbar-thumb) transparent;
79
+ }
80
+ }
81
+
44
82
  /* Spacing comes from layout (Stack, Grid, gap), not from the browser's margins */
45
83
  h1,
46
84
  h2,
@@ -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,13 +13,16 @@
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
  steps: {
17
21
  display: 'flex',
18
22
  flexDirection: 'column',
19
- gap: '0.5rem',
20
- paddingTop: '0.5rem',
21
- paddingBottom: '0.25rem'
23
+ gap: d('0.5rem'),
24
+ paddingTop: d('0.5rem'),
25
+ paddingBottom: d('0.25rem')
22
26
  }
23
27
  });
24
28
  </script>
@@ -2,6 +2,8 @@
2
2
  One thing the agent did: a command, an edit, a read, a search. Its label is
3
3
  the thing itself, as code; a step that did not go through says so, and one
4
4
  that was let be, such as one never checked, says that, without the red.
5
+ Its icon stays quiet: the row above it is what is lit while the work goes on,
6
+ so a step spins in grey, and one that failed is a faint red beside its badge.
5
7
  -->
6
8
  <script lang="ts" module>
7
9
  import * as stylex from '@stylexjs/stylex';
@@ -11,7 +13,7 @@
11
13
  import { attrs, type Sx } from '../../internal/sx.js';
12
14
  import { getFoldShown } from '../../internal/fold-shown.js';
13
15
  import Tile from '../../internal/Tile.svelte';
14
- import { colors, font, radius } from '../../tokens.stylex.js';
16
+ import { colors, density, font, radius } from '../../tokens.stylex.js';
15
17
  import Button from '../button/Button.svelte';
16
18
  import Spinner from '../spinner/Spinner.svelte';
17
19
 
@@ -35,7 +37,13 @@
35
37
  };
36
38
 
37
39
  export type ActivityStepProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
40
+ /** What kind of step it is, which picks its icon and the part of its label to stress. */
38
41
  kind?: ActivityStepKind | undefined;
42
+ /**
43
+ * An icon of your own in place of the kind's, such as a Lucide icon. It is sized to fit
44
+ * and takes the step's colour. A running step still shows its spinner.
45
+ */
46
+ icon?: Snippet | undefined;
39
47
  /** The command, the path, the query: shown as code. Cut to one line, unless `wrap`. */
40
48
  label: string;
41
49
  /** Lets the label run onto more lines, rather than cutting it off at the end of one. */
@@ -70,13 +78,16 @@
70
78
  neutral: 'Skipped'
71
79
  };
72
80
 
81
+ /** A length at the window's density (`density` in the tokens). */
82
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
83
+
73
84
  const styles = stylex.create({
74
85
  // The icon sits in a column as wide as the row's own icon above
75
86
  step: {
76
87
  display: 'grid',
77
88
  gridTemplateColumns: '1rem minmax(0, 1fr)',
78
89
  columnGap: '0.625rem',
79
- rowGap: '0.375rem',
90
+ rowGap: d('0.375rem'),
80
91
  minWidth: 0
81
92
  },
82
93
  icon: { display: 'grid', placeItems: 'center' },
@@ -85,7 +96,7 @@
85
96
  alignItems: 'center',
86
97
  gap: '0.5rem',
87
98
  minWidth: 0,
88
- minHeight: '1.25rem'
99
+ minHeight: d('1.25rem')
89
100
  },
90
101
  label: {
91
102
  minWidth: 0,
@@ -117,11 +128,13 @@
117
128
  fontWeight: font.weightMedium
118
129
  },
119
130
  badgeNeutral: { backgroundColor: colors.fillMuted, color: colors.textMuted },
131
+ // The badge says it in words; the icon only leans that way
132
+ failedIcon: { color: `color-mix(in oklab, ${colors.danger} 55%, transparent)` },
120
133
  body: {
121
134
  gridColumn: '2',
122
135
  display: 'flex',
123
136
  flexDirection: 'column',
124
- gap: '0.375rem',
137
+ gap: d('0.375rem'),
125
138
  minWidth: 0
126
139
  },
127
140
  reason: { margin: 0, color: colors.textMuted, fontSize: font.sizeMeta },
@@ -130,8 +143,8 @@
130
143
  margin: 0,
131
144
  maxHeight: '10rem',
132
145
  overflow: 'auto',
133
- paddingBlock: '0.5rem',
134
- paddingInline: '0.625rem',
146
+ paddingBlock: d('0.5rem'),
147
+ paddingInline: d('0.625rem'),
135
148
  borderRadius: radius.control,
136
149
  backgroundColor: colors.fillSunken,
137
150
  color: colors.textMuted,
@@ -139,8 +152,7 @@
139
152
  fontSize: font.sizeCaption,
140
153
  lineHeight: font.leadingNormal,
141
154
  whiteSpace: 'pre-wrap',
142
- overflowWrap: 'anywhere',
143
- scrollbarWidth: 'thin'
155
+ overflowWrap: 'anywhere'
144
156
  }
145
157
  });
146
158
  </script>
@@ -148,6 +160,7 @@
148
160
  <script lang="ts">
149
161
  let {
150
162
  kind = 'tool',
163
+ icon,
151
164
  label,
152
165
  status = 'done',
153
166
  reason,
@@ -223,9 +236,13 @@
223
236
  <span {...stylex.attrs(styles.icon)}>
224
237
  <Tile
225
238
  size="sm"
226
- tone={status === 'running' ? 'live' : bad ? 'danger' : 'neutral'}
227
- glyph={status === 'running' ? undefined : KIND_GLYPHS[kind]}
228
- >{#if status === 'running'}<Spinner size={11} label={null} />{/if}</Tile
239
+ tone={bad ? 'danger' : 'neutral'}
240
+ sx={bad && styles.failedIcon}
241
+ glyph={status === 'running' || icon ? undefined : KIND_GLYPHS[kind]}
242
+ >{#if status === 'running'}<Spinner
243
+ size={11}
244
+ label={null}
245
+ />{:else}{@render icon?.()}{/if}</Tile
229
246
  >
230
247
  </span>
231
248
  <span {...stylex.attrs(styles.line, wrap && styles.lineWrapped)}>
@@ -18,7 +18,13 @@ export type ActivityStepOutputLabels = {
18
18
  showLess?: string | undefined;
19
19
  };
20
20
  export type ActivityStepProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
21
+ /** What kind of step it is, which picks its icon and the part of its label to stress. */
21
22
  kind?: ActivityStepKind | undefined;
23
+ /**
24
+ * An icon of your own in place of the kind's, such as a Lucide icon. It is sized to fit
25
+ * and takes the step's colour. A running step still shows its spinner.
26
+ */
27
+ icon?: Snippet | undefined;
22
28
  /** The command, the path, the query: shown as code. Cut to one line, unless `wrap`. */
23
29
  label: string;
24
30
  /** Lets the label run onto more lines, rather than cutting it off at the end of one. */
@@ -6,7 +6,7 @@
6
6
  import { KIND_GLYPHS, type ActionKind } from '../../internal/kinds.js';
7
7
  import { attrs, type Sx } from '../../internal/sx.js';
8
8
  import Tile from '../../internal/Tile.svelte';
9
- import { colors, font, motion, radius } from '../../tokens.stylex.js';
9
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
10
10
  import { media } from '../../media.stylex.js';
11
11
  import RollingText from '../rolling-text/RollingText.svelte';
12
12
  import { getActivityContext } from './context.js';
@@ -25,6 +25,9 @@
25
25
  sx?: Sx | undefined;
26
26
  };
27
27
 
28
+ /** A length at the window's density (`density` in the tokens). */
29
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
30
+
28
31
  const styles = stylex.create({
29
32
  trigger: {
30
33
  display: 'flex',
@@ -32,7 +35,7 @@
32
35
  alignSelf: 'flex-start',
33
36
  gap: '0.625rem',
34
37
  maxWidth: '100%',
35
- minHeight: '1.75rem',
38
+ minHeight: d('1.75rem'),
36
39
  margin: 0,
37
40
  padding: 0,
38
41
  borderWidth: 0,
@@ -7,6 +7,7 @@
7
7
  -->
8
8
  <script lang="ts" module>
9
9
  import * as stylex from '@stylexjs/stylex';
10
+ import { density } from '../../tokens.stylex.js';
10
11
  import type { Snippet } from 'svelte';
11
12
  import type { HTMLAttributes } from 'svelte/elements';
12
13
  import { shared } from '../../internal/shared.js';
@@ -28,6 +29,9 @@
28
29
  children?: Snippet | undefined;
29
30
  };
30
31
 
32
+ /** A length at the window's density (`density` in the tokens). */
33
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
34
+
31
35
  const styles = stylex.create({
32
36
  // Three columns, the outer two equal, so the middle one is centred on the window
33
37
  bar: {
@@ -35,25 +39,26 @@
35
39
  display: 'grid',
36
40
  gridTemplateColumns: 'minmax(0, 1fr) auto minmax(0, 1fr)',
37
41
  alignItems: 'center',
38
- columnGap: '0.5rem',
42
+ columnGap: d('0.5rem'),
39
43
  minWidth: 0,
40
44
  height: '2.75rem',
41
45
  // Back over the shell's gutter, to the window's edges
42
46
  marginTop: '-0.375rem',
43
47
  marginInline: '-0.375rem',
44
48
  paddingInlineEnd: '0.75rem',
45
- // Clear of the traffic lights. With none, a 28px control here is centred over the rail's tiles.
49
+ // Clear of the traffic lights. With none, a 28px control here is centred over the rail's
50
+ // tiles at the default density. The bar's height and this room are kept at any density.
46
51
  paddingInlineStart: 'calc(0.75rem + var(--narvi-window-inset, 0px))'
47
52
  },
48
53
  // Spelled out side by side: a longhand outranks the `margin` shorthand
49
54
  narrow: { marginTop: 0, marginInline: 0 },
50
- start: { display: 'flex', alignItems: 'center', gap: '0.125rem', minWidth: 0 },
55
+ start: { display: 'flex', alignItems: 'center', gap: d('0.125rem'), minWidth: 0 },
51
56
  center: { display: 'flex', justifyContent: 'center', minWidth: 0 },
52
57
  end: {
53
58
  display: 'flex',
54
59
  alignItems: 'center',
55
60
  justifyContent: 'flex-end',
56
- gap: '0.25rem',
61
+ gap: d('0.25rem'),
57
62
  minWidth: 0
58
63
  }
59
64
  });
@@ -8,7 +8,7 @@
8
8
  import type { HTMLAttributes } from 'svelte/elements';
9
9
  import { shared } from '../../internal/shared.js';
10
10
  import { attrs, type Sx } from '../../internal/sx.js';
11
- import { colors, font } from '../../tokens.stylex.js';
11
+ import { colors, density, font } from '../../tokens.stylex.js';
12
12
 
13
13
  export type AppShellHeaderProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
14
14
  /**
@@ -25,19 +25,23 @@
25
25
  children?: Snippet | undefined;
26
26
  };
27
27
 
28
+ /** A length at the window's density (`density` in the tokens). */
29
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
30
+
28
31
  const styles = stylex.create({
29
32
  header: {
30
33
  boxSizing: 'border-box',
31
34
  display: 'flex',
32
35
  alignItems: 'center',
33
- gap: '0.5rem',
36
+ gap: d('0.5rem'),
34
37
  flexShrink: 0,
35
38
  minWidth: 0,
36
39
  height: '3rem',
37
40
  // The same edge as Sidebar.Header, and as a Conversation's column under it. In a shell
38
- // with no bar, clear of the traffic lights while the sidebar is away.
39
- paddingInlineStart: 'max(1rem, calc(var(--narvi-inset-page, 0px) + 0.5rem))',
40
- paddingInlineEnd: '0.625rem',
41
+ // with no bar, clear of the traffic lights while the sidebar is away. Its height and that
42
+ // room are kept at any density.
43
+ paddingInlineStart: `max(${d('1rem')}, calc(var(--narvi-inset-page, 0px) + 0.5rem))`,
44
+ paddingInlineEnd: d('0.625rem'),
41
45
  fontSize: font.sizeBody
42
46
  },
43
47
  divider: {
@@ -9,7 +9,7 @@
9
9
  import { onMount, tick, type Snippet } from 'svelte';
10
10
  import Glyph from '../../internal/Glyph.svelte';
11
11
  import { attrs, type Sx } from '../../internal/sx.js';
12
- import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
12
+ import { colors, density, font, motion, radius, space } from '../../tokens.stylex.js';
13
13
  import { media } from '../../media.stylex.js';
14
14
  import Button from '../button/Button.svelte';
15
15
  import Kbd from '../kbd/Kbd.svelte';
@@ -76,12 +76,15 @@
76
76
  class?: string | undefined;
77
77
  };
78
78
 
79
+ /** A length at the window's density (`density` in the tokens). */
80
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
81
+
79
82
  const styles = stylex.create({
80
83
  card: {
81
84
  display: 'flex',
82
85
  flexDirection: 'column',
83
86
  gap: space.x3,
84
- padding: '0.875rem',
87
+ padding: d('0.875rem'),
85
88
  borderRadius: radius.panel,
86
89
  backgroundColor: `color-mix(in oklab, ${colors.warning} 7%, ${colors.bgRaised})`,
87
90
  opacity: { default: 1, '@starting-style': 0 },
@@ -102,8 +105,8 @@
102
105
  },
103
106
  command: {
104
107
  margin: 0,
105
- paddingBlock: '0.5rem',
106
- paddingInline: '0.625rem',
108
+ paddingBlock: d('0.5rem'),
109
+ paddingInline: d('0.625rem'),
107
110
  overflowX: 'auto',
108
111
  borderRadius: radius.control,
109
112
  backgroundColor: colors.fillSunken,
@@ -4,7 +4,7 @@
4
4
  import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
5
5
  import { shared } from '../../internal/shared.js';
6
6
  import { attrs, classes, 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 Spinner from '../spinner/Spinner.svelte';
10
10
  import * as Tooltip from '../tooltip/index.js';
@@ -90,6 +90,9 @@
90
90
  const OPEN =
91
91
  ':is([aria-haspopup]:not([aria-haspopup="false"])[aria-expanded="true"], [aria-pressed="true"])';
92
92
 
93
+ /** A length at the window's density (`density` in the tokens). */
94
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
95
+
93
96
  const styles = stylex.create({
94
97
  base: {
95
98
  // A key hint inside takes the button's own ink, whatever it stands on
@@ -126,48 +129,69 @@
126
129
  }
127
130
  },
128
131
 
129
- // Sizes. All but the large one extend their hit area to 40px without moving the layout.
132
+ // Sizes. All but the large one extend their hit area to 40px without moving the layout,
133
+ // at any density.
130
134
  // Each sets the size of an icon put inside it (`internal/icons.css`): 12, 14, 14, 16, 18px.
131
135
  micro: {
132
136
  '--narvi-icon-size': '0.75rem',
133
- minHeight: '1.25rem',
134
- paddingInline: '0.375rem',
137
+ minHeight: d('1.25rem'),
138
+ paddingInline: d('0.375rem'),
135
139
  gap: '0.25rem',
136
140
  borderRadius: radius.chip,
137
141
  fontSize: font.sizeCaption,
138
- '::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-10px' }
142
+ '::after': {
143
+ content: '""',
144
+ position: 'absolute',
145
+ insetInline: 0,
146
+ insetBlock: `calc((${d('1.25rem')} - 2.5rem) / 2)`
147
+ }
139
148
  },
140
149
  xs: {
141
150
  '--narvi-icon-size': '0.875rem',
142
- minHeight: '1.5rem',
143
- paddingInline: '0.5rem',
151
+ minHeight: d('1.5rem'),
152
+ paddingInline: d('0.5rem'),
144
153
  gap: '0.3125rem',
145
154
  borderRadius: radius.item,
146
155
  fontSize: font.sizeMeta,
147
- '::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-8px' }
156
+ '::after': {
157
+ content: '""',
158
+ position: 'absolute',
159
+ insetInline: 0,
160
+ insetBlock: `calc((${d('1.5rem')} - 2.5rem) / 2)`
161
+ }
148
162
  },
149
163
  sm: {
150
164
  '--narvi-icon-size': '0.875rem',
151
- minHeight: '1.75rem',
152
- paddingInline: '0.625rem',
165
+ minHeight: d('1.75rem'),
166
+ paddingInline: d('0.625rem'),
153
167
  gap: '0.375rem',
154
168
  borderRadius: radius.item,
155
169
  fontSize: font.sizeMeta,
156
- '::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-6px' }
170
+ '::after': {
171
+ content: '""',
172
+ position: 'absolute',
173
+ insetInline: 0,
174
+ insetBlock: `calc((${d('1.75rem')} - 2.5rem) / 2)`
175
+ }
157
176
  },
158
177
  md: {
159
178
  '--narvi-icon-size': '1rem',
160
- minHeight: '2rem',
161
- paddingInline: '0.75rem',
179
+ minHeight: d('2rem'),
180
+ paddingInline: d('0.75rem'),
162
181
  gap: '0.4375rem',
163
182
  borderRadius: radius.control,
164
183
  fontSize: font.sizeBody,
165
- '::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-4px' }
184
+ '::after': {
185
+ content: '""',
186
+ position: 'absolute',
187
+ insetInline: 0,
188
+ insetBlock: `calc((${d('2rem')} - 2.5rem) / 2)`
189
+ }
166
190
  },
167
191
  lg: {
168
192
  '--narvi-icon-size': '1.125rem',
169
- minHeight: '2.5rem',
170
- paddingInline: '1rem',
193
+ minHeight: d('2.5rem'),
194
+ paddingInline: d('1rem'),
171
195
  gap: '0.5rem',
172
196
  borderRadius: radius.panel,
173
197
  fontSize: font.sizeReading
@@ -176,43 +200,43 @@
176
200
  // `--narvi-icon-flush: 1`, as a sidebar group's actions do), the button reaches out by the
177
201
  // room around its icon, so the icon, not the box, ends on the line.
178
202
  iconMicro: {
179
- width: '1.25rem',
203
+ width: d('1.25rem'),
180
204
  paddingInline: 0,
181
205
  marginInlineEnd: {
182
206
  default: null,
183
- ':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.75rem - 1.25rem) / 2)'
207
+ ':last-child': `calc(var(--narvi-icon-flush, 0) * (0.75rem - ${d('1.25rem')}) / 2)`
184
208
  }
185
209
  },
186
210
  iconXs: {
187
- width: '1.5rem',
211
+ width: d('1.5rem'),
188
212
  paddingInline: 0,
189
213
  marginInlineEnd: {
190
214
  default: null,
191
- ':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.875rem - 1.5rem) / 2)'
215
+ ':last-child': `calc(var(--narvi-icon-flush, 0) * (0.875rem - ${d('1.5rem')}) / 2)`
192
216
  }
193
217
  },
194
218
  iconSm: {
195
- width: '1.75rem',
219
+ width: d('1.75rem'),
196
220
  paddingInline: 0,
197
221
  marginInlineEnd: {
198
222
  default: null,
199
- ':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.875rem - 1.75rem) / 2)'
223
+ ':last-child': `calc(var(--narvi-icon-flush, 0) * (0.875rem - ${d('1.75rem')}) / 2)`
200
224
  }
201
225
  },
202
226
  iconMd: {
203
- width: '2rem',
227
+ width: d('2rem'),
204
228
  paddingInline: 0,
205
229
  marginInlineEnd: {
206
230
  default: null,
207
- ':last-child': 'calc(var(--narvi-icon-flush, 0) * (1rem - 2rem) / 2)'
231
+ ':last-child': `calc(var(--narvi-icon-flush, 0) * (1rem - ${d('2rem')}) / 2)`
208
232
  }
209
233
  },
210
234
  iconLg: {
211
- width: '2.5rem',
235
+ width: d('2.5rem'),
212
236
  paddingInline: 0,
213
237
  marginInlineEnd: {
214
238
  default: null,
215
- ':last-child': 'calc(var(--narvi-icon-flush, 0) * (1.125rem - 2.5rem) / 2)'
239
+ ':last-child': `calc(var(--narvi-icon-flush, 0) * (1.125rem - ${d('2.5rem')}) / 2)`
216
240
  }
217
241
  },
218
242
 
@@ -4,7 +4,7 @@
4
4
  import type { HTMLAnchorAttributes, 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, motion, radius, space } from '../../tokens.stylex.js';
7
+ import { colors, density, font, motion, radius, space } from '../../tokens.stylex.js';
8
8
  import { media } from '../../media.stylex.js';
9
9
 
10
10
  export type CardVariant = 'raised' | 'outlined' | 'filled';
@@ -26,6 +26,9 @@
26
26
  children?: Snippet | undefined;
27
27
  };
28
28
 
29
+ /** A length at the window's density (`density` in the tokens). */
30
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
31
+
29
32
  const styles = stylex.create({
30
33
  base: {
31
34
  boxSizing: 'border-box',
@@ -47,7 +50,7 @@
47
50
  },
48
51
  none: { padding: 0 },
49
52
  sm: { padding: space.x3 },
50
- md: { padding: '1.125rem' },
53
+ md: { padding: d('1.125rem') },
51
54
  lg: { padding: space.x6 },
52
55
 
53
56
  // A card that is a link: a block, in the card's own colours, that answers the pointer
@@ -2,7 +2,7 @@
2
2
  <script lang="ts" module>
3
3
  import * as stylex from '@stylexjs/stylex';
4
4
  import { attrs, type Sx } from '../../internal/sx.js';
5
- import { colors, font, radius } from '../../tokens.stylex.js';
5
+ import { colors, density, font, radius } from '../../tokens.stylex.js';
6
6
  import { media } from '../../media.stylex.js';
7
7
  import Button from '../button/Button.svelte';
8
8
  import ChangeStats from '../change-stats/ChangeStats.svelte';
@@ -27,6 +27,9 @@
27
27
 
28
28
  const STATUS = { added: 'A', modified: 'M', deleted: 'D', renamed: 'R' } as const;
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
  card: {
32
35
  display: 'flex',
@@ -38,24 +41,24 @@
38
41
  head: {
39
42
  display: 'flex',
40
43
  alignItems: 'center',
41
- gap: '0.75rem',
42
- minHeight: '2.5rem',
43
- paddingInlineStart: '0.75rem',
44
- paddingInlineEnd: '0.375rem',
44
+ gap: d('0.75rem'),
45
+ minHeight: d('2.5rem'),
46
+ paddingInlineStart: d('0.75rem'),
47
+ paddingInlineEnd: d('0.375rem'),
45
48
  borderBottomWidth: '1px',
46
49
  borderBottomStyle: 'solid',
47
50
  borderBottomColor: colors.border
48
51
  },
49
52
  title: { flexGrow: 1, margin: 0, fontSize: font.sizeBody, fontWeight: font.weightMedium },
50
- list: { margin: 0, padding: '0.25rem', listStyleType: 'none' },
53
+ list: { margin: 0, padding: d('0.25rem'), listStyleType: 'none' },
51
54
  file: {
52
55
  display: 'flex',
53
56
  alignItems: 'center',
54
57
  gap: '0.5rem',
55
58
  width: '100%',
56
- minHeight: '1.875rem',
59
+ minHeight: d('1.875rem'),
57
60
  margin: 0,
58
- paddingInline: '0.5rem',
61
+ paddingInline: d('0.5rem'),
59
62
  borderWidth: 0,
60
63
  borderRadius: radius.control,
61
64
  backgroundColor: {
@@ -9,7 +9,7 @@
9
9
  import type { HTMLAttributes } from 'svelte/elements';
10
10
  import '../../internal/icons.css';
11
11
  import { attrs, type Sx } from '../../internal/sx.js';
12
- import { colors, motion, radius, space } from '../../tokens.stylex.js';
12
+ import { colors, density, motion, radius, space } from '../../tokens.stylex.js';
13
13
  import { media } from '../../media.stylex.js';
14
14
  import { typography } from '../../typography.js';
15
15
  import { visuallyHidden } from '../../visually-hidden.js';
@@ -42,6 +42,9 @@
42
42
  const FOCUSED = ':has(:focus-visible)';
43
43
  const OFF = ':has(:disabled)';
44
44
 
45
+ /** A length at the window's density (`density` in the tokens). */
46
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
47
+
45
48
  const styles = stylex.create({
46
49
  root: {
47
50
  display: 'grid',
@@ -56,7 +59,7 @@
56
59
  gap: space.x3,
57
60
  minWidth: 0,
58
61
  paddingBlock: space.x3,
59
- paddingInline: '0.875rem',
62
+ paddingInline: d('0.875rem'),
60
63
  borderRadius: radius.panel,
61
64
  backgroundColor: colors.bgRaised,
62
65
  // The edge says which is chosen: the accent, twice as thick
@@ -5,7 +5,7 @@
5
5
  import type { Snippet } from 'svelte';
6
6
  import Chevron from '../../internal/Chevron.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 { getCollapsibleContext } from './context.js';
11
11
 
@@ -22,6 +22,9 @@
22
22
  }
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
  // A quiet line of text that names what folds, like Reasoning's and WorkFold's
27
30
  trigger: {
@@ -30,7 +33,7 @@
30
33
  alignSelf: 'flex-start',
31
34
  gap: '0.25rem',
32
35
  maxWidth: '100%',
33
- minHeight: '1.75rem',
36
+ minHeight: d('1.75rem'),
34
37
  margin: 0,
35
38
  padding: 0,
36
39
  borderWidth: 0,