@diegopluna/narvi 0.0.2 → 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 (313) hide show
  1. package/README.md +116 -44
  2. package/dist/base.css +96 -0
  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 +5 -6
  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 -17
  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 +41 -65
  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 +99 -23
  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 +227 -51
  36. package/dist/components/button/Button.svelte.d.ts +38 -2
  37. package/dist/components/card/Card.svelte +19 -33
  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 +31 -25
  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/CollapsibleContent.svelte +38 -0
  44. package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +11 -0
  45. package/dist/components/collapsible/CollapsibleRoot.svelte +44 -0
  46. package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +11 -0
  47. package/dist/components/collapsible/CollapsibleTrigger.svelte +83 -0
  48. package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +13 -0
  49. package/dist/components/collapsible/context.d.ts +5 -0
  50. package/dist/components/collapsible/context.js +11 -0
  51. package/dist/components/collapsible/index.d.ts +7 -0
  52. package/dist/components/collapsible/index.js +4 -0
  53. package/dist/components/command/CommandItem.svelte +1 -1
  54. package/dist/components/command/styles.d.ts +3 -2
  55. package/dist/components/command/styles.js +15 -12
  56. package/dist/components/composer/ComposerAttachButton.svelte +1 -1
  57. package/dist/components/composer/ComposerAttachment.svelte +13 -18
  58. package/dist/components/composer/ComposerModelPicker.svelte +24 -28
  59. package/dist/components/composer/ComposerRoot.svelte +15 -13
  60. package/dist/components/composer/ComposerSubmit.svelte +12 -20
  61. package/dist/components/composer/ComposerTextarea.svelte +1 -1
  62. package/dist/components/composer/ComposerToggle.svelte +16 -18
  63. package/dist/components/composer/ComposerTray.svelte +78 -0
  64. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -0
  65. package/dist/components/composer/index.d.ts +3 -1
  66. package/dist/components/composer/index.js +3 -2
  67. package/dist/components/conversation/ConversationContent.svelte +3 -2
  68. package/dist/components/conversation/ConversationEmpty.svelte +1 -1
  69. package/dist/components/conversation/ConversationScrollButton.svelte +9 -11
  70. package/dist/components/dialog/ConfirmDialog.svelte +1 -1
  71. package/dist/components/dialog/DialogContent.svelte +5 -1
  72. package/dist/components/dialog/styles.d.ts +2 -26
  73. package/dist/components/dialog/styles.js +12 -49
  74. package/dist/components/divider/Divider.svelte +3 -3
  75. package/dist/components/empty-state/EmptyState.svelte +4 -5
  76. package/dist/components/field/Field.svelte +4 -4
  77. package/dist/components/frame/Frame.svelte +6 -7
  78. package/dist/components/frame/Frame.svelte.d.ts +1 -1
  79. package/dist/components/grid/Grid.svelte +111 -0
  80. package/dist/components/grid/Grid.svelte.d.ts +27 -0
  81. package/dist/components/heading/Heading.svelte +2 -2
  82. package/dist/components/hover-card/HoverCardContent.svelte +50 -0
  83. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +10 -0
  84. package/dist/components/hover-card/HoverCardRoot.svelte +22 -0
  85. package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -0
  86. package/dist/components/hover-card/index.d.ts +7 -0
  87. package/dist/components/hover-card/index.js +7 -0
  88. package/dist/components/kbd/Kbd.svelte +12 -7
  89. package/dist/components/link/Link.svelte +9 -7
  90. package/dist/components/link/Link.svelte.d.ts +4 -1
  91. package/dist/components/markdown/Markdown.svelte +714 -0
  92. package/dist/components/markdown/Markdown.svelte.d.ts +80 -0
  93. package/dist/components/markdown/MarkdownBlock.svelte +231 -0
  94. package/dist/components/markdown/MarkdownBlock.svelte.d.ts +11 -0
  95. package/dist/components/markdown/MarkdownBlocks.svelte +115 -0
  96. package/dist/components/markdown/MarkdownBlocks.svelte.d.ts +15 -0
  97. package/dist/components/markdown/MarkdownCode.svelte +583 -0
  98. package/dist/components/markdown/MarkdownCode.svelte.d.ts +23 -0
  99. package/dist/components/markdown/MarkdownDiagram.svelte +310 -0
  100. package/dist/components/markdown/MarkdownDiagram.svelte.d.ts +6 -0
  101. package/dist/components/markdown/MarkdownFile.svelte +134 -0
  102. package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
  103. package/dist/components/markdown/MarkdownFootnotes.svelte +61 -0
  104. package/dist/components/markdown/MarkdownFootnotes.svelte.d.ts +8 -0
  105. package/dist/components/markdown/MarkdownFresh.svelte +69 -0
  106. package/dist/components/markdown/MarkdownFresh.svelte.d.ts +6 -0
  107. package/dist/components/markdown/MarkdownHtml.svelte +72 -0
  108. package/dist/components/markdown/MarkdownHtml.svelte.d.ts +7 -0
  109. package/dist/components/markdown/MarkdownImage.svelte +150 -0
  110. package/dist/components/markdown/MarkdownImage.svelte.d.ts +8 -0
  111. package/dist/components/markdown/MarkdownInlines.svelte +225 -0
  112. package/dist/components/markdown/MarkdownInlines.svelte.d.ts +7 -0
  113. package/dist/components/markdown/MarkdownLink.svelte +120 -0
  114. package/dist/components/markdown/MarkdownLink.svelte.d.ts +25 -0
  115. package/dist/components/markdown/MarkdownMath.svelte +138 -0
  116. package/dist/components/markdown/MarkdownMath.svelte.d.ts +7 -0
  117. package/dist/components/markdown/MarkdownTable.svelte +265 -0
  118. package/dist/components/markdown/MarkdownTable.svelte.d.ts +17 -0
  119. package/dist/components/markdown/caret.d.ts +14 -0
  120. package/dist/components/markdown/caret.js +67 -0
  121. package/dist/components/markdown/context.d.ts +93 -0
  122. package/dist/components/markdown/context.js +128 -0
  123. package/dist/components/markdown/copy.d.ts +13 -0
  124. package/dist/components/markdown/copy.js +74 -0
  125. package/dist/components/markdown/hidden.d.ts +12 -0
  126. package/dist/components/markdown/hidden.js +31 -0
  127. package/dist/components/markdown/kept.d.ts +32 -0
  128. package/dist/components/markdown/kept.js +71 -0
  129. package/dist/components/markdown/labels.d.ts +46 -0
  130. package/dist/components/markdown/labels.js +35 -0
  131. package/dist/components/markdown/save.d.ts +11 -0
  132. package/dist/components/markdown/save.js +58 -0
  133. package/dist/components/markdown/scrollable.d.ts +24 -0
  134. package/dist/components/markdown/scrollable.js +152 -0
  135. package/dist/components/markdown/static.d.ts +37 -0
  136. package/dist/components/markdown/static.js +233 -0
  137. package/dist/components/markdown/styles.d.ts +328 -0
  138. package/dist/components/markdown/styles.js +302 -0
  139. package/dist/components/menu/MenuRadioItem.svelte +3 -3
  140. package/dist/components/menu/index.d.ts +23 -0
  141. package/dist/components/menu/index.js +3 -1
  142. package/dist/components/message/MessageAction.svelte +24 -5
  143. package/dist/components/message/MessageAction.svelte.d.ts +9 -0
  144. package/dist/components/message/MessageActions.svelte +2 -3
  145. package/dist/components/message/MessageContent.svelte +2 -3
  146. package/dist/components/message/MessageCopy.svelte +66 -8
  147. package/dist/components/message/MessageCopy.svelte.d.ts +17 -1
  148. package/dist/components/message/MessageHeader.svelte +3 -3
  149. package/dist/components/message/MessagePending.svelte +1 -1
  150. package/dist/components/message/MessageRoot.svelte +3 -4
  151. package/dist/components/message/MessageTime.svelte +3 -4
  152. package/dist/components/notice/Notice.svelte +14 -10
  153. package/dist/components/plan/Plan.svelte +25 -21
  154. package/dist/components/progress/Progress.svelte +34 -38
  155. package/dist/components/questionnaire/Questionnaire.svelte +19 -22
  156. package/dist/components/queued-message/QueuedMessage.svelte +14 -7
  157. package/dist/components/rail/RailItem.svelte +43 -40
  158. package/dist/components/rail/RailItem.svelte.d.ts +3 -1
  159. package/dist/components/rail/RailRoot.svelte +18 -4
  160. package/dist/components/rail/RailRoot.svelte.d.ts +1 -1
  161. package/dist/components/rail/RailSeparator.svelte +17 -0
  162. package/dist/components/rail/RailSeparator.svelte.d.ts +18 -0
  163. package/dist/components/rail/index.d.ts +2 -1
  164. package/dist/components/rail/index.js +2 -1
  165. package/dist/components/reasoning/ReasoningContent.svelte +4 -8
  166. package/dist/components/reasoning/ReasoningTrigger.svelte +4 -5
  167. package/dist/components/resize-handle/ResizeHandle.svelte +4 -7
  168. package/dist/components/reveal/Reveal.svelte +89 -0
  169. package/dist/components/reveal/Reveal.svelte.d.ts +17 -0
  170. package/dist/components/reveal/revealed.d.ts +38 -0
  171. package/dist/components/reveal/revealed.js +79 -0
  172. package/dist/components/segmented/SegmentedControl.svelte +11 -16
  173. package/dist/components/select/Select.svelte +1 -1
  174. package/dist/components/separator/Separator.svelte +1 -1
  175. package/dist/components/settings-row/SettingsRow.svelte +5 -5
  176. package/dist/components/sheet/SheetContent.svelte +63 -0
  177. package/dist/components/sheet/SheetContent.svelte.d.ts +18 -0
  178. package/dist/components/sheet/index.d.ts +12 -0
  179. package/dist/components/sheet/index.js +12 -0
  180. package/dist/components/sheet/styles.d.ts +51 -0
  181. package/dist/components/sheet/styles.js +65 -0
  182. package/dist/components/shimmer/Shimmer.svelte +41 -26
  183. package/dist/components/sidebar/SidebarContent.svelte +1 -1
  184. package/dist/components/sidebar/SidebarFolder.svelte +142 -0
  185. package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
  186. package/dist/components/sidebar/SidebarFooter.svelte +1 -1
  187. package/dist/components/sidebar/SidebarGroup.svelte +41 -35
  188. package/dist/components/sidebar/SidebarGroup.svelte.d.ts +3 -3
  189. package/dist/components/sidebar/SidebarHeader.svelte +12 -6
  190. package/dist/components/sidebar/SidebarHeader.svelte.d.ts +4 -1
  191. package/dist/components/sidebar/SidebarItem.svelte +34 -38
  192. package/dist/components/sidebar/SidebarRoot.svelte +62 -0
  193. package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
  194. package/dist/components/sidebar/index.d.ts +5 -1
  195. package/dist/components/sidebar/index.js +3 -1
  196. package/dist/components/skeleton/Skeleton.svelte +26 -15
  197. package/dist/components/slider/Slider.svelte +200 -0
  198. package/dist/components/slider/Slider.svelte.d.ts +55 -0
  199. package/dist/components/spinner/Spinner.svelte +4 -11
  200. package/dist/components/stack/Stack.svelte +37 -44
  201. package/dist/components/stack/Stack.svelte.d.ts +12 -6
  202. package/dist/components/status-indicator/StatusIndicator.svelte +1 -1
  203. package/dist/components/suggestions/SuggestionsItem.svelte +11 -13
  204. package/dist/components/switch/Switch.svelte +16 -25
  205. package/dist/components/tab-strip/TabStrip.svelte +340 -0
  206. package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
  207. package/dist/components/tabs/Tabs.svelte +15 -14
  208. package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
  209. package/dist/components/text/Text.svelte +64 -14
  210. package/dist/components/text/Text.svelte.d.ts +13 -3
  211. package/dist/components/toast/Toaster.svelte +12 -10
  212. package/dist/components/toggle/Toggle.svelte +40 -0
  213. package/dist/components/toggle/Toggle.svelte.d.ts +15 -0
  214. package/dist/components/toggle-group/ToggleGroupItem.svelte +37 -0
  215. package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -0
  216. package/dist/components/toggle-group/ToggleGroupRoot.svelte +95 -0
  217. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +33 -0
  218. package/dist/components/toggle-group/context.d.ts +6 -0
  219. package/dist/components/toggle-group/context.js +11 -0
  220. package/dist/components/toggle-group/index.d.ts +5 -0
  221. package/dist/components/toggle-group/index.js +3 -0
  222. package/dist/components/tool/ToolContent.svelte +3 -8
  223. package/dist/components/tool/ToolSection.svelte +4 -5
  224. package/dist/components/tool/ToolTrigger.svelte +14 -15
  225. package/dist/components/tooltip/TooltipContent.svelte +9 -6
  226. package/dist/components/work-fold/WorkFold.svelte +17 -34
  227. package/dist/components/work-fold/WorkFold.svelte.d.ts +1 -1
  228. package/dist/index.d.ts +38 -10
  229. package/dist/index.js +38 -12
  230. package/dist/internal/Chevron.svelte +2 -3
  231. package/dist/internal/Code.svelte +3 -4
  232. package/dist/internal/Collapse.svelte +6 -5
  233. package/dist/internal/Collapse.svelte.d.ts +2 -1
  234. package/dist/internal/Glyph.svelte +16 -0
  235. package/dist/internal/Glyph.svelte.d.ts +6 -0
  236. package/dist/internal/Tile.svelte +17 -37
  237. package/dist/internal/control.d.ts +4 -4
  238. package/dist/internal/control.js +21 -18
  239. package/dist/internal/layer.d.ts +3 -5
  240. package/dist/internal/layer.js +14 -18
  241. package/dist/internal/layout.d.ts +13 -0
  242. package/dist/internal/layout.js +453 -0
  243. package/dist/internal/markers.stylex.d.ts +8 -0
  244. package/dist/internal/markers.stylex.js +4 -0
  245. package/dist/internal/plugin-order.d.ts +8 -0
  246. package/dist/internal/plugin-order.js +16 -0
  247. package/dist/internal/responsive.d.ts +45 -0
  248. package/dist/internal/responsive.js +42 -0
  249. package/dist/internal/roving.js +5 -2
  250. package/dist/internal/shared.d.ts +8 -1
  251. package/dist/internal/shared.js +21 -5
  252. package/dist/internal/sx.d.ts +31 -4
  253. package/dist/internal/sx.js +17 -0
  254. package/dist/internal/toggle.d.ts +73 -0
  255. package/dist/internal/toggle.js +83 -0
  256. package/dist/internal/visible.d.ts +32 -0
  257. package/dist/internal/visible.js +44 -0
  258. package/dist/markdown/ast.d.ts +209 -0
  259. package/dist/markdown/ast.js +10 -0
  260. package/dist/markdown/blocks.d.ts +177 -0
  261. package/dist/markdown/blocks.js +1489 -0
  262. package/dist/markdown/code-info.d.ts +10 -0
  263. package/dist/markdown/code-info.js +16 -0
  264. package/dist/markdown/common.d.ts +25 -0
  265. package/dist/markdown/common.js +107 -0
  266. package/dist/markdown/diagrams.d.ts +2 -0
  267. package/dist/markdown/diagrams.js +18 -0
  268. package/dist/markdown/file-paths.d.ts +29 -0
  269. package/dist/markdown/file-paths.js +80 -0
  270. package/dist/markdown/files.d.ts +16 -0
  271. package/dist/markdown/files.js +133 -0
  272. package/dist/markdown/highlight.d.ts +30 -0
  273. package/dist/markdown/highlight.js +127 -0
  274. package/dist/markdown/html.d.ts +23 -0
  275. package/dist/markdown/html.js +289 -0
  276. package/dist/markdown/images.d.ts +15 -0
  277. package/dist/markdown/images.js +45 -0
  278. package/dist/markdown/index.d.ts +12 -0
  279. package/dist/markdown/index.js +5 -0
  280. package/dist/markdown/inlines.d.ts +48 -0
  281. package/dist/markdown/inlines.js +1714 -0
  282. package/dist/markdown/math.d.ts +2 -0
  283. package/dist/markdown/math.js +22 -0
  284. package/dist/markdown/parse.d.ts +81 -0
  285. package/dist/markdown/parse.js +204 -0
  286. package/dist/markdown/plugin.d.ts +178 -0
  287. package/dist/markdown/plugin.js +160 -0
  288. package/dist/markdown/sanitize.d.ts +78 -0
  289. package/dist/markdown/sanitize.js +522 -0
  290. package/dist/markdown/share.d.ts +12 -0
  291. package/dist/markdown/share.js +59 -0
  292. package/dist/markdown/table.d.ts +13 -0
  293. package/dist/markdown/table.js +60 -0
  294. package/dist/media.stylex.d.ts +52 -0
  295. package/dist/media.stylex.js +53 -0
  296. package/dist/preset.d.ts +40 -16
  297. package/dist/preset.js +169 -51
  298. package/dist/tokens.stylex.d.ts +70 -37
  299. package/dist/tokens.stylex.js +127 -62
  300. package/dist/typography.d.ts +48 -0
  301. package/dist/typography.js +55 -0
  302. package/dist/vite.d.ts +9 -1
  303. package/dist/vite.js +37 -4
  304. package/package.json +58 -6
  305. package/skills/building-ui/SKILL.md +242 -0
  306. package/skills/building-ui/references/components.md +207 -0
  307. package/skills/markdown/SKILL.md +452 -0
  308. package/skills/markdown/references/plugins.md +103 -0
  309. package/skills/setup/SKILL.md +191 -0
  310. package/skills/styling/SKILL.md +269 -0
  311. package/skills/theming/SKILL.md +184 -0
  312. package/dist/internal/loop.d.ts +0 -35
  313. package/dist/internal/loop.js +0 -72
@@ -4,6 +4,7 @@
4
4
  import type { HTMLInputAttributes } from 'svelte/elements';
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
 
8
9
  export type SwitchProps = Omit<HTMLInputAttributes, 'type' | 'role' | 'children'> & {
9
10
  checked?: boolean;
@@ -17,11 +18,6 @@
17
18
  children?: Snippet;
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
  display: 'inline-flex',
@@ -29,7 +25,7 @@
29
25
  gap: '0.625rem',
30
26
  color: colors.text,
31
27
  fontFamily: font.body,
32
- fontSize: font.sizeMd,
28
+ fontSize: font.sizeBody,
33
29
  lineHeight: '1.25rem',
34
30
  cursor: 'pointer',
35
31
  WebkitTapHighlightColor: 'transparent'
@@ -41,7 +37,7 @@
41
37
  description: {
42
38
  display: 'block',
43
39
  color: colors.textSubtle,
44
- fontSize: font.sizeXs,
40
+ fontSize: font.sizeCaption,
45
41
  lineHeight: font.leadingSnug
46
42
  },
47
43
  input: {
@@ -53,20 +49,16 @@
53
49
  margin: 0,
54
50
  marginBlock: '1px',
55
51
  borderWidth: 0,
56
- borderRadius: radius.full,
52
+ borderRadius: radius.pill,
57
53
  backgroundColor: {
58
- default: colors.edge,
59
- ':hover': { default: null, [HOVER]: colors.edgeHover },
60
- [FORCED]: { default: 'Canvas', ':checked': 'Highlight' }
54
+ default: colors.borderControl,
55
+ ':hover': { default: null, [media.hover]: colors.borderControlHover },
56
+ [media.forcedColors]: { default: 'Canvas', ':checked': 'Highlight' }
61
57
  },
62
58
  backgroundImage: {
63
59
  default: 'none',
64
- ':checked': `linear-gradient(180deg, ${colors.ithil}, ${colors.ithilStrong})`,
65
- [FORCED]: 'none'
66
- },
67
- boxShadow: {
68
- default: `inset 0 1px 2px ${colors.shade}`,
69
- ':checked': `inset 0 1px 0 rgb(255 255 255 / 0.4), 0 0 8px ${colors.glow}`
60
+ ':checked': `linear-gradient(${colors.accent}, ${colors.accent})`,
61
+ [media.forcedColors]: 'none'
70
62
  },
71
63
  forcedColorAdjust: 'none',
72
64
  appearance: 'none',
@@ -77,7 +69,7 @@
77
69
  outlineColor: {
78
70
  default: 'transparent',
79
71
  ':focus-visible': colors.focusRing,
80
- [FORCED]: { default: 'ButtonText', ':focus-visible': 'Highlight' }
72
+ [media.forcedColors]: { default: 'ButtonText', ':focus-visible': 'Highlight' }
81
73
  },
82
74
  outlineOffset: { default: '-1px', ':focus-visible': '2px' },
83
75
  transitionProperty: 'background-color',
@@ -97,22 +89,21 @@
97
89
  ':checked': { default: '14px 0', ':dir(rtl)': '-14px 0' }
98
90
  },
99
91
  // While pressed, the thumb stretches towards where it is about to go
100
- scale: { default: null, ':active': { default: null, [MOTION]: '1.2 1' } },
92
+ scale: { default: null, ':active': { default: null, [media.motion]: '1.2 1' } },
101
93
  transformOrigin: {
102
94
  default: 'left center',
103
95
  ':dir(rtl)': 'right center',
104
96
  ':checked': { default: 'right center', ':dir(rtl)': 'left center' }
105
97
  },
106
- borderRadius: radius.full,
98
+ borderRadius: radius.pill,
107
99
  backgroundColor: {
108
- default: '#fff',
109
- ':checked': colors.onIthil,
110
- [FORCED]: { default: 'ButtonText', ':checked': 'HighlightText' }
100
+ default: colors.thumb,
101
+ ':checked': colors.onAccent,
102
+ [media.forcedColors]: { default: 'ButtonText', ':checked': 'HighlightText' }
111
103
  },
112
- boxShadow: '0 1px 2px rgb(0 0 0 / 0.4)',
113
104
  transitionProperty: {
114
105
  default: 'background-color',
115
- [MOTION]: 'translate, scale, transform-origin, background-color'
106
+ [media.motion]: 'translate, scale, transform-origin, background-color'
116
107
  },
117
108
  transitionDuration: '200ms',
118
109
  transitionTimingFunction: motion.easeOut
@@ -0,0 +1,340 @@
1
+ <!--
2
+ A strip of tabs for what is open in a pane: threads, files, terminals. Tabs
3
+ can be closed and one can be added; the strip scrolls sideways when they do
4
+ not fit, and keeps the open one in view.
5
+
6
+ It names the tabs and says which is open. The panel under it is yours: give
7
+ it `role="tabpanel"` and the id passed as `controls`. For a fixed set of
8
+ sections that own their panel, use Tabs.
9
+ -->
10
+ <script lang="ts" module>
11
+ import * as stylex from '@stylexjs/stylex';
12
+ import { tick, type Snippet } from 'svelte';
13
+ import type { HTMLAttributes } from 'svelte/elements';
14
+ import Glyph from '../../internal/Glyph.svelte';
15
+ import { tabStripTabMarker } from '../../internal/markers.stylex.js';
16
+ import { roving } from '../../internal/roving.js';
17
+ import { attrs, type Sx } from '../../internal/sx.js';
18
+ import { colors, font, motion, radius } from '../../tokens.stylex.js';
19
+ import { media } from '../../media.stylex.js';
20
+
21
+ export type TabStripTab = {
22
+ id: string;
23
+ label: string;
24
+ /** Shown in place of the close button until the pointer is on the tab: unsaved, or live. */
25
+ mark?: 'unsaved' | 'live';
26
+ };
27
+
28
+ export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onclose'> & {
29
+ tabs: TabStripTab[];
30
+ /** The id of the open tab. Bindable. */
31
+ value?: string;
32
+ /** Names the strip: "Open threads". */
33
+ label: string;
34
+ /** The id of the panel the tabs show. */
35
+ controls?: string;
36
+ /** Called to close a tab. Without it the tabs cannot be closed. */
37
+ onclose?: (id: string) => void;
38
+ /** Called to add one. Without it there is no button to add. */
39
+ onadd?: () => void;
40
+ addLabel?: string;
41
+ /** The name of a tab's close button. */
42
+ closeLabel?: (tab: TabStripTab) => string;
43
+ /** Before a tab's label: an icon, or a StatusIndicator. */
44
+ leading?: Snippet<[TabStripTab]>;
45
+ sx?: Sx;
46
+ };
47
+
48
+ // One key for every hover, so the catalog can show it without a pointer
49
+ const HOVER = ':is(:hover, [data-preview~="hover"])';
50
+
51
+ const styles = stylex.create({
52
+ root: {
53
+ display: 'flex',
54
+ alignItems: 'center',
55
+ gap: '0.125rem',
56
+ minWidth: 0,
57
+ fontFamily: font.body
58
+ },
59
+ // The tabs scroll; the button to add one stays put at their end
60
+ list: {
61
+ display: 'flex',
62
+ alignItems: 'center',
63
+ gap: '0.125rem',
64
+ minWidth: 0,
65
+ overflowX: 'auto',
66
+ overscrollBehaviorX: 'contain',
67
+ scrollbarWidth: 'none',
68
+ // Room for a tab's focus ring, which the scroller would otherwise clip
69
+ padding: '2px',
70
+ margin: '-2px'
71
+ },
72
+ tab: {
73
+ position: 'relative',
74
+ display: 'flex',
75
+ alignItems: 'center',
76
+ flexShrink: 0,
77
+ maxWidth: '14rem',
78
+ borderRadius: radius.control,
79
+ backgroundColor: {
80
+ default: 'transparent',
81
+ [HOVER]: { default: null, [media.hover]: colors.fillHover }
82
+ },
83
+ color: {
84
+ default: colors.textMuted,
85
+ [HOVER]: { default: null, [media.hover]: colors.text }
86
+ },
87
+ transitionProperty: 'background-color, color',
88
+ transitionDuration: motion.fast,
89
+ transitionTimingFunction: 'ease'
90
+ },
91
+ // The open tab: a fill, as the open row of a list has
92
+ selected: {
93
+ backgroundColor: { default: colors.fillSelected, [HOVER]: colors.fillSelected },
94
+ color: colors.text
95
+ },
96
+ button: {
97
+ display: 'flex',
98
+ alignItems: 'center',
99
+ gap: '0.4375rem',
100
+ minWidth: 0,
101
+ height: '1.75rem',
102
+ margin: 0,
103
+ paddingBlock: 0,
104
+ paddingInlineStart: '0.625rem',
105
+ paddingInlineEnd: '0.625rem',
106
+ borderWidth: 0,
107
+ borderRadius: 'inherit',
108
+ backgroundColor: 'transparent',
109
+ color: 'inherit',
110
+ fontFamily: 'inherit',
111
+ fontSize: font.sizeMeta,
112
+ fontWeight: font.weightMedium,
113
+ lineHeight: 1,
114
+ cursor: 'pointer',
115
+ WebkitAppRegion: 'no-drag',
116
+ WebkitTapHighlightColor: 'transparent',
117
+ outlineStyle: 'solid',
118
+ outlineWidth: { default: 0, ':focus-visible': '2px' },
119
+ outlineColor: colors.focusRing,
120
+ outlineOffset: '0px'
121
+ },
122
+ // A tab that can be closed keeps room at its end for the button
123
+ closable: { paddingInlineEnd: '1.625rem' },
124
+ text: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
125
+ leading: { display: 'grid', flexShrink: 0 },
126
+ // Over the end of the tab. Shown for the open tab, and for any under the pointer or
127
+ // with focus inside; until then a mark may stand there.
128
+ end: {
129
+ position: 'absolute',
130
+ insetInlineEnd: '0.25rem',
131
+ top: '50%',
132
+ translate: '0 -50%',
133
+ display: 'grid',
134
+ placeItems: 'center',
135
+ width: '1.125rem',
136
+ height: '1.125rem'
137
+ },
138
+ close: {
139
+ display: 'grid',
140
+ placeItems: 'center',
141
+ width: '100%',
142
+ height: '100%',
143
+ margin: 0,
144
+ padding: 0,
145
+ borderWidth: 0,
146
+ borderRadius: radius.chip,
147
+ backgroundColor: {
148
+ default: 'transparent',
149
+ [HOVER]: { default: null, [media.hover]: colors.fillHover }
150
+ },
151
+ color: { default: colors.textSubtle, [HOVER]: { default: null, [media.hover]: colors.text } },
152
+ cursor: 'pointer',
153
+ WebkitAppRegion: 'no-drag',
154
+ // Hidden where a pointer can hover, until it does; always there where it cannot
155
+ opacity: {
156
+ default: 1,
157
+ [media.hover]: { default: 0, [stylex.when.ancestor(':hover', tabStripTabMarker)]: 1 },
158
+ [stylex.when.ancestor(':focus-within', tabStripTabMarker)]: 1
159
+ },
160
+ outlineStyle: 'solid',
161
+ outlineWidth: { default: 0, ':focus-visible': '2px' },
162
+ outlineColor: colors.focusRing,
163
+ outlineOffset: '0px'
164
+ },
165
+ closeShown: { opacity: 1 },
166
+ mark: {
167
+ gridArea: '1 / 1',
168
+ width: '0.375rem',
169
+ height: '0.375rem',
170
+ borderRadius: radius.pill,
171
+ backgroundColor: colors.textSubtle,
172
+ pointerEvents: 'none',
173
+ // Gives way to the close button
174
+ opacity: {
175
+ default: 0,
176
+ [media.hover]: { default: 1, [stylex.when.ancestor(':hover', tabStripTabMarker)]: 0 },
177
+ [stylex.when.ancestor(':focus-within', tabStripTabMarker)]: 0
178
+ },
179
+ forcedColorAdjust: 'none'
180
+ },
181
+ live: { backgroundColor: colors.accent },
182
+ closeCell: { gridArea: '1 / 1', display: 'grid', width: '100%', height: '100%' },
183
+ add: {
184
+ display: 'grid',
185
+ placeItems: 'center',
186
+ flexShrink: 0,
187
+ width: '1.75rem',
188
+ height: '1.75rem',
189
+ margin: 0,
190
+ padding: 0,
191
+ borderWidth: 0,
192
+ borderRadius: radius.control,
193
+ backgroundColor: {
194
+ default: 'transparent',
195
+ [HOVER]: { default: null, [media.hover]: colors.fillHover }
196
+ },
197
+ color: { default: colors.textMuted, [HOVER]: { default: null, [media.hover]: colors.text } },
198
+ cursor: 'pointer',
199
+ WebkitAppRegion: 'no-drag',
200
+ outlineStyle: 'solid',
201
+ outlineWidth: { default: 0, ':focus-visible': '2px' },
202
+ outlineColor: colors.focusRing,
203
+ outlineOffset: '0px'
204
+ },
205
+ hidden: {
206
+ position: 'absolute',
207
+ width: '1px',
208
+ height: '1px',
209
+ overflow: 'hidden',
210
+ clipPath: 'inset(50%)',
211
+ whiteSpace: 'nowrap'
212
+ }
213
+ });
214
+ </script>
215
+
216
+ <script lang="ts">
217
+ let {
218
+ tabs,
219
+ value = $bindable(),
220
+ label,
221
+ controls,
222
+ onclose,
223
+ onadd,
224
+ addLabel = 'New tab',
225
+ closeLabel = (tab) => `Close ${tab.label}`,
226
+ leading,
227
+ sx,
228
+ class: className,
229
+ ...rest
230
+ }: TabStripProps = $props();
231
+
232
+ let list = $state<HTMLElement | null>(null);
233
+
234
+ // The open tab stays in view as tabs come, go and are chosen
235
+ $effect(() => {
236
+ void value;
237
+ void tabs.length;
238
+ tick().then(() =>
239
+ list
240
+ ?.querySelector<HTMLElement>('[role="tab"][aria-selected="true"]')
241
+ ?.scrollIntoView({ block: 'nearest', inline: 'nearest' })
242
+ );
243
+ });
244
+
245
+ function close(tab: TabStripTab, viaKeyboard = false) {
246
+ if (!onclose) return;
247
+ const index = tabs.indexOf(tab);
248
+ onclose(tab.id);
249
+ // The tab that held focus is gone: its neighbour takes it
250
+ if (!viaKeyboard) return;
251
+ tick().then(() => {
252
+ const buttons = list?.querySelectorAll<HTMLElement>('[role="tab"]');
253
+ (buttons?.[Math.min(index, (buttons?.length ?? 1) - 1)] ?? null)?.focus();
254
+ });
255
+ }
256
+ </script>
257
+
258
+ <div data-slot="tab-strip" {...rest} {...attrs([styles.root, sx], className)}>
259
+ <div
260
+ bind:this={list}
261
+ role="tablist"
262
+ aria-label={label}
263
+ aria-orientation="horizontal"
264
+ {...stylex.attrs(styles.list)}
265
+ {@attach roving({ selector: '[role="tab"]', orientation: 'horizontal' })}
266
+ >
267
+ {#each tabs as tab (tab.id)}
268
+ {@const selected = tab.id === value}
269
+ <div
270
+ data-slot="tab-strip-tab"
271
+ {...stylex.attrs(styles.tab, selected && styles.selected, tabStripTabMarker)}
272
+ >
273
+ <button
274
+ type="button"
275
+ role="tab"
276
+ aria-selected={selected}
277
+ aria-controls={controls}
278
+ aria-current={selected ? 'true' : undefined}
279
+ title={tab.label}
280
+ {...stylex.attrs(styles.button, onclose && styles.closable)}
281
+ onclick={() => (value = tab.id)}
282
+ onauxclick={(event) => {
283
+ // The middle button closes, as it does in a browser
284
+ if (event.button === 1) close(tab);
285
+ }}
286
+ onkeydown={(event) => {
287
+ if (!onclose || (event.key !== 'Delete' && event.key !== 'Backspace')) return;
288
+ event.preventDefault();
289
+ close(tab, true);
290
+ }}
291
+ >
292
+ {#if leading}<span {...stylex.attrs(styles.leading)}>{@render leading(tab)}</span>{/if}
293
+ <span {...stylex.attrs(styles.text)}>{tab.label}</span>
294
+ {#if tab.mark}<span {...stylex.attrs(styles.hidden)}
295
+ >, {tab.mark === 'live' ? 'working' : 'unsaved'}</span
296
+ >{/if}
297
+ </button>
298
+ {#if onclose || tab.mark}
299
+ <span {...stylex.attrs(styles.end)}>
300
+ {#if tab.mark}
301
+ <span
302
+ aria-hidden="true"
303
+ {...stylex.attrs(styles.mark, tab.mark === 'live' && styles.live)}
304
+ ></span>
305
+ {/if}
306
+ {#if onclose}
307
+ <span {...stylex.attrs(styles.closeCell)}>
308
+ <button
309
+ type="button"
310
+ tabindex="-1"
311
+ aria-label={closeLabel(tab)}
312
+ {...stylex.attrs(styles.close, selected && !tab.mark && styles.closeShown)}
313
+ onclick={() => close(tab)}
314
+ >
315
+ <Glyph name="close" size={12} />
316
+ </button>
317
+ </span>
318
+ {/if}
319
+ </span>
320
+ {/if}
321
+ </div>
322
+ {/each}
323
+ </div>
324
+ {#if onadd}
325
+ <button type="button" aria-label={addLabel} {...stylex.attrs(styles.add)} onclick={onadd}>
326
+ <svg
327
+ width="14"
328
+ height="14"
329
+ viewBox="0 0 16 16"
330
+ fill="none"
331
+ stroke="currentColor"
332
+ stroke-width="1.5"
333
+ stroke-linecap="round"
334
+ aria-hidden="true"
335
+ >
336
+ <path d="M8 3.5v9M3.5 8h9" />
337
+ </svg>
338
+ </button>
339
+ {/if}
340
+ </div>
@@ -0,0 +1,31 @@
1
+ import { type Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type TabStripTab = {
5
+ id: string;
6
+ label: string;
7
+ /** Shown in place of the close button until the pointer is on the tab: unsaved, or live. */
8
+ mark?: 'unsaved' | 'live';
9
+ };
10
+ export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onclose'> & {
11
+ tabs: TabStripTab[];
12
+ /** The id of the open tab. Bindable. */
13
+ value?: string;
14
+ /** Names the strip: "Open threads". */
15
+ label: string;
16
+ /** The id of the panel the tabs show. */
17
+ controls?: string;
18
+ /** Called to close a tab. Without it the tabs cannot be closed. */
19
+ onclose?: (id: string) => void;
20
+ /** Called to add one. Without it there is no button to add. */
21
+ onadd?: () => void;
22
+ addLabel?: string;
23
+ /** The name of a tab's close button. */
24
+ closeLabel?: (tab: TabStripTab) => string;
25
+ /** Before a tab's label: an icon, or a StatusIndicator. */
26
+ leading?: Snippet<[TabStripTab]>;
27
+ sx?: Sx;
28
+ };
29
+ declare const TabStrip: import("svelte").Component<TabStripProps, {}, "value">;
30
+ type TabStrip = ReturnType<typeof TabStrip>;
31
+ export default TabStrip;
@@ -4,6 +4,7 @@
4
4
  import type { HTMLAttributes } from 'svelte/elements';
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
 
8
9
  export type TabItem = { value: string; label: string; count?: number; disabled?: boolean };
9
10
 
@@ -14,14 +15,14 @@
14
15
  /** Accessible name for the row of tabs. */
15
16
  label: string;
16
17
  sx?: Sx;
18
+ /** Styles for the row of tabs: its height and padding, to line it up with what is beside it. */
19
+ listSx?: Sx;
20
+ /** Styles for the panel under the tabs. */
21
+ panelSx?: Sx;
17
22
  /** The panel for the selected tab. It receives the selected value. */
18
23
  children?: Snippet<[string]>;
19
24
  };
20
25
 
21
- // StyleX needs these in the same file to evaluate them at build time
22
- const HOVER = '@media (hover: hover) and (pointer: fine)';
23
- const FORCED = '@media (forced-colors: active)';
24
-
25
26
  const styles = stylex.create({
26
27
  root: {
27
28
  minWidth: 0,
@@ -33,7 +34,7 @@
33
34
  gap: '1.25rem',
34
35
  borderBottomWidth: '1px',
35
36
  borderBottomStyle: 'solid',
36
- borderBottomColor: colors.line
37
+ borderBottomColor: colors.border
37
38
  },
38
39
  tab: {
39
40
  position: 'relative',
@@ -42,14 +43,14 @@
42
43
  margin: 0,
43
44
  padding: 0,
44
45
  borderWidth: 0,
45
- borderRadius: radius.xs,
46
+ borderRadius: radius.chip,
46
47
  backgroundColor: 'transparent',
47
48
  color: {
48
49
  default: colors.textMuted,
49
- ':hover': { default: null, [HOVER]: colors.text }
50
+ ':hover': { default: null, [media.hover]: colors.text }
50
51
  },
51
52
  fontFamily: 'inherit',
52
- fontSize: font.sizeMd,
53
+ fontSize: font.sizeBody,
53
54
  fontWeight: font.weightMedium,
54
55
  lineHeight: 1,
55
56
  whiteSpace: 'nowrap',
@@ -74,16 +75,14 @@
74
75
  bottom: '-1px',
75
76
  height: '2px',
76
77
  borderRadius: '2px',
77
- backgroundColor: { default: colors.ithil, [FORCED]: 'Highlight' },
78
- boxShadow: `0 0 8px ${colors.glow}`,
78
+ backgroundColor: { default: colors.accent, [media.forcedColors]: 'Highlight' },
79
79
  forcedColorAdjust: 'none'
80
80
  }
81
81
  },
82
82
  count: {
83
83
  marginInlineStart: '0.375rem',
84
84
  color: colors.textSubtle,
85
- fontFamily: font.mono,
86
- fontSize: font.sizeXs,
85
+ fontSize: font.sizeCaption,
87
86
  fontVariantNumeric: 'tabular-nums'
88
87
  },
89
88
  panel: {
@@ -102,6 +101,8 @@
102
101
  value = $bindable(),
103
102
  label,
104
103
  sx,
104
+ listSx,
105
+ panelSx,
105
106
  class: className,
106
107
  children,
107
108
  ...rest
@@ -134,7 +135,7 @@
134
135
  role="tablist"
135
136
  aria-label={label}
136
137
  {onkeydown}
137
- {...stylex.attrs(styles.list)}
138
+ {...attrs([styles.list, listSx])}
138
139
  >
139
140
  {#each tabs as tab (tab.value)}
140
141
  {@const active = tab.value === selected}
@@ -162,7 +163,7 @@
162
163
  id="{uid}-panel"
163
164
  aria-labelledby="{uid}-tab-{selected}"
164
165
  tabindex="0"
165
- {...stylex.attrs(styles.panel)}
166
+ {...attrs([styles.panel, panelSx])}
166
167
  >
167
168
  {@render children(selected)}
168
169
  </div>
@@ -14,6 +14,10 @@ export type TabsProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
14
14
  /** Accessible name for the row of tabs. */
15
15
  label: string;
16
16
  sx?: Sx;
17
+ /** Styles for the row of tabs: its height and padding, to line it up with what is beside it. */
18
+ listSx?: Sx;
19
+ /** Styles for the panel under the tabs. */
20
+ panelSx?: Sx;
17
21
  /** The panel for the selected tab. It receives the selected value. */
18
22
  children?: Snippet<[string]>;
19
23
  };