@diegopluna/narvi 0.3.1 → 0.3.2

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 (40) hide show
  1. package/dist/components/app-shell/AppShellMain.svelte +5 -1
  2. package/dist/components/badge/Badge.svelte +16 -1
  3. package/dist/components/badge/Badge.svelte.d.ts +3 -0
  4. package/dist/components/button/Button.svelte +46 -7
  5. package/dist/components/hover-card/HoverCardContent.svelte +1 -1
  6. package/dist/components/menu/ContextMenuTrigger.svelte +14 -2
  7. package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +10 -0
  8. package/dist/components/menu/MenuCheckboxItem.svelte +8 -2
  9. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +6 -0
  10. package/dist/components/menu/MenuGroup.svelte +16 -0
  11. package/dist/components/menu/MenuGroup.svelte.d.ts +6 -0
  12. package/dist/components/menu/MenuLabel.svelte +22 -8
  13. package/dist/components/menu/MenuRadioGroup.svelte +16 -0
  14. package/dist/components/menu/MenuRadioGroup.svelte.d.ts +6 -0
  15. package/dist/components/menu/group.d.ts +2 -0
  16. package/dist/components/menu/group.js +9 -0
  17. package/dist/components/menu/index.d.ts +4 -2
  18. package/dist/components/menu/index.js +2 -2
  19. package/dist/components/sidebar/SidebarContent.svelte +59 -13
  20. package/dist/components/sidebar/SidebarContent.svelte.d.ts +6 -0
  21. package/dist/components/sidebar/SidebarFolder.svelte +29 -2
  22. package/dist/components/sidebar/SidebarGroup.svelte +50 -7
  23. package/dist/components/sidebar/SidebarGroup.svelte.d.ts +10 -1
  24. package/dist/components/sidebar/SidebarItem.svelte +136 -21
  25. package/dist/components/sidebar/SidebarItem.svelte.d.ts +22 -2
  26. package/dist/components/sidebar/SidebarSwitcher.svelte +18 -2
  27. package/dist/components/sidebar/SidebarSwitcher.svelte.d.ts +2 -0
  28. package/dist/components/sidebar/fold.d.ts +12 -0
  29. package/dist/components/sidebar/fold.js +8 -0
  30. package/dist/components/status-indicator/StatusDot.svelte +90 -0
  31. package/dist/components/status-indicator/StatusDot.svelte.d.ts +18 -0
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.js +1 -0
  34. package/package.json +1 -1
  35. package/skills/building-ui/SKILL.md +33 -6
  36. package/skills/building-ui/references/components.md +7 -6
  37. package/skills/markdown/SKILL.md +1 -1
  38. package/skills/setup/SKILL.md +1 -1
  39. package/skills/styling/SKILL.md +1 -1
  40. package/skills/theming/SKILL.md +1 -1
@@ -19,6 +19,7 @@
19
19
  flexGrow: 1,
20
20
  minWidth: 0,
21
21
  minHeight: 0,
22
+ // Focused from a skip link, it is the page that is reached, not a control
22
23
  outlineStyle: 'none'
23
24
  }
24
25
  });
@@ -28,6 +29,9 @@
28
29
  let { sx, class: className, children, ...rest }: AppShellMainProps = $props();
29
30
  </script>
30
31
 
31
- <main tabindex="-1" data-slot="app-shell-main" {...rest} {...attrs([styles.main, sx], className)}>
32
+ <!-- Not focusable by default: with `tabindex="-1"` a click on plain text in the page would move
33
+ focus to the whole of it, away from a panel that keeps its own, such as a find bar. Pass a
34
+ `tabindex` to make it the target of a skip link. -->
35
+ <main data-slot="app-shell-main" {...rest} {...attrs([styles.main, sx], className)}>
32
36
  {@render children?.()}
33
37
  </main>
@@ -5,6 +5,7 @@
5
5
  import { shared } from '../../internal/shared.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
7
  import { colors, font, radius } from '../../tokens.stylex.js';
8
+ import '../../internal/icons.css';
8
9
 
9
10
  export type BadgeTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
10
11
 
@@ -16,12 +17,16 @@
16
17
  * text colour, which holds its contrast on a badge's own surface.
17
18
  */
18
19
  plain?: boolean | undefined;
20
+ /** `sm` is as tall as a sidebar row's line, 18px, to sit in a row without growing it. */
21
+ size?: 'sm' | 'md' | undefined;
19
22
  sx?: Sx | undefined;
20
23
  children?: Snippet | undefined;
21
24
  };
22
25
 
23
26
  const styles = stylex.create({
24
27
  base: {
28
+ // An icon put in it, beside the words, is 12px (`internal/icons.css`)
29
+ '--narvi-icon-size': '0.75rem',
25
30
  display: 'inline-flex',
26
31
  alignItems: 'center',
27
32
  gap: '0.375rem',
@@ -47,6 +52,7 @@
47
52
  borderRadius: radius.pill,
48
53
  forcedColorAdjust: 'none'
49
54
  },
55
+ sm: { gap: '0.25rem', minHeight: '1.125rem', paddingInline: '0.375rem' },
50
56
  lit: { color: colors.text }
51
57
  });
52
58
 
@@ -72,6 +78,7 @@
72
78
  let {
73
79
  tone = 'neutral',
74
80
  plain = false,
81
+ size = 'md',
75
82
  sx,
76
83
  class: className,
77
84
  children,
@@ -80,9 +87,17 @@
80
87
  </script>
81
88
 
82
89
  <span
90
+ data-icons
83
91
  {...rest}
84
92
  {...attrs(
85
- [styles.base, shared.edged, tone === 'accent' && styles.lit, plain && words[tone], sx],
93
+ [
94
+ styles.base,
95
+ size === 'sm' && styles.sm,
96
+ shared.edged,
97
+ tone === 'accent' && styles.lit,
98
+ plain && words[tone],
99
+ sx
100
+ ],
86
101
  className
87
102
  )}
88
103
  >
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
+ import '../../internal/icons.css';
4
5
  export type BadgeTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
5
6
  export type BadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
6
7
  /** Colour of the dot. The words stay in the text colour, so they are always readable. */
@@ -10,6 +11,8 @@ export type BadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
10
11
  * text colour, which holds its contrast on a badge's own surface.
11
12
  */
12
13
  plain?: boolean | undefined;
14
+ /** `sm` is as tall as a sidebar row's line, 18px, to sit in a row without growing it. */
15
+ size?: 'sm' | 'md' | undefined;
13
16
  sx?: Sx | undefined;
14
17
  children?: Snippet | undefined;
15
18
  };
@@ -138,11 +138,49 @@
138
138
  borderRadius: radius.panel,
139
139
  fontSize: font.sizeReading
140
140
  },
141
- iconMicro: { width: '1.25rem', paddingInline: 0 },
142
- iconXs: { width: '1.5rem', paddingInline: 0 },
143
- iconSm: { width: '1.75rem', paddingInline: 0 },
144
- iconMd: { width: '2rem', paddingInline: 0 },
145
- iconLg: { width: '2.5rem', paddingInline: 0 },
141
+ // Square. Last in a slot that lines its controls up by their marks (one that sets
142
+ // `--narvi-icon-flush: 1`, as a sidebar group's actions do), the button reaches out by the
143
+ // room around its icon, so the icon, not the box, ends on the line.
144
+ iconMicro: {
145
+ width: '1.25rem',
146
+ paddingInline: 0,
147
+ marginInlineEnd: {
148
+ default: null,
149
+ ':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.75rem - 1.25rem) / 2)'
150
+ }
151
+ },
152
+ iconXs: {
153
+ width: '1.5rem',
154
+ paddingInline: 0,
155
+ marginInlineEnd: {
156
+ default: null,
157
+ ':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.875rem - 1.5rem) / 2)'
158
+ }
159
+ },
160
+ iconSm: {
161
+ width: '1.75rem',
162
+ paddingInline: 0,
163
+ marginInlineEnd: {
164
+ default: null,
165
+ ':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.875rem - 1.75rem) / 2)'
166
+ }
167
+ },
168
+ iconMd: {
169
+ width: '2rem',
170
+ paddingInline: 0,
171
+ marginInlineEnd: {
172
+ default: null,
173
+ ':last-child': 'calc(var(--narvi-icon-flush, 0) * (1rem - 2rem) / 2)'
174
+ }
175
+ },
176
+ iconLg: {
177
+ width: '2.5rem',
178
+ paddingInline: 0,
179
+ marginInlineEnd: {
180
+ default: null,
181
+ ':last-child': 'calc(var(--narvi-icon-flush, 0) * (1.125rem - 2.5rem) / 2)'
182
+ }
183
+ },
146
184
 
147
185
  pill: { borderRadius: radius.pill },
148
186
 
@@ -382,7 +420,8 @@
382
420
  }
383
421
  const contentClass = classes(styles.content);
384
422
 
385
- // The spinner beside a loading label, as large as an icon in a button of that size
423
+ // The spinner, beside a loading label or in place of the content, as large as an icon in a
424
+ // button of that size
386
425
  const SPINNER = { micro: 12, xs: 14, sm: 14, md: 16, lg: 18 } as const;
387
426
  </script>
388
427
 
@@ -437,7 +476,7 @@
437
476
  {/if}
438
477
  {#if loading && !loadingLabel}
439
478
  <span {...stylex.attrs(styles.spinner)}>
440
- <Spinner size={16} label="Loading" />
479
+ <Spinner size={SPINNER[size]} label="Loading" />
441
480
  </span>
442
481
  {/if}
443
482
  {/snippet}
@@ -44,7 +44,7 @@
44
44
  {sideOffset}
45
45
  {collisionPadding}
46
46
  {align}
47
- data-slot="hover-card"
47
+ data-slot="hover-card-content"
48
48
  {...rest}
49
49
  {...attrs([layer.surface, styles.card, sx], className)}
50
50
  >
@@ -9,19 +9,31 @@
9
9
  sx?: Sx | undefined;
10
10
  /** The region a right-click opens the menu over. */
11
11
  children?: Snippet | undefined;
12
+ /**
13
+ * Opens the menu from Shift+F10 and the Menu key at the focused element. Pass `false`
14
+ * where the list's own keys already open it, or it would open twice.
15
+ */
16
+ menuKey?: boolean | undefined;
12
17
  }
13
18
  >;
14
19
  </script>
15
20
 
16
21
  <script lang="ts">
17
- let { sx, class: className, children, onkeydown, ...rest }: ContextMenuTriggerProps = $props();
22
+ let {
23
+ sx,
24
+ class: className,
25
+ children,
26
+ onkeydown,
27
+ menuKey = true,
28
+ ...rest
29
+ }: ContextMenuTriggerProps = $props();
18
30
 
19
31
  // bits-ui opens a context menu only on the `contextmenu` event. Shift+F10 and
20
32
  // the Menu key send one on Windows and Linux, but a Mac has neither, so the
21
33
  // event is sent here, at the focused element, from the keyboard.
22
34
  function openFromKeyboard(event: KeyboardEvent & { currentTarget: HTMLDivElement }) {
23
35
  onkeydown?.(event);
24
- if (event.defaultPrevented) return;
36
+ if (!menuKey || event.defaultPrevented) return;
25
37
  if (!(event.key === 'ContextMenu' || (event.key === 'F10' && event.shiftKey))) return;
26
38
  event.preventDefault();
27
39
  const target = (document.activeElement as HTMLElement | null) ?? event.currentTarget;
@@ -6,11 +6,21 @@ export type ContextMenuTriggerProps = Loose<Omit<ContextMenu.TriggerProps, 'chil
6
6
  sx?: Sx | undefined;
7
7
  /** The region a right-click opens the menu over. */
8
8
  children?: Snippet | undefined;
9
+ /**
10
+ * Opens the menu from Shift+F10 and the Menu key at the focused element. Pass `false`
11
+ * where the list's own keys already open it, or it would open twice.
12
+ */
13
+ menuKey?: boolean | undefined;
9
14
  }>;
10
15
  declare const ContextMenuTrigger: import("svelte").Component<Loose<Omit<ContextMenu.TriggerProps, "children"> & {
11
16
  sx?: Sx | undefined;
12
17
  /** The region a right-click opens the menu over. */
13
18
  children?: Snippet | undefined;
19
+ /**
20
+ * Opens the menu from Shift+F10 and the Menu key at the focused element. Pass `false`
21
+ * where the list's own keys already open it, or it would open twice.
22
+ */
23
+ menuKey?: boolean | undefined;
14
24
  }>, {}, "">;
15
25
  type ContextMenuTrigger = ReturnType<typeof ContextMenuTrigger>;
16
26
  export default ContextMenuTrigger;
@@ -9,7 +9,10 @@
9
9
 
10
10
  export type MenuCheckboxItemProps = Loose<
11
11
  Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
12
+ /** The keys that do the same, shown at the end, such as "⌘D". */
12
13
  shortcut?: string | undefined;
14
+ /** A 16px icon before the label, after the tick. */
15
+ icon?: Snippet | undefined;
13
16
  sx?: Sx | undefined;
14
17
  children?: Snippet | undefined;
15
18
  }
@@ -20,7 +23,10 @@
20
23
  let {
21
24
  checked = $bindable(false),
22
25
  shortcut,
23
- closeOnSelect = false,
26
+ icon,
27
+ // Picking it closes the menu, as a radio item's does: one left open takes the next click
28
+ // that was meant for the page. Pass `false` for a menu of settings set several at a time.
29
+ closeOnSelect = true,
24
30
  sx,
25
31
  class: className,
26
32
  children: label,
@@ -28,7 +34,6 @@
28
34
  }: MenuCheckboxItemProps = $props();
29
35
  </script>
30
36
 
31
- <!-- Stays open by default, so several can be set in one visit -->
32
37
  <DropdownMenu.CheckboxItem
33
38
  bind:checked
34
39
  {closeOnSelect}
@@ -40,6 +45,7 @@
40
45
  <span {...stylex.attrs(layer.icon)}>
41
46
  {#if checked}<Glyph name="check" stroke={1.75} />{/if}
42
47
  </span>
48
+ {#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
43
49
  <span {...stylex.attrs(layer.label)}>{@render label?.()}</span>
44
50
  {#if shortcut}<span {...stylex.attrs(layer.trailing)}>{shortcut}</span>{/if}
45
51
  {/snippet}
@@ -3,12 +3,18 @@ import { DropdownMenu } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type MenuCheckboxItemProps = Loose<Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
6
+ /** The keys that do the same, shown at the end, such as "⌘D". */
6
7
  shortcut?: string | undefined;
8
+ /** A 16px icon before the label, after the tick. */
9
+ icon?: Snippet | undefined;
7
10
  sx?: Sx | undefined;
8
11
  children?: Snippet | undefined;
9
12
  }>;
10
13
  declare const MenuCheckboxItem: import("svelte").Component<Loose<Omit<DropdownMenu.CheckboxItemProps, "children" | "child"> & {
14
+ /** The keys that do the same, shown at the end, such as "⌘D". */
11
15
  shortcut?: string | undefined;
16
+ /** A 16px icon before the label, after the tick. */
17
+ icon?: Snippet | undefined;
12
18
  sx?: Sx | undefined;
13
19
  children?: Snippet | undefined;
14
20
  }>, {}, "checked">;
@@ -0,0 +1,16 @@
1
+ <script lang="ts" module>
2
+ import type { Loose } from '../../internal/loose.js';
3
+ import { DropdownMenu } from 'bits-ui';
4
+ import { markMenuGroup } from './group.js';
5
+
6
+ export type MenuGroupProps = Loose<DropdownMenu.GroupProps>;
7
+ </script>
8
+
9
+ <script lang="ts">
10
+ let { children, ...rest }: MenuGroupProps = $props();
11
+
12
+ // A Menu.Label in it names it
13
+ markMenuGroup();
14
+ </script>
15
+
16
+ <DropdownMenu.Group {...rest}>{@render children?.()}</DropdownMenu.Group>
@@ -0,0 +1,6 @@
1
+ import type { Loose } from '../../internal/loose.js';
2
+ import { DropdownMenu } from 'bits-ui';
3
+ export type MenuGroupProps = Loose<DropdownMenu.GroupProps>;
4
+ declare const MenuGroup: import("svelte").Component<Loose<DropdownMenu.GroupProps>, {}, "">;
5
+ type MenuGroup = ReturnType<typeof MenuGroup>;
6
+ export default MenuGroup;
@@ -4,6 +4,7 @@
4
4
  import type { Snippet } from 'svelte';
5
5
  import { layer } from '../../internal/layer.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
+ import { inMenuGroup } from './group.js';
7
8
 
8
9
  export type MenuLabelProps = Loose<
9
10
  Omit<DropdownMenu.GroupHeadingProps, 'children' | 'child'> & {
@@ -15,13 +16,26 @@
15
16
 
16
17
  <script lang="ts">
17
18
  let { sx, class: className, children, ...rest }: MenuLabelProps = $props();
19
+
20
+ const grouped = inMenuGroup();
18
21
  </script>
19
22
 
20
- <!-- Names the Menu.Group it is placed in -->
21
- <DropdownMenu.GroupHeading
22
- data-slot="menu-label"
23
- {...rest}
24
- {...attrs([layer.heading, sx], className)}
25
- >
26
- {@render children?.()}
27
- </DropdownMenu.GroupHeading>
23
+ <!-- In a Menu.Group it names the group. On its own it is a heading only to the eye, with nothing
24
+ to name, so it is plain text there rather than an error. -->
25
+ {#if grouped}
26
+ <DropdownMenu.GroupHeading
27
+ data-slot="menu-label"
28
+ {...rest}
29
+ {...attrs([layer.heading, sx], className)}
30
+ >
31
+ {@render children?.()}
32
+ </DropdownMenu.GroupHeading>
33
+ {:else}
34
+ <div
35
+ data-slot="menu-label"
36
+ {...rest as Record<string, unknown>}
37
+ {...attrs([layer.heading, sx], className)}
38
+ >
39
+ {@render children?.()}
40
+ </div>
41
+ {/if}
@@ -0,0 +1,16 @@
1
+ <script lang="ts" module>
2
+ import type { Loose } from '../../internal/loose.js';
3
+ import { DropdownMenu } from 'bits-ui';
4
+ import { markMenuGroup } from './group.js';
5
+
6
+ export type MenuRadioGroupProps = Loose<DropdownMenu.RadioGroupProps>;
7
+ </script>
8
+
9
+ <script lang="ts">
10
+ let { value = $bindable(''), children, ...rest }: MenuRadioGroupProps = $props();
11
+
12
+ // A Menu.Label in it names it
13
+ markMenuGroup();
14
+ </script>
15
+
16
+ <DropdownMenu.RadioGroup bind:value {...rest}>{@render children?.()}</DropdownMenu.RadioGroup>
@@ -0,0 +1,6 @@
1
+ import type { Loose } from '../../internal/loose.js';
2
+ import { DropdownMenu } from 'bits-ui';
3
+ export type MenuRadioGroupProps = Loose<DropdownMenu.RadioGroupProps>;
4
+ declare const MenuRadioGroup: import("svelte").Component<Loose<DropdownMenu.RadioGroupProps>, {}, "value">;
5
+ type MenuRadioGroup = ReturnType<typeof MenuRadioGroup>;
6
+ export default MenuRadioGroup;
@@ -0,0 +1,2 @@
1
+ export declare function markMenuGroup(): void;
2
+ export declare function inMenuGroup(): boolean;
@@ -0,0 +1,9 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ // Whether a Menu.Label sits in a Menu.Group or Menu.RadioGroup, which bits-ui's heading needs
3
+ const KEY = Symbol('narvi.menu-group');
4
+ export function markMenuGroup() {
5
+ setContext(KEY, true);
6
+ }
7
+ export function inMenuGroup() {
8
+ return getContext(KEY) === true;
9
+ }
@@ -2,22 +2,24 @@ import { DropdownMenu } from 'bits-ui';
2
2
  import { type Loosened } from '../../internal/loose.js';
3
3
  import CheckboxItem from './MenuCheckboxItem.svelte';
4
4
  import Content from './MenuContent.svelte';
5
+ import Group from './MenuGroup.svelte';
5
6
  import Item from './MenuItem.svelte';
6
7
  import Label from './MenuLabel.svelte';
8
+ import RadioGroup from './MenuRadioGroup.svelte';
7
9
  import RadioItem from './MenuRadioItem.svelte';
8
10
  import Separator from './MenuSeparator.svelte';
9
11
  import SubContent from './MenuSubContent.svelte';
10
12
  import SubTrigger from './MenuSubTrigger.svelte';
11
13
  declare const Root: Loosened<typeof DropdownMenu.Root>;
12
14
  declare const Trigger: Loosened<typeof DropdownMenu.Trigger>;
13
- declare const Group: Loosened<typeof DropdownMenu.Group>;
14
- declare const RadioGroup: Loosened<typeof DropdownMenu.RadioGroup>;
15
15
  declare const Sub: Loosened<typeof DropdownMenu.Sub>;
16
16
  export { Root, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, Group, Label, Separator, Sub, SubTrigger, SubContent };
17
17
  export type { MenuCheckboxItemProps } from './MenuCheckboxItem.svelte';
18
18
  export type { MenuContentProps } from './MenuContent.svelte';
19
+ export type { MenuGroupProps } from './MenuGroup.svelte';
19
20
  export type { MenuItemProps } from './MenuItem.svelte';
20
21
  export type { MenuLabelProps } from './MenuLabel.svelte';
22
+ export type { MenuRadioGroupProps } from './MenuRadioGroup.svelte';
21
23
  export type { MenuRadioItemProps } from './MenuRadioItem.svelte';
22
24
  export type { MenuSeparatorProps } from './MenuSeparator.svelte';
23
25
  export type { MenuSubContentProps } from './MenuSubContent.svelte';
@@ -2,8 +2,10 @@ import { DropdownMenu } from 'bits-ui';
2
2
  import { loose } from '../../internal/loose.js';
3
3
  import CheckboxItem from './MenuCheckboxItem.svelte';
4
4
  import Content from './MenuContent.svelte';
5
+ import Group from './MenuGroup.svelte';
5
6
  import Item from './MenuItem.svelte';
6
7
  import Label from './MenuLabel.svelte';
8
+ import RadioGroup from './MenuRadioGroup.svelte';
7
9
  import RadioItem from './MenuRadioItem.svelte';
8
10
  import Separator from './MenuSeparator.svelte';
9
11
  import SubContent from './MenuSubContent.svelte';
@@ -13,7 +15,5 @@ import SubTrigger from './MenuSubTrigger.svelte';
13
15
  // this module's declarations (it leaves them out without a word on TS2883).
14
16
  const Root = loose(DropdownMenu.Root);
15
17
  const Trigger = loose(DropdownMenu.Trigger);
16
- const Group = loose(DropdownMenu.Group);
17
- const RadioGroup = loose(DropdownMenu.RadioGroup);
18
18
  const Sub = loose(DropdownMenu.Sub);
19
19
  export { Root, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, Group, Label, Separator, Sub, SubTrigger, SubContent };
@@ -12,6 +12,12 @@
12
12
  sx?: Sx | undefined;
13
13
  /** Sidebar.Group and Sidebar.Item. */
14
14
  children?: Snippet | undefined;
15
+ /**
16
+ * Groups held at the foot of the list, below what scrolls, such as shelves of settled
17
+ * threads. They are part of the same list: one tab stop, and the arrow keys run on into
18
+ * them. Opened, they take at most 40% of the height and scroll on their own.
19
+ */
20
+ pinned?: Snippet | undefined;
15
21
  };
16
22
 
17
23
  const styles = stylex.create({
@@ -27,12 +33,29 @@
27
33
  // The list fades at an edge with more beyond it
28
34
  maskImage:
29
35
  'linear-gradient(to bottom, transparent, #000 var(--narvi-fade-start, 0px), #000 calc(100% - var(--narvi-fade-end, 0px)), transparent)'
36
+ },
37
+ // With pinned groups, the list is a column: what scrolls, then what stays at its foot
38
+ split: {
39
+ display: 'flex',
40
+ flexDirection: 'column',
41
+ flexGrow: 1,
42
+ minHeight: 0
43
+ },
44
+ pinned: {
45
+ flexShrink: 0,
46
+ maxHeight: '40%',
47
+ overflowY: 'auto',
48
+ overscrollBehavior: 'contain',
49
+ paddingInline: '0.5rem',
50
+ paddingBottom: '0.5rem',
51
+ scrollbarWidth: 'thin',
52
+ scrollbarColor: `${colors.borderStrong} transparent`
30
53
  }
31
54
  });
32
55
  </script>
33
56
 
34
57
  <script lang="ts">
35
- let { label, sx, class: className, children, ...rest }: SidebarContentProps = $props();
58
+ let { label, sx, class: className, children, pinned, ...rest }: SidebarContentProps = $props();
36
59
 
37
60
  let fadeStart = $state(0);
38
61
  let fadeEnd = $state(0);
@@ -56,15 +79,38 @@
56
79
  </script>
57
80
 
58
81
  <!-- One tab stop for every row in every group; the arrow keys move between them -->
59
- <nav
60
- aria-label={label}
61
- data-slot="sidebar-content"
62
- style:--narvi-fade-start="{fadeStart}px"
63
- style:--narvi-fade-end="{fadeEnd}px"
64
- {...rest}
65
- {...attrs([styles.content, sx], className)}
66
- {@attach measure}
67
- {@attach roving({ selector: '[data-sidebar-row]' })}
68
- >
69
- <div>{@render children?.()}</div>
70
- </nav>
82
+ {#if pinned}
83
+ <nav
84
+ aria-label={label}
85
+ data-slot="sidebar-content"
86
+ {...rest}
87
+ {...attrs([styles.split, sx], className)}
88
+ {@attach roving({ selector: '[data-sidebar-row]' })}
89
+ >
90
+ <div
91
+ data-slot="sidebar-content-scroll"
92
+ style:--narvi-fade-start="{fadeStart}px"
93
+ style:--narvi-fade-end="{fadeEnd}px"
94
+ {...stylex.attrs(styles.content)}
95
+ {@attach measure}
96
+ >
97
+ <div>{@render children?.()}</div>
98
+ </div>
99
+ <div data-slot="sidebar-content-pinned" {...stylex.attrs(styles.pinned)}>
100
+ {@render pinned()}
101
+ </div>
102
+ </nav>
103
+ {:else}
104
+ <nav
105
+ aria-label={label}
106
+ data-slot="sidebar-content"
107
+ style:--narvi-fade-start="{fadeStart}px"
108
+ style:--narvi-fade-end="{fadeEnd}px"
109
+ {...rest}
110
+ {...attrs([styles.content, sx], className)}
111
+ {@attach measure}
112
+ {@attach roving({ selector: '[data-sidebar-row]' })}
113
+ >
114
+ <div>{@render children?.()}</div>
115
+ </nav>
116
+ {/if}
@@ -7,6 +7,12 @@ export type SidebarContentProps = Omit<HTMLAttributes<HTMLElement>, 'children'>
7
7
  sx?: Sx | undefined;
8
8
  /** Sidebar.Group and Sidebar.Item. */
9
9
  children?: Snippet | undefined;
10
+ /**
11
+ * Groups held at the foot of the list, below what scrolls, such as shelves of settled
12
+ * threads. They are part of the same list: one tab stop, and the arrow keys run on into
13
+ * them. Opened, they take at most 40% of the height and scroll on their own.
14
+ */
15
+ pinned?: Snippet | undefined;
10
16
  };
11
17
  declare const SidebarContent: import("svelte").Component<SidebarContentProps, {}, "">;
12
18
  type SidebarContent = ReturnType<typeof SidebarContent>;
@@ -15,6 +15,7 @@
15
15
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
16
16
  import { media } from '../../media.stylex.js';
17
17
  import { getSidebarDepth, setSidebarDepth } from './depth.js';
18
+ import { getSidebarFold, setSidebarFold } from './fold.js';
18
19
 
19
20
  export type SidebarFolderProps = Omit<HTMLAttributes<HTMLLIElement>, 'children'> & {
20
21
  /** Its name: a project. */
@@ -32,6 +33,8 @@
32
33
 
33
34
  const styles = stylex.create({
34
35
  folder: { position: 'relative', listStyleType: 'none' },
36
+ // Its group is folded, and the open row is not in it
37
+ foldedAway: { display: 'none' },
35
38
  row: {
36
39
  boxSizing: 'border-box',
37
40
  display: 'flex',
@@ -121,9 +124,33 @@
121
124
  const depth = $derived(parent());
122
125
  // Its rows start where its name does: past the chevron, and past the mark when it has one
123
126
  setSidebarDepth(() => parent() + (leading ? 2 : 1));
127
+
128
+ // Folded, with the open row in it, the folder stays open on that row alone; and in a folded
129
+ // group, it shows only while it holds the open row
130
+ const outer = getSidebarFold();
131
+ let held = $state(0);
132
+ setSidebarFold(
133
+ outer && {
134
+ folded: () => outer.folded() || !open,
135
+ hold: () => {
136
+ held += 1;
137
+ const release = outer.hold();
138
+ return () => {
139
+ held -= 1;
140
+ release();
141
+ };
142
+ }
143
+ }
144
+ );
145
+ const shown = $derived(open || (outer !== undefined && held > 0));
146
+ const away = $derived(outer !== undefined && outer.folded() && held === 0);
124
147
  </script>
125
148
 
126
- <li data-slot="sidebar-folder" {...rest} {...attrs([styles.folder, sx], className)}>
149
+ <li
150
+ data-slot="sidebar-folder"
151
+ {...rest}
152
+ {...attrs([styles.folder, away && styles.foldedAway, sx], className)}
153
+ >
127
154
  <button
128
155
  type="button"
129
156
  data-sidebar-row
@@ -146,7 +173,7 @@
146
173
  <span {...stylex.attrs(styles.grow)}></span>
147
174
  {#if trailing}<span {...stylex.attrs(styles.trail)}>{@render trailing()}</span>{/if}
148
175
  </button>
149
- <Collapse {open} id="{uid}-rows">
176
+ <Collapse open={shown} id="{uid}-rows">
150
177
  <ul aria-label={label} {...stylex.attrs(styles.list)}>{@render children?.()}</ul>
151
178
  </Collapse>
152
179
  </li>