@diegopluna/narvi 0.3.11 → 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 (86) hide show
  1. package/dist/components/activity/ActivityContent.svelte +7 -3
  2. package/dist/components/activity/ActivityStep.svelte +9 -6
  3. package/dist/components/activity/ActivityTrigger.svelte +5 -2
  4. package/dist/components/app-shell/AppShellBar.svelte +9 -4
  5. package/dist/components/app-shell/AppShellHeader.svelte +9 -5
  6. package/dist/components/approval/Approval.svelte +7 -4
  7. package/dist/components/button/Button.svelte +50 -26
  8. package/dist/components/card/Card.svelte +5 -2
  9. package/dist/components/changes-summary/ChangesSummary.svelte +11 -8
  10. package/dist/components/choice-cards/ChoiceCards.svelte +5 -2
  11. package/dist/components/collapsible/CollapsibleTrigger.svelte +5 -2
  12. package/dist/components/color-field/ColorField.svelte +9 -6
  13. package/dist/components/command/styles.d.ts +8 -8
  14. package/dist/components/command/styles.js +11 -9
  15. package/dist/components/composer/ComposerAttachment.svelte +7 -3
  16. package/dist/components/composer/ComposerAttachments.svelte +5 -1
  17. package/dist/components/composer/ComposerModelPicker.svelte +37 -34
  18. package/dist/components/composer/ComposerRoot.svelte +9 -5
  19. package/dist/components/composer/ComposerTextarea.svelte +9 -5
  20. package/dist/components/composer/ComposerToggle.svelte +7 -4
  21. package/dist/components/composer/ComposerToolbar.svelte +5 -1
  22. package/dist/components/composer/ComposerTray.svelte +10 -7
  23. package/dist/components/conversation/ConversationScrollButton.svelte +10 -7
  24. package/dist/components/dialog/ConfirmDialog.svelte +5 -2
  25. package/dist/components/dialog/styles.d.ts +3 -3
  26. package/dist/components/dialog/styles.js +6 -4
  27. package/dist/components/frame/Frame.svelte +8 -5
  28. package/dist/components/hover-card/HoverCardContent.svelte +5 -1
  29. package/dist/components/input/Input.svelte +12 -8
  30. package/dist/components/message/MessageActions.svelte +8 -4
  31. package/dist/components/message/MessageContent.svelte +6 -2
  32. package/dist/components/message/MessagePending.svelte +5 -2
  33. package/dist/components/message/MessageRoot.svelte +10 -4
  34. package/dist/components/message/MessageTime.svelte +5 -2
  35. package/dist/components/message/styles.d.ts +2 -2
  36. package/dist/components/message/styles.js +5 -3
  37. package/dist/components/notice/Notice.svelte +13 -4
  38. package/dist/components/plan/Plan.svelte +13 -10
  39. package/dist/components/popover/PopoverContent.svelte +8 -1
  40. package/dist/components/questionnaire/Questionnaire.svelte +12 -9
  41. package/dist/components/queued-message/QueuedMessage.svelte +14 -7
  42. package/dist/components/rail/RailItem.svelte +16 -7
  43. package/dist/components/rail/RailRoot.svelte +9 -4
  44. package/dist/components/rail/RailSeparator.svelte +5 -2
  45. package/dist/components/reasoning/ReasoningContent.svelte +6 -3
  46. package/dist/components/reasoning/ReasoningTrigger.svelte +5 -2
  47. package/dist/components/search-button/SearchButton.svelte +6 -3
  48. package/dist/components/segmented/SegmentedControl.svelte +6 -3
  49. package/dist/components/settings-group/SettingsGroup.svelte +5 -2
  50. package/dist/components/sidebar/SidebarContent.svelte +8 -4
  51. package/dist/components/sidebar/SidebarFolder.svelte +8 -5
  52. package/dist/components/sidebar/SidebarFooter.svelte +5 -2
  53. package/dist/components/sidebar/SidebarGroup.svelte +11 -8
  54. package/dist/components/sidebar/SidebarHeader.svelte +9 -4
  55. package/dist/components/sidebar/SidebarItem.svelte +14 -9
  56. package/dist/components/split-button/SplitButton.svelte +5 -2
  57. package/dist/components/suggestions/SuggestionsItem.svelte +6 -3
  58. package/dist/components/suggestions/SuggestionsRoot.svelte +5 -1
  59. package/dist/components/tab-strip/TabStrip.svelte +21 -16
  60. package/dist/components/tabs/Tabs.svelte +7 -4
  61. package/dist/components/textarea/Textarea.svelte +6 -2
  62. package/dist/components/theme/Theme.svelte +28 -2
  63. package/dist/components/toast/Toaster.svelte +14 -5
  64. package/dist/components/toggle-group/ToggleGroupRoot.svelte +5 -1
  65. package/dist/components/tool/ToolContent.svelte +8 -4
  66. package/dist/components/tool/ToolSection.svelte +7 -4
  67. package/dist/components/tool/ToolTrigger.svelte +5 -2
  68. package/dist/components/tooltip/TooltipContent.svelte +7 -4
  69. package/dist/components/work-fold/WorkFold.svelte +9 -6
  70. package/dist/internal/Code.svelte +6 -3
  71. package/dist/internal/control.d.ts +6 -6
  72. package/dist/internal/control.js +9 -7
  73. package/dist/internal/layer.d.ts +10 -10
  74. package/dist/internal/layer.js +14 -12
  75. package/dist/internal/toggle.d.ts +8 -8
  76. package/dist/internal/toggle.js +22 -10
  77. package/dist/preset.d.ts +12 -3
  78. package/dist/preset.js +18 -4
  79. package/dist/tokens.stylex.d.ts +13 -3
  80. package/dist/tokens.stylex.js +25 -14
  81. package/package.json +1 -1
  82. package/skills/building-ui/SKILL.md +1 -1
  83. package/skills/markdown/SKILL.md +1 -1
  84. package/skills/setup/SKILL.md +1 -1
  85. package/skills/styling/SKILL.md +5 -2
  86. package/skills/theming/SKILL.md +44 -3
@@ -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,6 +25,29 @@
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.
@@ -47,6 +70,9 @@
47
70
  const themes = $derived(theme === undefined ? [] : Array.isArray(theme) ? theme : [theme]);
48
71
  </script>
49
72
 
50
- <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
+ >
51
77
  {@render children?.()}
52
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,
@@ -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>
@@ -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,
@@ -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
  }
@@ -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>}`>;
@@ -47,7 +47,7 @@ export declare const layer: Readonly<{
47
47
  readonly column: Readonly<{
48
48
  readonly display: stylex.StyleXClassNameFor<"display", "flex">;
49
49
  readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
50
- readonly gap: stylex.StyleXClassNameFor<"gap", "0.625rem">;
50
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
51
51
  }>;
52
52
  readonly item: Readonly<{
53
53
  readonly position: stylex.StyleXClassNameFor<"position", "relative">;
@@ -55,9 +55,9 @@ export declare const layer: Readonly<{
55
55
  readonly display: stylex.StyleXClassNameFor<"display", "flex">;
56
56
  readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
57
57
  readonly gap: stylex.StyleXClassNameFor<"gap", "0.5rem">;
58
- readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "2rem">;
59
- readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", "0.375rem">;
60
- 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>;
61
61
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
62
62
  readonly color: stylex.StyleXClassNameFor<"color", string>;
63
63
  readonly cursor: stylex.StyleXClassNameFor<"cursor", "default" | "not-allowed">;
@@ -109,17 +109,17 @@ export declare const layer: Readonly<{
109
109
  readonly fontVariantNumeric: stylex.StyleXClassNameFor<"fontVariantNumeric", "tabular-nums">;
110
110
  }>;
111
111
  readonly heading: Readonly<{
112
- readonly paddingTop: stylex.StyleXClassNameFor<"paddingTop", "0.5rem">;
113
- readonly paddingBottom: stylex.StyleXClassNameFor<"paddingBottom", "0.25rem">;
114
- 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>;
115
115
  readonly color: stylex.StyleXClassNameFor<"color", string>;
116
116
  readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
117
117
  readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", "500">;
118
118
  }>;
119
119
  readonly separator: Readonly<{
120
120
  readonly height: stylex.StyleXClassNameFor<"height", "1px">;
121
- readonly marginBlock: stylex.StyleXClassNameFor<"marginBlock", "0.25rem">;
122
- readonly marginInline: stylex.StyleXClassNameFor<"marginInline", "-0.25rem">;
121
+ readonly marginBlock: stylex.StyleXClassNameFor<"marginBlock", string>;
122
+ readonly marginInline: stylex.StyleXClassNameFor<"marginInline", string>;
123
123
  readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
124
124
  }>;
125
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}`,
@@ -68,7 +70,7 @@ export const layer = stylex.create({
68
70
  maxWidth: 'none'
69
71
  },
70
72
  // Content of its own, one part under another, with room between them
71
- column: { display: 'flex', flexDirection: 'column', gap: '0.625rem' },
73
+ column: { display: 'flex', flexDirection: 'column', gap: d('0.625rem') },
72
74
  // A row in a menu, a select or the palette
73
75
  item: {
74
76
  position: 'relative',
@@ -76,9 +78,9 @@ export const layer = stylex.create({
76
78
  display: 'flex',
77
79
  alignItems: 'center',
78
80
  gap: '0.5rem',
79
- minHeight: '2rem',
80
- paddingBlock: '0.375rem',
81
- paddingInline: '0.5rem',
81
+ minHeight: d('2rem'),
82
+ paddingBlock: d('0.375rem'),
83
+ paddingInline: d('0.5rem'),
82
84
  borderRadius: radius.control,
83
85
  color: { default: colors.text, [DISABLED]: colors.textSubtle },
84
86
  cursor: { default: 'default', [DISABLED]: 'not-allowed' },
@@ -133,17 +135,17 @@ export const layer = stylex.create({
133
135
  fontVariantNumeric: 'tabular-nums'
134
136
  },
135
137
  heading: {
136
- paddingTop: '0.5rem',
137
- paddingBottom: '0.25rem',
138
- paddingInline: '0.5rem',
138
+ paddingTop: d('0.5rem'),
139
+ paddingBottom: d('0.25rem'),
140
+ paddingInline: d('0.5rem'),
139
141
  color: colors.textSubtle,
140
142
  fontSize: font.sizeCaption,
141
143
  fontWeight: '500'
142
144
  },
143
145
  separator: {
144
146
  height: '1px',
145
- marginBlock: '0.25rem',
146
- marginInline: '-0.25rem',
147
+ marginBlock: d('0.25rem'),
148
+ marginInline: d('-0.25rem'),
147
149
  backgroundColor: colors.border
148
150
  },
149
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: {