@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
@@ -68,9 +68,8 @@
68
68
  position: 'relative',
69
69
  flexGrow: 1,
70
70
  overflow: 'hidden',
71
- borderRadius: radius.full,
72
- backgroundColor: colors.well,
73
- boxShadow: `inset 0 0 0 1px ${colors.lineStrong}`,
71
+ borderRadius: radius.pill,
72
+ backgroundColor: colors.fillSunken,
74
73
  outlineStyle: 'solid',
75
74
  outlineWidth: '1px',
76
75
  outlineColor: 'transparent',
@@ -78,10 +77,12 @@
78
77
  },
79
78
  trackHorizontal: { height: '0.25rem' },
80
79
  trackVertical: { width: '0.25rem' },
81
- // How far along: lit with ithildin, as progress is
80
+ // How far along: lit with the accent, as progress is
82
81
  range: {
82
+ backgroundColor: colors.accent,
83
+ // Forced colours drop a background colour, not an image
83
84
  backgroundImage: {
84
- default: `linear-gradient(90deg, ${colors.ithilStrong}, ${colors.ithil})`,
85
+ default: 'none',
85
86
  [media.forcedColors]: 'linear-gradient(Highlight, Highlight)'
86
87
  },
87
88
  forcedColorAdjust: 'none'
@@ -95,13 +96,13 @@
95
96
  display: 'block',
96
97
  width: '1rem',
97
98
  height: '1rem',
98
- borderRadius: radius.full,
99
- backgroundColor: { default: '#fff', [media.forcedColors]: 'ButtonText' },
99
+ borderRadius: radius.pill,
100
+ backgroundColor: { default: colors.thumb, [media.forcedColors]: 'ButtonText' },
100
101
  boxShadow: {
101
- default: `0 0 0 1px ${colors.lineStrong}, 0 1px 3px rgb(0 0 0 / 0.3)`,
102
+ default: `0 0 0 1px ${colors.borderStrong}`,
102
103
  ':hover': {
103
104
  default: null,
104
- [media.hover]: `0 0 0 1px ${colors.edgeHover}, 0 1px 3px rgb(0 0 0 / 0.3)`
105
+ [media.hover]: `0 0 0 1px ${colors.borderControlHover}`
105
106
  }
106
107
  },
107
108
  forcedColorAdjust: 'none',
@@ -122,7 +123,7 @@
122
123
  content: '""',
123
124
  position: 'absolute',
124
125
  inset: '-0.75rem',
125
- borderRadius: radius.full
126
+ borderRadius: radius.pill
126
127
  }
127
128
  }
128
129
  });
@@ -1,8 +1,9 @@
1
1
  <script lang="ts" module>
2
2
  import * as stylex from '@stylexjs/stylex';
3
3
  import type { SVGAttributes } from 'svelte/elements';
4
- import { loop } from '../../internal/loop.js';
4
+ import { shared } from '../../internal/shared.js';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
+ import { whileVisible } from '../../internal/visible.js';
6
7
 
7
8
  export type SpinnerProps = Omit<SVGAttributes<SVGSVGElement>, 'children'> & {
8
9
  /** Width and height in pixels, or any CSS length. Defaults to `1em`. */
@@ -12,14 +13,6 @@
12
13
  sx?: Sx;
13
14
  };
14
15
 
15
- // Turns on Narvi's shared clock rather than a CSS animation, which would repaint
16
- // at the display's rate. Slower for people who have asked for less motion.
17
- const spin = loop(
18
- (reduced) => (reduced ? 2400 : 700),
19
- (element, { progress }) => (element.style.rotate = `${progress}turn`),
20
- (element) => (element.style.rotate = '')
21
- );
22
-
23
16
  const styles = stylex.create({
24
17
  base: {
25
18
  display: 'inline-block',
@@ -44,8 +37,8 @@
44
37
  aria-label={label ?? undefined}
45
38
  aria-hidden={label ? undefined : true}
46
39
  {...rest}
47
- {...attrs([styles.base, sx], className)}
48
- {@attach spin}
40
+ {...attrs([styles.base, shared.spin, sx], className)}
41
+ {@attach whileVisible}
49
42
  >
50
43
  <circle cx="8" cy="8" r="6.25" stroke="currentColor" stroke-width="1.5" opacity="0.25" />
51
44
  <path
@@ -36,7 +36,7 @@
36
36
  const styles = stylex.create({
37
37
  root: { display: 'inline-grid', placeItems: 'center', flexShrink: 0, verticalAlign: 'middle' },
38
38
  idle: { color: colors.textSubtle },
39
- working: { color: colors.ithil },
39
+ working: { color: colors.accent },
40
40
  waiting: { color: colors.warning },
41
41
  done: { color: colors.success },
42
42
  failed: { color: colors.danger },
@@ -37,18 +37,18 @@
37
37
  margin: 0,
38
38
  paddingInline: '0.75rem',
39
39
  borderWidth: 0,
40
- borderRadius: `calc(${radius.xl} * 4 / 3)`,
40
+ borderRadius: `calc(${radius.card} * 4 / 3)`,
41
41
  backgroundColor: {
42
- default: colors.surface,
43
- ':hover': { default: null, [media.hover]: colors.hover }
42
+ default: 'transparent',
43
+ ':hover': { default: null, [media.hover]: colors.fillHover }
44
44
  },
45
- boxShadow: `inset 0 0 0 1px ${colors.line}`,
45
+ boxShadow: `inset 0 0 0 1px ${colors.border}`,
46
46
  color: {
47
47
  default: colors.textMuted,
48
48
  ':hover': { default: null, [media.hover]: colors.text }
49
49
  },
50
50
  fontFamily: 'inherit',
51
- fontSize: font.sizeSm,
51
+ fontSize: font.sizeMeta,
52
52
  fontWeight: font.weightMedium,
53
53
  lineHeight: 1,
54
54
  whiteSpace: 'nowrap',
@@ -25,7 +25,7 @@
25
25
  gap: '0.625rem',
26
26
  color: colors.text,
27
27
  fontFamily: font.body,
28
- fontSize: font.sizeMd,
28
+ fontSize: font.sizeBody,
29
29
  lineHeight: '1.25rem',
30
30
  cursor: 'pointer',
31
31
  WebkitTapHighlightColor: 'transparent'
@@ -37,7 +37,7 @@
37
37
  description: {
38
38
  display: 'block',
39
39
  color: colors.textSubtle,
40
- fontSize: font.sizeXs,
40
+ fontSize: font.sizeCaption,
41
41
  lineHeight: font.leadingSnug
42
42
  },
43
43
  input: {
@@ -49,21 +49,17 @@
49
49
  margin: 0,
50
50
  marginBlock: '1px',
51
51
  borderWidth: 0,
52
- borderRadius: radius.full,
52
+ borderRadius: radius.pill,
53
53
  backgroundColor: {
54
- default: colors.edge,
55
- ':hover': { default: null, [media.hover]: colors.edgeHover },
54
+ default: colors.borderControl,
55
+ ':hover': { default: null, [media.hover]: colors.borderControlHover },
56
56
  [media.forcedColors]: { default: 'Canvas', ':checked': 'Highlight' }
57
57
  },
58
58
  backgroundImage: {
59
59
  default: 'none',
60
- ':checked': `linear-gradient(180deg, ${colors.ithil}, ${colors.ithilStrong})`,
60
+ ':checked': `linear-gradient(${colors.accent}, ${colors.accent})`,
61
61
  [media.forcedColors]: 'none'
62
62
  },
63
- boxShadow: {
64
- default: `inset 0 1px 2px ${colors.shade}`,
65
- ':checked': `inset 0 1px 0 rgb(255 255 255 / 0.4), 0 0 8px ${colors.glow}`
66
- },
67
63
  forcedColorAdjust: 'none',
68
64
  appearance: 'none',
69
65
  cursor: { default: 'pointer', ':disabled': 'not-allowed' },
@@ -99,13 +95,12 @@
99
95
  ':dir(rtl)': 'right center',
100
96
  ':checked': { default: 'right center', ':dir(rtl)': 'left center' }
101
97
  },
102
- borderRadius: radius.full,
98
+ borderRadius: radius.pill,
103
99
  backgroundColor: {
104
- default: '#fff',
105
- ':checked': colors.onIthil,
100
+ default: colors.thumb,
101
+ ':checked': colors.onAccent,
106
102
  [media.forcedColors]: { default: 'ButtonText', ':checked': 'HighlightText' }
107
103
  },
108
- boxShadow: '0 1px 2px rgb(0 0 0 / 0.4)',
109
104
  transitionProperty: {
110
105
  default: 'background-color',
111
106
  [media.motion]: 'translate, scale, transform-origin, background-color'
@@ -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;
@@ -15,6 +15,10 @@
15
15
  /** Accessible name for the row of tabs. */
16
16
  label: string;
17
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;
18
22
  /** The panel for the selected tab. It receives the selected value. */
19
23
  children?: Snippet<[string]>;
20
24
  };
@@ -30,7 +34,7 @@
30
34
  gap: '1.25rem',
31
35
  borderBottomWidth: '1px',
32
36
  borderBottomStyle: 'solid',
33
- borderBottomColor: colors.line
37
+ borderBottomColor: colors.border
34
38
  },
35
39
  tab: {
36
40
  position: 'relative',
@@ -39,14 +43,14 @@
39
43
  margin: 0,
40
44
  padding: 0,
41
45
  borderWidth: 0,
42
- borderRadius: radius.xs,
46
+ borderRadius: radius.chip,
43
47
  backgroundColor: 'transparent',
44
48
  color: {
45
49
  default: colors.textMuted,
46
50
  ':hover': { default: null, [media.hover]: colors.text }
47
51
  },
48
52
  fontFamily: 'inherit',
49
- fontSize: font.sizeMd,
53
+ fontSize: font.sizeBody,
50
54
  fontWeight: font.weightMedium,
51
55
  lineHeight: 1,
52
56
  whiteSpace: 'nowrap',
@@ -71,16 +75,14 @@
71
75
  bottom: '-1px',
72
76
  height: '2px',
73
77
  borderRadius: '2px',
74
- backgroundColor: { default: colors.ithil, [media.forcedColors]: 'Highlight' },
75
- boxShadow: `0 0 8px ${colors.glow}`,
78
+ backgroundColor: { default: colors.accent, [media.forcedColors]: 'Highlight' },
76
79
  forcedColorAdjust: 'none'
77
80
  }
78
81
  },
79
82
  count: {
80
83
  marginInlineStart: '0.375rem',
81
84
  color: colors.textSubtle,
82
- fontFamily: font.mono,
83
- fontSize: font.sizeXs,
85
+ fontSize: font.sizeCaption,
84
86
  fontVariantNumeric: 'tabular-nums'
85
87
  },
86
88
  panel: {
@@ -99,6 +101,8 @@
99
101
  value = $bindable(),
100
102
  label,
101
103
  sx,
104
+ listSx,
105
+ panelSx,
102
106
  class: className,
103
107
  children,
104
108
  ...rest
@@ -131,7 +135,7 @@
131
135
  role="tablist"
132
136
  aria-label={label}
133
137
  {onkeydown}
134
- {...stylex.attrs(styles.list)}
138
+ {...attrs([styles.list, listSx])}
135
139
  >
136
140
  {#each tabs as tab (tab.value)}
137
141
  {@const active = tab.value === selected}
@@ -159,7 +163,7 @@
159
163
  id="{uid}-panel"
160
164
  aria-labelledby="{uid}-tab-{selected}"
161
165
  tabindex="0"
162
- {...stylex.attrs(styles.panel)}
166
+ {...attrs([styles.panel, panelSx])}
163
167
  >
164
168
  {@render children(selected)}
165
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
  };