@diegopluna/narvi 0.0.1 → 0.1.0

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 (112) hide show
  1. package/README.md +27 -8
  2. package/dist/base.css +96 -0
  3. package/dist/color.d.ts +38 -0
  4. package/dist/color.js +88 -0
  5. package/dist/components/activity/ActivityTrigger.svelte +2 -3
  6. package/dist/components/app-shell/AppShellHeader.svelte +2 -3
  7. package/dist/components/app-shell/AppShellSidebar.svelte +6 -6
  8. package/dist/components/approval/Approval.svelte +8 -4
  9. package/dist/components/button/Button.svelte +15 -18
  10. package/dist/components/card/Card.svelte +98 -12
  11. package/dist/components/card/Card.svelte.d.ts +8 -3
  12. package/dist/components/checkbox/Checkbox.svelte +16 -13
  13. package/dist/components/collapsible/CollapsibleContent.svelte +38 -0
  14. package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +11 -0
  15. package/dist/components/collapsible/CollapsibleRoot.svelte +44 -0
  16. package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +11 -0
  17. package/dist/components/collapsible/CollapsibleTrigger.svelte +83 -0
  18. package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +13 -0
  19. package/dist/components/collapsible/context.d.ts +5 -0
  20. package/dist/components/collapsible/context.js +11 -0
  21. package/dist/components/collapsible/index.d.ts +7 -0
  22. package/dist/components/collapsible/index.js +4 -0
  23. package/dist/components/command/styles.js +3 -3
  24. package/dist/components/composer/ComposerAttachment.svelte +4 -6
  25. package/dist/components/composer/ComposerModelPicker.svelte +8 -10
  26. package/dist/components/composer/ComposerRoot.svelte +7 -6
  27. package/dist/components/composer/ComposerSubmit.svelte +4 -5
  28. package/dist/components/composer/ComposerToggle.svelte +11 -11
  29. package/dist/components/conversation/ConversationScrollButton.svelte +6 -8
  30. package/dist/components/dialog/DialogContent.svelte +5 -1
  31. package/dist/components/dialog/styles.d.ts +0 -23
  32. package/dist/components/dialog/styles.js +7 -43
  33. package/dist/components/grid/Grid.svelte +111 -0
  34. package/dist/components/grid/Grid.svelte.d.ts +27 -0
  35. package/dist/components/hover-card/HoverCardContent.svelte +50 -0
  36. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +10 -0
  37. package/dist/components/hover-card/HoverCardRoot.svelte +22 -0
  38. package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -0
  39. package/dist/components/hover-card/index.d.ts +7 -0
  40. package/dist/components/hover-card/index.js +7 -0
  41. package/dist/components/link/Link.svelte +2 -4
  42. package/dist/components/message/MessageAction.svelte +2 -3
  43. package/dist/components/message/MessageActions.svelte +2 -3
  44. package/dist/components/message/MessageCopy.svelte +4 -5
  45. package/dist/components/message/MessageRoot.svelte +3 -4
  46. package/dist/components/message/MessageTime.svelte +2 -3
  47. package/dist/components/plan/Plan.svelte +3 -4
  48. package/dist/components/progress/Progress.svelte +4 -6
  49. package/dist/components/rail/RailItem.svelte +9 -9
  50. package/dist/components/reasoning/ReasoningTrigger.svelte +2 -3
  51. package/dist/components/resize-handle/ResizeHandle.svelte +3 -5
  52. package/dist/components/reveal/Reveal.svelte +89 -0
  53. package/dist/components/reveal/Reveal.svelte.d.ts +17 -0
  54. package/dist/components/reveal/revealed.d.ts +38 -0
  55. package/dist/components/reveal/revealed.js +79 -0
  56. package/dist/components/segmented/SegmentedControl.svelte +5 -9
  57. package/dist/components/sheet/SheetContent.svelte +63 -0
  58. package/dist/components/sheet/SheetContent.svelte.d.ts +18 -0
  59. package/dist/components/sheet/index.d.ts +12 -0
  60. package/dist/components/sheet/index.js +12 -0
  61. package/dist/components/sheet/styles.d.ts +51 -0
  62. package/dist/components/sheet/styles.js +65 -0
  63. package/dist/components/shimmer/Shimmer.svelte +8 -6
  64. package/dist/components/sidebar/SidebarGroup.svelte +5 -3
  65. package/dist/components/sidebar/SidebarItem.svelte +10 -8
  66. package/dist/components/slider/Slider.svelte +199 -0
  67. package/dist/components/slider/Slider.svelte.d.ts +55 -0
  68. package/dist/components/stack/Stack.svelte +37 -44
  69. package/dist/components/stack/Stack.svelte.d.ts +12 -6
  70. package/dist/components/suggestions/SuggestionsItem.svelte +7 -9
  71. package/dist/components/switch/Switch.svelte +8 -12
  72. package/dist/components/tabs/Tabs.svelte +3 -6
  73. package/dist/components/text/Text.svelte +47 -5
  74. package/dist/components/text/Text.svelte.d.ts +8 -2
  75. package/dist/components/toast/Toaster.svelte +7 -5
  76. package/dist/components/toggle/Toggle.svelte +40 -0
  77. package/dist/components/toggle/Toggle.svelte.d.ts +15 -0
  78. package/dist/components/toggle-group/ToggleGroupItem.svelte +37 -0
  79. package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -0
  80. package/dist/components/toggle-group/ToggleGroupRoot.svelte +95 -0
  81. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +33 -0
  82. package/dist/components/toggle-group/context.d.ts +6 -0
  83. package/dist/components/toggle-group/context.js +11 -0
  84. package/dist/components/toggle-group/index.d.ts +5 -0
  85. package/dist/components/toggle-group/index.js +3 -0
  86. package/dist/components/tool/ToolTrigger.svelte +4 -6
  87. package/dist/components/tooltip/TooltipContent.svelte +6 -3
  88. package/dist/components/work-fold/WorkFold.svelte +12 -25
  89. package/dist/components/work-fold/WorkFold.svelte.d.ts +1 -1
  90. package/dist/index.d.ts +25 -3
  91. package/dist/index.js +24 -2
  92. package/dist/internal/Chevron.svelte +2 -3
  93. package/dist/internal/Collapse.svelte +6 -5
  94. package/dist/internal/Collapse.svelte.d.ts +2 -1
  95. package/dist/internal/control.js +4 -4
  96. package/dist/internal/layer.js +6 -8
  97. package/dist/internal/layout.d.ts +13 -0
  98. package/dist/internal/layout.js +453 -0
  99. package/dist/internal/responsive.d.ts +45 -0
  100. package/dist/internal/responsive.js +42 -0
  101. package/dist/internal/sx.d.ts +39 -4
  102. package/dist/internal/sx.js +17 -0
  103. package/dist/internal/toggle.d.ts +74 -0
  104. package/dist/internal/toggle.js +87 -0
  105. package/dist/media.stylex.d.ts +52 -0
  106. package/dist/media.stylex.js +53 -0
  107. package/dist/preset.js +9 -3
  108. package/dist/tokens.stylex.d.ts +15 -0
  109. package/dist/tokens.stylex.js +24 -2
  110. package/dist/vite.d.ts +27 -3
  111. package/dist/vite.js +25 -3
  112. package/package.json +14 -5
@@ -7,6 +7,7 @@
7
7
  import { messageMarker } from '../../internal/markers.stylex.js';
8
8
  import { attrs, type Sx } from '../../internal/sx.js';
9
9
  import { colors, font, motion } from '../../tokens.stylex.js';
10
+ import { media } from '../../media.stylex.js';
10
11
 
11
12
  export type MessageTimeProps = {
12
13
  /** When it was sent. */
@@ -17,8 +18,6 @@
17
18
  class?: string;
18
19
  };
19
20
 
20
- const FINE = '@media (hover: hover) and (pointer: fine)';
21
-
22
21
  const styles = stylex.create({
23
22
  time: {
24
23
  paddingInline: '0.375rem',
@@ -28,7 +27,7 @@
28
27
  whiteSpace: 'nowrap',
29
28
  opacity: {
30
29
  default: 1,
31
- [FINE]: {
30
+ [media.hover]: {
32
31
  default: 0,
33
32
  [stylex.when.ancestor(':hover', messageMarker)]: 1,
34
33
  [stylex.when.ancestor(':focus-within', messageMarker)]: 1
@@ -5,6 +5,7 @@
5
5
  import { shared } from '../../internal/shared.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
7
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
8
+ import { media } from '../../media.stylex.js';
8
9
  import Spinner from '../spinner/Spinner.svelte';
9
10
 
10
11
  export type PlanStepStatus = 'pending' | 'active' | 'done' | 'skipped';
@@ -20,8 +21,6 @@
20
21
  class?: string;
21
22
  };
22
23
 
23
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
24
-
25
24
  const styles = stylex.create({
26
25
  plan: {
27
26
  display: 'flex',
@@ -104,8 +103,8 @@
104
103
  borderRadius: radius.full,
105
104
  color: colors.textSubtle,
106
105
  opacity: { default: 1, '@starting-style': 0 },
107
- scale: { default: null, [MOTION]: { default: 1, '@starting-style': 0.6 } },
108
- transitionProperty: { default: 'opacity', [MOTION]: 'opacity, scale' },
106
+ scale: { default: null, [media.motion]: { default: 1, '@starting-style': 0.6 } },
107
+ transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale' },
109
108
  transitionDuration: motion.slow,
110
109
  transitionTimingFunction: motion.easeOut
111
110
  },
@@ -4,6 +4,7 @@
4
4
  import { loop } from '../../internal/loop.js';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
6
  import { colors, motion, radius } from '../../tokens.stylex.js';
7
+ import { media } from '../../media.stylex.js';
7
8
 
8
9
  export type ProgressProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
9
10
  /** How far along, from 0 to `max`. Leave out while the amount is unknown. */
@@ -12,9 +13,6 @@
12
13
  sx?: Sx;
13
14
  };
14
15
 
15
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
16
- const FORCED = '@media (forced-colors: active)';
17
-
18
16
  // The bar of an unknown amount sweeps across on Narvi's shared clock, easing in
19
17
  // and out. With reduced motion it breathes in place instead.
20
18
  const ease = (t: number) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2);
@@ -67,7 +65,7 @@
67
65
  borderRadius: radius.full,
68
66
  backgroundImage: {
69
67
  default: `linear-gradient(90deg, ${colors.ithilStrong}, ${colors.ithil})`,
70
- [FORCED]: 'linear-gradient(Highlight, Highlight)'
68
+ [media.forcedColors]: 'linear-gradient(Highlight, Highlight)'
71
69
  },
72
70
  forcedColorAdjust: 'none'
73
71
  },
@@ -78,12 +76,12 @@
78
76
  default: 'calc(var(--narvi-progress) - 100%) 0',
79
77
  ':dir(rtl)': 'calc(100% - var(--narvi-progress)) 0'
80
78
  },
81
- transitionProperty: { default: 'none', [MOTION]: 'translate' },
79
+ transitionProperty: { default: 'none', [media.motion]: 'translate' },
82
80
  transitionDuration: motion.slow,
83
81
  transitionTimingFunction: motion.easeOut
84
82
  },
85
83
  unknown: {
86
- width: { default: '100%', [MOTION]: '40%' }
84
+ width: { default: '100%', [media.motion]: '40%' }
87
85
  }
88
86
  });
89
87
  </script>
@@ -4,6 +4,7 @@
4
4
  import { shared } from '../../internal/shared.js';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
6
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
7
+ import { media } from '../../media.stylex.js';
7
8
  import * as Tooltip from '../tooltip/index.js';
8
9
 
9
10
  export type RailItemProps = {
@@ -23,10 +24,6 @@
23
24
  children?: Snippet;
24
25
  };
25
26
 
26
- const HOVER = '@media (hover: hover) and (pointer: fine)';
27
- const FORCED = '@media (forced-colors: active)';
28
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
29
-
30
27
  const styles = stylex.create({
31
28
  item: {
32
29
  position: 'relative',
@@ -41,16 +38,19 @@
41
38
  borderRadius: radius.lg,
42
39
  backgroundColor: {
43
40
  default: 'transparent',
44
- ':hover': { default: null, [HOVER]: colors.hover }
41
+ ':hover': { default: null, [media.hover]: colors.hover }
42
+ },
43
+ color: {
44
+ default: colors.textSubtle,
45
+ ':hover': { default: null, [media.hover]: colors.text }
45
46
  },
46
- color: { default: colors.textSubtle, ':hover': { default: null, [HOVER]: colors.text } },
47
47
  cursor: 'pointer',
48
48
  textDecoration: 'none',
49
49
  WebkitTapHighlightColor: 'transparent',
50
- scale: { default: null, ':active': { default: null, [MOTION]: 0.95 } },
50
+ scale: { default: null, ':active': { default: null, [media.motion]: 0.95 } },
51
51
  transitionProperty: {
52
52
  default: 'background-color, color',
53
- [MOTION]: 'background-color, color, scale'
53
+ [media.motion]: 'background-color, color, scale'
54
54
  },
55
55
  transitionDuration: motion.fast,
56
56
  transitionTimingFunction: 'ease'
@@ -68,7 +68,7 @@
68
68
  bottom: '25%',
69
69
  width: '2px',
70
70
  borderRadius: '2px',
71
- backgroundColor: { default: colors.ithil, [FORCED]: 'Highlight' },
71
+ backgroundColor: { default: colors.ithil, [media.forcedColors]: 'Highlight' },
72
72
  boxShadow: `0 0 8px ${colors.glow}`,
73
73
  forcedColorAdjust: 'none'
74
74
  }
@@ -6,6 +6,7 @@
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
7
  import Tile from '../../internal/Tile.svelte';
8
8
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
9
+ import { media } from '../../media.stylex.js';
9
10
  import Shimmer from '../shimmer/Shimmer.svelte';
10
11
  import { getReasoningContext } from './context.js';
11
12
 
@@ -19,8 +20,6 @@
19
20
  children?: Snippet<[{ streaming: boolean; duration: number | undefined }]>;
20
21
  };
21
22
 
22
- const HOVER = '@media (hover: hover) and (pointer: fine)';
23
-
24
23
  const styles = stylex.create({
25
24
  trigger: {
26
25
  display: 'inline-flex',
@@ -35,7 +34,7 @@
35
34
  backgroundColor: 'transparent',
36
35
  color: {
37
36
  default: colors.textMuted,
38
- ':hover': { default: null, [HOVER]: colors.text }
37
+ ':hover': { default: null, [media.hover]: colors.text }
39
38
  },
40
39
  fontFamily: 'inherit',
41
40
  fontSize: font.sizeMd,
@@ -11,6 +11,7 @@
11
11
  import type { HTMLAttributes } from 'svelte/elements';
12
12
  import { attrs, type Sx } from '../../internal/sx.js';
13
13
  import { colors, motion } from '../../tokens.stylex.js';
14
+ import { media } from '../../media.stylex.js';
14
15
 
15
16
  export type ResizeHandleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
16
17
  /** The size, in pixels. Bindable. */
@@ -37,9 +38,6 @@
37
38
  sx?: Sx;
38
39
  };
39
40
 
40
- const HOVER = '@media (hover: hover) and (pointer: fine)';
41
- const FORCED = '@media (forced-colors: active)';
42
-
43
41
  const styles = stylex.create({
44
42
  // An 8px target with a 1px line in the middle, lit when it is reached
45
43
  handle: {
@@ -54,9 +52,9 @@
54
52
  position: 'absolute',
55
53
  backgroundColor: {
56
54
  default: 'transparent',
57
- ':hover': { default: null, [HOVER]: colors.ithil },
55
+ ':hover': { default: null, [media.hover]: colors.ithil },
58
56
  ':focus-visible': colors.focusRing,
59
- [FORCED]: 'CanvasText'
57
+ [media.forcedColors]: 'CanvasText'
60
58
  },
61
59
  boxShadow: { default: null, ':hover': `0 0 8px ${colors.glow}` },
62
60
  transitionProperty: 'background-color',
@@ -0,0 +1,89 @@
1
+ <!--
2
+ Eases its content up into place as it is scrolled to. It hides the content itself, once its
3
+ script runs, and only when it starts below the fold: a page without script, or opened halfway
4
+ down, shows everything at once and never flickers. Readers who ask for less motion see no move.
5
+ -->
6
+ <script lang="ts" module>
7
+ import * as stylex from '@stylexjs/stylex';
8
+ import type { Snippet } from 'svelte';
9
+ import type { HTMLAttributes } from 'svelte/elements';
10
+ import { attrs, type Sx } from '../../internal/sx.js';
11
+ import { media } from '../../media.stylex.js';
12
+ import { pageMotion } from '../../tokens.stylex.js';
13
+
14
+ export type RevealProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
15
+ /** Element to render. */
16
+ as?: 'div' | 'section' | 'article' | 'header' | 'footer' | 'figure' | 'li' | 'p' | 'span';
17
+ /**
18
+ * How long after it is reached it starts, in milliseconds: `index * 80` staggers a row.
19
+ * Styles from `revealed` inside it wait as long.
20
+ */
21
+ delay?: number;
22
+ sx?: Sx;
23
+ children?: Snippet;
24
+ };
25
+
26
+ const HIDDEN = ':is([data-reveal=hidden])';
27
+ const SHOWN = ':is([data-reveal=shown])';
28
+
29
+ const styles = stylex.create({
30
+ root: {
31
+ opacity: { default: null, [HIDDEN]: 0 },
32
+ translate: { default: null, [HIDDEN]: '0 1.25rem' },
33
+ transitionProperty: 'opacity, translate',
34
+ // It moves only on the way in: hiding is instant
35
+ transitionDuration: {
36
+ default: '0s',
37
+ [SHOWN]: { default: '0s', [media.motion]: pageMotion.base }
38
+ },
39
+ transitionTimingFunction: pageMotion.ease,
40
+ transitionDelay: { default: '0s', [SHOWN]: 'var(--narvi-reveal-delay)' }
41
+ },
42
+ // Always set, so a Reveal never takes the delay of one around it
43
+ noDelay: { '--narvi-reveal-delay': '0ms' },
44
+ delay: (delay: string) => ({ '--narvi-reveal-delay': delay })
45
+ });
46
+
47
+ /** Where above the bottom of the viewport it counts as reached: a tenth of the way up. */
48
+ const ROOT_MARGIN = '0px 0px -10% 0px';
49
+ </script>
50
+
51
+ <script lang="ts">
52
+ let { as = 'div', delay = 0, sx, class: className, children, ...rest }: RevealProps = $props();
53
+
54
+ function watch(element: HTMLElement) {
55
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
56
+ // Already in view, or above it: leave it be
57
+ if (element.getBoundingClientRect().top < innerHeight) return;
58
+
59
+ element.dataset.reveal = 'hidden';
60
+ const observer = new IntersectionObserver(
61
+ ([entry]) => {
62
+ if (!entry?.isIntersecting) return;
63
+ element.dataset.reveal = 'shown';
64
+ observer.disconnect();
65
+ },
66
+ { rootMargin: ROOT_MARGIN }
67
+ );
68
+ observer.observe(element);
69
+ return () => observer.disconnect();
70
+ }
71
+ </script>
72
+
73
+ <svelte:element
74
+ this={as}
75
+ data-slot="reveal"
76
+ {...rest}
77
+ {@attach watch}
78
+ {...attrs(
79
+ [
80
+ styles.root,
81
+ delay > 0 ? styles.delay(`${delay}ms`) : styles.noDelay,
82
+ stylex.defaultMarker(),
83
+ sx
84
+ ],
85
+ className
86
+ )}
87
+ >
88
+ {@render children?.()}
89
+ </svelte:element>
@@ -0,0 +1,17 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type RevealProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
5
+ /** Element to render. */
6
+ as?: 'div' | 'section' | 'article' | 'header' | 'footer' | 'figure' | 'li' | 'p' | 'span';
7
+ /**
8
+ * How long after it is reached it starts, in milliseconds: `index * 80` staggers a row.
9
+ * Styles from `revealed` inside it wait as long.
10
+ */
11
+ delay?: number;
12
+ sx?: Sx;
13
+ children?: Snippet;
14
+ };
15
+ declare const Reveal: import("svelte").Component<RevealProps, {}, "">;
16
+ type Reveal = ReturnType<typeof Reveal>;
17
+ export default Reveal;
@@ -0,0 +1,38 @@
1
+ import * as stylex from '@stylexjs/stylex';
2
+ /**
3
+ * Styles for what sits inside a `Reveal`, which follow it in as it is reached. Each moves
4
+ * only on the way in, so hiding below the fold is instant, and only for readers who have
5
+ * not asked for less motion. Each also waits for the Reveal's own `delay`.
6
+ *
7
+ * Apply them with `sx` on a component, or spread `sx(...)` onto an element:
8
+ * `<path pathLength="1" {...sx(revealed.drawIn)} />`.
9
+ *
10
+ * Fine-tune them with custom properties, set on the element or anywhere above it:
11
+ * - `--narvi-draw-delay`, `--narvi-fade-delay` and `--narvi-sweep-delay`: a wait of its own,
12
+ * after the Reveal's
13
+ * - `--narvi-sweep-from`: where a sweep starts, as a dash offset (`1`, a whole turn, by default)
14
+ */
15
+ export declare const revealed: Readonly<{
16
+ readonly drawIn: Readonly<{
17
+ readonly strokeDasharray: stylex.StyleXClassNameFor<"strokeDasharray", 1>;
18
+ readonly strokeDashoffset: stylex.StyleXClassNameFor<"strokeDashoffset", 0 | 1>;
19
+ readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "stroke-dashoffset">;
20
+ readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
21
+ readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
22
+ readonly transitionDelay: stylex.StyleXClassNameFor<"transitionDelay", "0s" | "calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-draw-delay, 0ms))">;
23
+ }>;
24
+ readonly fadeAfter: Readonly<{
25
+ readonly opacity: stylex.StyleXClassNameFor<"opacity", 0 | null>;
26
+ readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "opacity">;
27
+ readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
28
+ readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
29
+ readonly transitionDelay: stylex.StyleXClassNameFor<"transitionDelay", "0s" | `calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-fade-delay, ${stylex.StyleXVar<string>}))`>;
30
+ }>;
31
+ readonly sweep: Readonly<{
32
+ readonly strokeDashoffset: stylex.StyleXClassNameFor<"strokeDashoffset", 0 | "var(--narvi-sweep-from, 1)">;
33
+ readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "stroke-dashoffset">;
34
+ readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
35
+ readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
36
+ readonly transitionDelay: stylex.StyleXClassNameFor<"transitionDelay", "0s" | "calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-sweep-delay, 0ms))">;
37
+ }>;
38
+ }>;
@@ -0,0 +1,79 @@
1
+ import * as stylex from '@stylexjs/stylex';
2
+ import { media } from '../../media.stylex.js';
3
+ import { pageMotion } from '../../tokens.stylex.js';
4
+ /**
5
+ * Styles for what sits inside a `Reveal`, which follow it in as it is reached. Each moves
6
+ * only on the way in, so hiding below the fold is instant, and only for readers who have
7
+ * not asked for less motion. Each also waits for the Reveal's own `delay`.
8
+ *
9
+ * Apply them with `sx` on a component, or spread `sx(...)` onto an element:
10
+ * `<path pathLength="1" {...sx(revealed.drawIn)} />`.
11
+ *
12
+ * Fine-tune them with custom properties, set on the element or anywhere above it:
13
+ * - `--narvi-draw-delay`, `--narvi-fade-delay` and `--narvi-sweep-delay`: a wait of its own,
14
+ * after the Reveal's
15
+ * - `--narvi-sweep-from`: where a sweep starts, as a dash offset (`1`, a whole turn, by default)
16
+ */
17
+ export const revealed = stylex.create({
18
+ /**
19
+ * Draws a stroke in, end to end. Give the path, line or circle `pathLength="1"`, so its
20
+ * length is 1 whatever its size.
21
+ */
22
+ drawIn: {
23
+ strokeDasharray: 1,
24
+ strokeDashoffset: { default: 0, [stylex.when.ancestor('[data-reveal=hidden]')]: 1 },
25
+ transitionProperty: 'stroke-dashoffset',
26
+ transitionDuration: {
27
+ default: '0s',
28
+ [stylex.when.ancestor('[data-reveal=shown]')]: {
29
+ default: '0s',
30
+ [media.motion]: pageMotion.longest
31
+ }
32
+ },
33
+ transitionTimingFunction: pageMotion.ease,
34
+ transitionDelay: {
35
+ default: '0s',
36
+ [stylex.when.ancestor('[data-reveal=shown]')]: 'calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-draw-delay, 0ms))'
37
+ }
38
+ },
39
+ /** Fades in once a drawing is well under way: a mark or a label that sits on it. */
40
+ fadeAfter: {
41
+ opacity: { default: null, [stylex.when.ancestor('[data-reveal=hidden]')]: 0 },
42
+ transitionProperty: 'opacity',
43
+ transitionDuration: {
44
+ default: '0s',
45
+ [stylex.when.ancestor('[data-reveal=shown]')]: {
46
+ default: '0s',
47
+ [media.motion]: pageMotion.long
48
+ }
49
+ },
50
+ transitionTimingFunction: pageMotion.ease,
51
+ transitionDelay: {
52
+ default: '0s',
53
+ [stylex.when.ancestor('[data-reveal=shown]')]: `calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-fade-delay, ${pageMotion.long}))`
54
+ }
55
+ },
56
+ /**
57
+ * Runs a dash round its path into place. Give it `pathLength="1"` and a dash of your own,
58
+ * such as `stroke-dasharray="0.25 0.75"`: a lit stretch of a ring, or a comet on a line.
59
+ */
60
+ sweep: {
61
+ strokeDashoffset: {
62
+ default: 0,
63
+ [stylex.when.ancestor('[data-reveal=hidden]')]: 'var(--narvi-sweep-from, 1)'
64
+ },
65
+ transitionProperty: 'stroke-dashoffset',
66
+ transitionDuration: {
67
+ default: '0s',
68
+ [stylex.when.ancestor('[data-reveal=shown]')]: {
69
+ default: '0s',
70
+ [media.motion]: pageMotion.longest
71
+ }
72
+ },
73
+ transitionTimingFunction: pageMotion.ease,
74
+ transitionDelay: {
75
+ default: '0s',
76
+ [stylex.when.ancestor('[data-reveal=shown]')]: 'calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-sweep-delay, 0ms))'
77
+ }
78
+ }
79
+ });
@@ -3,6 +3,7 @@
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
  import { attrs, type Sx } from '../../internal/sx.js';
5
5
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
6
+ import { media } from '../../media.stylex.js';
6
7
 
7
8
  export type SegmentedOption = { value: string; label: string; disabled?: boolean };
8
9
 
@@ -17,11 +18,6 @@
17
18
  sx?: Sx;
18
19
  };
19
20
 
20
- // StyleX needs these in the same file to evaluate them at build time
21
- const HOVER = '@media (hover: hover) and (pointer: fine)';
22
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
23
- const FORCED = '@media (forced-colors: active)';
24
-
25
21
  const styles = stylex.create({
26
22
  root: {
27
23
  WebkitAppRegion: 'no-drag',
@@ -54,16 +50,16 @@
54
50
  ':dir(rtl)': 'calc(var(--narvi-seg-index) * -100%) 0'
55
51
  },
56
52
  borderRadius: radius.sm,
57
- backgroundColor: { default: colors.surfaceRaised, [FORCED]: 'Canvas' },
53
+ backgroundColor: { default: colors.surfaceRaised, [media.forcedColors]: 'Canvas' },
58
54
  boxShadow: `inset 0 0 0 1px ${colors.lineStrong}, inset 0 1px 0 ${colors.highlight}, 0 1px 3px ${colors.shade}`,
59
55
  outlineStyle: 'solid',
60
56
  outlineWidth: '2px',
61
57
  outlineOffset: '-2px',
62
- outlineColor: { default: 'transparent', [FORCED]: 'Highlight' },
58
+ outlineColor: { default: 'transparent', [media.forcedColors]: 'Highlight' },
63
59
  forcedColorAdjust: 'none'
64
60
  },
65
61
  thumbSlides: {
66
- transitionProperty: { default: 'none', [MOTION]: 'translate' },
62
+ transitionProperty: { default: 'none', [media.motion]: 'translate' },
67
63
  transitionDuration: motion.slow,
68
64
  transitionTimingFunction: motion.easeInOut
69
65
  },
@@ -95,7 +91,7 @@
95
91
  borderRadius: radius.sm,
96
92
  color: {
97
93
  default: colors.textMuted,
98
- ':hover': { default: null, [HOVER]: colors.text },
94
+ ':hover': { default: null, [media.hover]: colors.text },
99
95
  [stylex.when.siblingBefore(':checked')]: colors.text
100
96
  },
101
97
  fontSize: font.sizeMd,
@@ -0,0 +1,63 @@
1
+ <script lang="ts" module>
2
+ import { Dialog } from 'bits-ui';
3
+ import * as stylex from '@stylexjs/stylex';
4
+ import type { Snippet } from 'svelte';
5
+ import Glyph from '../../internal/Glyph.svelte';
6
+ import { attrs, type Sx } from '../../internal/sx.js';
7
+ import Button from '../button/Button.svelte';
8
+ import { dialog } from '../dialog/styles.js';
9
+ import { sheet } from './styles.js';
10
+
11
+ export type SheetSide = 'start' | 'end' | 'top' | 'bottom';
12
+
13
+ export type SheetContentProps = Omit<Dialog.ContentProps, 'children' | 'child'> & {
14
+ /** The edge it slides in from. `start` and `end` follow the writing direction. */
15
+ side?: SheetSide;
16
+ /** How wide a sheet along the start or end is: 20, 26 or 36rem. */
17
+ size?: 'sm' | 'md' | 'lg';
18
+ /** Accessible name of the close button in the corner. `null` leaves it out. */
19
+ closeLabel?: string | null;
20
+ sx?: Sx;
21
+ /** A Sheet.Header, a Sheet.Body and a Sheet.Footer. */
22
+ children?: Snippet;
23
+ };
24
+ </script>
25
+
26
+ <script lang="ts">
27
+ let {
28
+ side = 'end',
29
+ size = 'md',
30
+ closeLabel = 'Close',
31
+ ref = $bindable(null),
32
+ sx,
33
+ class: className,
34
+ children,
35
+ ...rest
36
+ }: SheetContentProps = $props();
37
+
38
+ const across = $derived(side === 'start' || side === 'end');
39
+ </script>
40
+
41
+ <Dialog.Portal>
42
+ <Dialog.Overlay data-slot="sheet-overlay" {...stylex.attrs(dialog.overlay)} />
43
+ <Dialog.Content
44
+ bind:ref
45
+ data-slot="sheet"
46
+ data-side={side}
47
+ {...rest}
48
+ {...attrs([dialog.content, sheet.sheet, across && sheet[size], sheet[side], sx], className)}
49
+ >
50
+ {@render children?.()}
51
+ {#if closeLabel}
52
+ <span {...stylex.attrs(dialog.close)}>
53
+ <Dialog.Close>
54
+ {#snippet child({ props })}
55
+ <Button {...props} variant="ghost" size="sm" iconOnly aria-label={closeLabel}>
56
+ <Glyph name="close" />
57
+ </Button>
58
+ {/snippet}
59
+ </Dialog.Close>
60
+ </span>
61
+ {/if}
62
+ </Dialog.Content>
63
+ </Dialog.Portal>
@@ -0,0 +1,18 @@
1
+ import { Dialog } from 'bits-ui';
2
+ import type { Snippet } from 'svelte';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type SheetSide = 'start' | 'end' | 'top' | 'bottom';
5
+ export type SheetContentProps = Omit<Dialog.ContentProps, 'children' | 'child'> & {
6
+ /** The edge it slides in from. `start` and `end` follow the writing direction. */
7
+ side?: SheetSide;
8
+ /** How wide a sheet along the start or end is: 20, 26 or 36rem. */
9
+ size?: 'sm' | 'md' | 'lg';
10
+ /** Accessible name of the close button in the corner. `null` leaves it out. */
11
+ closeLabel?: string | null;
12
+ sx?: Sx;
13
+ /** A Sheet.Header, a Sheet.Body and a Sheet.Footer. */
14
+ children?: Snippet;
15
+ };
16
+ declare const SheetContent: import("svelte").Component<SheetContentProps, {}, "ref">;
17
+ type SheetContent = ReturnType<typeof SheetContent>;
18
+ export default SheetContent;
@@ -0,0 +1,12 @@
1
+ import { Dialog } from 'bits-ui';
2
+ import Body from '../dialog/DialogBody.svelte';
3
+ import Description from '../dialog/DialogDescription.svelte';
4
+ import Footer from '../dialog/DialogFooter.svelte';
5
+ import Header from '../dialog/DialogHeader.svelte';
6
+ import Title from '../dialog/DialogTitle.svelte';
7
+ import Content from './SheetContent.svelte';
8
+ declare const Root: import("svelte").Component<import("bits-ui").AlertDialogRootPropsWithoutHTML, {}, "open">;
9
+ declare const Trigger: import("svelte").Component<Dialog.TriggerProps, {}, "ref">;
10
+ declare const Close: import("svelte").Component<Dialog.TriggerProps, {}, "ref">;
11
+ export { Root, Trigger, Content, Header, Title, Description, Body, Footer, Close };
12
+ export type { SheetContentProps, SheetSide } from './SheetContent.svelte';
@@ -0,0 +1,12 @@
1
+ import { Dialog } from 'bits-ui';
2
+ import Body from '../dialog/DialogBody.svelte';
3
+ import Description from '../dialog/DialogDescription.svelte';
4
+ import Footer from '../dialog/DialogFooter.svelte';
5
+ import Header from '../dialog/DialogHeader.svelte';
6
+ import Title from '../dialog/DialogTitle.svelte';
7
+ import Content from './SheetContent.svelte';
8
+ // A sheet is a dialog along an edge: the same behaviour and the same parts
9
+ const Root = Dialog.Root;
10
+ const Trigger = Dialog.Trigger;
11
+ const Close = Dialog.Close;
12
+ export { Root, Trigger, Content, Header, Title, Description, Body, Footer, Close };
@@ -0,0 +1,51 @@
1
+ import * as stylex from '@stylexjs/stylex';
2
+ /** Laid over Dialog's content: a panel along one edge of the window, which it slides in from. */
3
+ export declare const sheet: Readonly<{
4
+ readonly sheet: Readonly<{
5
+ readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "none">;
6
+ readonly marginInline: stylex.StyleXClassNameFor<"marginInline", 0>;
7
+ readonly translate: stylex.StyleXClassNameFor<"translate", "none">;
8
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", 0>;
9
+ readonly scale: stylex.StyleXClassNameFor<"scale", null>;
10
+ readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "opacity" | "opacity, translate">;
11
+ readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
12
+ readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", "cubic-bezier(0.32, 0.72, 0, 1)">;
13
+ }>;
14
+ readonly sm: Readonly<{
15
+ readonly width: stylex.StyleXClassNameFor<"width", "min(20rem, calc(100vw - 2rem))">;
16
+ }>;
17
+ readonly md: Readonly<{
18
+ readonly width: stylex.StyleXClassNameFor<"width", "min(26rem, calc(100vw - 2rem))">;
19
+ }>;
20
+ readonly lg: Readonly<{
21
+ readonly width: stylex.StyleXClassNameFor<"width", "min(36rem, calc(100vw - 2rem))">;
22
+ }>;
23
+ readonly end: Readonly<{
24
+ readonly top: stylex.StyleXClassNameFor<"top", 0>;
25
+ readonly bottom: stylex.StyleXClassNameFor<"bottom", 0>;
26
+ readonly insetInlineStart: stylex.StyleXClassNameFor<"insetInlineStart", "auto">;
27
+ readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", 0>;
28
+ readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "100% 0" | null>;
29
+ }>;
30
+ readonly start: Readonly<{
31
+ readonly top: stylex.StyleXClassNameFor<"top", 0>;
32
+ readonly bottom: stylex.StyleXClassNameFor<"bottom", 0>;
33
+ readonly insetInlineStart: stylex.StyleXClassNameFor<"insetInlineStart", 0>;
34
+ readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", "auto">;
35
+ readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "-100% 0" | null>;
36
+ }>;
37
+ readonly top: Readonly<{
38
+ readonly top: stylex.StyleXClassNameFor<"top", 0>;
39
+ readonly bottom: stylex.StyleXClassNameFor<"bottom", "auto">;
40
+ readonly width: stylex.StyleXClassNameFor<"width", "100%">;
41
+ readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "calc(100dvh - 4rem)">;
42
+ readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "0 -100%" | null>;
43
+ }>;
44
+ readonly bottom: Readonly<{
45
+ readonly top: stylex.StyleXClassNameFor<"top", "auto">;
46
+ readonly bottom: stylex.StyleXClassNameFor<"bottom", 0>;
47
+ readonly width: stylex.StyleXClassNameFor<"width", "100%">;
48
+ readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "calc(100dvh - 4rem)">;
49
+ readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "0 100%" | null>;
50
+ }>;
51
+ }>;