@diegopluna/narvi 0.1.0 → 0.2.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 (259) hide show
  1. package/README.md +102 -41
  2. package/dist/base.css +2 -2
  3. package/dist/color.d.ts +1 -1
  4. package/dist/color.js +1 -1
  5. package/dist/components/activity/ActivityContent.svelte +3 -15
  6. package/dist/components/activity/ActivityStep.svelte +12 -12
  7. package/dist/components/activity/ActivityThought.svelte +4 -4
  8. package/dist/components/activity/ActivityTrigger.svelte +3 -3
  9. package/dist/components/app-shell/AppShellBar.svelte +89 -0
  10. package/dist/components/app-shell/AppShellBar.svelte.d.ts +20 -0
  11. package/dist/components/app-shell/AppShellHeader.svelte +17 -16
  12. package/dist/components/app-shell/AppShellHeader.svelte.d.ts +2 -2
  13. package/dist/components/app-shell/AppShellMain.svelte +4 -20
  14. package/dist/components/app-shell/AppShellPanel.svelte +21 -19
  15. package/dist/components/app-shell/AppShellPanes.svelte +58 -0
  16. package/dist/components/app-shell/AppShellPanes.svelte.d.ts +11 -0
  17. package/dist/components/app-shell/AppShellRail.svelte +85 -0
  18. package/dist/components/app-shell/AppShellRail.svelte.d.ts +11 -0
  19. package/dist/components/app-shell/AppShellRoot.svelte +50 -24
  20. package/dist/components/app-shell/AppShellRoot.svelte.d.ts +8 -6
  21. package/dist/components/app-shell/AppShellSheet.svelte +95 -0
  22. package/dist/components/app-shell/AppShellSheet.svelte.d.ts +17 -0
  23. package/dist/components/app-shell/AppShellSidebar.svelte +37 -61
  24. package/dist/components/app-shell/AppShellSidebar.svelte.d.ts +1 -5
  25. package/dist/components/app-shell/AppShellToggle.svelte +62 -23
  26. package/dist/components/app-shell/AppShellToggle.svelte.d.ts +2 -0
  27. package/dist/components/app-shell/context.d.ts +6 -0
  28. package/dist/components/app-shell/index.d.ts +9 -1
  29. package/dist/components/app-shell/index.js +5 -1
  30. package/dist/components/approval/Approval.svelte +91 -19
  31. package/dist/components/approval/Approval.svelte.d.ts +7 -0
  32. package/dist/components/avatar/AvatarFallback.svelte +1 -2
  33. package/dist/components/avatar/AvatarRoot.svelte +2 -2
  34. package/dist/components/badge/Badge.svelte +5 -5
  35. package/dist/components/button/Button.svelte +219 -40
  36. package/dist/components/button/Button.svelte.d.ts +38 -2
  37. package/dist/components/card/Card.svelte +15 -26
  38. package/dist/components/change-stats/ChangeStats.svelte +1 -2
  39. package/dist/components/changes-summary/ChangesSummary.svelte +14 -15
  40. package/dist/components/checkbox/Checkbox.svelte +18 -15
  41. package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
  42. package/dist/components/code/Code.svelte +1 -2
  43. package/dist/components/collapsible/CollapsibleTrigger.svelte +2 -2
  44. package/dist/components/command/CommandItem.svelte +1 -1
  45. package/dist/components/command/styles.d.ts +3 -2
  46. package/dist/components/command/styles.js +13 -10
  47. package/dist/components/composer/ComposerAttachButton.svelte +1 -1
  48. package/dist/components/composer/ComposerAttachment.svelte +9 -12
  49. package/dist/components/composer/ComposerModelPicker.svelte +18 -20
  50. package/dist/components/composer/ComposerRoot.svelte +8 -7
  51. package/dist/components/composer/ComposerSubmit.svelte +8 -15
  52. package/dist/components/composer/ComposerTextarea.svelte +1 -1
  53. package/dist/components/composer/ComposerToggle.svelte +9 -11
  54. package/dist/components/composer/ComposerTray.svelte +78 -0
  55. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -0
  56. package/dist/components/composer/index.d.ts +3 -1
  57. package/dist/components/composer/index.js +3 -2
  58. package/dist/components/conversation/ConversationContent.svelte +3 -2
  59. package/dist/components/conversation/ConversationEmpty.svelte +1 -1
  60. package/dist/components/conversation/ConversationScrollButton.svelte +3 -3
  61. package/dist/components/dialog/ConfirmDialog.svelte +1 -1
  62. package/dist/components/dialog/styles.d.ts +2 -3
  63. package/dist/components/dialog/styles.js +5 -6
  64. package/dist/components/divider/Divider.svelte +3 -3
  65. package/dist/components/empty-state/EmptyState.svelte +4 -5
  66. package/dist/components/field/Field.svelte +4 -4
  67. package/dist/components/frame/Frame.svelte +6 -7
  68. package/dist/components/frame/Frame.svelte.d.ts +1 -1
  69. package/dist/components/heading/Heading.svelte +2 -2
  70. package/dist/components/kbd/Kbd.svelte +12 -7
  71. package/dist/components/link/Link.svelte +7 -3
  72. package/dist/components/link/Link.svelte.d.ts +4 -1
  73. package/dist/components/markdown/Markdown.svelte +714 -0
  74. package/dist/components/markdown/Markdown.svelte.d.ts +80 -0
  75. package/dist/components/markdown/MarkdownBlock.svelte +231 -0
  76. package/dist/components/markdown/MarkdownBlock.svelte.d.ts +11 -0
  77. package/dist/components/markdown/MarkdownBlocks.svelte +115 -0
  78. package/dist/components/markdown/MarkdownBlocks.svelte.d.ts +15 -0
  79. package/dist/components/markdown/MarkdownCode.svelte +583 -0
  80. package/dist/components/markdown/MarkdownCode.svelte.d.ts +23 -0
  81. package/dist/components/markdown/MarkdownDiagram.svelte +310 -0
  82. package/dist/components/markdown/MarkdownDiagram.svelte.d.ts +6 -0
  83. package/dist/components/markdown/MarkdownFile.svelte +134 -0
  84. package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
  85. package/dist/components/markdown/MarkdownFootnotes.svelte +61 -0
  86. package/dist/components/markdown/MarkdownFootnotes.svelte.d.ts +8 -0
  87. package/dist/components/markdown/MarkdownFresh.svelte +69 -0
  88. package/dist/components/markdown/MarkdownFresh.svelte.d.ts +6 -0
  89. package/dist/components/markdown/MarkdownHtml.svelte +72 -0
  90. package/dist/components/markdown/MarkdownHtml.svelte.d.ts +7 -0
  91. package/dist/components/markdown/MarkdownImage.svelte +150 -0
  92. package/dist/components/markdown/MarkdownImage.svelte.d.ts +8 -0
  93. package/dist/components/markdown/MarkdownInlines.svelte +225 -0
  94. package/dist/components/markdown/MarkdownInlines.svelte.d.ts +7 -0
  95. package/dist/components/markdown/MarkdownLink.svelte +120 -0
  96. package/dist/components/markdown/MarkdownLink.svelte.d.ts +25 -0
  97. package/dist/components/markdown/MarkdownMath.svelte +138 -0
  98. package/dist/components/markdown/MarkdownMath.svelte.d.ts +7 -0
  99. package/dist/components/markdown/MarkdownTable.svelte +265 -0
  100. package/dist/components/markdown/MarkdownTable.svelte.d.ts +17 -0
  101. package/dist/components/markdown/caret.d.ts +14 -0
  102. package/dist/components/markdown/caret.js +67 -0
  103. package/dist/components/markdown/context.d.ts +93 -0
  104. package/dist/components/markdown/context.js +128 -0
  105. package/dist/components/markdown/copy.d.ts +13 -0
  106. package/dist/components/markdown/copy.js +74 -0
  107. package/dist/components/markdown/hidden.d.ts +12 -0
  108. package/dist/components/markdown/hidden.js +31 -0
  109. package/dist/components/markdown/kept.d.ts +32 -0
  110. package/dist/components/markdown/kept.js +71 -0
  111. package/dist/components/markdown/labels.d.ts +46 -0
  112. package/dist/components/markdown/labels.js +35 -0
  113. package/dist/components/markdown/save.d.ts +11 -0
  114. package/dist/components/markdown/save.js +58 -0
  115. package/dist/components/markdown/scrollable.d.ts +24 -0
  116. package/dist/components/markdown/scrollable.js +152 -0
  117. package/dist/components/markdown/static.d.ts +37 -0
  118. package/dist/components/markdown/static.js +233 -0
  119. package/dist/components/markdown/styles.d.ts +328 -0
  120. package/dist/components/markdown/styles.js +302 -0
  121. package/dist/components/menu/MenuRadioItem.svelte +3 -3
  122. package/dist/components/menu/index.d.ts +23 -0
  123. package/dist/components/menu/index.js +3 -1
  124. package/dist/components/message/MessageAction.svelte +22 -2
  125. package/dist/components/message/MessageAction.svelte.d.ts +9 -0
  126. package/dist/components/message/MessageContent.svelte +2 -3
  127. package/dist/components/message/MessageCopy.svelte +62 -3
  128. package/dist/components/message/MessageCopy.svelte.d.ts +17 -1
  129. package/dist/components/message/MessageHeader.svelte +3 -3
  130. package/dist/components/message/MessagePending.svelte +1 -1
  131. package/dist/components/message/MessageTime.svelte +1 -1
  132. package/dist/components/notice/Notice.svelte +14 -10
  133. package/dist/components/plan/Plan.svelte +22 -17
  134. package/dist/components/progress/Progress.svelte +31 -33
  135. package/dist/components/questionnaire/Questionnaire.svelte +19 -22
  136. package/dist/components/queued-message/QueuedMessage.svelte +14 -7
  137. package/dist/components/rail/RailItem.svelte +37 -34
  138. package/dist/components/rail/RailItem.svelte.d.ts +3 -1
  139. package/dist/components/rail/RailRoot.svelte +18 -4
  140. package/dist/components/rail/RailRoot.svelte.d.ts +1 -1
  141. package/dist/components/rail/RailSeparator.svelte +17 -0
  142. package/dist/components/rail/RailSeparator.svelte.d.ts +18 -0
  143. package/dist/components/rail/index.d.ts +2 -1
  144. package/dist/components/rail/index.js +2 -1
  145. package/dist/components/reasoning/ReasoningContent.svelte +4 -8
  146. package/dist/components/reasoning/ReasoningTrigger.svelte +2 -2
  147. package/dist/components/resize-handle/ResizeHandle.svelte +2 -3
  148. package/dist/components/segmented/SegmentedControl.svelte +7 -8
  149. package/dist/components/select/Select.svelte +1 -1
  150. package/dist/components/separator/Separator.svelte +1 -1
  151. package/dist/components/settings-row/SettingsRow.svelte +5 -5
  152. package/dist/components/shimmer/Shimmer.svelte +34 -21
  153. package/dist/components/sidebar/SidebarContent.svelte +1 -1
  154. package/dist/components/sidebar/SidebarFolder.svelte +142 -0
  155. package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
  156. package/dist/components/sidebar/SidebarFooter.svelte +1 -1
  157. package/dist/components/sidebar/SidebarGroup.svelte +36 -32
  158. package/dist/components/sidebar/SidebarGroup.svelte.d.ts +3 -3
  159. package/dist/components/sidebar/SidebarHeader.svelte +12 -6
  160. package/dist/components/sidebar/SidebarHeader.svelte.d.ts +4 -1
  161. package/dist/components/sidebar/SidebarItem.svelte +26 -32
  162. package/dist/components/sidebar/SidebarRoot.svelte +62 -0
  163. package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
  164. package/dist/components/sidebar/index.d.ts +5 -1
  165. package/dist/components/sidebar/index.js +3 -1
  166. package/dist/components/skeleton/Skeleton.svelte +26 -15
  167. package/dist/components/slider/Slider.svelte +11 -10
  168. package/dist/components/spinner/Spinner.svelte +4 -11
  169. package/dist/components/status-indicator/StatusIndicator.svelte +1 -1
  170. package/dist/components/suggestions/SuggestionsItem.svelte +5 -5
  171. package/dist/components/switch/Switch.svelte +9 -14
  172. package/dist/components/tab-strip/TabStrip.svelte +340 -0
  173. package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
  174. package/dist/components/tabs/Tabs.svelte +13 -9
  175. package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
  176. package/dist/components/text/Text.svelte +31 -23
  177. package/dist/components/text/Text.svelte.d.ts +8 -4
  178. package/dist/components/toast/Toaster.svelte +5 -5
  179. package/dist/components/tool/ToolContent.svelte +3 -8
  180. package/dist/components/tool/ToolSection.svelte +4 -5
  181. package/dist/components/tool/ToolTrigger.svelte +10 -9
  182. package/dist/components/tooltip/TooltipContent.svelte +3 -3
  183. package/dist/components/work-fold/WorkFold.svelte +5 -9
  184. package/dist/index.d.ts +16 -8
  185. package/dist/index.js +17 -10
  186. package/dist/internal/Code.svelte +3 -4
  187. package/dist/internal/Glyph.svelte +16 -0
  188. package/dist/internal/Glyph.svelte.d.ts +6 -0
  189. package/dist/internal/Tile.svelte +17 -37
  190. package/dist/internal/control.d.ts +4 -4
  191. package/dist/internal/control.js +20 -17
  192. package/dist/internal/layer.d.ts +3 -5
  193. package/dist/internal/layer.js +10 -12
  194. package/dist/internal/markers.stylex.d.ts +8 -0
  195. package/dist/internal/markers.stylex.js +4 -0
  196. package/dist/internal/plugin-order.d.ts +8 -0
  197. package/dist/internal/plugin-order.js +16 -0
  198. package/dist/internal/roving.js +5 -2
  199. package/dist/internal/shared.d.ts +8 -1
  200. package/dist/internal/shared.js +21 -5
  201. package/dist/internal/sx.d.ts +1 -1
  202. package/dist/internal/toggle.d.ts +1 -2
  203. package/dist/internal/toggle.js +8 -12
  204. package/dist/internal/visible.d.ts +32 -0
  205. package/dist/internal/visible.js +44 -0
  206. package/dist/markdown/ast.d.ts +209 -0
  207. package/dist/markdown/ast.js +10 -0
  208. package/dist/markdown/blocks.d.ts +177 -0
  209. package/dist/markdown/blocks.js +1489 -0
  210. package/dist/markdown/code-info.d.ts +10 -0
  211. package/dist/markdown/code-info.js +16 -0
  212. package/dist/markdown/common.d.ts +25 -0
  213. package/dist/markdown/common.js +107 -0
  214. package/dist/markdown/diagrams.d.ts +2 -0
  215. package/dist/markdown/diagrams.js +18 -0
  216. package/dist/markdown/file-paths.d.ts +29 -0
  217. package/dist/markdown/file-paths.js +80 -0
  218. package/dist/markdown/files.d.ts +16 -0
  219. package/dist/markdown/files.js +133 -0
  220. package/dist/markdown/highlight.d.ts +30 -0
  221. package/dist/markdown/highlight.js +127 -0
  222. package/dist/markdown/html.d.ts +23 -0
  223. package/dist/markdown/html.js +289 -0
  224. package/dist/markdown/images.d.ts +15 -0
  225. package/dist/markdown/images.js +45 -0
  226. package/dist/markdown/index.d.ts +12 -0
  227. package/dist/markdown/index.js +5 -0
  228. package/dist/markdown/inlines.d.ts +48 -0
  229. package/dist/markdown/inlines.js +1714 -0
  230. package/dist/markdown/math.d.ts +2 -0
  231. package/dist/markdown/math.js +22 -0
  232. package/dist/markdown/parse.d.ts +81 -0
  233. package/dist/markdown/parse.js +204 -0
  234. package/dist/markdown/plugin.d.ts +178 -0
  235. package/dist/markdown/plugin.js +160 -0
  236. package/dist/markdown/sanitize.d.ts +78 -0
  237. package/dist/markdown/sanitize.js +522 -0
  238. package/dist/markdown/share.d.ts +12 -0
  239. package/dist/markdown/share.js +59 -0
  240. package/dist/markdown/table.d.ts +13 -0
  241. package/dist/markdown/table.js +60 -0
  242. package/dist/preset.d.ts +40 -16
  243. package/dist/preset.js +169 -51
  244. package/dist/tokens.stylex.d.ts +55 -37
  245. package/dist/tokens.stylex.js +107 -62
  246. package/dist/typography.d.ts +48 -0
  247. package/dist/typography.js +55 -0
  248. package/dist/vite.d.ts +7 -1
  249. package/dist/vite.js +27 -2
  250. package/package.json +53 -6
  251. package/skills/building-ui/SKILL.md +242 -0
  252. package/skills/building-ui/references/components.md +207 -0
  253. package/skills/markdown/SKILL.md +452 -0
  254. package/skills/markdown/references/plugins.md +103 -0
  255. package/skills/setup/SKILL.md +191 -0
  256. package/skills/styling/SKILL.md +269 -0
  257. package/skills/theming/SKILL.md +184 -0
  258. package/dist/internal/loop.d.ts +0 -35
  259. package/dist/internal/loop.js +0 -72
@@ -1,10 +1,13 @@
1
+ <!--
2
+ The last column of the sheet, beside the page: what the page is about, such as
3
+ the files a thread changed. Its start edge drags to resize it.
4
+ -->
1
5
  <script lang="ts" module>
2
6
  import * as stylex from '@stylexjs/stylex';
3
7
  import type { Snippet } from 'svelte';
4
8
  import type { HTMLAttributes } from 'svelte/elements';
5
- import { shared } from '../../internal/shared.js';
6
9
  import { attrs, type Sx } from '../../internal/sx.js';
7
- import { colors, radius } from '../../tokens.stylex.js';
10
+ import { colors } from '../../tokens.stylex.js';
8
11
  import ResizeHandle from '../resize-handle/ResizeHandle.svelte';
9
12
  import { useAppShell } from './context.js';
10
13
 
@@ -24,31 +27,32 @@
24
27
  const styles = stylex.create({
25
28
  panel: {
26
29
  position: 'relative',
30
+ boxSizing: 'border-box',
27
31
  display: 'flex',
28
32
  flexDirection: 'column',
29
33
  flexShrink: 0,
30
34
  width: 'var(--narvi-panel-width)',
31
35
  minWidth: 0,
32
- marginBlock: '0.375rem',
33
- marginInlineEnd: '0.375rem',
36
+ minHeight: 0,
34
37
  overflow: 'clip',
35
- borderRadius: radius.frame,
36
- backgroundColor: colors.bgRaised,
37
- boxShadow: `inset 0 0 0 1px ${colors.line}, 0 1px 2px ${colors.shade}`
38
+ borderInlineStartWidth: '1px',
39
+ borderInlineStartStyle: 'solid',
40
+ borderInlineStartColor: colors.border,
41
+ // The traffic lights are never over a panel, so a header inside one keeps no room for them
42
+ '--narvi-inset-page': '0px'
38
43
  },
39
44
  // On a narrow window the panel takes the place of the page, under its
40
45
  // header, which stays in reach with the sidebar's toggle
41
46
  narrow: {
42
47
  position: 'absolute',
43
48
  inset: 0,
44
- top: '3.25rem',
49
+ top: '3rem',
45
50
  zIndex: 5,
46
51
  width: 'auto',
47
- margin: 0,
48
- borderRadius: 0,
49
- boxShadow: 'none'
52
+ borderInlineStartWidth: 0,
53
+ backgroundColor: colors.bgRaised
50
54
  },
51
- handle: { position: 'relative', alignSelf: 'stretch', marginBlock: '0.375rem' }
55
+ handle: { position: 'relative', alignSelf: 'stretch' }
52
56
  });
53
57
  </script>
54
58
 
@@ -72,13 +76,11 @@
72
76
  const largest = () => {
73
77
  // On the server there is no window to measure: no limit yet
74
78
  if (typeof window === 'undefined') return Infinity;
75
- const shellWidth =
76
- element?.closest<HTMLElement>('[data-slot="app-shell"]')?.clientWidth ?? innerWidth;
77
- const main = element?.parentElement?.querySelector<HTMLElement>('[data-slot="app-shell-main"]');
78
- const sidebar = element?.parentElement?.querySelector<HTMLElement>(
79
- '[data-slot="app-shell-sidebar"]'
79
+ const sheet = element?.parentElement;
80
+ const sidebar = sheet?.querySelector<HTMLElement>(':scope > [data-slot="app-shell-sidebar"]');
81
+ return (
82
+ (sheet?.clientWidth ?? innerWidth) - (sidebar?.offsetWidth ?? 0) - Math.max(mainMinWidth, 0)
80
83
  );
81
- return shellWidth - (sidebar?.offsetWidth ?? 0) - Math.max(mainMinWidth, 0) - (main ? 12 : 0);
82
84
  };
83
85
  </script>
84
86
 
@@ -101,7 +103,7 @@
101
103
  data-slot="app-shell-panel"
102
104
  style:--narvi-panel-width="{width}px"
103
105
  {...rest}
104
- {...attrs([styles.panel, shared.edged, shell.narrow && styles.narrow, sx], className)}
106
+ {...attrs([styles.panel, shell.narrow && styles.narrow, sx], className)}
105
107
  >
106
108
  {@render children?.()}
107
109
  </aside>
@@ -0,0 +1,58 @@
1
+ <!--
2
+ Several sheets side by side, each a pane of its own, with the shell's gutter
3
+ between them. Put AppShell.Sheets inside: one for the sidebar, one for each
4
+ thing that is open.
5
+
6
+ The panes share the room equally unless one is given a width. On a narrow
7
+ window each is as wide as the window, and they are moved between by scrolling
8
+ sideways, one at a time.
9
+ -->
10
+ <script lang="ts" module>
11
+ import * as stylex from '@stylexjs/stylex';
12
+ import type { Snippet } from 'svelte';
13
+ import type { HTMLAttributes } from 'svelte/elements';
14
+ import { attrs, type Sx } from '../../internal/sx.js';
15
+ import { useAppShell } from './context.js';
16
+
17
+ export type AppShellPanesProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
18
+ sx?: Sx;
19
+ /** AppShell.Sheets. */
20
+ children?: Snippet;
21
+ };
22
+
23
+ const styles = stylex.create({
24
+ panes: {
25
+ gridArea: 'sheet',
26
+ display: 'flex',
27
+ gap: '0.375rem',
28
+ minWidth: 0,
29
+ minHeight: 0,
30
+ // Room for each sheet's edge, which is drawn just outside it
31
+ padding: '1px',
32
+ margin: '-1px'
33
+ },
34
+ narrow: {
35
+ gap: 0,
36
+ padding: 0,
37
+ margin: 0,
38
+ overflowX: 'auto',
39
+ overscrollBehaviorX: 'contain',
40
+ scrollSnapType: 'x mandatory',
41
+ scrollbarWidth: 'none'
42
+ }
43
+ });
44
+ </script>
45
+
46
+ <script lang="ts">
47
+ let { sx, class: className, children, ...rest }: AppShellPanesProps = $props();
48
+
49
+ const shell = useAppShell('Panes');
50
+ </script>
51
+
52
+ <div
53
+ data-slot="app-shell-panes"
54
+ {...rest}
55
+ {...attrs([styles.panes, shell.narrow && styles.narrow, sx], className)}
56
+ >
57
+ {@render children?.()}
58
+ </div>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type AppShellPanesProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
+ sx?: Sx;
6
+ /** AppShell.Sheets. */
7
+ children?: Snippet;
8
+ };
9
+ declare const AppShellPanes: import("svelte").Component<AppShellPanesProps, {}, "">;
10
+ type AppShellPanes = ReturnType<typeof AppShellPanes>;
11
+ export default AppShellPanes;
@@ -0,0 +1,85 @@
1
+ <!--
2
+ Where the rail stands: on the window itself, beside the sheet and under the bar.
3
+ It stays when the sidebar folds away. On a narrow window it joins the sidebar's
4
+ drawer, and the two slide in together.
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 { colors, motion } from '../../tokens.stylex.js';
12
+ import { media } from '../../media.stylex.js';
13
+ import { useAppShell } from './context.js';
14
+
15
+ export type AppShellRailProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
16
+ sx?: Sx;
17
+ /** A Rail.Root. */
18
+ children?: Snippet;
19
+ };
20
+
21
+ // The drawer's curve: quick out of the edge, a long gentle settle
22
+ const DRAWER = 'cubic-bezier(0.32, 0.72, 0, 1)';
23
+
24
+ const styles = stylex.create({
25
+ rail: {
26
+ gridArea: 'rail',
27
+ display: 'flex',
28
+ flexDirection: 'column',
29
+ minHeight: 0,
30
+ width: 'var(--narvi-rail-width)',
31
+ // Back over the shell's gutter, to the window's edge and its foot
32
+ marginInlineStart: '-0.375rem',
33
+ marginBottom: '-0.375rem'
34
+ },
35
+ // Narrow: the first strip of the drawer
36
+ drawer: {
37
+ position: 'fixed',
38
+ insetBlock: 0,
39
+ insetInlineStart: 0,
40
+ zIndex: 41,
41
+ marginInlineStart: 0,
42
+ marginBottom: 0,
43
+ backgroundColor: colors.bgWindow,
44
+ // A divider, so a border: it follows the writing direction and survives forced colours
45
+ borderInlineEndWidth: '1px',
46
+ borderInlineEndStyle: 'solid',
47
+ borderInlineEndColor: colors.border,
48
+ boxSizing: 'border-box',
49
+ translate: { default: '-100% 0', ':dir(rtl)': '100% 0' },
50
+ visibility: 'hidden',
51
+ transitionProperty: { default: 'visibility', [media.motion]: 'translate, visibility' },
52
+ transitionDuration: { default: '0s', [media.motion]: `${motion.slow}, 0s` },
53
+ transitionDelay: { default: '0s', [media.motion]: `0s, ${motion.slow}` },
54
+ transitionTimingFunction: DRAWER
55
+ },
56
+ drawerOpen: {
57
+ translate: '0 0',
58
+ visibility: 'visible',
59
+ transitionDelay: { default: '0s', [media.motion]: '0s, 0s' }
60
+ }
61
+ });
62
+ </script>
63
+
64
+ <script lang="ts">
65
+ let { sx, class: className, children, ...rest }: AppShellRailProps = $props();
66
+
67
+ const shell = useAppShell('Rail');
68
+
69
+ $effect(() => {
70
+ shell.setRail(true);
71
+ return () => shell.setRail(false);
72
+ });
73
+ </script>
74
+
75
+ <div
76
+ inert={(shell.narrow && !shell.open) || undefined}
77
+ data-slot="app-shell-rail"
78
+ {...rest}
79
+ {...attrs(
80
+ [styles.rail, shell.narrow && [styles.drawer, shell.open && styles.drawerOpen], sx],
81
+ className
82
+ )}
83
+ >
84
+ {@render children?.()}
85
+ </div>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type AppShellRailProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
+ sx?: Sx;
6
+ /** A Rail.Root. */
7
+ children?: Snippet;
8
+ };
9
+ declare const AppShellRail: import("svelte").Component<AppShellRailProps, {}, "">;
10
+ type AppShellRail = ReturnType<typeof AppShellRail>;
11
+ export default AppShellRail;
@@ -1,5 +1,12 @@
1
1
  <!--
2
- The frame of an app: a sidebar, the main area, and an optional panel.
2
+ The frame of an app. A bar across the top is the window's own; under it a
3
+ narrow rail stands on the window, and beside the rail one sheet holds the
4
+ sidebar, the page and a panel.
5
+
6
+ The bar and the rail are optional. Without a bar the window's controls go in
7
+ the head of the first column: the sidebar's, or the page's while the sidebar
8
+ is away. A flush sheet then makes the sidebar and the page two columns of the
9
+ window itself.
3
10
 
4
11
  Narvi lays it out and moves it; the app decides what is remembered. The open
5
12
  state is bindable and nothing is stored, and no shortcut is bound: wire ⌘B,
@@ -14,15 +21,17 @@
14
21
  import { setAppShellContext } from './context.js';
15
22
 
16
23
  export type AppShellRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
17
- /** Whether the sidebar shows in full; closed, it shrinks to its rail. Bindable. */
24
+ /** Whether the sidebar shows; closed, the page takes its room and the rail stays. Bindable. */
18
25
  sidebarOpen?: boolean;
19
- /** The width of the sidebar's list, in rem or px. A rail, if there is one, is added to it. */
26
+ /** The width of the sidebar, in rem or px. */
20
27
  sidebarWidth?: string;
21
- /** Below this window width, in pixels, the sidebar becomes a drawer over the page. */
28
+ /** Below this window width, in pixels, the rail and the sidebar become a drawer over the page. */
22
29
  narrowAt?: number;
23
30
  /**
24
- * Room kept clear at the top start corner of the window, for macOS's traffic
25
- * lights in an Electron window with a hidden title bar. Headers start after it.
31
+ * Room kept clear at the start of the bar, for macOS's traffic lights in an Electron
32
+ * window with a hidden title bar. They grew in macOS 26, so set it from the system the
33
+ * app runs on, and to `0px` in full screen and wherever the window has no lights.
34
+ * In a shell with no bar, the sidebar's head keeps it, or the page's while the sidebar is away.
26
35
  */
27
36
  windowInset?: string;
28
37
  /**
@@ -32,32 +41,42 @@
32
41
  covered?: boolean;
33
42
  sx?: Sx;
34
43
  ref?: HTMLDivElement | null;
35
- /** An AppShell.Sidebar, an AppShell.Main and, if you like, an AppShell.Panel. */
44
+ /** An AppShell.Bar, an AppShell.Rail and an AppShell.Sheet. The bar and the rail are optional. */
36
45
  children?: Snippet;
37
46
  };
38
47
 
39
48
  const styles = stylex.create({
49
+ // The window: one flat grey, a shade under the page's, for the sheet to stand out against
40
50
  root: {
41
51
  position: 'relative',
42
- display: 'flex',
52
+ boxSizing: 'border-box',
53
+ display: 'grid',
54
+ gridTemplateColumns: 'auto minmax(0, 1fr)',
55
+ gridTemplateRows: 'auto minmax(0, 1fr)',
56
+ gridTemplateAreas: '"bar bar" "rail sheet"',
43
57
  height: '100dvh',
58
+ // The gutter around the sheet. The bar and the rail reach back over it to the
59
+ // window's edge, so the sheet keeps a gutter only on the sides they leave free.
60
+ padding: '0.375rem',
44
61
  // `clip`, not `hidden`: scrollIntoView scrolls an overflow:hidden box, and
45
62
  // in Eregion one stray button slid the whole window under its header
46
63
  overflow: 'clip',
47
64
  overscrollBehavior: 'none',
48
- backgroundColor: colors.bg,
65
+ backgroundColor: colors.bgWindow,
49
66
  color: colors.text,
50
67
  fontFamily: font.body,
51
- fontSize: font.sizeMd,
52
- lineHeight: font.leadingNormal
53
- }
68
+ fontSize: font.sizeMeta,
69
+ lineHeight: font.leadingSnug
70
+ },
71
+ // A narrow window is all sheet
72
+ narrow: { padding: 0 }
54
73
  });
55
74
  </script>
56
75
 
57
76
  <script lang="ts">
58
77
  let {
59
78
  sidebarOpen = $bindable(true),
60
- sidebarWidth = '16rem',
79
+ sidebarWidth = '16.25rem',
61
80
  narrowAt = 768,
62
81
  windowInset = '0px',
63
82
  covered = false,
@@ -72,6 +91,10 @@
72
91
  let narrow = $state(false);
73
92
  let drawer = $state(false);
74
93
  let rail = $state(false);
94
+ let bar = $state(false);
95
+ // Each time the person shows or hides the sidebar; a toggle that takes the place of
96
+ // the one pressed picks up the focus then, and not when the window changes size
97
+ let moves = $state(0);
75
98
 
76
99
  $effect(() => {
77
100
  const query = matchMedia(`(max-width: ${narrowAt - 0.02}px)`);
@@ -85,15 +108,6 @@
85
108
  });
86
109
 
87
110
  const open = $derived(narrow ? drawer : sidebarOpen);
88
- // What the sidebar takes up now, so headers know how much of the window
89
- // inset is still theirs to keep clear
90
- const taken = $derived(
91
- narrow
92
- ? '0px'
93
- : sidebarOpen
94
- ? 'calc(var(--narvi-sidebar-width) + var(--narvi-rail-current))'
95
- : 'var(--narvi-rail-current)'
96
- );
97
111
 
98
112
  setAppShellContext({
99
113
  get open() {
@@ -103,16 +117,27 @@
103
117
  return narrow;
104
118
  },
105
119
  sidebarId: `${uid}-sidebar`,
120
+ get moves() {
121
+ return moves;
122
+ },
106
123
  toggle() {
107
124
  if (narrow) drawer = !drawer;
108
125
  else sidebarOpen = !sidebarOpen;
126
+ moves++;
109
127
  },
110
128
  close() {
111
129
  if (narrow) drawer = false;
112
130
  else sidebarOpen = false;
131
+ moves++;
132
+ },
133
+ get bar() {
134
+ return bar;
113
135
  },
114
136
  setRail(present) {
115
137
  rail = present;
138
+ },
139
+ setBar(present) {
140
+ bar = present;
116
141
  }
117
142
  });
118
143
  </script>
@@ -128,9 +153,10 @@
128
153
  style:--narvi-rail-width="3.25rem"
129
154
  style:--narvi-rail-current={rail ? 'var(--narvi-rail-width)' : '0px'}
130
155
  style:--narvi-window-inset={windowInset}
131
- style:--narvi-sidebar-taken={taken}
156
+ style:--narvi-inset-sidebar={bar ? '0px' : windowInset}
157
+ style:--narvi-inset-page={bar || (open && !narrow) ? '0px' : windowInset}
132
158
  {...rest}
133
- {...attrs([styles.root, sx], className)}
159
+ {...attrs([styles.root, narrow && styles.narrow, sx], className)}
134
160
  >
135
161
  {@render children?.()}
136
162
  </div>
@@ -2,15 +2,17 @@ import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
4
  export type AppShellRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
- /** Whether the sidebar shows in full; closed, it shrinks to its rail. Bindable. */
5
+ /** Whether the sidebar shows; closed, the page takes its room and the rail stays. Bindable. */
6
6
  sidebarOpen?: boolean;
7
- /** The width of the sidebar's list, in rem or px. A rail, if there is one, is added to it. */
7
+ /** The width of the sidebar, in rem or px. */
8
8
  sidebarWidth?: string;
9
- /** Below this window width, in pixels, the sidebar becomes a drawer over the page. */
9
+ /** Below this window width, in pixels, the rail and the sidebar become a drawer over the page. */
10
10
  narrowAt?: number;
11
11
  /**
12
- * Room kept clear at the top start corner of the window, for macOS's traffic
13
- * lights in an Electron window with a hidden title bar. Headers start after it.
12
+ * Room kept clear at the start of the bar, for macOS's traffic lights in an Electron
13
+ * window with a hidden title bar. They grew in macOS 26, so set it from the system the
14
+ * app runs on, and to `0px` in full screen and wherever the window has no lights.
15
+ * In a shell with no bar, the sidebar's head keeps it, or the page's while the sidebar is away.
14
16
  */
15
17
  windowInset?: string;
16
18
  /**
@@ -20,7 +22,7 @@ export type AppShellRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>
20
22
  covered?: boolean;
21
23
  sx?: Sx;
22
24
  ref?: HTMLDivElement | null;
23
- /** An AppShell.Sidebar, an AppShell.Main and, if you like, an AppShell.Panel. */
25
+ /** An AppShell.Bar, an AppShell.Rail and an AppShell.Sheet. The bar and the rail are optional. */
24
26
  children?: Snippet;
25
27
  };
26
28
  declare const AppShellRoot: import("svelte").Component<AppShellRootProps, {}, "ref" | "sidebarOpen">;
@@ -0,0 +1,95 @@
1
+ <!--
2
+ The one sheet the work is laid on: the sidebar, the page and a panel, side by
3
+ side, divided by hairlines.
4
+
5
+ Flush, it has no edge of its own and fills the window: the sidebar and the page
6
+ are then two columns of the window itself. That is for a shell with no bar.
7
+ -->
8
+ <script lang="ts" module>
9
+ import * as stylex from '@stylexjs/stylex';
10
+ import type { Snippet } from 'svelte';
11
+ import type { HTMLAttributes } from 'svelte/elements';
12
+ import { shared } from '../../internal/shared.js';
13
+ import { attrs, type Sx } from '../../internal/sx.js';
14
+ import { colors, radius } from '../../tokens.stylex.js';
15
+ import { useAppShell } from './context.js';
16
+
17
+ export type AppShellSheetProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
18
+ /**
19
+ * Fills the window to its edges, with no gutter, corner or edge of its own. The
20
+ * sidebar takes the page's colour, and what is beside it stays raised.
21
+ */
22
+ flush?: boolean;
23
+ sx?: Sx;
24
+ ref?: HTMLDivElement | null;
25
+ /** An AppShell.Sidebar, an AppShell.Main and, if you like, an AppShell.Panel. */
26
+ children?: Snippet;
27
+ };
28
+
29
+ const styles = stylex.create({
30
+ // A plain surface with a hairline round it. Nothing is lit and nothing is cast.
31
+ sheet: {
32
+ gridArea: 'sheet',
33
+ position: 'relative',
34
+ display: 'flex',
35
+ // One of several in AppShell.Panes: they share the room equally
36
+ flexGrow: 1,
37
+ flexBasis: 0,
38
+ scrollSnapAlign: 'start',
39
+ minWidth: 0,
40
+ minHeight: 0,
41
+ overflow: 'clip',
42
+ // The window's corner less the gutter, near enough, so the two curves run together
43
+ borderRadius: radius.panel,
44
+ backgroundColor: colors.bgRaised,
45
+ boxShadow: `0 0 0 1px ${colors.border}`
46
+ },
47
+ // On a narrow window a pane is as wide as the window
48
+ narrow: { borderRadius: 0, boxShadow: 'none', flexShrink: 0, flexBasis: '100%' },
49
+ // Back over the shell's gutter, to the window's edges. The sidebar reads the colour
50
+ // it is given here; anywhere else it has none and shows the sheet.
51
+ flush: {
52
+ marginInline: '-0.375rem',
53
+ marginBottom: '-0.375rem',
54
+ borderRadius: 0,
55
+ boxShadow: 'none',
56
+ '--narvi-sidebar-surface': colors.bg
57
+ },
58
+ // With no bar above it, to the window's top as well
59
+ flushTop: { marginTop: '-0.375rem' },
60
+ // A narrow window has no gutter to reach over. Spelled out: a longhand outranks `margin`.
61
+ flushNarrow: { marginTop: 0, marginInline: 0, marginBottom: 0 }
62
+ });
63
+ </script>
64
+
65
+ <script lang="ts">
66
+ let {
67
+ flush = false,
68
+ sx,
69
+ class: className,
70
+ ref = $bindable(null),
71
+ children,
72
+ ...rest
73
+ }: AppShellSheetProps = $props();
74
+
75
+ const shell = useAppShell('Sheet');
76
+ </script>
77
+
78
+ <div
79
+ bind:this={ref}
80
+ data-slot="app-shell-sheet"
81
+ data-flush={flush || undefined}
82
+ {...rest}
83
+ {...attrs(
84
+ [
85
+ styles.sheet,
86
+ shared.edged,
87
+ flush && [styles.flush, !shell.bar && styles.flushTop],
88
+ shell.narrow && [styles.narrow, flush && styles.flushNarrow],
89
+ sx
90
+ ],
91
+ className
92
+ )}
93
+ >
94
+ {@render children?.()}
95
+ </div>
@@ -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 AppShellSheetProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
+ /**
6
+ * Fills the window to its edges, with no gutter, corner or edge of its own. The
7
+ * sidebar takes the page's colour, and what is beside it stays raised.
8
+ */
9
+ flush?: boolean;
10
+ sx?: Sx;
11
+ ref?: HTMLDivElement | null;
12
+ /** An AppShell.Sidebar, an AppShell.Main and, if you like, an AppShell.Panel. */
13
+ children?: Snippet;
14
+ };
15
+ declare const AppShellSheet: import("svelte").Component<AppShellSheetProps, {}, "ref">;
16
+ type AppShellSheet = ReturnType<typeof AppShellSheet>;
17
+ export default AppShellSheet;