@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
@@ -0,0 +1,242 @@
1
+ ---
2
+ name: building-ui
3
+ description: >
4
+ Use when building pages, forms, dialogs, menus, app shells or AI chat screens with
5
+ @diegopluna/narvi components: choosing a component, composing compound parts such as
6
+ Dialog.Root, rendering a Button as a trigger, laying out with Stack and Grid, and following
7
+ Narvi's colour, label and copy conventions.
8
+ metadata:
9
+ purpose: >
10
+ Build interfaces from Narvi's components and compound parts instead of hand-written markup
11
+ and CSS, with correct composition of bits-ui based popups, responsive layout through Stack and
12
+ Grid, and Narvi's conventions for colour, labels and copy.
13
+ type: core
14
+ library: '@diegopluna/narvi'
15
+ library_version: '0.1.0'
16
+ requires:
17
+ - setup
18
+ sources:
19
+ - src/lib/index.ts
20
+ - src/lib/components/stack/Stack.svelte
21
+ - src/lib/components/grid/Grid.svelte
22
+ - src/lib/components/dialog/index.ts
23
+ - src/lib/components/tooltip/index.ts
24
+ - src/routes/components/dialog/Basic.svelte
25
+ - src/routes/components/chat/anatomy.svelte.txt
26
+ - src/routes/components/app-shell/anatomy.svelte.txt
27
+ - src/lib/components/app-shell/index.ts
28
+ ---
29
+
30
+ # Build interfaces with Narvi
31
+
32
+ This assumes Narvi is installed (see the `setup` skill). Reach for a Narvi component before
33
+ writing markup and CSS of your own. To find the right one, read the
34
+ [component catalogue](references/components.md) when you're not sure which component fits the
35
+ job, or which parts a compound component has. In an app, the file is
36
+ `node_modules/@diegopluna/narvi/skills/building-ui/references/components.md`.
37
+
38
+ Each component's props are typed. The authoritative list is the component's `.svelte.d.ts` in
39
+ `node_modules/@diegopluna/narvi/dist/components/<name>/`, and the docs page with live examples is
40
+ `https://narvi.dpeter.dev/components/<slug>`.
41
+
42
+ ## Setup
43
+
44
+ Everything except tokens and media conditions is imported from the package root:
45
+
46
+ ```svelte
47
+ <script lang="ts">
48
+ import { Button, Card, Heading, Stack, Text } from '@diegopluna/narvi';
49
+ </script>
50
+
51
+ <Card>
52
+ <Stack gap={3}>
53
+ <Heading level={2} size="lg">The West-gate</Heading>
54
+ <Text tone="muted">Speak, friend, and enter.</Text>
55
+ <Stack direction="row" gap={2} justify="end">
56
+ <Button variant="ghost">Later</Button>
57
+ <Button variant="primary">Enter</Button>
58
+ </Stack>
59
+ </Stack>
60
+ </Card>
61
+ ```
62
+
63
+ ## Core patterns
64
+
65
+ ### Compound components
66
+
67
+ Components with parts are namespaces: `Dialog.Root`, `Dialog.Content`, `Menu.Item`. Import the
68
+ namespace (`import { Dialog } from '@diegopluna/narvi'`) and nest the parts as the catalogue lists
69
+ them. The Root holds the state, and most of them take `bind:open` or `bind:value`.
70
+
71
+ ### Render a Narvi Button as a trigger
72
+
73
+ Popups are built on bits-ui. A `Trigger` or `Close` renders its own `<button>` unless you give it a
74
+ `child` snippet. To use a Narvi Button, spread the `props` the snippet receives onto it, so it
75
+ gets the ARIA attributes, the handlers and the ref:
76
+
77
+ ```svelte
78
+ <script lang="ts">
79
+ import { Button, Dialog, Field, Input } from '@diegopluna/narvi';
80
+
81
+ let open = $state(false);
82
+ let name = $state('narvi');
83
+ </script>
84
+
85
+ <Dialog.Root bind:open>
86
+ <Dialog.Trigger>
87
+ {#snippet child({ props })}<Button {...props}>Rename project</Button>{/snippet}
88
+ </Dialog.Trigger>
89
+ <Dialog.Content size="sm">
90
+ <Dialog.Header>
91
+ <Dialog.Title>Rename project</Dialog.Title>
92
+ <Dialog.Description>The name shows in the sidebar and in shared links.</Dialog.Description>
93
+ </Dialog.Header>
94
+ <Dialog.Body>
95
+ <Field label="Name">
96
+ <Input bind:value={name} />
97
+ </Field>
98
+ </Dialog.Body>
99
+ <Dialog.Footer>
100
+ <Dialog.Close>
101
+ {#snippet child({ props })}<Button {...props} variant="ghost">Cancel</Button>{/snippet}
102
+ </Dialog.Close>
103
+ <Button variant="primary" onclick={() => (open = false)}>Rename</Button>
104
+ </Dialog.Footer>
105
+ </Dialog.Content>
106
+ </Dialog.Root>
107
+ ```
108
+
109
+ The same `child` pattern applies to `Menu.Trigger`, `Popover.Trigger`, `Tooltip.Trigger`,
110
+ `HoverCard.Trigger`, `Sheet.Trigger` and `Collapsible.Trigger`.
111
+
112
+ For a yes/no confirmation, use `ConfirmDialog`. It takes a `title` that asks the question and a
113
+ `confirmLabel` that names the action. If `onconfirm` returns a promise, the dialog waits for it
114
+ and shows the error when it rejects.
115
+
116
+ ### Forms
117
+
118
+ Wrap a text control (`Input`, `Textarea` or `Select`) in `Field`. Those three read Field's
119
+ context, so it gives them a label, help text (`description`) and an error message (`error`), and
120
+ wires up `id`, `aria-describedby` and `aria-invalid`. Don't hand-write a `<label>` or the ARIA
121
+ wiring for them.
122
+
123
+ ```svelte
124
+ <Field label="Email" description="We only write when a run needs you." error={emailError}>
125
+ <Input type="email" bind:value={email} />
126
+ </Field>
127
+ ```
128
+
129
+ The other controls don't read Field, so label them directly:
130
+
131
+ - `Checkbox` and `Switch` take their label as children: `<Switch bind:checked>Night shift</Switch>`.
132
+ - `SegmentedControl`, `ToggleGroup.Root` and `Slider` need an `aria-label` (or
133
+ `aria-labelledby`), for example `<SegmentedControl aria-label="Theme" … />`.
134
+
135
+ For a settings page, put each control in a `SettingsRow` (`label`, `description`). Its
136
+ `children` snippet receives `{ id, describedBy }` for the control:
137
+
138
+ ```svelte
139
+ <SettingsRow label="Project name">
140
+ {#snippet children({ id, describedBy })}
141
+ <Input {id} aria-describedby={describedBy} bind:value={name} />
142
+ {/snippet}
143
+ </SettingsRow>
144
+ ```
145
+
146
+ A control that is a group rather than a single element, such as `SegmentedControl`, still needs
147
+ its own `aria-label` inside a SettingsRow.
148
+
149
+ ### Layout with Stack and Grid
150
+
151
+ `Stack` lays children out in a column (the default) or a row. `Grid` lays them out in columns.
152
+ Their gaps are steps on the 4px scale: `gap={4}` is 16px, and the steps are 0, 1, 2, 3, 4, 5, 6, 8,
153
+ 10, 12 and 16. Every layout prop takes a value, or values by breakpoint (`sm` 640px, `md` 768px,
154
+ `lg` 1024px, `xl` 1280px, mobile first):
155
+
156
+ ```svelte
157
+ <Stack direction={{ default: 'column', md: 'row' }} gap={{ default: 3, md: 6 }} align="start">
158
+ <Grid columns={{ default: 1, sm: 2, lg: 3 }} gap={4} as="ul">
159
+ <li>…</li>
160
+ </Grid>
161
+ </Stack>
162
+ ```
163
+
164
+ - Stack: `direction`, `gap`, `align` (`start | center | end | stretch | baseline`), `justify`
165
+ (`start | center | end | between`), `wrap`, and `as` for the element.
166
+ - Grid: `columns` (1–12, or a template string such as `'200px 1fr'`), `gap`, `align` and `as`.
167
+
168
+ Each value compiles to a static class, and nothing is styled at runtime. Use these instead of a
169
+ flex or grid style of your own. For anything they can't express, see the `styling` skill.
170
+
171
+ ### Text
172
+
173
+ Use `Heading` (`level` 1–6 for the outline, and `size` from `sm` to `4xl` for the look) and
174
+ `Text` (`variant` is what the text is: `title`, `reading`, `label`, `body`, `meta`, `caption`,
175
+ `micro` or `lead`, each one size, weight and line height; `tone` default, muted, subtle, accent,
176
+ danger or success; `weight`; `face="display"` for the serif; `truncate`). Use `Code` and `Kbd` inline, and
177
+ `Link` for links inside text. `Button href` gives a link that looks like a button, and
178
+ `Card href` makes the whole card a link.
179
+
180
+ ### Feedback
181
+
182
+ - Toasts: mount one `<Toaster />` near the root, then call `toast('Copied the link')` from
183
+ anywhere. A toast can take an `action` (`{ label: 'Undo', onclick }`).
184
+ - `Tooltip.Root` must sit inside a `Tooltip.Provider`. Mount one near the root. Give an icon
185
+ button an `aria-label` too, because the tooltip shows a name but doesn't supply one.
186
+ - Use `Notice` for a note in place (`tone`: neutral, info, success, warning, danger),
187
+ `EmptyState` for an empty place, `Skeleton`, `Spinner` or `Progress` while loading, and
188
+ `StatusIndicator` (`status`: idle, working, waiting, done, failed, stopped, connecting) for where
189
+ a run stands.
190
+
191
+ ### App and chat screens
192
+
193
+ `AppShell` is the window: its bar across the top, a rail, and one sheet that holds the sidebar,
194
+ the page and a side panel; or, with no bar and a `flush` sheet, two columns of the window
195
+ itself. `Sidebar` and `Rail` fill it; each also stands on its own: a `Sidebar` in a
196
+ `Sidebar.Root`, a `Rail.Root` beside any page. Chat screens nest `Message` parts inside
197
+ `Conversation.Content`, with `Reasoning` and `Tool` inside a reply, and `Composer` below. Agent work uses `Activity`, `WorkFold`, `Plan`,
198
+ `Approval`, `Questionnaire`, `QueuedMessage` and `ChangesSummary`. Read the
199
+ [component catalogue](references/components.md) for their anatomy before building one of these
200
+ screens. Render a reply's text with `<Markdown value={text} streaming={!done} />` inside `Message.Content`; the `markdown` skill covers it.
201
+
202
+ ## Conventions
203
+
204
+ - **Colour is for state.** `accent` (blue by default) marks focus, selection, progress and
205
+ something live. For status, use a component's `tone` or `status` prop (success, warning,
206
+ danger). Don't tint headings, icons or decoration with the accent.
207
+ - **The primary button is the only bright solid.** Keep one `variant="primary"` per view. Use
208
+ `secondary`, `soft`, `ghost`, `bare` or `link` for the rest. For what cannot be undone:
209
+ `danger` is the solid a confirming dialog asks for, `danger-outline` its quieter form, and
210
+ `ghost-danger` an icon that deletes. `warning-outline` and `success-outline` say the same of
211
+ their own. Sizes run `micro`, `xs`, `sm`, `md`, `lg`; `shape="pill"` rounds the ends.
212
+ - **One short label.** Don't join details with a dot ("Queued · sends later"). Put the rest in
213
+ an element of its own, or a tooltip.
214
+ - **What waits on the person goes over the composer.** Put an `Approval`, a `Questionnaire` or
215
+ `QueuedMessage`s in `Composer.Tray`'s `pending`, not up the conversation.
216
+ - **Labels are sentence case.** Small labels and eyebrows are never uppercase or mono.
217
+ - **Buttons name their action**: "Rename", "Delete thread", never "OK" or "Submit". A
218
+ confirmation's cancel button can name the way out: "Keep it".
219
+ - **Edges are quiet.** Prefer `Card`, `Frame` and `Separator` to hand-drawn borders.
220
+
221
+ ## Common mistakes
222
+
223
+ - **HIGH: `Tooltip.Root` without a `Tooltip.Provider`.** bits-ui reads the provider from
224
+ context and throws when there isn't one.
225
+ - **HIGH: nesting a Button inside a Trigger without `child`.** `<Dialog.Trigger><Button/></Dialog.Trigger>`
226
+ renders a button inside a button: invalid HTML, with two focus stops. Use the `child` snippet.
227
+ - **HIGH: an icon-only Button without `aria-label`.** `iconOnly` makes it square, but it has
228
+ no accessible name until you give it one.
229
+ - **MEDIUM: a raw `<label>` beside an Input.** It misses Field's description and error wiring.
230
+ - **MEDIUM: wrapping a Checkbox, Switch or SegmentedControl in `Field`.** They don't read Field's
231
+ context, so the label names nothing. Use children or `aria-label`, as above.
232
+ - **MEDIUM: a flex `<div>` with margins between children.** Use Stack or Grid. Their gaps follow
233
+ the spacing scale and change by breakpoint without media queries.
234
+ - **MEDIUM: styling inside a `<Theme>` and expecting popups to follow.** They render at the end
235
+ of the body. See the `theming` skill.
236
+
237
+ ## Completion
238
+
239
+ The screen uses Narvi components for its controls, layout and text, and has no hand-written
240
+ layout CSS. Popups open from their triggers and close with Escape, returning focus to the
241
+ trigger. Every control has a visible or ARIA label, and the screen reads correctly in light and
242
+ dark.
@@ -0,0 +1,207 @@
1
+ # Narvi component catalogue
2
+
3
+ Everything here is imported from `@diegopluna/narvi`. A name with dots is a part of a compound
4
+ component: import the namespace (`Dialog`) and use `Dialog.Root`. Docs and live examples are at
5
+ `https://narvi.dpeter.dev/components/<slug>`, and the full props are in
6
+ `node_modules/@diegopluna/narvi/dist/components/<folder>/*.svelte.d.ts`.
7
+
8
+ ## Layout and text
9
+
10
+ | Component | Use it for | Docs slug |
11
+ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
12
+ | `Stack` | Children in a column or a row, with even gaps, by breakpoint | `stack` |
13
+ | `Grid` | Children in columns (a count or a template), by breakpoint | `grid` |
14
+ | `Card` | A surface that groups related content; `href` makes the whole card a link | `card` |
15
+ | `Frame` | A tray around an inset panel, with an optional title: Narvi's signature container | `frame` |
16
+ | `Separator` | A thin line between groups | `separator` |
17
+ | `Heading` | A title: `level` for the outline, `size` for the look | `heading` |
18
+ | `Text` | Text in a role (`variant`: `title`, `reading`, `label`, `body`, `meta`, `caption`, `micro`, `lead`), in the page's face or the display serif | `text` |
19
+ | `Link` | A link inside running text | `link` |
20
+ | `Code` | A short piece of code inside text | `code` |
21
+ | `Markdown` | Markdown, streamed or finished: an AI reply, a README (see the `markdown` skill) | `markdown` |
22
+ | `Kbd` | A key cap, for shortcuts. Inside a `Button` it takes the button's ink | `kbd` |
23
+ | `Reveal` | Eases part of a scrolled page into place. For marketing pages, not apps | `reveal` |
24
+ | `Theme` | Sets the scheme or a custom theme for part of the page (see `theming`) | `theme` |
25
+
26
+ ## Controls and forms
27
+
28
+ | Component | Use it for | Docs slug |
29
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------- |
30
+ | `Button` | An action; `href` makes it a link; `variant` (12, from `primary` to `success-outline`), `size` (`micro` to `lg`), `shape`, `loading`, `iconOnly` | `button` |
31
+ | `Field` | Label, help text and error around one control | `field` |
32
+ | `Input` | One line of text | `input` |
33
+ | `Textarea` | Several lines of text | `textarea` |
34
+ | `Select` | One choice from a short list (`options: { value, label, group? }[]`) | `select` |
35
+ | `Checkbox` | An option on or off, or several from a list | `checkbox` |
36
+ | `Switch` | A setting that takes effect at once | `switch` |
37
+ | `SegmentedControl` | One of a few options, all visible (`options: { value, label }[]`) | `segmented-control` |
38
+ | `Slider` | A value or a range along a track | `slider` |
39
+ | `Toggle` | A button that stays pressed | `toggle` |
40
+ | `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number | `toggle-group` |
41
+ | `SettingsRow` | One setting: what it is, beside its control | `settings-row` |
42
+ | `Tabs` | Views that share one place (`items: TabItem[]`) | `tabs` |
43
+ | `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`). The panel is yours | `tab-strip` |
44
+
45
+ ## Overlays (bits-ui; use `child` snippets on triggers)
46
+
47
+ | Component | Use it for | Docs slug |
48
+ | ------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- | ------------- |
49
+ | `Dialog.Root`, `.Trigger`, `.Content` (`size`, `side`), `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Close` | A focused task over the page | `dialog` |
50
+ | `ConfirmDialog` | A confirmation for an action that matters | `dialog` |
51
+ | `Sheet.Root`, `.Trigger`, `.Content` (`side`), `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Close` | A panel that slides in from an edge | `sheet` |
52
+ | `Popover.Root`, `.Trigger`, `.Content`, `.Close` | Content anchored to the control that opened it | `popover` |
53
+ | `HoverCard.Root`, `.Trigger`, `.Content` | A preview while the pointer rests on a link or chip | `hover-card` |
54
+ | `Menu.Root`, `.Trigger`, `.Content`, `.Item`, `.CheckboxItem`, `.RadioGroup`, `.RadioItem`, `.Group`, `.Label`, `.Separator`, `.Sub` | Actions and choices from a button | `menu` |
55
+ | `ContextMenu.Root`, `.Trigger`, `.Content`, filled with `Menu` items | The same, from a right-click | `menu` |
56
+ | `Command.Dialog`, `.Root`, `.Input`, `.List`, `.Group`, `.Item`, `.Empty`, `.Separator`, `.Footer` | A search field over everything the app can do (⌘K) | `command` |
57
+ | `Tooltip.Provider`, `.Root`, `.Trigger`, `.Content` (`shortcut`) | A control's name and its keys. Needs the Provider | `tooltip` |
58
+ | `Collapsible.Root`, `.Trigger`, `.Content` | A region the person can fold away | `collapsible` |
59
+
60
+ ## Feedback and status
61
+
62
+ | Component | Use it for | Docs slug |
63
+ | ------------------------------------ | ---------------------------------------------------------------------------------------------- | ------------------ |
64
+ | `Toaster`, `toast()` | Short notes about something that happened; one Toaster at the root | `toast` |
65
+ | `Notice` | A note in place: what is happening or went wrong, and what to do | `notice` |
66
+ | `EmptyState` | An empty place: what it is for and how to fill it (`title`, `description`, `media`, `actions`) | `empty-state` |
67
+ | `Badge` | A status, category or count (`tone`) | `badge` |
68
+ | `StatusIndicator` | Where a run, thread or machine stands, by shape and colour | `status-indicator` |
69
+ | `Progress` | How far along a task is | `progress` |
70
+ | `Spinner` | Something in progress | `spinner` |
71
+ | `Skeleton` | A stand-in for content on its way | `skeleton` |
72
+ | `Shimmer` | Text that says work is under way | `shimmer` |
73
+ | `RollingText` | A phrase that rolls to its next value ("Reading…", "Running…") | none |
74
+ | `Announcer` | Says a short message to screen readers without showing anything | `announcer` |
75
+ | `Avatar.Root`, `.Image`, `.Fallback` | A person: a picture, or initials | `avatar` |
76
+
77
+ ## App shell
78
+
79
+ | Component | Use it for | Docs slug |
80
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ----------- |
81
+ | `AppShell.Root` (`bind:sidebarOpen`, `windowInset`), `.Bar` (`center`, `end` snippets), `.Rail`, `.Panes`, `.Sheet` (`flush`), `.Sidebar`, `.Main`, `.Header` (`drag`), `.Panel` (`bind:width`), `.Toggle` (`when`) | The window: its bar, a rail, and one sheet for the sidebar, the page and a side panel | `app-shell` |
82
+ | `Sidebar.Root` (`label`), `.Header` (`drag`), `.Content` (`label`), `.Group`, `.Folder` (`bind:open`, `leading`, `trailing` snippets), `.Item` (`current`, `leading`, `trailing`, `meta`, `actions` snippets), `.Footer` | A column of rows, in groups and folders. `Root` is for one on its own; in an app shell the same parts go in `AppShell.Sidebar` | `sidebar` |
83
+ | `Rail.Root` (`label`), `.Item` (`label`, `href`, `current`, `badge`, `badgeTone`, `shortcut`), `.Separator`, `.Spacer` | A narrow strip of places to go: workspaces, settings. On its own beside a page, or in `AppShell.Rail` | `rail` |
84
+ | `ResizeHandle` | A draggable edge between two areas | none |
85
+
86
+ `AppShell.Bar`, `AppShell.Rail` and `AppShell.Sheet` are direct children of `AppShell.Root`; the
87
+ sidebar, the page and the panel go inside the sheet. The bar is where macOS's traffic lights sit
88
+ in a desktop window with a hidden title bar: set `windowInset` on the root to the room they take
89
+ (about `5.25rem` since macOS 26, `4.5rem` before, `0px` in full screen and off macOS).
90
+
91
+ ```svelte
92
+ <AppShell.Root bind:sidebarOpen windowInset="5.25rem">
93
+ <AppShell.Bar>
94
+ <AppShell.Toggle />
95
+ {#snippet center()}…{/snippet}
96
+ {#snippet end()}…{/snippet}
97
+ </AppShell.Bar>
98
+ <AppShell.Rail>
99
+ <Rail.Root label="Workspaces">
100
+ <Rail.Item label="Forge" current>F</Rail.Item>
101
+ </Rail.Root>
102
+ </AppShell.Rail>
103
+ <AppShell.Sheet>
104
+ <AppShell.Sidebar label="Threads">
105
+ <Sidebar.Header>…</Sidebar.Header>
106
+ <Sidebar.Content label="Threads">
107
+ <Sidebar.Group label="Projects">
108
+ <Sidebar.Folder label="narvi">
109
+ <Sidebar.Item current onclick={open}>Fix the flaky Avatar test</Sidebar.Item>
110
+ </Sidebar.Folder>
111
+ </Sidebar.Group>
112
+ </Sidebar.Content>
113
+ </AppShell.Sidebar>
114
+ <AppShell.Main>
115
+ <AppShell.Header>…</AppShell.Header>
116
+ …
117
+ </AppShell.Main>
118
+ <AppShell.Panel label="Changes" bind:width={panelWidth}>…</AppShell.Panel>
119
+ </AppShell.Sheet>
120
+ </AppShell.Root>
121
+ ```
122
+
123
+ For panes, put several `AppShell.Sheet`s in an `AppShell.Panes` in place of the one sheet: each
124
+ is a pane of its own, with a `TabStrip` in its `AppShell.Header` for what is open in it.
125
+
126
+ The bar and the rail are optional. For a shell that is two columns of the window, with no bar,
127
+ make the sheet `flush`. The heads of the columns are then the window's: give them `drag`, put a
128
+ toggle in the sidebar's head and one with `when="closed"` in the page's header, which shows only
129
+ while the sidebar is away. `windowInset` then clears the traffic lights in whichever head is
130
+ first. Don't use a rail without a bar in a window that has traffic lights: they are wider than it.
131
+
132
+ ```svelte
133
+ <AppShell.Root bind:sidebarOpen windowInset="5.25rem">
134
+ <AppShell.Sheet flush>
135
+ <AppShell.Sidebar label="Sessions">
136
+ <Sidebar.Header drag><AppShell.Toggle /></Sidebar.Header>
137
+ <Sidebar.Content label="Sessions">…</Sidebar.Content>
138
+ </AppShell.Sidebar>
139
+ <AppShell.Main>
140
+ <AppShell.Header drag><AppShell.Toggle when="closed" />…</AppShell.Header>
141
+ …
142
+ </AppShell.Main>
143
+ </AppShell.Sheet>
144
+ </AppShell.Root>
145
+ ```
146
+
147
+ ## AI chat
148
+
149
+ | Component | Use it for | Docs slug |
150
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | -------------- |
151
+ | `Conversation.Root`, `.Content`, `.ScrollButton`, `.Empty` | The scrolling log; keeps the newest in view while it streams | `conversation` |
152
+ | `Message.Root` (`from`, `streaming`), `.Header`, `.Pending`, `.Content`, `.Actions`, `.Action`, `.Copy` | One turn, from the person or the model | `message` |
153
+ | `Reasoning.Root` (`streaming`), `.Trigger`, `.Content` | The model's thinking, folded once done | `reasoning` |
154
+ | `Tool.Root` (`name`, `state`), `.Trigger`, `.Content`, `.Input`, `.Output` | A tool call: what it asked, how it went, what came back | `tool` |
155
+ | `Composer.Tray` (`pending` snippet), `.Root` (`bind:value`, `status`, `onsubmit`, `onstop`), `.Textarea`, `.Toolbar`, `.Attachments`, `.AttachButton`, `.Toggle`, `.ModelPicker`, `.Submit` | Where the person writes to the model | `composer` |
156
+ | `Suggestions.Root`, `.Item` | Prompts to start from | `suggestions` |
157
+
158
+ ```svelte
159
+ <Conversation.Root>
160
+ <Conversation.Content>
161
+ <Message.Root from="user"><Message.Content>…</Message.Content></Message.Root>
162
+ <Message.Root from="assistant" streaming>
163
+ <Message.Content>
164
+ <Reasoning.Root streaming>
165
+ <Reasoning.Trigger />
166
+ <Reasoning.Content>…</Reasoning.Content>
167
+ </Reasoning.Root>
168
+ <Tool.Root name="search_docs" state="running">
169
+ <Tool.Trigger />
170
+ <Tool.Content><Tool.Input value={input} /><Tool.Output value={output} /></Tool.Content>
171
+ </Tool.Root>
172
+ </Message.Content>
173
+ <Message.Actions><Message.Copy value={text} /></Message.Actions>
174
+ </Message.Root>
175
+ </Conversation.Content>
176
+ <Conversation.ScrollButton />
177
+ </Conversation.Root>
178
+
179
+ <Composer.Root bind:value {status} onsubmit={send} onstop={stop}>
180
+ <Composer.Textarea placeholder="Ask anything" />
181
+ <Composer.Toolbar><Composer.Submit /></Composer.Toolbar>
182
+ </Composer.Root>
183
+ ```
184
+
185
+ ## Agent timeline
186
+
187
+ Docs slug: `agent-timeline`.
188
+
189
+ | Component | Use it for |
190
+ | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
191
+ | `Activity.Root`, `.Trigger`, `.Content`, `.Step`, `.Thought` | A stretch of work: says what the agent is doing, then what it did |
192
+ | `WorkFold` | Folds a finished turn's work behind "Worked for 2m 5s" |
193
+ | `Plan` (`steps: { label, status }[]`) | What the agent means to do, ticked off as it goes |
194
+ | `Approval` | The agent asks before acting; folds into the decision once answered. A choice's `shortcut` (`mod+enter`, `mod+backspace`, `enter`, `escape`) shows on its button and makes it |
195
+ | `Questionnaire` | Questions one at a time, with keys 1–9 to pick and ⌘Enter to send |
196
+ | `QueuedMessage` | A message sent while the agent was still working, waiting its turn |
197
+ | `ChangesSummary` (`ChangedFile[]`), `ChangeStats` (`additions`, `deletions`) | What a turn changed, and +12 −3 counts |
198
+ | `Divider` (`label`) | A labelled break in a timeline: a new day, "Context compacted" |
199
+
200
+ ## Utilities
201
+
202
+ - `sx()`, `classes()` and the `Sx` type: see the `styling` skill.
203
+ - `resolveColor()` and `resolveRgba()`: see the `theming` skill.
204
+ - `whileVisible`: an attachment that runs an animation that never ends only while it can be seen, with `animationPlayState: play.whileVisible` from the tokens. Step the animation itself.
205
+ Shimmer, Skeleton and Progress run on it. Spinner does not: it is a CSS animation of `rotate`,
206
+ one turn in 600ms, so it stays smooth.
207
+ - `DevStyles`: see the `setup` skill.