@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,13 +1,14 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
A stand-in for content on its way. It breathes
|
|
3
|
-
|
|
4
|
-
that is loading with aria-busy instead.
|
|
2
|
+
A stand-in for content on its way. It breathes in a few stepped frames, and
|
|
3
|
+
only while it can be seen. It is hidden from assistive technology: mark the
|
|
4
|
+
region that is loading with aria-busy instead.
|
|
5
5
|
-->
|
|
6
6
|
<script lang="ts" module>
|
|
7
7
|
import * as stylex from '@stylexjs/stylex';
|
|
8
|
-
import { loop } from '../../internal/loop.js';
|
|
9
8
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
10
|
-
import {
|
|
9
|
+
import { whileVisible } from '../../internal/visible.js';
|
|
10
|
+
import { colors, play, radius } from '../../tokens.stylex.js';
|
|
11
|
+
import { media } from '../../media.stylex.js';
|
|
11
12
|
|
|
12
13
|
export type SkeletonProps = {
|
|
13
14
|
/** Lines of text to stand in for; the last is shorter. Leave out for one block. */
|
|
@@ -19,14 +20,24 @@
|
|
|
19
20
|
class?: string;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
// One breath for however many bars sit under it: long holds with short stepped ramps
|
|
24
|
+
// between, so the compositor draws a handful of frames a cycle
|
|
25
|
+
const breath = stylex.keyframes({
|
|
26
|
+
'0%, 42%': { opacity: 1, animationTimingFunction: 'steps(4)' },
|
|
27
|
+
'50%, 92%': { opacity: 0.55, animationTimingFunction: 'steps(4)' },
|
|
28
|
+
'100%': { opacity: 1 }
|
|
26
29
|
});
|
|
27
30
|
|
|
28
|
-
const
|
|
29
|
-
|
|
31
|
+
const styles = stylex.create({
|
|
32
|
+
breathes: {
|
|
33
|
+
animationName: { default: null, [media.motion]: breath },
|
|
34
|
+
animationDuration: '2.4s',
|
|
35
|
+
animationIterationCount: 'infinite',
|
|
36
|
+
animationPlayState: play.whileVisible
|
|
37
|
+
},
|
|
38
|
+
block: { display: 'block', borderRadius: radius.item, backgroundColor: colors.fillMuted },
|
|
39
|
+
lines: { display: 'flex', flexDirection: 'column', gap: '0.5em' },
|
|
40
|
+
line: { height: '0.8em', borderRadius: radius.chip, backgroundColor: colors.fillMuted }
|
|
30
41
|
});
|
|
31
42
|
</script>
|
|
32
43
|
|
|
@@ -38,9 +49,9 @@
|
|
|
38
49
|
<span
|
|
39
50
|
aria-hidden="true"
|
|
40
51
|
data-slot="skeleton"
|
|
41
|
-
{...attrs([styles.lines, sx], className)}
|
|
52
|
+
{...attrs([styles.lines, styles.breathes, sx], className)}
|
|
42
53
|
style:width
|
|
43
|
-
{@attach
|
|
54
|
+
{@attach whileVisible}
|
|
44
55
|
>
|
|
45
56
|
{#each { length: lines }, index (index)}
|
|
46
57
|
<span
|
|
@@ -53,9 +64,9 @@
|
|
|
53
64
|
<span
|
|
54
65
|
aria-hidden="true"
|
|
55
66
|
data-slot="skeleton"
|
|
56
|
-
{...attrs([styles.block, sx], className)}
|
|
67
|
+
{...attrs([styles.block, styles.breathes, sx], className)}
|
|
57
68
|
style:width
|
|
58
69
|
style:height
|
|
59
|
-
{@attach
|
|
70
|
+
{@attach whileVisible}
|
|
60
71
|
></span>
|
|
61
72
|
{/if}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { Slider } from 'bits-ui';
|
|
3
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
|
+
import { colors, motion, radius } from '../../tokens.stylex.js';
|
|
7
|
+
import { media } from '../../media.stylex.js';
|
|
8
|
+
|
|
9
|
+
export type SliderProps<T extends number | number[] = number> = Omit<
|
|
10
|
+
HTMLAttributes<HTMLSpanElement>,
|
|
11
|
+
'children' | 'dir'
|
|
12
|
+
> & {
|
|
13
|
+
/**
|
|
14
|
+
* Where the thumb stands. Bindable. A number gives one thumb; an array gives
|
|
15
|
+
* one thumb for each of its values, such as a range's two ends.
|
|
16
|
+
*/
|
|
17
|
+
value?: T;
|
|
18
|
+
/** Called as the value changes, while dragging and with each key press. */
|
|
19
|
+
onValueChange?: (value: T) => void;
|
|
20
|
+
/** Called once the person lets go, or with each key press: the moment to save. */
|
|
21
|
+
onValueCommit?: (value: T) => void;
|
|
22
|
+
min?: number;
|
|
23
|
+
max?: number;
|
|
24
|
+
/** How far one step goes, or the values it may stop at. */
|
|
25
|
+
step?: number | number[];
|
|
26
|
+
orientation?: 'horizontal' | 'vertical';
|
|
27
|
+
/** Set `rtl` in a right-to-left layout, so the slider runs from the right. */
|
|
28
|
+
dir?: 'ltr' | 'rtl';
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Names each thumb, for a slider of more than one: `['Minimum', 'Maximum']`.
|
|
32
|
+
* One thumb takes the slider's own `aria-label` or `aria-labelledby`.
|
|
33
|
+
*/
|
|
34
|
+
thumbLabels?: string[];
|
|
35
|
+
/** Reads a value out in words, such as `0:42` for a playhead or `40%`. */
|
|
36
|
+
format?: (value: number) => string;
|
|
37
|
+
sx?: Sx;
|
|
38
|
+
ref?: HTMLSpanElement | null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const DISABLED = ':is([data-disabled])';
|
|
42
|
+
const ACTIVE = ':is([data-active])';
|
|
43
|
+
|
|
44
|
+
const styles = stylex.create({
|
|
45
|
+
root: {
|
|
46
|
+
position: 'relative',
|
|
47
|
+
boxSizing: 'border-box',
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
flexShrink: 0,
|
|
51
|
+
touchAction: 'none',
|
|
52
|
+
userSelect: 'none',
|
|
53
|
+
WebkitUserSelect: 'none',
|
|
54
|
+
WebkitTapHighlightColor: 'transparent',
|
|
55
|
+
WebkitAppRegion: 'no-drag',
|
|
56
|
+
cursor: { default: 'pointer', [DISABLED]: 'not-allowed' },
|
|
57
|
+
opacity: { default: 1, [DISABLED]: 0.5 }
|
|
58
|
+
},
|
|
59
|
+
horizontal: { width: '100%', minWidth: '6rem', height: '1.5rem' },
|
|
60
|
+
vertical: {
|
|
61
|
+
flexDirection: 'column',
|
|
62
|
+
width: '1.5rem',
|
|
63
|
+
height: '100%',
|
|
64
|
+
minHeight: '6rem'
|
|
65
|
+
},
|
|
66
|
+
// A recess, like Progress's track
|
|
67
|
+
track: {
|
|
68
|
+
position: 'relative',
|
|
69
|
+
flexGrow: 1,
|
|
70
|
+
overflow: 'hidden',
|
|
71
|
+
borderRadius: radius.pill,
|
|
72
|
+
backgroundColor: colors.fillSunken,
|
|
73
|
+
outlineStyle: 'solid',
|
|
74
|
+
outlineWidth: '1px',
|
|
75
|
+
outlineColor: 'transparent',
|
|
76
|
+
outlineOffset: '-1px'
|
|
77
|
+
},
|
|
78
|
+
trackHorizontal: { height: '0.25rem' },
|
|
79
|
+
trackVertical: { width: '0.25rem' },
|
|
80
|
+
// How far along: lit with the accent, as progress is
|
|
81
|
+
range: {
|
|
82
|
+
backgroundColor: colors.accent,
|
|
83
|
+
// Forced colours drop a background colour, not an image
|
|
84
|
+
backgroundImage: {
|
|
85
|
+
default: 'none',
|
|
86
|
+
[media.forcedColors]: 'linear-gradient(Highlight, Highlight)'
|
|
87
|
+
},
|
|
88
|
+
forcedColorAdjust: 'none'
|
|
89
|
+
},
|
|
90
|
+
rangeHorizontal: { height: '100%' },
|
|
91
|
+
rangeVertical: { width: '100%' },
|
|
92
|
+
// Placed by bits-ui with `left` and `translate`, so a press grows it with `scale`
|
|
93
|
+
thumb: {
|
|
94
|
+
zIndex: 1,
|
|
95
|
+
boxSizing: 'border-box',
|
|
96
|
+
display: 'block',
|
|
97
|
+
width: '1rem',
|
|
98
|
+
height: '1rem',
|
|
99
|
+
borderRadius: radius.pill,
|
|
100
|
+
backgroundColor: { default: colors.thumb, [media.forcedColors]: 'ButtonText' },
|
|
101
|
+
boxShadow: {
|
|
102
|
+
default: `0 0 0 1px ${colors.borderStrong}`,
|
|
103
|
+
':hover': {
|
|
104
|
+
default: null,
|
|
105
|
+
[media.hover]: `0 0 0 1px ${colors.borderControlHover}`
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
forcedColorAdjust: 'none',
|
|
109
|
+
cursor: { default: 'grab', [ACTIVE]: 'grabbing', [DISABLED]: 'not-allowed' },
|
|
110
|
+
scale: { default: null, [media.motion]: { default: 1, [ACTIVE]: 1.15 } },
|
|
111
|
+
outlineStyle: 'solid',
|
|
112
|
+
outlineWidth: { default: '1px', ':focus-visible': '2px' },
|
|
113
|
+
outlineColor: {
|
|
114
|
+
default: 'transparent',
|
|
115
|
+
':focus-visible': { default: colors.focusRing, [media.forcedColors]: 'Highlight' }
|
|
116
|
+
},
|
|
117
|
+
outlineOffset: { default: '-1px', ':focus-visible': '2px' },
|
|
118
|
+
transitionProperty: { default: 'box-shadow', [media.motion]: 'scale, box-shadow' },
|
|
119
|
+
transitionDuration: motion.fast,
|
|
120
|
+
transitionTimingFunction: motion.easeOut,
|
|
121
|
+
// A 40px target for a finger, without changing the layout
|
|
122
|
+
'::after': {
|
|
123
|
+
content: '""',
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
inset: '-0.75rem',
|
|
126
|
+
borderRadius: radius.pill
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
<script lang="ts" generics="T extends number | number[] = number">
|
|
133
|
+
let {
|
|
134
|
+
value = $bindable(),
|
|
135
|
+
onValueChange,
|
|
136
|
+
onValueCommit,
|
|
137
|
+
min = 0,
|
|
138
|
+
max = 100,
|
|
139
|
+
step = 1,
|
|
140
|
+
orientation = 'horizontal',
|
|
141
|
+
dir = 'ltr',
|
|
142
|
+
disabled = false,
|
|
143
|
+
thumbLabels,
|
|
144
|
+
format,
|
|
145
|
+
'aria-label': ariaLabel,
|
|
146
|
+
'aria-labelledby': ariaLabelledby,
|
|
147
|
+
sx,
|
|
148
|
+
class: className,
|
|
149
|
+
ref = $bindable(null),
|
|
150
|
+
...rest
|
|
151
|
+
}: SliderProps<T> = $props();
|
|
152
|
+
|
|
153
|
+
const vertical = $derived(orientation === 'vertical');
|
|
154
|
+
|
|
155
|
+
// bits-ui types a single and a multiple slider apart; which one this is
|
|
156
|
+
// follows from the value it is given
|
|
157
|
+
const root = $derived({
|
|
158
|
+
type: Array.isArray(value) ? 'multiple' : 'single',
|
|
159
|
+
value,
|
|
160
|
+
onValueChange: (next: number | number[]) => {
|
|
161
|
+
value = next as T;
|
|
162
|
+
onValueChange?.(next as T);
|
|
163
|
+
},
|
|
164
|
+
onValueCommit: (next: number | number[]) => onValueCommit?.(next as T),
|
|
165
|
+
min,
|
|
166
|
+
max,
|
|
167
|
+
step,
|
|
168
|
+
orientation,
|
|
169
|
+
dir,
|
|
170
|
+
disabled
|
|
171
|
+
} as Slider.RootProps);
|
|
172
|
+
|
|
173
|
+
const valueAt = (index: number) =>
|
|
174
|
+
Array.isArray(value) ? (value[index] ?? min) : ((value as number | undefined) ?? min);
|
|
175
|
+
</script>
|
|
176
|
+
|
|
177
|
+
<Slider.Root
|
|
178
|
+
bind:ref
|
|
179
|
+
data-slot="slider"
|
|
180
|
+
{...root}
|
|
181
|
+
{...rest as Record<string, unknown>}
|
|
182
|
+
{...attrs([styles.root, vertical ? styles.vertical : styles.horizontal, sx], className)}
|
|
183
|
+
>
|
|
184
|
+
{#snippet children({ thumbItems })}
|
|
185
|
+
<span {...stylex.attrs(styles.track, vertical ? styles.trackVertical : styles.trackHorizontal)}>
|
|
186
|
+
<Slider.Range
|
|
187
|
+
{...stylex.attrs(styles.range, vertical ? styles.rangeVertical : styles.rangeHorizontal)}
|
|
188
|
+
/>
|
|
189
|
+
</span>
|
|
190
|
+
{#each thumbItems as thumb (thumb.index)}
|
|
191
|
+
<Slider.Thumb
|
|
192
|
+
index={thumb.index}
|
|
193
|
+
aria-label={thumbLabels?.[thumb.index] ?? ariaLabel}
|
|
194
|
+
aria-labelledby={thumbLabels?.[thumb.index] ? undefined : ariaLabelledby}
|
|
195
|
+
aria-valuetext={format?.(valueAt(thumb.index))}
|
|
196
|
+
{...stylex.attrs(styles.thumb)}
|
|
197
|
+
/>
|
|
198
|
+
{/each}
|
|
199
|
+
{/snippet}
|
|
200
|
+
</Slider.Root>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Slider } from 'bits-ui';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
export type SliderProps<T extends number | number[] = number> = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'dir'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Where the thumb stands. Bindable. A number gives one thumb; an array gives
|
|
7
|
+
* one thumb for each of its values, such as a range's two ends.
|
|
8
|
+
*/
|
|
9
|
+
value?: T;
|
|
10
|
+
/** Called as the value changes, while dragging and with each key press. */
|
|
11
|
+
onValueChange?: (value: T) => void;
|
|
12
|
+
/** Called once the person lets go, or with each key press: the moment to save. */
|
|
13
|
+
onValueCommit?: (value: T) => void;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
/** How far one step goes, or the values it may stop at. */
|
|
17
|
+
step?: number | number[];
|
|
18
|
+
orientation?: 'horizontal' | 'vertical';
|
|
19
|
+
/** Set `rtl` in a right-to-left layout, so the slider runs from the right. */
|
|
20
|
+
dir?: 'ltr' | 'rtl';
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Names each thumb, for a slider of more than one: `['Minimum', 'Maximum']`.
|
|
24
|
+
* One thumb takes the slider's own `aria-label` or `aria-labelledby`.
|
|
25
|
+
*/
|
|
26
|
+
thumbLabels?: string[];
|
|
27
|
+
/** Reads a value out in words, such as `0:42` for a playhead or `40%`. */
|
|
28
|
+
format?: (value: number) => string;
|
|
29
|
+
sx?: Sx;
|
|
30
|
+
ref?: HTMLSpanElement | null;
|
|
31
|
+
};
|
|
32
|
+
declare function $$render<T extends number | number[] = number>(): {
|
|
33
|
+
props: SliderProps<T>;
|
|
34
|
+
exports: {};
|
|
35
|
+
bindings: "value" | "ref";
|
|
36
|
+
slots: {};
|
|
37
|
+
events: {};
|
|
38
|
+
};
|
|
39
|
+
declare class __sveltets_Render<T extends number | number[] = number> {
|
|
40
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
41
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
42
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
43
|
+
bindings(): "value" | "ref";
|
|
44
|
+
exports(): {};
|
|
45
|
+
}
|
|
46
|
+
interface $$IsomorphicComponent {
|
|
47
|
+
new <T extends number | number[] = number>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
48
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
49
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
50
|
+
<T extends number | number[] = number>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
51
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
52
|
+
}
|
|
53
|
+
declare const Slider: $$IsomorphicComponent;
|
|
54
|
+
type Slider<T extends number | number[] = number> = InstanceType<typeof Slider<T>>;
|
|
55
|
+
export default Slider;
|
|
@@ -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 {
|
|
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
|
|
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
|
|
@@ -2,20 +2,35 @@
|
|
|
2
2
|
import * as stylex from '@stylexjs/stylex';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
|
+
import {
|
|
6
|
+
alignStyles,
|
|
7
|
+
directionStyles,
|
|
8
|
+
gapStyles,
|
|
9
|
+
justifyStyles,
|
|
10
|
+
wrapStyles,
|
|
11
|
+
type Align,
|
|
12
|
+
type Direction,
|
|
13
|
+
type Gap,
|
|
14
|
+
type Justify
|
|
15
|
+
} from '../../internal/layout.js';
|
|
16
|
+
import { responsive, type Responsive } from '../../internal/responsive.js';
|
|
5
17
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
|
-
import { space } from '../../tokens.stylex.js';
|
|
7
18
|
|
|
8
19
|
/** Steps on the 4px spacing scale: `4` is 16px. */
|
|
9
|
-
export type StackGap =
|
|
20
|
+
export type StackGap = Gap;
|
|
21
|
+
export type StackDirection = Direction;
|
|
22
|
+
export type StackAlign = Align;
|
|
23
|
+
export type StackJustify = Justify;
|
|
10
24
|
|
|
11
25
|
export type StackProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
12
26
|
/** Element to render. */
|
|
13
27
|
as?: 'div' | 'section' | 'article' | 'nav' | 'header' | 'footer' | 'main' | 'ul' | 'ol' | 'li';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
/** Main axis. Like every layout prop, a value or values by breakpoint. */
|
|
29
|
+
direction?: Responsive<StackDirection>;
|
|
30
|
+
gap?: Responsive<StackGap>;
|
|
31
|
+
align?: Responsive<StackAlign>;
|
|
32
|
+
justify?: Responsive<StackJustify>;
|
|
33
|
+
wrap?: Responsive<boolean>;
|
|
19
34
|
sx?: Sx;
|
|
20
35
|
children?: Snippet;
|
|
21
36
|
};
|
|
@@ -28,40 +43,10 @@
|
|
|
28
43
|
margin: 0,
|
|
29
44
|
padding: 0,
|
|
30
45
|
listStyleType: 'none'
|
|
31
|
-
}
|
|
32
|
-
column: { flexDirection: 'column' },
|
|
33
|
-
row: { flexDirection: 'row' },
|
|
34
|
-
wrap: { flexWrap: 'wrap' }
|
|
46
|
+
}
|
|
35
47
|
});
|
|
36
48
|
|
|
37
|
-
const
|
|
38
|
-
0: { gap: 0 },
|
|
39
|
-
1: { gap: space.x1 },
|
|
40
|
-
2: { gap: space.x2 },
|
|
41
|
-
3: { gap: space.x3 },
|
|
42
|
-
4: { gap: space.x4 },
|
|
43
|
-
5: { gap: space.x5 },
|
|
44
|
-
6: { gap: space.x6 },
|
|
45
|
-
8: { gap: space.x8 },
|
|
46
|
-
10: { gap: space.x10 },
|
|
47
|
-
12: { gap: space.x12 },
|
|
48
|
-
16: { gap: space.x16 }
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const aligns = stylex.create({
|
|
52
|
-
start: { alignItems: 'flex-start' },
|
|
53
|
-
center: { alignItems: 'center' },
|
|
54
|
-
end: { alignItems: 'flex-end' },
|
|
55
|
-
stretch: { alignItems: 'stretch' },
|
|
56
|
-
baseline: { alignItems: 'baseline' }
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const justifies = stylex.create({
|
|
60
|
-
start: { justifyContent: 'flex-start' },
|
|
61
|
-
center: { justifyContent: 'center' },
|
|
62
|
-
end: { justifyContent: 'flex-end' },
|
|
63
|
-
between: { justifyContent: 'space-between' }
|
|
64
|
-
});
|
|
49
|
+
const toWrap = (value: boolean) => (value ? 'wrap' : 'nowrap');
|
|
65
50
|
</script>
|
|
66
51
|
|
|
67
52
|
<script lang="ts">
|
|
@@ -77,6 +62,14 @@
|
|
|
77
62
|
children,
|
|
78
63
|
...rest
|
|
79
64
|
}: StackProps = $props();
|
|
65
|
+
|
|
66
|
+
// `wrap` is a boolean outside, and a keyword inside. A plain `false` adds no class, as before.
|
|
67
|
+
const wrapValue = $derived.by((): Responsive<'wrap' | 'nowrap'> | undefined => {
|
|
68
|
+
if (typeof wrap === 'boolean') return wrap ? 'wrap' : undefined;
|
|
69
|
+
return Object.fromEntries(
|
|
70
|
+
Object.entries(wrap).map(([at, value]) => [at, toWrap(value as boolean)])
|
|
71
|
+
);
|
|
72
|
+
});
|
|
80
73
|
</script>
|
|
81
74
|
|
|
82
75
|
<svelte:element
|
|
@@ -85,11 +78,11 @@
|
|
|
85
78
|
{...attrs(
|
|
86
79
|
[
|
|
87
80
|
styles.base,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
align
|
|
91
|
-
justify
|
|
92
|
-
|
|
81
|
+
responsive(direction, 'column', directionStyles),
|
|
82
|
+
responsive(gap, 4, gapStyles),
|
|
83
|
+
responsive(align, undefined, alignStyles),
|
|
84
|
+
responsive(justify, undefined, justifyStyles),
|
|
85
|
+
responsive(wrapValue, undefined, wrapStyles),
|
|
93
86
|
sx
|
|
94
87
|
],
|
|
95
88
|
className
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Align, type Direction, type Gap, type Justify } from '../../internal/layout.js';
|
|
4
|
+
import { type Responsive } from '../../internal/responsive.js';
|
|
3
5
|
import { type Sx } from '../../internal/sx.js';
|
|
4
6
|
/** Steps on the 4px spacing scale: `4` is 16px. */
|
|
5
|
-
export type StackGap =
|
|
7
|
+
export type StackGap = Gap;
|
|
8
|
+
export type StackDirection = Direction;
|
|
9
|
+
export type StackAlign = Align;
|
|
10
|
+
export type StackJustify = Justify;
|
|
6
11
|
export type StackProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
7
12
|
/** Element to render. */
|
|
8
13
|
as?: 'div' | 'section' | 'article' | 'nav' | 'header' | 'footer' | 'main' | 'ul' | 'ol' | 'li';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
/** Main axis. Like every layout prop, a value or values by breakpoint. */
|
|
15
|
+
direction?: Responsive<StackDirection>;
|
|
16
|
+
gap?: Responsive<StackGap>;
|
|
17
|
+
align?: Responsive<StackAlign>;
|
|
18
|
+
justify?: Responsive<StackJustify>;
|
|
19
|
+
wrap?: Responsive<boolean>;
|
|
14
20
|
sx?: Sx;
|
|
15
21
|
children?: Snippet;
|
|
16
22
|
};
|
|
@@ -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.
|
|
39
|
+
working: { color: colors.accent },
|
|
40
40
|
waiting: { color: colors.warning },
|
|
41
41
|
done: { color: colors.success },
|
|
42
42
|
failed: { color: colors.danger },
|
|
@@ -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, motion, radius } from '../../tokens.stylex.js';
|
|
8
|
+
import { media } from '../../media.stylex.js';
|
|
8
9
|
import { getSuggestionsContext } from './context.js';
|
|
9
10
|
|
|
10
11
|
export type SuggestionsItemProps = Omit<HTMLButtonAttributes, 'children' | 'value'> & {
|
|
@@ -16,9 +17,6 @@
|
|
|
16
17
|
children?: Snippet;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
20
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
21
|
-
|
|
22
20
|
// They rise into place one after another, the first time they are shown
|
|
23
21
|
const arrive = stylex.keyframes({
|
|
24
22
|
from: { opacity: 0, translate: '0 6px' },
|
|
@@ -39,36 +37,36 @@
|
|
|
39
37
|
margin: 0,
|
|
40
38
|
paddingInline: '0.75rem',
|
|
41
39
|
borderWidth: 0,
|
|
42
|
-
borderRadius: `calc(${radius.
|
|
40
|
+
borderRadius: `calc(${radius.card} * 4 / 3)`,
|
|
43
41
|
backgroundColor: {
|
|
44
|
-
default:
|
|
45
|
-
':hover': { default: null, [
|
|
42
|
+
default: 'transparent',
|
|
43
|
+
':hover': { default: null, [media.hover]: colors.fillHover }
|
|
46
44
|
},
|
|
47
|
-
boxShadow: `inset 0 0 0 1px ${colors.
|
|
45
|
+
boxShadow: `inset 0 0 0 1px ${colors.border}`,
|
|
48
46
|
color: {
|
|
49
47
|
default: colors.textMuted,
|
|
50
|
-
':hover': { default: null, [
|
|
48
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
51
49
|
},
|
|
52
50
|
fontFamily: 'inherit',
|
|
53
|
-
fontSize: font.
|
|
51
|
+
fontSize: font.sizeMeta,
|
|
54
52
|
fontWeight: font.weightMedium,
|
|
55
53
|
lineHeight: 1,
|
|
56
54
|
whiteSpace: 'nowrap',
|
|
57
55
|
cursor: 'pointer',
|
|
58
56
|
WebkitTapHighlightColor: 'transparent',
|
|
59
|
-
animationName: { default: fade, [
|
|
57
|
+
animationName: { default: fade, [media.motion]: arrive },
|
|
60
58
|
animationDuration: motion.slow,
|
|
61
59
|
animationTimingFunction: motion.easeOut,
|
|
62
60
|
animationFillMode: 'backwards',
|
|
63
61
|
// Capped, so a long list does not keep the last ones waiting
|
|
64
62
|
animationDelay: 'calc(min(var(--narvi-suggestion-index, 0), 6) * 40ms)',
|
|
65
|
-
scale: { default: null, ':active': { default: null, [
|
|
63
|
+
scale: { default: null, ':active': { default: null, [media.motion]: 0.97 } },
|
|
66
64
|
transitionProperty: {
|
|
67
65
|
default: 'background-color, color',
|
|
68
|
-
[
|
|
66
|
+
[media.motion]: 'scale, background-color, color'
|
|
69
67
|
},
|
|
70
68
|
transitionDuration: motion.base,
|
|
71
|
-
transitionTimingFunction: { default: 'ease', [
|
|
69
|
+
transitionTimingFunction: { default: 'ease', [media.motion]: `${motion.easeOut}, ease, ease` }
|
|
72
70
|
}
|
|
73
71
|
});
|
|
74
72
|
</script>
|