@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
@@ -4,7 +4,7 @@
4
4
  import * as stylex from '@stylexjs/stylex';
5
5
  import type { Snippet } from 'svelte';
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 Kbd from '../kbd/Kbd.svelte';
10
10
 
@@ -25,6 +25,9 @@
25
25
  const CLOSED = ':is([data-state="closed"])';
26
26
  const INSTANT = ':is([data-state="instant-open"])';
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
  content: {
30
33
  zIndex: 60,
@@ -32,8 +35,8 @@
32
35
  alignItems: 'center',
33
36
  gap: '0.5rem',
34
37
  maxWidth: '18rem',
35
- paddingBlock: '0.3125rem',
36
- paddingInline: '0.5rem',
38
+ paddingBlock: d('0.3125rem'),
39
+ paddingInline: d('0.5rem'),
37
40
  borderRadius: radius.control,
38
41
  backgroundColor: colors.bgRaised,
39
42
  boxShadow: `inset 0 0 0 1px ${colors.borderStrong}, 0 4px 12px -4px ${colors.shadow}`,
@@ -57,7 +60,7 @@
57
60
  flexDirection: 'column',
58
61
  alignItems: 'flex-start',
59
62
  gap: '0.125rem',
60
- paddingBlock: '0.4375rem'
63
+ paddingBlock: d('0.4375rem')
61
64
  },
62
65
  keys: { display: 'inline-flex', gap: '0.125rem' }
63
66
  });
@@ -9,7 +9,7 @@
9
9
  import Chevron from '../../internal/Chevron.svelte';
10
10
  import type { Sx } from '../../internal/sx.js';
11
11
  import Tile from '../../internal/Tile.svelte';
12
- import { colors, font, motion, radius } from '../../tokens.stylex.js';
12
+ import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
13
13
  import { media } from '../../media.stylex.js';
14
14
  import CollapsibleContent from '../collapsible/CollapsibleContent.svelte';
15
15
  import CollapsibleRoot, {
@@ -27,13 +27,16 @@
27
27
  children?: Snippet | undefined;
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
  trigger: {
32
35
  display: 'inline-flex',
33
36
  alignItems: 'center',
34
37
  alignSelf: 'flex-start',
35
38
  gap: '0.625rem',
36
- minHeight: '1.75rem',
39
+ minHeight: d('1.75rem'),
37
40
  margin: 0,
38
41
  padding: 0,
39
42
  borderWidth: 0,
@@ -57,11 +60,11 @@
57
60
  work: {
58
61
  display: 'flex',
59
62
  flexDirection: 'column',
60
- gap: '0.75rem',
61
- marginTop: '0.5rem',
62
- marginBottom: '0.25rem',
63
+ gap: d('0.75rem'),
64
+ marginTop: d('0.5rem'),
65
+ marginBottom: d('0.25rem'),
63
66
  paddingInlineStart: '1.625rem',
64
- paddingBlock: '0.25rem'
67
+ paddingBlock: d('0.25rem')
65
68
  }
66
69
  });
67
70
  </script>
package/dist/index.d.ts CHANGED
@@ -25,6 +25,8 @@ export { default as Checkbox } from './components/checkbox/Checkbox.svelte';
25
25
  export type { CheckboxProps } from './components/checkbox/Checkbox.svelte';
26
26
  export { default as Code } from './components/code/Code.svelte';
27
27
  export type { CodeProps } from './components/code/Code.svelte';
28
+ export { default as ColorField } from './components/color-field/ColorField.svelte';
29
+ export type { ColorFieldLabels, ColorFieldProps, ColorFieldSize } from './components/color-field/ColorField.svelte';
28
30
  export * as Collapsible from './components/collapsible/index.js';
29
31
  export type { CollapsibleContentProps, CollapsibleRootProps, CollapsibleTriggerProps } from './components/collapsible/index.js';
30
32
  export * as Command from './components/command/index.js';
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export { default as ChangesSummary } from './components/changes-summary/ChangesS
18
18
  export { default as ChoiceCards } from './components/choice-cards/ChoiceCards.svelte';
19
19
  export { default as Checkbox } from './components/checkbox/Checkbox.svelte';
20
20
  export { default as Code } from './components/code/Code.svelte';
21
+ export { default as ColorField } from './components/color-field/ColorField.svelte';
21
22
  // Compound: <Collapsible.Root>, <Collapsible.Trigger>, <Collapsible.Content>
22
23
  export * as Collapsible from './components/collapsible/index.js';
23
24
  // Compound: <Command.Dialog>, <Command.Root>, <Command.Input>, <Command.List>, <Command.Group>,
@@ -6,15 +6,18 @@
6
6
  import * as stylex from '@stylexjs/stylex';
7
7
  import { tokenize } from './json.js';
8
8
  import type { Sx } from './sx.js';
9
- import { colors, font, radius } from '../tokens.stylex.js';
9
+ import { colors, density, font, radius } from '../tokens.stylex.js';
10
+
11
+ /** A length at the window's density (`density` in the tokens). */
12
+ const d = (rem: string) => `calc(${rem} * ${density.factor})`;
10
13
 
11
14
  const styles = stylex.create({
12
15
  pre: {
13
16
  boxSizing: 'border-box',
14
17
  maxHeight: '16rem',
15
18
  margin: 0,
16
- paddingBlock: '0.625rem',
17
- paddingInline: '0.75rem',
19
+ paddingBlock: d('0.625rem'),
20
+ paddingInline: d('0.75rem'),
18
21
  overflow: 'auto',
19
22
  borderRadius: radius.control,
20
23
  backgroundColor: colors.fillSunken,
@@ -24,7 +27,6 @@
24
27
  lineHeight: font.leadingNormal,
25
28
  tabSize: 2,
26
29
  whiteSpace: 'pre',
27
- scrollbarWidth: 'thin',
28
30
  outlineStyle: 'solid',
29
31
  outlineWidth: { default: 0, ':focus-visible': '2px' },
30
32
  outlineColor: colors.focusRing,
@@ -31,8 +31,23 @@
31
31
  'M2 8h12',
32
32
  'M8 2c1.7 1.7 2.5 3.7 2.5 6S9.7 12.3 8 14C6.3 12.3 5.5 10.3 5.5 8S6.3 3.7 8 2Z'
33
33
  ],
34
- plug: ['M6 2.5v3', 'M10 2.5v3', 'M4.5 5.5h7v2.5a3.5 3.5 0 0 1-7 0Z', 'M8 11.5v2'],
35
34
  sparkle: ['M8 2.5 9.4 6.6 13.5 8 9.4 9.4 8 13.5 6.6 9.4 2.5 8 6.6 6.6Z'],
35
+ // An agent's steps by kind, drawn as Lucide's square-pen, wrench and bot, on this grid
36
+ squarePen: [
37
+ 'M8 2.75H4.25C3.56 2.75 3 3.31 3 4v7.75c0 .69.56 1.25 1.25 1.25H12c.69 0 1.25-.56 1.25-1.25V8',
38
+ 'M12.25 1.75a.67.67 0 0 1 2 2L8.24 9.76a1.33 1.33 0 0 1-.57.34l-1.92.56a.33.33 0 0 1-.41-.41l.56-1.92a1.33 1.33 0 0 1 .34-.57Z'
39
+ ],
40
+ wrench: [
41
+ 'M9.8 4.2a.67.67 0 0 0 0 .93l1.07 1.07a.67.67 0 0 0 .93 0l2.07-2.07c.21-.21.58-.15.66.15a4 4 0 0 1-5.51 4.7l-5.27 5.27a.67.67 0 0 1-2-2l5.27-5.27a4 4 0 0 1 4.7-5.51c.29.08.36.44.15.66Z'
42
+ ],
43
+ bot: [
44
+ 'M8 5.25v-2.5H5.5',
45
+ 'M4.25 5.25h7.5c.69 0 1.25.56 1.25 1.25V12c0 .69-.56 1.25-1.25 1.25h-7.5C3.56 13.25 3 12.69 3 12V6.5c0-.69.56-1.25 1.25-1.25Z',
46
+ 'M1.5 9.25H3',
47
+ 'M13 9.25h1.5',
48
+ 'M10 8.5V10',
49
+ 'M6 8.5V10'
50
+ ],
36
51
  undo: ['M5.5 4 2.5 7l3 3', 'M2.5 7h6.75a4 4 0 0 1 0 8H8'],
37
52
  send: ['M8 13V3.25', 'M3.75 7.5 8 3.25l4.25 4.25'],
38
53
  steer: ['M3.5 3v5.5a2 2 0 0 0 2 2h7', 'M10 8l2.5 2.5L10 13'],
@@ -80,7 +95,13 @@
80
95
  ],
81
96
  // The arch of the doors: Narvi's own mark
82
97
  arch: ['M4 13.5V7.25a4 4 0 0 1 8 0v6.25', 'M8 3.25v10.25', 'M2.5 13.5h11'],
83
- minus: ['M5 8h6']
98
+ minus: ['M5 8h6'],
99
+ // Taking a colour from the screen: Lucide's pipette, on this grid
100
+ pipette: [
101
+ 'm8 6-5.61 5.61a1.33 1.33 0 0 0-.39.94v.9a1.33 1.33 0 0 1-.39.94 1.33 1.33 0 0 1 .94-.39h.9a1.33 1.33 0 0 0 .94-.39L10 8',
102
+ 'm12 6 .27.27a.67.67 0 1 1-2 2l-2.53-2.53a.67.67 0 1 1 2-2l.27.27 2.27-2.27a.67.67 0 1 1 2 2Z',
103
+ 'm1.33 14.67.28-.28'
104
+ ]
84
105
  } as const;
85
106
 
86
107
  export type GlyphName = keyof typeof paths;
@@ -14,8 +14,10 @@ declare const paths: {
14
14
  readonly pencil: readonly ["M10.5 3.5 12.5 5.5", "M3 13l.5-2.5 7.75-7.75a1.4 1.4 0 0 1 2 2L5.5 12.5Z"];
15
15
  readonly eye: readonly ["M1.75 8S4 3.75 8 3.75 14.25 8 14.25 8 12 12.25 8 12.25 1.75 8 1.75 8Z", "M10 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z"];
16
16
  readonly globe: readonly ["M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0Z", "M2 8h12", "M8 2c1.7 1.7 2.5 3.7 2.5 6S9.7 12.3 8 14C6.3 12.3 5.5 10.3 5.5 8S6.3 3.7 8 2Z"];
17
- readonly plug: readonly ["M6 2.5v3", "M10 2.5v3", "M4.5 5.5h7v2.5a3.5 3.5 0 0 1-7 0Z", "M8 11.5v2"];
18
17
  readonly sparkle: readonly ["M8 2.5 9.4 6.6 13.5 8 9.4 9.4 8 13.5 6.6 9.4 2.5 8 6.6 6.6Z"];
18
+ readonly squarePen: readonly ["M8 2.75H4.25C3.56 2.75 3 3.31 3 4v7.75c0 .69.56 1.25 1.25 1.25H12c.69 0 1.25-.56 1.25-1.25V8", "M12.25 1.75a.67.67 0 0 1 2 2L8.24 9.76a1.33 1.33 0 0 1-.57.34l-1.92.56a.33.33 0 0 1-.41-.41l.56-1.92a1.33 1.33 0 0 1 .34-.57Z"];
19
+ readonly wrench: readonly ["M9.8 4.2a.67.67 0 0 0 0 .93l1.07 1.07a.67.67 0 0 0 .93 0l2.07-2.07c.21-.21.58-.15.66.15a4 4 0 0 1-5.51 4.7l-5.27 5.27a.67.67 0 0 1-2-2l5.27-5.27a4 4 0 0 1 4.7-5.51c.29.08.36.44.15.66Z"];
20
+ readonly bot: readonly ["M8 5.25v-2.5H5.5", "M4.25 5.25h7.5c.69 0 1.25.56 1.25 1.25V12c0 .69-.56 1.25-1.25 1.25h-7.5C3.56 13.25 3 12.69 3 12V6.5c0-.69.56-1.25 1.25-1.25Z", "M1.5 9.25H3", "M13 9.25h1.5", "M10 8.5V10", "M6 8.5V10"];
19
21
  readonly undo: readonly ["M5.5 4 2.5 7l3 3", "M2.5 7h6.75a4 4 0 0 1 0 8H8"];
20
22
  readonly send: readonly ["M8 13V3.25", "M3.75 7.5 8 3.25l4.25 4.25"];
21
23
  readonly steer: readonly ["M3.5 3v5.5a2 2 0 0 0 2 2h7", "M10 8l2.5 2.5L10 13"];
@@ -31,6 +33,7 @@ declare const paths: {
31
33
  readonly layers: readonly ["M8 2.75 13.25 5.5 8 8.25 2.75 5.5Z", "M2.75 8.25 8 11l5.25-2.75", "M2.75 11 8 13.75 13.25 11"];
32
34
  readonly arch: readonly ["M4 13.5V7.25a4 4 0 0 1 8 0v6.25", "M8 3.25v10.25", "M2.5 13.5h11"];
33
35
  readonly minus: readonly ["M5 8h6"];
36
+ readonly pipette: readonly ["m8 6-5.61 5.61a1.33 1.33 0 0 0-.39.94v.9a1.33 1.33 0 0 1-.39.94 1.33 1.33 0 0 1 .94-.39h.9a1.33 1.33 0 0 0 .94-.39L10 8", "m12 6 .27.27a.67.67 0 1 1-2 2l-2.53-2.53a.67.67 0 1 1 2-2l.27.27 2.27-2.27a.67.67 0 1 1 2 2Z", "m1.33 14.67.28-.28"];
34
37
  };
35
38
  export type GlyphName = keyof typeof paths;
36
39
  /**
@@ -39,18 +39,18 @@ export declare const control: Readonly<{
39
39
  readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", "none" | `inset 0 0 0 0.5px ${stylex.StyleXVar<string>}, 0 0 0 3px color-mix(in oklab, ${stylex.StyleXVar<string>} 22%, transparent)`>;
40
40
  }>;
41
41
  readonly sm: Readonly<{
42
- readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "28px">;
43
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "8px">;
42
+ readonly minHeight: stylex.StyleXClassNameFor<"minHeight", string>;
43
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
44
44
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
45
45
  readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
46
46
  }>;
47
47
  readonly md: Readonly<{
48
- readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "34px">;
49
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "10px">;
48
+ readonly minHeight: stylex.StyleXClassNameFor<"minHeight", string>;
49
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
50
50
  }>;
51
51
  readonly lg: Readonly<{
52
- readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "40px">;
53
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "12px">;
52
+ readonly minHeight: stylex.StyleXClassNameFor<"minHeight", string>;
53
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
54
54
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
55
55
  readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
56
56
  }>;
@@ -1,9 +1,11 @@
1
1
  import * as stylex from '@stylexjs/stylex';
2
- import { colors, font, motion, radius } from '../tokens.stylex.js';
2
+ import { colors, density, font, motion, radius } from '../tokens.stylex.js';
3
3
  import { media } from '../media.stylex.js';
4
4
  // Hover and focus as they happen, or as the catalog shows them without a pointer or a keyboard
5
5
  const HOVER = ':is(:hover, [data-preview~="hover"])';
6
6
  const FOCUS = ':is(:focus-visible, [data-preview~="focus"])';
7
+ /** A length at the window's density (`density` in the tokens). */
8
+ const d = (rem) => `calc(${rem} * ${density.factor})`;
7
9
  /** Shared look for text-entry controls: Input and Textarea. A 3:1 edge, and nothing behind it. */
8
10
  export const control = stylex.create({
9
11
  base: {
@@ -59,18 +61,18 @@ export const control = stylex.create({
59
61
  }
60
62
  },
61
63
  sm: {
62
- minHeight: '28px',
63
- paddingInline: '8px',
64
+ minHeight: d('1.75rem'),
65
+ paddingInline: d('0.5rem'),
64
66
  borderRadius: radius.item,
65
67
  fontSize: { default: font.sizeMeta, [media.coarse]: font.sizeReading }
66
68
  },
67
69
  md: {
68
- minHeight: '34px',
69
- paddingInline: '10px'
70
+ minHeight: d('2.125rem'),
71
+ paddingInline: d('0.625rem')
70
72
  },
71
73
  lg: {
72
- minHeight: '40px',
73
- paddingInline: '12px',
74
+ minHeight: d('2.5rem'),
75
+ paddingInline: d('0.75rem'),
74
76
  borderRadius: radius.panel,
75
77
  fontSize: font.sizeReading
76
78
  }
@@ -0,0 +1,18 @@
1
+ /** Hue from 0 to 360, saturation and brightness from 0 to 1. */
2
+ export type Hsv = {
3
+ h: number;
4
+ s: number;
5
+ v: number;
6
+ };
7
+ export declare const rgbToHex: (r: number, g: number, b: number) => string;
8
+ /** `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` as `#rrggbb`, its alpha left out. */
9
+ export declare function parseHex(text: string): string | undefined;
10
+ /**
11
+ * Any CSS colour as `#rrggbb`: a hex with or without its `#`, a name, `rgb()`, `hsl()`,
12
+ * `oklch()` and the rest. Its alpha is left out. Undefined for anything else, and on the
13
+ * server for anything but a hex, which needs the browser to read.
14
+ */
15
+ export declare function toHex(text: string): string | undefined;
16
+ /** A `#rrggbb` as HSV, keeping `hue` where the colour has none of its own (a grey). */
17
+ export declare function hexToHsv(hex: string, hue?: number): Hsv;
18
+ export declare function hsvToHex({ h, s, v }: Hsv): string;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * A colour as a picker moves it: hue, saturation and brightness (HSV), each kept as a float so
3
+ * a colour taken in and given back is the same hex, and the hue is kept when saturation or
4
+ * brightness reaches 0, where the hex alone would forget it.
5
+ */
6
+ import { resolveRgba } from '../color.js';
7
+ const clamp = (value, max = 1) => Math.min(Math.max(value, 0), max);
8
+ const pad = (channel) => Math.round(clamp(channel, 255)).toString(16).padStart(2, '0');
9
+ export const rgbToHex = (r, g, b) => `#${pad(r)}${pad(g)}${pad(b)}`;
10
+ /** `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` as `#rrggbb`, its alpha left out. */
11
+ export function parseHex(text) {
12
+ const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(text.trim())?.[1];
13
+ if (hex === undefined)
14
+ return undefined;
15
+ const full = hex.length <= 4 ? [...hex].map((digit) => digit + digit).join('') : hex;
16
+ return `#${full.slice(0, 6).toLowerCase()}`;
17
+ }
18
+ /** Words that are valid colours in CSS but are not a colour of their own. */
19
+ const NOT_A_COLOUR = /var\(|env\(|attr\(|currentcolor|inherit|initial|unset|revert/i;
20
+ /**
21
+ * Any CSS colour as `#rrggbb`: a hex with or without its `#`, a name, `rgb()`, `hsl()`,
22
+ * `oklch()` and the rest. Its alpha is left out. Undefined for anything else, and on the
23
+ * server for anything but a hex, which needs the browser to read.
24
+ */
25
+ export function toHex(text) {
26
+ const trimmed = text.trim();
27
+ const hex = parseHex(/^[0-9a-f]{3,8}$/i.test(trimmed) ? `#${trimmed}` : trimmed);
28
+ if (hex !== undefined)
29
+ return hex;
30
+ if (typeof document === 'undefined' ||
31
+ trimmed === '' ||
32
+ NOT_A_COLOUR.test(trimmed) ||
33
+ !CSS.supports('color', trimmed))
34
+ return undefined;
35
+ const [r, g, b] = resolveRgba(trimmed);
36
+ return rgbToHex(r, g, b);
37
+ }
38
+ /** A `#rrggbb` as HSV, keeping `hue` where the colour has none of its own (a grey). */
39
+ export function hexToHsv(hex, hue = 0) {
40
+ const value = Number.parseInt(hex.slice(1), 16);
41
+ const r = ((value >> 16) & 255) / 255;
42
+ const g = ((value >> 8) & 255) / 255;
43
+ const b = (value & 255) / 255;
44
+ const max = Math.max(r, g, b);
45
+ const range = max - Math.min(r, g, b);
46
+ let h = hue;
47
+ if (range > 0) {
48
+ if (max === r)
49
+ h = 60 * (((g - b) / range + 6) % 6);
50
+ else if (max === g)
51
+ h = 60 * ((b - r) / range + 2);
52
+ else
53
+ h = 60 * ((r - g) / range + 4);
54
+ }
55
+ return { h, s: max === 0 ? 0 : range / max, v: max };
56
+ }
57
+ export function hsvToHex({ h, s, v }) {
58
+ const channel = (n) => {
59
+ const k = (n + h / 60) % 6;
60
+ return (v - v * s * Math.max(0, Math.min(k, 4 - k, 1))) * 255;
61
+ };
62
+ return rgbToHex(channel(5), channel(3), channel(1));
63
+ }
@@ -1,5 +1,5 @@
1
1
  import type { GlyphName } from './Glyph.svelte';
2
- /** What an agent's action was, which picks its icon. */
2
+ /** What an agent's action was, which picks its icon: the ones T3 Code's work log draws. */
3
3
  export type ActionKind = 'command' | 'edit' | 'read' | 'search' | 'web' | 'tool' | 'agent';
4
4
  export declare const KIND_GLYPHS: Record<ActionKind, GlyphName>;
5
5
  /**
@@ -1,11 +1,11 @@
1
1
  export const KIND_GLYPHS = {
2
2
  command: 'terminal',
3
- edit: 'pencil',
3
+ edit: 'squarePen',
4
4
  read: 'eye',
5
5
  search: 'search',
6
6
  web: 'globe',
7
- tool: 'plug',
8
- agent: 'sparkle'
7
+ tool: 'wrench',
8
+ agent: 'bot'
9
9
  };
10
10
  /**
11
11
  * A step's label split so the part that matters stands out: the file name of a
@@ -21,7 +21,7 @@ export declare const layer: Readonly<{
21
21
  readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "var(--bits-floating-available-height, 80vh)">;
22
22
  readonly overflowY: stylex.StyleXClassNameFor<"overflowY", "auto">;
23
23
  readonly overscrollBehavior: stylex.StyleXClassNameFor<"overscrollBehavior", "contain">;
24
- readonly padding: stylex.StyleXClassNameFor<"padding", "0.25rem">;
24
+ readonly padding: stylex.StyleXClassNameFor<"padding", string>;
25
25
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
26
26
  readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
27
27
  readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", `inset 0 0 0 1px ${stylex.StyleXVar<string>}, 0 16px 40px -12px ${stylex.StyleXVar<string>}`>;
@@ -29,7 +29,6 @@ export declare const layer: Readonly<{
29
29
  readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
30
30
  readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
31
31
  readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", string>;
32
- readonly scrollbarWidth: stylex.StyleXClassNameFor<"scrollbarWidth", "thin">;
33
32
  readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
34
33
  readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", 0 | "1px">;
35
34
  readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", "CanvasText">;
@@ -48,7 +47,7 @@ export declare const layer: Readonly<{
48
47
  readonly column: Readonly<{
49
48
  readonly display: stylex.StyleXClassNameFor<"display", "flex">;
50
49
  readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
51
- readonly gap: stylex.StyleXClassNameFor<"gap", "0.625rem">;
50
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
52
51
  }>;
53
52
  readonly item: Readonly<{
54
53
  readonly position: stylex.StyleXClassNameFor<"position", "relative">;
@@ -56,9 +55,9 @@ export declare const layer: Readonly<{
56
55
  readonly display: stylex.StyleXClassNameFor<"display", "flex">;
57
56
  readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
58
57
  readonly gap: stylex.StyleXClassNameFor<"gap", "0.5rem">;
59
- readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "2rem">;
60
- readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", "0.375rem">;
61
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.5rem">;
58
+ readonly minHeight: stylex.StyleXClassNameFor<"minHeight", string>;
59
+ readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", string>;
60
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
62
61
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
63
62
  readonly color: stylex.StyleXClassNameFor<"color", string>;
64
63
  readonly cursor: stylex.StyleXClassNameFor<"cursor", "default" | "not-allowed">;
@@ -110,17 +109,17 @@ export declare const layer: Readonly<{
110
109
  readonly fontVariantNumeric: stylex.StyleXClassNameFor<"fontVariantNumeric", "tabular-nums">;
111
110
  }>;
112
111
  readonly heading: Readonly<{
113
- readonly paddingTop: stylex.StyleXClassNameFor<"paddingTop", "0.5rem">;
114
- readonly paddingBottom: stylex.StyleXClassNameFor<"paddingBottom", "0.25rem">;
115
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.5rem">;
112
+ readonly paddingTop: stylex.StyleXClassNameFor<"paddingTop", string>;
113
+ readonly paddingBottom: stylex.StyleXClassNameFor<"paddingBottom", string>;
114
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
116
115
  readonly color: stylex.StyleXClassNameFor<"color", string>;
117
116
  readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
118
117
  readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", "500">;
119
118
  }>;
120
119
  readonly separator: Readonly<{
121
120
  readonly height: stylex.StyleXClassNameFor<"height", "1px">;
122
- readonly marginBlock: stylex.StyleXClassNameFor<"marginBlock", "0.25rem">;
123
- readonly marginInline: stylex.StyleXClassNameFor<"marginInline", "-0.25rem">;
121
+ readonly marginBlock: stylex.StyleXClassNameFor<"marginBlock", string>;
122
+ readonly marginInline: stylex.StyleXClassNameFor<"marginInline", string>;
124
123
  readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
125
124
  }>;
126
125
  readonly hoverable: Readonly<{
@@ -6,7 +6,7 @@
6
6
  * the exit is seen.
7
7
  */
8
8
  import * as stylex from '@stylexjs/stylex';
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 './icons.css';
12
12
  const CLOSED = ':is([data-state="closed"])';
@@ -25,6 +25,8 @@ export function widthStyle(width, style, minWidth) {
25
25
  ].filter(Boolean);
26
26
  return parts.length ? parts.join('; ') : undefined;
27
27
  }
28
+ /** A length at the window's density (`density` in the tokens). */
29
+ const d = (rem) => `calc(${rem} * ${density.factor})`;
28
30
  export const layer = stylex.create({
29
31
  surface: {
30
32
  boxSizing: 'border-box',
@@ -38,8 +40,8 @@ export const layer = stylex.create({
38
40
  maxHeight: 'var(--bits-floating-available-height, 80vh)',
39
41
  overflowY: 'auto',
40
42
  overscrollBehavior: 'contain',
41
- padding: '0.25rem',
42
- // Items are 8px round inside 4px of padding: 12px outside
43
+ padding: d('0.25rem'),
44
+ // Items are 8px round inside 4px of padding (at the default density): 12px outside
43
45
  borderRadius: radius.card,
44
46
  backgroundColor: colors.bgRaised,
45
47
  boxShadow: `inset 0 0 0 1px ${colors.borderStrong}, 0 16px 40px -12px ${colors.shadow}`,
@@ -47,7 +49,6 @@ export const layer = stylex.create({
47
49
  fontFamily: font.body,
48
50
  fontSize: font.sizeBody,
49
51
  lineHeight: font.leadingSnug,
50
- scrollbarWidth: 'thin',
51
52
  outlineStyle: 'solid',
52
53
  outlineWidth: { default: 0, [media.forcedColors]: '1px' },
53
54
  outlineColor: 'CanvasText',
@@ -69,7 +70,7 @@ export const layer = stylex.create({
69
70
  maxWidth: 'none'
70
71
  },
71
72
  // Content of its own, one part under another, with room between them
72
- column: { display: 'flex', flexDirection: 'column', gap: '0.625rem' },
73
+ column: { display: 'flex', flexDirection: 'column', gap: d('0.625rem') },
73
74
  // A row in a menu, a select or the palette
74
75
  item: {
75
76
  position: 'relative',
@@ -77,9 +78,9 @@ export const layer = stylex.create({
77
78
  display: 'flex',
78
79
  alignItems: 'center',
79
80
  gap: '0.5rem',
80
- minHeight: '2rem',
81
- paddingBlock: '0.375rem',
82
- paddingInline: '0.5rem',
81
+ minHeight: d('2rem'),
82
+ paddingBlock: d('0.375rem'),
83
+ paddingInline: d('0.5rem'),
83
84
  borderRadius: radius.control,
84
85
  color: { default: colors.text, [DISABLED]: colors.textSubtle },
85
86
  cursor: { default: 'default', [DISABLED]: 'not-allowed' },
@@ -134,17 +135,17 @@ export const layer = stylex.create({
134
135
  fontVariantNumeric: 'tabular-nums'
135
136
  },
136
137
  heading: {
137
- paddingTop: '0.5rem',
138
- paddingBottom: '0.25rem',
139
- paddingInline: '0.5rem',
138
+ paddingTop: d('0.5rem'),
139
+ paddingBottom: d('0.25rem'),
140
+ paddingInline: d('0.5rem'),
140
141
  color: colors.textSubtle,
141
142
  fontSize: font.sizeCaption,
142
143
  fontWeight: '500'
143
144
  },
144
145
  separator: {
145
146
  height: '1px',
146
- marginBlock: '0.25rem',
147
- marginInline: '-0.25rem',
147
+ marginBlock: d('0.25rem'),
148
+ marginInline: d('-0.25rem'),
148
149
  backgroundColor: colors.border
149
150
  },
150
151
  hoverable: {
@@ -37,8 +37,8 @@ export declare const toggle: Readonly<{
37
37
  readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", "ease" | `${stylex.StyleXVar<string>}, ease, ease, ease`>;
38
38
  }>;
39
39
  readonly sm: Readonly<{
40
- readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "1.75rem">;
41
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.625rem">;
40
+ readonly minHeight: stylex.StyleXClassNameFor<"minHeight", string>;
41
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
42
42
  readonly gap: stylex.StyleXClassNameFor<"gap", "0.375rem">;
43
43
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
44
44
  readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
@@ -46,12 +46,12 @@ export declare const toggle: Readonly<{
46
46
  readonly content: "\"\"";
47
47
  readonly position: "absolute";
48
48
  readonly insetInline: 0;
49
- readonly insetBlock: "-6px";
49
+ readonly insetBlock: `calc((${string} - 2.5rem) / 2)`;
50
50
  }>;
51
51
  }>;
52
52
  readonly md: Readonly<{
53
- readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "2rem">;
54
- readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.75rem">;
53
+ readonly minHeight: stylex.StyleXClassNameFor<"minHeight", string>;
54
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
55
55
  readonly gap: stylex.StyleXClassNameFor<"gap", "0.4375rem">;
56
56
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
57
57
  readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
@@ -59,15 +59,15 @@ export declare const toggle: Readonly<{
59
59
  readonly content: "\"\"";
60
60
  readonly position: "absolute";
61
61
  readonly insetInline: 0;
62
- readonly insetBlock: "-4px";
62
+ readonly insetBlock: `calc((${string} - 2.5rem) / 2)`;
63
63
  }>;
64
64
  }>;
65
65
  readonly iconSm: Readonly<{
66
- readonly width: stylex.StyleXClassNameFor<"width", "1.75rem">;
66
+ readonly width: stylex.StyleXClassNameFor<"width", string>;
67
67
  readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
68
68
  }>;
69
69
  readonly iconMd: Readonly<{
70
- readonly width: stylex.StyleXClassNameFor<"width", "2rem">;
70
+ readonly width: stylex.StyleXClassNameFor<"width", string>;
71
71
  readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
72
72
  }>;
73
73
  readonly neutral: Readonly<{
@@ -5,10 +5,12 @@
5
5
  * the fill of what is chosen.
6
6
  */
7
7
  import * as stylex from '@stylexjs/stylex';
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
  const ON = ':is([data-state="on"])';
11
11
  const DISABLED = ':is([data-disabled])';
12
+ /** A length at the window's density (`density` in the tokens). */
13
+ const d = (rem) => `calc(${rem} * ${density.factor})`;
12
14
  export const toggle = stylex.create({
13
15
  base: {
14
16
  position: 'relative',
@@ -62,25 +64,35 @@ export const toggle = stylex.create({
62
64
  [media.motion]: `${motion.easeOut}, ease, ease, ease`
63
65
  }
64
66
  },
65
- // The same heights as Button's, and the same 40px reach for a finger
67
+ // The same heights as Button's, and the same 40px reach for a finger, at any density
66
68
  sm: {
67
- minHeight: '1.75rem',
68
- paddingInline: '0.625rem',
69
+ minHeight: d('1.75rem'),
70
+ paddingInline: d('0.625rem'),
69
71
  gap: '0.375rem',
70
72
  borderRadius: radius.item,
71
73
  fontSize: font.sizeMeta,
72
- '::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-6px' }
74
+ '::after': {
75
+ content: '""',
76
+ position: 'absolute',
77
+ insetInline: 0,
78
+ insetBlock: `calc((${d('1.75rem')} - 2.5rem) / 2)`
79
+ }
73
80
  },
74
81
  md: {
75
- minHeight: '2rem',
76
- paddingInline: '0.75rem',
82
+ minHeight: d('2rem'),
83
+ paddingInline: d('0.75rem'),
77
84
  gap: '0.4375rem',
78
85
  borderRadius: radius.control,
79
86
  fontSize: font.sizeBody,
80
- '::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-4px' }
87
+ '::after': {
88
+ content: '""',
89
+ position: 'absolute',
90
+ insetInline: 0,
91
+ insetBlock: `calc((${d('2rem')} - 2.5rem) / 2)`
92
+ }
81
93
  },
82
- iconSm: { width: '1.75rem', paddingInline: 0 },
83
- iconMd: { width: '2rem', paddingInline: 0 },
94
+ iconSm: { width: d('1.75rem'), paddingInline: 0 },
95
+ iconMd: { width: d('2rem'), paddingInline: 0 },
84
96
  // On, without the accent: the fill of what is chosen, in the text's colour. For a toolbar's
85
97
  // icons, such as a panel shown or hidden, where a lit one would read as something live.
86
98
  neutral: {