@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.
- package/README.md +116 -44
- package/dist/base.css +96 -0
- package/dist/color.d.ts +1 -1
- package/dist/color.js +1 -1
- package/dist/components/activity/ActivityContent.svelte +3 -15
- package/dist/components/activity/ActivityStep.svelte +12 -12
- package/dist/components/activity/ActivityThought.svelte +4 -4
- package/dist/components/activity/ActivityTrigger.svelte +5 -6
- package/dist/components/app-shell/AppShellBar.svelte +89 -0
- package/dist/components/app-shell/AppShellBar.svelte.d.ts +20 -0
- package/dist/components/app-shell/AppShellHeader.svelte +17 -17
- package/dist/components/app-shell/AppShellHeader.svelte.d.ts +2 -2
- package/dist/components/app-shell/AppShellMain.svelte +4 -20
- package/dist/components/app-shell/AppShellPanel.svelte +21 -19
- package/dist/components/app-shell/AppShellPanes.svelte +58 -0
- package/dist/components/app-shell/AppShellPanes.svelte.d.ts +11 -0
- package/dist/components/app-shell/AppShellRail.svelte +85 -0
- package/dist/components/app-shell/AppShellRail.svelte.d.ts +11 -0
- package/dist/components/app-shell/AppShellRoot.svelte +50 -24
- package/dist/components/app-shell/AppShellRoot.svelte.d.ts +8 -6
- package/dist/components/app-shell/AppShellSheet.svelte +95 -0
- package/dist/components/app-shell/AppShellSheet.svelte.d.ts +17 -0
- package/dist/components/app-shell/AppShellSidebar.svelte +41 -65
- package/dist/components/app-shell/AppShellSidebar.svelte.d.ts +1 -5
- package/dist/components/app-shell/AppShellToggle.svelte +62 -23
- package/dist/components/app-shell/AppShellToggle.svelte.d.ts +2 -0
- package/dist/components/app-shell/context.d.ts +6 -0
- package/dist/components/app-shell/index.d.ts +9 -1
- package/dist/components/app-shell/index.js +5 -1
- package/dist/components/approval/Approval.svelte +99 -23
- package/dist/components/approval/Approval.svelte.d.ts +7 -0
- package/dist/components/avatar/AvatarFallback.svelte +1 -2
- package/dist/components/avatar/AvatarRoot.svelte +2 -2
- package/dist/components/badge/Badge.svelte +5 -5
- package/dist/components/button/Button.svelte +227 -51
- package/dist/components/button/Button.svelte.d.ts +38 -2
- package/dist/components/card/Card.svelte +19 -33
- package/dist/components/change-stats/ChangeStats.svelte +1 -2
- package/dist/components/changes-summary/ChangesSummary.svelte +14 -15
- package/dist/components/checkbox/Checkbox.svelte +31 -25
- package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
- package/dist/components/code/Code.svelte +1 -2
- package/dist/components/collapsible/CollapsibleContent.svelte +38 -0
- package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +11 -0
- package/dist/components/collapsible/CollapsibleRoot.svelte +44 -0
- package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +11 -0
- package/dist/components/collapsible/CollapsibleTrigger.svelte +83 -0
- package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +13 -0
- package/dist/components/collapsible/context.d.ts +5 -0
- package/dist/components/collapsible/context.js +11 -0
- package/dist/components/collapsible/index.d.ts +7 -0
- package/dist/components/collapsible/index.js +4 -0
- package/dist/components/command/CommandItem.svelte +1 -1
- package/dist/components/command/styles.d.ts +3 -2
- package/dist/components/command/styles.js +15 -12
- package/dist/components/composer/ComposerAttachButton.svelte +1 -1
- package/dist/components/composer/ComposerAttachment.svelte +13 -18
- package/dist/components/composer/ComposerModelPicker.svelte +24 -28
- package/dist/components/composer/ComposerRoot.svelte +15 -13
- package/dist/components/composer/ComposerSubmit.svelte +12 -20
- package/dist/components/composer/ComposerTextarea.svelte +1 -1
- package/dist/components/composer/ComposerToggle.svelte +16 -18
- package/dist/components/composer/ComposerTray.svelte +78 -0
- package/dist/components/composer/ComposerTray.svelte.d.ts +15 -0
- package/dist/components/composer/index.d.ts +3 -1
- package/dist/components/composer/index.js +3 -2
- package/dist/components/conversation/ConversationContent.svelte +3 -2
- package/dist/components/conversation/ConversationEmpty.svelte +1 -1
- package/dist/components/conversation/ConversationScrollButton.svelte +9 -11
- package/dist/components/dialog/ConfirmDialog.svelte +1 -1
- package/dist/components/dialog/DialogContent.svelte +5 -1
- package/dist/components/dialog/styles.d.ts +2 -26
- package/dist/components/dialog/styles.js +12 -49
- package/dist/components/divider/Divider.svelte +3 -3
- package/dist/components/empty-state/EmptyState.svelte +4 -5
- package/dist/components/field/Field.svelte +4 -4
- package/dist/components/frame/Frame.svelte +6 -7
- package/dist/components/frame/Frame.svelte.d.ts +1 -1
- package/dist/components/grid/Grid.svelte +111 -0
- package/dist/components/grid/Grid.svelte.d.ts +27 -0
- package/dist/components/heading/Heading.svelte +2 -2
- package/dist/components/hover-card/HoverCardContent.svelte +50 -0
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +10 -0
- package/dist/components/hover-card/HoverCardRoot.svelte +22 -0
- package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -0
- package/dist/components/hover-card/index.d.ts +7 -0
- package/dist/components/hover-card/index.js +7 -0
- package/dist/components/kbd/Kbd.svelte +12 -7
- package/dist/components/link/Link.svelte +9 -7
- package/dist/components/link/Link.svelte.d.ts +4 -1
- package/dist/components/markdown/Markdown.svelte +714 -0
- package/dist/components/markdown/Markdown.svelte.d.ts +80 -0
- package/dist/components/markdown/MarkdownBlock.svelte +231 -0
- package/dist/components/markdown/MarkdownBlock.svelte.d.ts +11 -0
- package/dist/components/markdown/MarkdownBlocks.svelte +115 -0
- package/dist/components/markdown/MarkdownBlocks.svelte.d.ts +15 -0
- package/dist/components/markdown/MarkdownCode.svelte +583 -0
- package/dist/components/markdown/MarkdownCode.svelte.d.ts +23 -0
- package/dist/components/markdown/MarkdownDiagram.svelte +310 -0
- package/dist/components/markdown/MarkdownDiagram.svelte.d.ts +6 -0
- package/dist/components/markdown/MarkdownFile.svelte +134 -0
- package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
- package/dist/components/markdown/MarkdownFootnotes.svelte +61 -0
- package/dist/components/markdown/MarkdownFootnotes.svelte.d.ts +8 -0
- package/dist/components/markdown/MarkdownFresh.svelte +69 -0
- package/dist/components/markdown/MarkdownFresh.svelte.d.ts +6 -0
- package/dist/components/markdown/MarkdownHtml.svelte +72 -0
- package/dist/components/markdown/MarkdownHtml.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownImage.svelte +150 -0
- package/dist/components/markdown/MarkdownImage.svelte.d.ts +8 -0
- package/dist/components/markdown/MarkdownInlines.svelte +225 -0
- package/dist/components/markdown/MarkdownInlines.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownLink.svelte +120 -0
- package/dist/components/markdown/MarkdownLink.svelte.d.ts +25 -0
- package/dist/components/markdown/MarkdownMath.svelte +138 -0
- package/dist/components/markdown/MarkdownMath.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownTable.svelte +265 -0
- package/dist/components/markdown/MarkdownTable.svelte.d.ts +17 -0
- package/dist/components/markdown/caret.d.ts +14 -0
- package/dist/components/markdown/caret.js +67 -0
- package/dist/components/markdown/context.d.ts +93 -0
- package/dist/components/markdown/context.js +128 -0
- package/dist/components/markdown/copy.d.ts +13 -0
- package/dist/components/markdown/copy.js +74 -0
- package/dist/components/markdown/hidden.d.ts +12 -0
- package/dist/components/markdown/hidden.js +31 -0
- package/dist/components/markdown/kept.d.ts +32 -0
- package/dist/components/markdown/kept.js +71 -0
- package/dist/components/markdown/labels.d.ts +46 -0
- package/dist/components/markdown/labels.js +35 -0
- package/dist/components/markdown/save.d.ts +11 -0
- package/dist/components/markdown/save.js +58 -0
- package/dist/components/markdown/scrollable.d.ts +24 -0
- package/dist/components/markdown/scrollable.js +152 -0
- package/dist/components/markdown/static.d.ts +37 -0
- package/dist/components/markdown/static.js +233 -0
- package/dist/components/markdown/styles.d.ts +328 -0
- package/dist/components/markdown/styles.js +302 -0
- package/dist/components/menu/MenuRadioItem.svelte +3 -3
- package/dist/components/menu/index.d.ts +23 -0
- package/dist/components/menu/index.js +3 -1
- package/dist/components/message/MessageAction.svelte +24 -5
- package/dist/components/message/MessageAction.svelte.d.ts +9 -0
- package/dist/components/message/MessageActions.svelte +2 -3
- package/dist/components/message/MessageContent.svelte +2 -3
- package/dist/components/message/MessageCopy.svelte +66 -8
- package/dist/components/message/MessageCopy.svelte.d.ts +17 -1
- package/dist/components/message/MessageHeader.svelte +3 -3
- package/dist/components/message/MessagePending.svelte +1 -1
- package/dist/components/message/MessageRoot.svelte +3 -4
- package/dist/components/message/MessageTime.svelte +3 -4
- package/dist/components/notice/Notice.svelte +14 -10
- package/dist/components/plan/Plan.svelte +25 -21
- package/dist/components/progress/Progress.svelte +34 -38
- package/dist/components/questionnaire/Questionnaire.svelte +19 -22
- package/dist/components/queued-message/QueuedMessage.svelte +14 -7
- package/dist/components/rail/RailItem.svelte +43 -40
- package/dist/components/rail/RailItem.svelte.d.ts +3 -1
- package/dist/components/rail/RailRoot.svelte +18 -4
- package/dist/components/rail/RailRoot.svelte.d.ts +1 -1
- package/dist/components/rail/RailSeparator.svelte +17 -0
- package/dist/components/rail/RailSeparator.svelte.d.ts +18 -0
- package/dist/components/rail/index.d.ts +2 -1
- package/dist/components/rail/index.js +2 -1
- package/dist/components/reasoning/ReasoningContent.svelte +4 -8
- package/dist/components/reasoning/ReasoningTrigger.svelte +4 -5
- package/dist/components/resize-handle/ResizeHandle.svelte +4 -7
- package/dist/components/reveal/Reveal.svelte +89 -0
- package/dist/components/reveal/Reveal.svelte.d.ts +17 -0
- package/dist/components/reveal/revealed.d.ts +38 -0
- package/dist/components/reveal/revealed.js +79 -0
- package/dist/components/segmented/SegmentedControl.svelte +11 -16
- package/dist/components/select/Select.svelte +1 -1
- package/dist/components/separator/Separator.svelte +1 -1
- package/dist/components/settings-row/SettingsRow.svelte +5 -5
- package/dist/components/sheet/SheetContent.svelte +63 -0
- package/dist/components/sheet/SheetContent.svelte.d.ts +18 -0
- package/dist/components/sheet/index.d.ts +12 -0
- package/dist/components/sheet/index.js +12 -0
- package/dist/components/sheet/styles.d.ts +51 -0
- package/dist/components/sheet/styles.js +65 -0
- package/dist/components/shimmer/Shimmer.svelte +41 -26
- package/dist/components/sidebar/SidebarContent.svelte +1 -1
- package/dist/components/sidebar/SidebarFolder.svelte +142 -0
- package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
- package/dist/components/sidebar/SidebarFooter.svelte +1 -1
- package/dist/components/sidebar/SidebarGroup.svelte +41 -35
- package/dist/components/sidebar/SidebarGroup.svelte.d.ts +3 -3
- package/dist/components/sidebar/SidebarHeader.svelte +12 -6
- package/dist/components/sidebar/SidebarHeader.svelte.d.ts +4 -1
- package/dist/components/sidebar/SidebarItem.svelte +34 -38
- package/dist/components/sidebar/SidebarRoot.svelte +62 -0
- package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
- package/dist/components/sidebar/index.d.ts +5 -1
- package/dist/components/sidebar/index.js +3 -1
- package/dist/components/skeleton/Skeleton.svelte +26 -15
- package/dist/components/slider/Slider.svelte +200 -0
- package/dist/components/slider/Slider.svelte.d.ts +55 -0
- package/dist/components/spinner/Spinner.svelte +4 -11
- package/dist/components/stack/Stack.svelte +37 -44
- package/dist/components/stack/Stack.svelte.d.ts +12 -6
- package/dist/components/status-indicator/StatusIndicator.svelte +1 -1
- package/dist/components/suggestions/SuggestionsItem.svelte +11 -13
- package/dist/components/switch/Switch.svelte +16 -25
- package/dist/components/tab-strip/TabStrip.svelte +340 -0
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
- package/dist/components/tabs/Tabs.svelte +15 -14
- package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
- package/dist/components/text/Text.svelte +64 -14
- package/dist/components/text/Text.svelte.d.ts +13 -3
- package/dist/components/toast/Toaster.svelte +12 -10
- package/dist/components/toggle/Toggle.svelte +40 -0
- package/dist/components/toggle/Toggle.svelte.d.ts +15 -0
- package/dist/components/toggle-group/ToggleGroupItem.svelte +37 -0
- package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -0
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +95 -0
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +33 -0
- package/dist/components/toggle-group/context.d.ts +6 -0
- package/dist/components/toggle-group/context.js +11 -0
- package/dist/components/toggle-group/index.d.ts +5 -0
- package/dist/components/toggle-group/index.js +3 -0
- package/dist/components/tool/ToolContent.svelte +3 -8
- package/dist/components/tool/ToolSection.svelte +4 -5
- package/dist/components/tool/ToolTrigger.svelte +14 -15
- package/dist/components/tooltip/TooltipContent.svelte +9 -6
- package/dist/components/work-fold/WorkFold.svelte +17 -34
- package/dist/components/work-fold/WorkFold.svelte.d.ts +1 -1
- package/dist/index.d.ts +38 -10
- package/dist/index.js +38 -12
- package/dist/internal/Chevron.svelte +2 -3
- package/dist/internal/Code.svelte +3 -4
- package/dist/internal/Collapse.svelte +6 -5
- package/dist/internal/Collapse.svelte.d.ts +2 -1
- package/dist/internal/Glyph.svelte +16 -0
- package/dist/internal/Glyph.svelte.d.ts +6 -0
- package/dist/internal/Tile.svelte +17 -37
- package/dist/internal/control.d.ts +4 -4
- package/dist/internal/control.js +21 -18
- package/dist/internal/layer.d.ts +3 -5
- package/dist/internal/layer.js +14 -18
- package/dist/internal/layout.d.ts +13 -0
- package/dist/internal/layout.js +453 -0
- package/dist/internal/markers.stylex.d.ts +8 -0
- package/dist/internal/markers.stylex.js +4 -0
- package/dist/internal/plugin-order.d.ts +8 -0
- package/dist/internal/plugin-order.js +16 -0
- package/dist/internal/responsive.d.ts +45 -0
- package/dist/internal/responsive.js +42 -0
- package/dist/internal/roving.js +5 -2
- package/dist/internal/shared.d.ts +8 -1
- package/dist/internal/shared.js +21 -5
- package/dist/internal/sx.d.ts +31 -4
- package/dist/internal/sx.js +17 -0
- package/dist/internal/toggle.d.ts +73 -0
- package/dist/internal/toggle.js +83 -0
- package/dist/internal/visible.d.ts +32 -0
- package/dist/internal/visible.js +44 -0
- package/dist/markdown/ast.d.ts +209 -0
- package/dist/markdown/ast.js +10 -0
- package/dist/markdown/blocks.d.ts +177 -0
- package/dist/markdown/blocks.js +1489 -0
- package/dist/markdown/code-info.d.ts +10 -0
- package/dist/markdown/code-info.js +16 -0
- package/dist/markdown/common.d.ts +25 -0
- package/dist/markdown/common.js +107 -0
- package/dist/markdown/diagrams.d.ts +2 -0
- package/dist/markdown/diagrams.js +18 -0
- package/dist/markdown/file-paths.d.ts +29 -0
- package/dist/markdown/file-paths.js +80 -0
- package/dist/markdown/files.d.ts +16 -0
- package/dist/markdown/files.js +133 -0
- package/dist/markdown/highlight.d.ts +30 -0
- package/dist/markdown/highlight.js +127 -0
- package/dist/markdown/html.d.ts +23 -0
- package/dist/markdown/html.js +289 -0
- package/dist/markdown/images.d.ts +15 -0
- package/dist/markdown/images.js +45 -0
- package/dist/markdown/index.d.ts +12 -0
- package/dist/markdown/index.js +5 -0
- package/dist/markdown/inlines.d.ts +48 -0
- package/dist/markdown/inlines.js +1714 -0
- package/dist/markdown/math.d.ts +2 -0
- package/dist/markdown/math.js +22 -0
- package/dist/markdown/parse.d.ts +81 -0
- package/dist/markdown/parse.js +204 -0
- package/dist/markdown/plugin.d.ts +178 -0
- package/dist/markdown/plugin.js +160 -0
- package/dist/markdown/sanitize.d.ts +78 -0
- package/dist/markdown/sanitize.js +522 -0
- package/dist/markdown/share.d.ts +12 -0
- package/dist/markdown/share.js +59 -0
- package/dist/markdown/table.d.ts +13 -0
- package/dist/markdown/table.js +60 -0
- package/dist/media.stylex.d.ts +52 -0
- package/dist/media.stylex.js +53 -0
- package/dist/preset.d.ts +40 -16
- package/dist/preset.js +169 -51
- package/dist/tokens.stylex.d.ts +70 -37
- package/dist/tokens.stylex.js +127 -62
- package/dist/typography.d.ts +48 -0
- package/dist/typography.js +55 -0
- package/dist/vite.d.ts +9 -1
- package/dist/vite.js +37 -4
- package/package.json +58 -6
- package/skills/building-ui/SKILL.md +242 -0
- package/skills/building-ui/references/components.md +207 -0
- package/skills/markdown/SKILL.md +452 -0
- package/skills/markdown/references/plugins.md +103 -0
- package/skills/setup/SKILL.md +191 -0
- package/skills/styling/SKILL.md +269 -0
- package/skills/theming/SKILL.md +184 -0
- package/dist/internal/loop.d.ts +0 -35
- package/dist/internal/loop.js +0 -72
|
@@ -1,24 +1,25 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The first column of the sheet: a Sidebar.Header, the list and a footer. Folded
|
|
3
|
+
away, it gives its room to the page and the rail stays. On a narrow window it
|
|
4
|
+
is a drawer over the page, beside the rail.
|
|
5
|
+
-->
|
|
1
6
|
<script lang="ts" module>
|
|
2
7
|
import * as stylex from '@stylexjs/stylex';
|
|
3
8
|
import { tick, type Snippet } from 'svelte';
|
|
4
9
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
10
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
11
|
import { colors, motion } from '../../tokens.stylex.js';
|
|
12
|
+
import { media } from '../../media.stylex.js';
|
|
7
13
|
import { useAppShell } from './context.js';
|
|
8
14
|
|
|
9
15
|
export type AppShellSidebarProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
10
16
|
/** Names the region: "Threads", "Projects". */
|
|
11
17
|
label?: string;
|
|
12
|
-
/** A Sidebar.Header, across the full width, above the rail. */
|
|
13
|
-
header?: Snippet;
|
|
14
|
-
/** A Rail, the narrow column of icons that stays when the sidebar collapses. */
|
|
15
|
-
rail?: Snippet;
|
|
16
18
|
sx?: Sx;
|
|
17
|
-
/** Sidebar.Content and Sidebar.Footer. */
|
|
19
|
+
/** A Sidebar.Header, a Sidebar.Content and a Sidebar.Footer. */
|
|
18
20
|
children?: Snippet;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
22
23
|
// The drawer's curve: quick out of the edge, a long gentle settle
|
|
23
24
|
const DRAWER = 'cubic-bezier(0.32, 0.72, 0, 1)';
|
|
24
25
|
|
|
@@ -27,78 +28,77 @@
|
|
|
27
28
|
position: 'relative',
|
|
28
29
|
zIndex: 1,
|
|
29
30
|
display: 'flex',
|
|
30
|
-
flexDirection: 'column',
|
|
31
31
|
flexShrink: 0,
|
|
32
|
+
minHeight: 0,
|
|
32
33
|
overflow: 'clip',
|
|
33
34
|
color: colors.text
|
|
34
35
|
},
|
|
35
36
|
wide: {
|
|
36
|
-
width: '
|
|
37
|
-
|
|
37
|
+
width: 'var(--narvi-sidebar-width)',
|
|
38
|
+
// A flush sheet gives it the page's colour; on a sheet with an edge it has none
|
|
39
|
+
backgroundColor: 'var(--narvi-sidebar-surface, transparent)',
|
|
40
|
+
transitionProperty: { default: 'none', [media.motion]: 'width' },
|
|
38
41
|
transitionDuration: motion.slow,
|
|
39
42
|
transitionTimingFunction: motion.easeInOut
|
|
40
43
|
},
|
|
41
44
|
collapsed: { width: 0 },
|
|
42
|
-
|
|
43
|
-
// Narrow: a drawer over the page, from the start edge
|
|
45
|
+
// Narrow: a drawer over the page, from the start edge, after the rail
|
|
44
46
|
drawer: {
|
|
45
47
|
position: 'fixed',
|
|
46
48
|
insetBlock: 0,
|
|
47
|
-
insetInlineStart:
|
|
49
|
+
insetInlineStart: 'var(--narvi-rail-current, 0px)',
|
|
48
50
|
zIndex: 40,
|
|
49
|
-
width: 'min(
|
|
50
|
-
backgroundColor: colors.
|
|
51
|
-
boxShadow: `0 24px 64px -12px
|
|
52
|
-
translate: {
|
|
51
|
+
width: 'min(var(--narvi-sidebar-width), calc(86vw - var(--narvi-rail-current, 0px)))',
|
|
52
|
+
backgroundColor: colors.bgRaised,
|
|
53
|
+
boxShadow: `0 24px 64px -12px ${colors.shadow}`,
|
|
54
|
+
translate: {
|
|
55
|
+
default: 'calc(-100% - var(--narvi-rail-current, 0px)) 0',
|
|
56
|
+
':dir(rtl)': 'calc(100% + var(--narvi-rail-current, 0px)) 0'
|
|
57
|
+
},
|
|
53
58
|
// Hidden only once it has slid away; shown at once when it opens, so
|
|
54
59
|
// focus can move into it on the first frame
|
|
55
60
|
visibility: 'hidden',
|
|
56
|
-
transitionProperty: { default: 'visibility', [
|
|
57
|
-
transitionDuration: { default: '0s', [
|
|
58
|
-
transitionDelay: { default: '0s', [
|
|
61
|
+
transitionProperty: { default: 'visibility', [media.motion]: 'translate, visibility' },
|
|
62
|
+
transitionDuration: { default: '0s', [media.motion]: `${motion.slow}, 0s` },
|
|
63
|
+
transitionDelay: { default: '0s', [media.motion]: `0s, ${motion.slow}` },
|
|
59
64
|
transitionTimingFunction: DRAWER
|
|
60
65
|
},
|
|
61
66
|
drawerOpen: {
|
|
62
67
|
translate: '0 0',
|
|
63
68
|
visibility: 'visible',
|
|
64
|
-
transitionDelay: { default: '0s', [
|
|
69
|
+
transitionDelay: { default: '0s', [media.motion]: '0s, 0s' }
|
|
65
70
|
},
|
|
66
71
|
scrim: {
|
|
67
72
|
position: 'fixed',
|
|
68
73
|
inset: 0,
|
|
69
74
|
zIndex: 39,
|
|
70
|
-
backgroundColor:
|
|
75
|
+
backgroundColor: colors.scrim,
|
|
71
76
|
opacity: { default: 1, '@starting-style': 0 },
|
|
72
77
|
transitionProperty: 'opacity',
|
|
73
78
|
transitionDuration: motion.slow,
|
|
74
79
|
transitionTimingFunction: motion.easeOut
|
|
75
80
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
transitionDuration: motion.fast,
|
|
80
|
-
transitionTimingFunction: 'ease'
|
|
81
|
-
},
|
|
82
|
-
// Folded to the rail, the header has no room; it steps out rather than being cut
|
|
83
|
-
headerHidden: { opacity: 0, visibility: 'hidden' },
|
|
84
|
-
body: { display: 'flex', flexGrow: 1, minHeight: 0 },
|
|
85
|
-
rail: { display: 'flex', flexShrink: 0, width: 'var(--narvi-rail-width)' },
|
|
86
|
-
// The column keeps its width while the sidebar narrows, so its rows are
|
|
87
|
-
// clipped rather than squeezed and reflowed on every frame
|
|
81
|
+
// The column keeps its width while the sidebar narrows, so its rows are clipped
|
|
82
|
+
// rather than squeezed and reflowed on every frame. The hairline that divides it
|
|
83
|
+
// from the page is on the column, so it goes when the sidebar does.
|
|
88
84
|
column: {
|
|
85
|
+
boxSizing: 'border-box',
|
|
89
86
|
display: 'flex',
|
|
90
87
|
flexDirection: 'column',
|
|
91
88
|
flexShrink: 0,
|
|
92
|
-
minHeight: 0
|
|
93
|
-
|
|
89
|
+
minHeight: 0,
|
|
90
|
+
width: 'var(--narvi-sidebar-width)',
|
|
91
|
+
borderInlineEndWidth: '1px',
|
|
92
|
+
borderInlineEndStyle: 'solid',
|
|
93
|
+
borderInlineEndColor: colors.border
|
|
94
|
+
},
|
|
95
|
+
columnDrawer: { width: '100%', borderInlineEndWidth: 0 }
|
|
94
96
|
});
|
|
95
97
|
</script>
|
|
96
98
|
|
|
97
99
|
<script lang="ts">
|
|
98
100
|
let {
|
|
99
101
|
label = 'Sidebar',
|
|
100
|
-
header,
|
|
101
|
-
rail,
|
|
102
102
|
sx,
|
|
103
103
|
class: className,
|
|
104
104
|
children,
|
|
@@ -108,11 +108,6 @@
|
|
|
108
108
|
const shell = useAppShell('Sidebar');
|
|
109
109
|
let element = $state<HTMLElement | null>(null);
|
|
110
110
|
|
|
111
|
-
$effect(() => {
|
|
112
|
-
shell.setRail(!!rail);
|
|
113
|
-
return () => shell.setRail(false);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
111
|
// A drawer takes focus when it opens and gives it back when it closes
|
|
117
112
|
let returnTo: HTMLElement | null = null;
|
|
118
113
|
$effect(() => {
|
|
@@ -137,8 +132,6 @@
|
|
|
137
132
|
returnTo = null;
|
|
138
133
|
}
|
|
139
134
|
});
|
|
140
|
-
|
|
141
|
-
const hidden = $derived(shell.narrow ? !shell.open : !shell.open && !rail);
|
|
142
135
|
</script>
|
|
143
136
|
|
|
144
137
|
<svelte:window
|
|
@@ -155,7 +148,7 @@
|
|
|
155
148
|
bind:this={element}
|
|
156
149
|
id={shell.sidebarId}
|
|
157
150
|
aria-label={label}
|
|
158
|
-
inert={
|
|
151
|
+
inert={!shell.open || undefined}
|
|
159
152
|
data-slot="app-shell-sidebar"
|
|
160
153
|
{...rest}
|
|
161
154
|
{...attrs(
|
|
@@ -163,30 +156,13 @@
|
|
|
163
156
|
styles.sidebar,
|
|
164
157
|
shell.narrow
|
|
165
158
|
? [styles.drawer, shell.open && styles.drawerOpen]
|
|
166
|
-
: [styles.wide, !shell.open &&
|
|
159
|
+
: [styles.wide, !shell.open && styles.collapsed],
|
|
167
160
|
sx
|
|
168
161
|
],
|
|
169
162
|
className
|
|
170
163
|
)}
|
|
171
164
|
>
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
{...stylex.attrs(styles.header, !shell.open && !shell.narrow && styles.headerHidden)}
|
|
175
|
-
inert={!shell.open && !shell.narrow ? true : undefined}
|
|
176
|
-
>
|
|
177
|
-
{@render header()}
|
|
178
|
-
</div>
|
|
179
|
-
{/if}
|
|
180
|
-
<div {...stylex.attrs(styles.body)}>
|
|
181
|
-
{#if rail}
|
|
182
|
-
<div {...stylex.attrs(styles.rail)}>{@render rail()}</div>
|
|
183
|
-
{/if}
|
|
184
|
-
<div
|
|
185
|
-
{...stylex.attrs(styles.column)}
|
|
186
|
-
style:width="var(--narvi-sidebar-width)"
|
|
187
|
-
inert={!shell.open && !shell.narrow ? true : undefined}
|
|
188
|
-
>
|
|
189
|
-
{@render children?.()}
|
|
190
|
-
</div>
|
|
165
|
+
<div {...stylex.attrs(styles.column, shell.narrow && styles.columnDrawer)}>
|
|
166
|
+
{@render children?.()}
|
|
191
167
|
</div>
|
|
192
168
|
</aside>
|
|
@@ -4,12 +4,8 @@ import { type Sx } from '../../internal/sx.js';
|
|
|
4
4
|
export type AppShellSidebarProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
5
5
|
/** Names the region: "Threads", "Projects". */
|
|
6
6
|
label?: string;
|
|
7
|
-
/** A Sidebar.Header, across the full width, above the rail. */
|
|
8
|
-
header?: Snippet;
|
|
9
|
-
/** A Rail, the narrow column of icons that stays when the sidebar collapses. */
|
|
10
|
-
rail?: Snippet;
|
|
11
7
|
sx?: Sx;
|
|
12
|
-
/** Sidebar.Content and Sidebar.Footer. */
|
|
8
|
+
/** A Sidebar.Header, a Sidebar.Content and a Sidebar.Footer. */
|
|
13
9
|
children?: Snippet;
|
|
14
10
|
};
|
|
15
11
|
declare const AppShellSidebar: import("svelte").Component<AppShellSidebarProps, {}, "">;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Shows and hides the sidebar. Put one in the AppShell.Bar. In a shell with no
|
|
3
|
+
bar, put one in the sidebar's head and another, `when="closed"`, in the page's
|
|
4
|
+
header: that one shows only while the sidebar is away, and focus passes
|
|
5
|
+
between the two as the sidebar comes and goes.
|
|
6
|
+
-->
|
|
1
7
|
<script lang="ts" module>
|
|
8
|
+
import { tick, untrack } from 'svelte';
|
|
2
9
|
import type { Sx } from '../../internal/sx.js';
|
|
3
10
|
import Button, { type ButtonProps } from '../button/Button.svelte';
|
|
4
11
|
import { useAppShell } from './context.js';
|
|
@@ -7,6 +14,8 @@
|
|
|
7
14
|
ButtonProps,
|
|
8
15
|
'children' | 'variant' | 'iconOnly' | 'href' | 'ref' | 'onclick'
|
|
9
16
|
> & {
|
|
17
|
+
/** `closed` shows the button only while the sidebar is away: for the page's header in a shell with no bar. */
|
|
18
|
+
when?: 'always' | 'closed';
|
|
10
19
|
showLabel?: string;
|
|
11
20
|
hideLabel?: string;
|
|
12
21
|
sx?: Sx;
|
|
@@ -15,6 +24,7 @@
|
|
|
15
24
|
|
|
16
25
|
<script lang="ts">
|
|
17
26
|
let {
|
|
27
|
+
when = 'always',
|
|
18
28
|
showLabel = 'Show the sidebar',
|
|
19
29
|
hideLabel = 'Hide the sidebar',
|
|
20
30
|
size = 'sm',
|
|
@@ -22,29 +32,58 @@
|
|
|
22
32
|
}: AppShellToggleProps = $props();
|
|
23
33
|
|
|
24
34
|
const shell = useAppShell('Toggle');
|
|
35
|
+
const shown = $derived(when === 'always' || !shell.open);
|
|
36
|
+
let ref = $state<HTMLButtonElement | HTMLAnchorElement | null>(null);
|
|
37
|
+
|
|
38
|
+
// The button that was pressed goes with the sidebar, or goes when it comes back, and
|
|
39
|
+
// focus would fall to the page. The one that takes its place picks it up: the page's
|
|
40
|
+
// when the sidebar closes, the sidebar's own when it opens. Only when the person moved
|
|
41
|
+
// the sidebar: a window that becomes narrow hides it too, and must not move the focus.
|
|
42
|
+
let before: number | undefined;
|
|
43
|
+
$effect(() => {
|
|
44
|
+
const moves = shell.moves;
|
|
45
|
+
const moved = before !== undefined && before !== moves;
|
|
46
|
+
before = moves;
|
|
47
|
+
if (!moved) return;
|
|
48
|
+
const open = untrack(() => shell.open);
|
|
49
|
+
const takes =
|
|
50
|
+
when === 'closed' ? !open : open && !!ref?.closest('[data-slot="app-shell-sidebar"]');
|
|
51
|
+
if (!takes) return;
|
|
52
|
+
tick().then(() =>
|
|
53
|
+
requestAnimationFrame(() => {
|
|
54
|
+
// Lost: on the body, or still on a button the browser has yet to take it from
|
|
55
|
+
const active = document.activeElement;
|
|
56
|
+
if (!active || active === document.body || !active.isConnected || active.closest('[inert]'))
|
|
57
|
+
ref?.focus();
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
});
|
|
25
61
|
</script>
|
|
26
62
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
width="16"
|
|
40
|
-
height="16"
|
|
41
|
-
viewBox="0 0 16 16"
|
|
42
|
-
fill="none"
|
|
43
|
-
stroke="currentColor"
|
|
44
|
-
stroke-width="1.5"
|
|
45
|
-
aria-hidden="true"
|
|
63
|
+
{#if shown}
|
|
64
|
+
<Button
|
|
65
|
+
bind:ref
|
|
66
|
+
variant="ghost"
|
|
67
|
+
{size}
|
|
68
|
+
iconOnly
|
|
69
|
+
aria-label={shell.open ? hideLabel : showLabel}
|
|
70
|
+
aria-expanded={shell.open}
|
|
71
|
+
aria-controls={shell.sidebarId}
|
|
72
|
+
data-slot="app-shell-toggle"
|
|
73
|
+
{...rest}
|
|
74
|
+
onclick={() => shell.toggle()}
|
|
46
75
|
>
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
76
|
+
<svg
|
|
77
|
+
width="16"
|
|
78
|
+
height="16"
|
|
79
|
+
viewBox="0 0 16 16"
|
|
80
|
+
fill="none"
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
stroke-width="1.5"
|
|
83
|
+
aria-hidden="true"
|
|
84
|
+
>
|
|
85
|
+
<rect x="2.25" y="2.75" width="11.5" height="10.5" rx="2" />
|
|
86
|
+
<path d="M6.25 2.75v10.5" />
|
|
87
|
+
</svg>
|
|
88
|
+
</Button>
|
|
89
|
+
{/if}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Sx } from '../../internal/sx.js';
|
|
2
2
|
import { type ButtonProps } from '../button/Button.svelte';
|
|
3
3
|
export type AppShellToggleProps = Omit<ButtonProps, 'children' | 'variant' | 'iconOnly' | 'href' | 'ref' | 'onclick'> & {
|
|
4
|
+
/** `closed` shows the button only while the sidebar is away: for the page's header in a shell with no bar. */
|
|
5
|
+
when?: 'always' | 'closed';
|
|
4
6
|
showLabel?: string;
|
|
5
7
|
hideLabel?: string;
|
|
6
8
|
sx?: Sx;
|
|
@@ -6,8 +6,14 @@ export type AppShellContext = {
|
|
|
6
6
|
readonly sidebarId: string;
|
|
7
7
|
toggle(): void;
|
|
8
8
|
close(): void;
|
|
9
|
+
/** True while the shell has an AppShell.Bar. Without one, the first column's head is the window's. */
|
|
10
|
+
readonly bar: boolean;
|
|
11
|
+
/** @internal Counts the times the person showed or hid the sidebar, as against the window changing size. */
|
|
12
|
+
readonly moves: number;
|
|
9
13
|
/** @internal The sidebar says whether it has a rail, which stays when it collapses. */
|
|
10
14
|
setRail(present: boolean): void;
|
|
15
|
+
/** @internal The bar says it is there, so nothing under it keeps room for the traffic lights. */
|
|
16
|
+
setBar(present: boolean): void;
|
|
11
17
|
};
|
|
12
18
|
export declare function setAppShellContext(context: AppShellContext): void;
|
|
13
19
|
/** The surrounding AppShell, for building parts of your own. */
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
+
import Bar from './AppShellBar.svelte';
|
|
1
2
|
import Header from './AppShellHeader.svelte';
|
|
2
3
|
import Main from './AppShellMain.svelte';
|
|
3
4
|
import Panel from './AppShellPanel.svelte';
|
|
5
|
+
import Panes from './AppShellPanes.svelte';
|
|
6
|
+
import Rail from './AppShellRail.svelte';
|
|
4
7
|
import Root from './AppShellRoot.svelte';
|
|
8
|
+
import Sheet from './AppShellSheet.svelte';
|
|
5
9
|
import Sidebar from './AppShellSidebar.svelte';
|
|
6
10
|
import Toggle from './AppShellToggle.svelte';
|
|
7
|
-
export { Root, Sidebar, Main, Header, Panel, Toggle };
|
|
11
|
+
export { Root, Bar, Rail, Panes, Sheet, Sidebar, Main, Header, Panel, Toggle };
|
|
8
12
|
export { getAppShellContext } from './context.js';
|
|
9
13
|
export type { AppShellContext } from './context.js';
|
|
14
|
+
export type { AppShellBarProps } from './AppShellBar.svelte';
|
|
10
15
|
export type { AppShellHeaderProps } from './AppShellHeader.svelte';
|
|
11
16
|
export type { AppShellMainProps } from './AppShellMain.svelte';
|
|
12
17
|
export type { AppShellPanelProps } from './AppShellPanel.svelte';
|
|
18
|
+
export type { AppShellPanesProps } from './AppShellPanes.svelte';
|
|
19
|
+
export type { AppShellRailProps } from './AppShellRail.svelte';
|
|
13
20
|
export type { AppShellRootProps } from './AppShellRoot.svelte';
|
|
21
|
+
export type { AppShellSheetProps } from './AppShellSheet.svelte';
|
|
14
22
|
export type { AppShellSidebarProps } from './AppShellSidebar.svelte';
|
|
15
23
|
export type { AppShellToggleProps } from './AppShellToggle.svelte';
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import Bar from './AppShellBar.svelte';
|
|
1
2
|
import Header from './AppShellHeader.svelte';
|
|
2
3
|
import Main from './AppShellMain.svelte';
|
|
3
4
|
import Panel from './AppShellPanel.svelte';
|
|
5
|
+
import Panes from './AppShellPanes.svelte';
|
|
6
|
+
import Rail from './AppShellRail.svelte';
|
|
4
7
|
import Root from './AppShellRoot.svelte';
|
|
8
|
+
import Sheet from './AppShellSheet.svelte';
|
|
5
9
|
import Sidebar from './AppShellSidebar.svelte';
|
|
6
10
|
import Toggle from './AppShellToggle.svelte';
|
|
7
|
-
export { Root, Sidebar, Main, Header, Panel, Toggle };
|
|
11
|
+
export { Root, Bar, Rail, Panes, Sheet, Sidebar, Main, Header, Panel, Toggle };
|
|
8
12
|
export { getAppShellContext } from './context.js';
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<script lang="ts" module>
|
|
8
8
|
import * as stylex from '@stylexjs/stylex';
|
|
9
|
-
import { tick, type Snippet } from 'svelte';
|
|
9
|
+
import { onMount, tick, type Snippet } from 'svelte';
|
|
10
10
|
import Glyph from '../../internal/Glyph.svelte';
|
|
11
11
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
12
12
|
import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
|
|
13
|
+
import { media } from '../../media.stylex.js';
|
|
13
14
|
import Button from '../button/Button.svelte';
|
|
15
|
+
import Kbd from '../kbd/Kbd.svelte';
|
|
14
16
|
|
|
15
17
|
export type ApprovalChoice = {
|
|
16
18
|
value: string;
|
|
@@ -19,6 +21,27 @@
|
|
|
19
21
|
primary?: boolean;
|
|
20
22
|
/** For a choice that refuses, or refuses and stops. */
|
|
21
23
|
tone?: 'default' | 'danger';
|
|
24
|
+
/**
|
|
25
|
+
* Keys that make this choice, shown on its button. `mod` is ⌘ on Apple systems and Ctrl
|
|
26
|
+
* elsewhere, and works from anywhere on the page; `enter` and `escape` on their own work
|
|
27
|
+
* only while focus is in the card, so they never take a key from the composer.
|
|
28
|
+
*/
|
|
29
|
+
shortcut?: ApprovalShortcut;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type ApprovalShortcut = 'mod+enter' | 'mod+backspace' | 'enter' | 'escape';
|
|
33
|
+
|
|
34
|
+
const KEY: Record<ApprovalShortcut, string> = {
|
|
35
|
+
'mod+enter': 'Enter',
|
|
36
|
+
'mod+backspace': 'Backspace',
|
|
37
|
+
enter: 'Enter',
|
|
38
|
+
escape: 'Escape'
|
|
39
|
+
};
|
|
40
|
+
const CAP: Record<ApprovalShortcut, string> = {
|
|
41
|
+
'mod+enter': '⏎',
|
|
42
|
+
'mod+backspace': '⌫',
|
|
43
|
+
enter: '⏎',
|
|
44
|
+
escape: 'Esc'
|
|
22
45
|
};
|
|
23
46
|
|
|
24
47
|
export type ApprovalAnswer = {
|
|
@@ -48,28 +71,28 @@
|
|
|
48
71
|
class?: string;
|
|
49
72
|
};
|
|
50
73
|
|
|
51
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
52
|
-
|
|
53
74
|
const styles = stylex.create({
|
|
54
75
|
card: {
|
|
55
76
|
display: 'flex',
|
|
56
77
|
flexDirection: 'column',
|
|
57
78
|
gap: space.x3,
|
|
58
79
|
padding: '0.875rem',
|
|
59
|
-
borderRadius: radius.
|
|
80
|
+
borderRadius: radius.panel,
|
|
60
81
|
backgroundColor: `color-mix(in oklab, ${colors.warning} 7%, ${colors.bgRaised})`,
|
|
61
|
-
boxShadow: `inset 0 0 0 1px color-mix(in oklab, ${colors.warning} 40%, transparent)`,
|
|
62
82
|
opacity: { default: 1, '@starting-style': 0 },
|
|
63
|
-
translate: {
|
|
64
|
-
|
|
83
|
+
translate: {
|
|
84
|
+
default: null,
|
|
85
|
+
[media.motion]: { default: '0 0', '@starting-style': '0 0.375rem' }
|
|
86
|
+
},
|
|
87
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, translate' },
|
|
65
88
|
transitionDuration: motion.slow,
|
|
66
89
|
transitionTimingFunction: motion.easeOut
|
|
67
90
|
},
|
|
68
|
-
title: { margin: 0, fontSize: font.
|
|
91
|
+
title: { margin: 0, fontSize: font.sizeBody, fontWeight: font.weightSemibold },
|
|
69
92
|
reason: {
|
|
70
93
|
margin: 0,
|
|
71
94
|
color: colors.textMuted,
|
|
72
|
-
fontSize: font.
|
|
95
|
+
fontSize: font.sizeBody,
|
|
73
96
|
lineHeight: font.leadingNormal
|
|
74
97
|
},
|
|
75
98
|
command: {
|
|
@@ -77,11 +100,10 @@
|
|
|
77
100
|
paddingBlock: '0.5rem',
|
|
78
101
|
paddingInline: '0.625rem',
|
|
79
102
|
overflowX: 'auto',
|
|
80
|
-
borderRadius: radius.
|
|
81
|
-
backgroundColor: colors.
|
|
82
|
-
boxShadow: `inset 0 0 0 1px ${colors.line}`,
|
|
103
|
+
borderRadius: radius.control,
|
|
104
|
+
backgroundColor: colors.fillSunken,
|
|
83
105
|
fontFamily: font.mono,
|
|
84
|
-
fontSize: font.
|
|
106
|
+
fontSize: font.sizeMeta,
|
|
85
107
|
whiteSpace: 'pre-wrap',
|
|
86
108
|
overflowWrap: 'anywhere',
|
|
87
109
|
userSelect: 'text'
|
|
@@ -90,9 +112,10 @@
|
|
|
90
112
|
files: {
|
|
91
113
|
margin: 0,
|
|
92
114
|
paddingInlineStart: '1rem',
|
|
115
|
+
// Stated, not left to the browser: a reset such as base.css removes markers
|
|
116
|
+
listStyleType: 'disc',
|
|
93
117
|
color: colors.textMuted,
|
|
94
|
-
|
|
95
|
-
fontSize: font.sizeXs,
|
|
118
|
+
fontSize: font.sizeCaption,
|
|
96
119
|
lineHeight: 1.7
|
|
97
120
|
},
|
|
98
121
|
actions: { display: 'flex', flexWrap: 'wrap', gap: space.x2 },
|
|
@@ -102,8 +125,8 @@
|
|
|
102
125
|
gap: '0.5rem',
|
|
103
126
|
minWidth: 0,
|
|
104
127
|
color: colors.textMuted,
|
|
105
|
-
fontSize: font.
|
|
106
|
-
borderRadius: radius.
|
|
128
|
+
fontSize: font.sizeMeta,
|
|
129
|
+
borderRadius: radius.chip,
|
|
107
130
|
outlineStyle: 'solid',
|
|
108
131
|
outlineWidth: { default: 0, ':focus-visible': '2px' },
|
|
109
132
|
outlineColor: colors.focusRing,
|
|
@@ -117,8 +140,9 @@
|
|
|
117
140
|
overflow: 'hidden',
|
|
118
141
|
textOverflow: 'ellipsis',
|
|
119
142
|
whiteSpace: 'nowrap',
|
|
120
|
-
|
|
121
|
-
|
|
143
|
+
// A `<code>`, in the text's own face
|
|
144
|
+
fontFamily: 'inherit',
|
|
145
|
+
fontSize: font.sizeCaption
|
|
122
146
|
}
|
|
123
147
|
});
|
|
124
148
|
</script>
|
|
@@ -154,6 +178,41 @@
|
|
|
154
178
|
keepFocus = false;
|
|
155
179
|
tick().then(() => line?.focus());
|
|
156
180
|
});
|
|
181
|
+
|
|
182
|
+
// ⌘ where there is one, Ctrl elsewhere. Found once the page is in a browser.
|
|
183
|
+
let apple = $state(true);
|
|
184
|
+
onMount(() => {
|
|
185
|
+
apple = /Mac|iPhone|iPad/.test(navigator.platform);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
function onkeydown(event: KeyboardEvent) {
|
|
189
|
+
if (answer || event.defaultPrevented || event.repeat || !card) return;
|
|
190
|
+
// With several cards waiting, the first one on the page answers
|
|
191
|
+
if (document.querySelector('[data-slot="approval"][data-shortcuts]') !== card) return;
|
|
192
|
+
const mod = event.metaKey || event.ctrlKey;
|
|
193
|
+
const inside = card.contains(document.activeElement);
|
|
194
|
+
// Words already typed are being sent: the key is the field's, not the card's
|
|
195
|
+
const target = event.target;
|
|
196
|
+
const typed =
|
|
197
|
+
(target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement) &&
|
|
198
|
+
target.value.trim() !== '';
|
|
199
|
+
const choice = choices.find((choice) => {
|
|
200
|
+
if (!choice.shortcut || event.key !== KEY[choice.shortcut]) return false;
|
|
201
|
+
return choice.shortcut.startsWith('mod+') ? mod && !typed : !mod && inside;
|
|
202
|
+
});
|
|
203
|
+
if (!choice) return;
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
choose(choice.value);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Heard before the composer hears it: with nothing typed, ⌘⏎ answers the card and
|
|
210
|
+
// does not also send an empty message
|
|
211
|
+
$effect(() => {
|
|
212
|
+
if (answer || !choices.some((choice) => choice.shortcut)) return;
|
|
213
|
+
window.addEventListener('keydown', onkeydown, true);
|
|
214
|
+
return () => window.removeEventListener('keydown', onkeydown, true);
|
|
215
|
+
});
|
|
157
216
|
</script>
|
|
158
217
|
|
|
159
218
|
{#if answer}
|
|
@@ -174,9 +233,7 @@
|
|
|
174
233
|
/>{/if}
|
|
175
234
|
</span>
|
|
176
235
|
<span>{answer.label}</span>
|
|
177
|
-
{#if subject ?? command}<
|
|
178
|
-
>{subject ?? command}</code
|
|
179
|
-
>{/if}
|
|
236
|
+
{#if subject ?? command}<code {...stylex.attrs(styles.subject)}>{subject ?? command}</code>{/if}
|
|
180
237
|
</p>
|
|
181
238
|
{:else}
|
|
182
239
|
<section
|
|
@@ -184,6 +241,7 @@
|
|
|
184
241
|
role="group"
|
|
185
242
|
aria-labelledby="{uid}-title"
|
|
186
243
|
data-slot="approval"
|
|
244
|
+
data-shortcuts={choices.some((choice) => choice.shortcut) || undefined}
|
|
187
245
|
{...attrs([styles.card, sx], className)}
|
|
188
246
|
>
|
|
189
247
|
<p id="{uid}-title" {...stylex.attrs(styles.title)}>{title}</p>
|
|
@@ -202,10 +260,28 @@
|
|
|
202
260
|
{#each choices as choice (choice.value)}
|
|
203
261
|
<Button
|
|
204
262
|
size="sm"
|
|
205
|
-
variant={choice.primary
|
|
263
|
+
variant={choice.primary
|
|
264
|
+
? 'primary'
|
|
265
|
+
: choice.tone === 'danger'
|
|
266
|
+
? 'danger-outline'
|
|
267
|
+
: 'ghost'}
|
|
268
|
+
aria-keyshortcuts={choice.shortcut
|
|
269
|
+
? choice.shortcut
|
|
270
|
+
.replace('mod', apple ? 'Meta' : 'Control')
|
|
271
|
+
.replace('escape', 'Escape')
|
|
272
|
+
.replace('enter', 'Enter')
|
|
273
|
+
.replace('backspace', 'Backspace')
|
|
274
|
+
: undefined}
|
|
206
275
|
onclick={() => choose(choice.value)}
|
|
207
276
|
>
|
|
208
277
|
{choice.label}
|
|
278
|
+
{#if choice.shortcut}
|
|
279
|
+
<Kbd aria-hidden="true"
|
|
280
|
+
>{choice.shortcut.startsWith('mod+') ? (apple ? '⌘' : 'Ctrl ') : ''}{CAP[
|
|
281
|
+
choice.shortcut
|
|
282
|
+
]}</Kbd
|
|
283
|
+
>
|
|
284
|
+
{/if}
|
|
209
285
|
</Button>
|
|
210
286
|
{/each}
|
|
211
287
|
</div>
|
|
@@ -7,7 +7,14 @@ export type ApprovalChoice = {
|
|
|
7
7
|
primary?: boolean;
|
|
8
8
|
/** For a choice that refuses, or refuses and stops. */
|
|
9
9
|
tone?: 'default' | 'danger';
|
|
10
|
+
/**
|
|
11
|
+
* Keys that make this choice, shown on its button. `mod` is ⌘ on Apple systems and Ctrl
|
|
12
|
+
* elsewhere, and works from anywhere on the page; `enter` and `escape` on their own work
|
|
13
|
+
* only while focus is in the card, so they never take a key from the composer.
|
|
14
|
+
*/
|
|
15
|
+
shortcut?: ApprovalShortcut;
|
|
10
16
|
};
|
|
17
|
+
export type ApprovalShortcut = 'mod+enter' | 'mod+backspace' | 'enter' | 'escape';
|
|
11
18
|
export type ApprovalAnswer = {
|
|
12
19
|
/** What was decided, in words: "Approved", "Declined". */
|
|
13
20
|
label: string;
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
// Initials sit on the person's own colour: dark enough for white text at every hue
|
|
23
23
|
initials: {
|
|
24
|
-
|
|
25
|
-
'linear-gradient(140deg, oklch(0.56 0.075 var(--narvi-avatar-hue, 255)), oklch(0.3 0.06 var(--narvi-avatar-hue, 255)))',
|
|
24
|
+
backgroundColor: 'oklch(0.44 0.07 var(--narvi-avatar-hue, 255))',
|
|
26
25
|
color: '#fff',
|
|
27
26
|
forcedColorAdjust: 'none'
|
|
28
27
|
},
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
display: 'inline-grid',
|
|
28
28
|
flexShrink: 0,
|
|
29
29
|
overflow: 'hidden',
|
|
30
|
-
borderRadius: radius.
|
|
30
|
+
borderRadius: radius.pill,
|
|
31
31
|
fontFamily: font.body,
|
|
32
32
|
fontWeight: font.weightSemibold,
|
|
33
33
|
lineHeight: 1,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
const sizes = stylex.create({
|
|
55
55
|
sm: { width: '1.5rem', height: '1.5rem', fontSize: '0.625rem' },
|
|
56
56
|
md: { width: '1.75rem', height: '1.75rem', fontSize: '0.6875rem' },
|
|
57
|
-
lg: { width: '2.25rem', height: '2.25rem', fontSize: font.
|
|
57
|
+
lg: { width: '2.25rem', height: '2.25rem', fontSize: font.sizeMeta },
|
|
58
58
|
xl: { width: '3.5rem', height: '3.5rem', fontSize: '1.125rem' }
|
|
59
59
|
});
|
|
60
60
|
|