@diegopluna/narvi 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -41
- package/dist/base.css +2 -2
- 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 +3 -3
- 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 -16
- 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 +37 -61
- 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 +91 -19
- 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 +219 -40
- package/dist/components/button/Button.svelte.d.ts +38 -2
- package/dist/components/card/Card.svelte +15 -26
- package/dist/components/change-stats/ChangeStats.svelte +1 -2
- package/dist/components/changes-summary/ChangesSummary.svelte +14 -15
- package/dist/components/checkbox/Checkbox.svelte +18 -15
- package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
- package/dist/components/code/Code.svelte +1 -2
- package/dist/components/collapsible/CollapsibleTrigger.svelte +2 -2
- package/dist/components/command/CommandItem.svelte +1 -1
- package/dist/components/command/styles.d.ts +3 -2
- package/dist/components/command/styles.js +13 -10
- package/dist/components/composer/ComposerAttachButton.svelte +1 -1
- package/dist/components/composer/ComposerAttachment.svelte +9 -12
- package/dist/components/composer/ComposerModelPicker.svelte +18 -20
- package/dist/components/composer/ComposerRoot.svelte +8 -7
- package/dist/components/composer/ComposerSubmit.svelte +8 -15
- package/dist/components/composer/ComposerTextarea.svelte +1 -1
- package/dist/components/composer/ComposerToggle.svelte +9 -11
- 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 +3 -3
- package/dist/components/dialog/ConfirmDialog.svelte +1 -1
- package/dist/components/dialog/styles.d.ts +2 -3
- package/dist/components/dialog/styles.js +5 -6
- 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/heading/Heading.svelte +2 -2
- package/dist/components/kbd/Kbd.svelte +12 -7
- package/dist/components/link/Link.svelte +7 -3
- 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 +22 -2
- package/dist/components/message/MessageAction.svelte.d.ts +9 -0
- package/dist/components/message/MessageContent.svelte +2 -3
- package/dist/components/message/MessageCopy.svelte +62 -3
- 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/MessageTime.svelte +1 -1
- package/dist/components/notice/Notice.svelte +14 -10
- package/dist/components/plan/Plan.svelte +22 -17
- package/dist/components/progress/Progress.svelte +31 -33
- package/dist/components/questionnaire/Questionnaire.svelte +19 -22
- package/dist/components/queued-message/QueuedMessage.svelte +14 -7
- package/dist/components/rail/RailItem.svelte +37 -34
- 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 +2 -2
- package/dist/components/resize-handle/ResizeHandle.svelte +2 -3
- package/dist/components/segmented/SegmentedControl.svelte +7 -8
- 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/shimmer/Shimmer.svelte +34 -21
- 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 +36 -32
- 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 +26 -32
- 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 +11 -10
- package/dist/components/spinner/Spinner.svelte +4 -11
- package/dist/components/status-indicator/StatusIndicator.svelte +1 -1
- package/dist/components/suggestions/SuggestionsItem.svelte +5 -5
- package/dist/components/switch/Switch.svelte +9 -14
- 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 +13 -9
- package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
- package/dist/components/text/Text.svelte +31 -23
- package/dist/components/text/Text.svelte.d.ts +8 -4
- package/dist/components/toast/Toaster.svelte +5 -5
- package/dist/components/tool/ToolContent.svelte +3 -8
- package/dist/components/tool/ToolSection.svelte +4 -5
- package/dist/components/tool/ToolTrigger.svelte +10 -9
- package/dist/components/tooltip/TooltipContent.svelte +3 -3
- package/dist/components/work-fold/WorkFold.svelte +5 -9
- package/dist/index.d.ts +16 -8
- package/dist/index.js +17 -10
- package/dist/internal/Code.svelte +3 -4
- 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 +20 -17
- package/dist/internal/layer.d.ts +3 -5
- package/dist/internal/layer.js +10 -12
- 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/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 +1 -1
- package/dist/internal/toggle.d.ts +1 -2
- package/dist/internal/toggle.js +8 -12
- 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/preset.d.ts +40 -16
- package/dist/preset.js +169 -51
- package/dist/tokens.stylex.d.ts +55 -37
- package/dist/tokens.stylex.js +107 -62
- package/dist/typography.d.ts +48 -0
- package/dist/typography.js +55 -0
- package/dist/vite.d.ts +7 -1
- package/dist/vite.js +27 -2
- package/package.json +53 -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,57 +1,37 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
runs, green when it went through, red when it did not. It is opaque, so the
|
|
5
|
-
rail that joins the rows passes behind it.
|
|
2
|
+
The icon at the start of a row in the agent's timeline. Its colour says where the row
|
|
3
|
+
stands: the accent while it runs, green when it went through, red when it did not.
|
|
6
4
|
-->
|
|
7
5
|
<script lang="ts" module>
|
|
8
6
|
import * as stylex from '@stylexjs/stylex';
|
|
9
7
|
import type { Snippet } from 'svelte';
|
|
10
8
|
import Glyph, { type GlyphName } from './Glyph.svelte';
|
|
11
9
|
import type { Sx } from './sx.js';
|
|
12
|
-
import { colors, motion
|
|
10
|
+
import { colors, motion } from '../tokens.stylex.js';
|
|
13
11
|
|
|
14
12
|
export type TileTone = 'neutral' | 'live' | 'success' | 'warning' | 'danger';
|
|
15
13
|
|
|
16
14
|
const styles = stylex.create({
|
|
15
|
+
// No box: the icon alone, in the colour of where the row stands. It is as wide as
|
|
16
|
+
// its glyph, so the icon starts on the edge the text above and below starts on, and
|
|
17
|
+
// as tall as the row, so what follows it lines up from row to row.
|
|
17
18
|
tile: {
|
|
18
19
|
position: 'relative',
|
|
19
|
-
boxSizing: 'border-box',
|
|
20
20
|
display: 'grid',
|
|
21
21
|
placeItems: 'center',
|
|
22
22
|
flexShrink: 0,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
transitionProperty: 'color, box-shadow, background-image',
|
|
23
|
+
color: colors.textSubtle,
|
|
24
|
+
transitionProperty: 'color',
|
|
26
25
|
transitionDuration: motion.slow,
|
|
27
26
|
transitionTimingFunction: 'ease'
|
|
28
27
|
},
|
|
29
|
-
md: { width: '
|
|
30
|
-
sm: { width: '
|
|
31
|
-
neutral: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
color: colors.ithil,
|
|
37
|
-
backgroundImage: `linear-gradient(${colors.ithilSoft}, ${colors.ithilSoft})`,
|
|
38
|
-
boxShadow: `inset 0 0 0 1px color-mix(in oklab, ${colors.ithil} 38%, transparent), 0 0 12px ${colors.glow}`
|
|
39
|
-
},
|
|
40
|
-
success: {
|
|
41
|
-
color: colors.success,
|
|
42
|
-
backgroundImage: `linear-gradient(${colors.successSoft}, ${colors.successSoft})`,
|
|
43
|
-
boxShadow: `inset 0 0 0 1px color-mix(in oklab, ${colors.success} 30%, transparent)`
|
|
44
|
-
},
|
|
45
|
-
warning: {
|
|
46
|
-
color: colors.warning,
|
|
47
|
-
backgroundImage: `linear-gradient(${colors.warningSoft}, ${colors.warningSoft})`,
|
|
48
|
-
boxShadow: `inset 0 0 0 1px color-mix(in oklab, ${colors.warning} 32%, transparent)`
|
|
49
|
-
},
|
|
50
|
-
danger: {
|
|
51
|
-
color: colors.danger,
|
|
52
|
-
backgroundImage: `linear-gradient(${colors.dangerSoft}, ${colors.dangerSoft})`,
|
|
53
|
-
boxShadow: `inset 0 0 0 1px color-mix(in oklab, ${colors.danger} 32%, transparent)`
|
|
54
|
-
}
|
|
28
|
+
md: { width: '1rem', height: '1.5rem' },
|
|
29
|
+
sm: { width: '1rem', height: '1.25rem' },
|
|
30
|
+
neutral: {},
|
|
31
|
+
live: { color: colors.accent },
|
|
32
|
+
success: { color: colors.success },
|
|
33
|
+
warning: { color: colors.warning },
|
|
34
|
+
danger: { color: colors.danger }
|
|
55
35
|
});
|
|
56
36
|
</script>
|
|
57
37
|
|
|
@@ -80,7 +60,7 @@
|
|
|
80
60
|
>
|
|
81
61
|
{#if glyph}<Glyph
|
|
82
62
|
name={glyph}
|
|
83
|
-
size={size === 'md' ?
|
|
84
|
-
stroke={1.
|
|
63
|
+
size={size === 'md' ? 16 : 14}
|
|
64
|
+
stroke={1.5}
|
|
85
65
|
/>{:else}{@render children?.()}{/if}
|
|
86
66
|
</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
|
-
/** Shared look for text-entry controls: Input and Textarea. A
|
|
2
|
+
/** Shared look for text-entry controls: Input and Textarea. A 3:1 edge, and nothing behind it. */
|
|
3
3
|
export declare const control: Readonly<{
|
|
4
4
|
readonly base: Readonly<{
|
|
5
5
|
readonly WebkitAppRegion: stylex.StyleXClassNameFor<"WebkitAppRegion", "no-drag">;
|
|
@@ -13,8 +13,8 @@ export declare const control: Readonly<{
|
|
|
13
13
|
readonly borderStyle: stylex.StyleXClassNameFor<"borderStyle", "solid">;
|
|
14
14
|
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", string | null>;
|
|
15
15
|
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
16
|
-
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor",
|
|
17
|
-
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow",
|
|
16
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "transparent">;
|
|
17
|
+
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", "none" | `inset 0 0 0 0.5px ${stylex.StyleXVar<string>}, 0 0 0 3px ${stylex.StyleXVar<string>}`>;
|
|
18
18
|
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
19
19
|
readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
|
|
20
20
|
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
@@ -36,7 +36,7 @@ export declare const control: Readonly<{
|
|
|
36
36
|
}>;
|
|
37
37
|
readonly invalid: Readonly<{
|
|
38
38
|
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", string>;
|
|
39
|
-
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow",
|
|
39
|
+
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", "none" | `inset 0 0 0 0.5px ${stylex.StyleXVar<string>}, 0 0 0 3px color-mix(in oklab, ${stylex.StyleXVar<string>} 22%, transparent)`>;
|
|
40
40
|
}>;
|
|
41
41
|
readonly sm: Readonly<{
|
|
42
42
|
readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "28px">;
|
package/dist/internal/control.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
2
|
import { colors, font, motion, radius } from '../tokens.stylex.js';
|
|
3
3
|
import { media } from '../media.stylex.js';
|
|
4
|
-
|
|
4
|
+
// Hover and focus as they happen, or as the catalog shows them without a pointer or a keyboard
|
|
5
|
+
const HOVER = ':is(:hover, [data-preview~="hover"])';
|
|
6
|
+
const FOCUS = ':is(:focus-visible, [data-preview~="focus"])';
|
|
7
|
+
/** Shared look for text-entry controls: Input and Textarea. A 3:1 edge, and nothing behind it. */
|
|
5
8
|
export const control = stylex.create({
|
|
6
9
|
base: {
|
|
7
10
|
// A field in an Electron title bar takes clicks instead of dragging the window
|
|
@@ -15,20 +18,20 @@ export const control = stylex.create({
|
|
|
15
18
|
borderWidth: '1px',
|
|
16
19
|
borderStyle: 'solid',
|
|
17
20
|
borderColor: {
|
|
18
|
-
default: colors.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
default: colors.borderControl,
|
|
22
|
+
[HOVER]: { default: null, [media.hover]: colors.borderControlHover },
|
|
23
|
+
[FOCUS]: colors.focusRing
|
|
21
24
|
},
|
|
22
|
-
borderRadius: radius.
|
|
23
|
-
backgroundColor:
|
|
25
|
+
borderRadius: radius.control,
|
|
26
|
+
backgroundColor: 'transparent',
|
|
24
27
|
boxShadow: {
|
|
25
|
-
default:
|
|
26
|
-
|
|
28
|
+
default: 'none',
|
|
29
|
+
[FOCUS]: `inset 0 0 0 0.5px ${colors.focusRing}, 0 0 0 3px ${colors.focusHalo}`
|
|
27
30
|
},
|
|
28
31
|
color: colors.text,
|
|
29
32
|
fontFamily: font.body,
|
|
30
33
|
// 16px on touch devices stops iOS from zooming the page on focus
|
|
31
|
-
fontSize: { default: font.
|
|
34
|
+
fontSize: { default: font.sizeBody, [media.coarse]: font.sizeReading },
|
|
32
35
|
lineHeight: font.leadingSnug,
|
|
33
36
|
appearance: 'none',
|
|
34
37
|
opacity: { default: 1, ':disabled': 0.5 },
|
|
@@ -36,12 +39,12 @@ export const control = stylex.create({
|
|
|
36
39
|
// Invisible normally; in forced-colours mode it is the focus indicator
|
|
37
40
|
outlineStyle: 'solid',
|
|
38
41
|
outlineColor: 'transparent',
|
|
39
|
-
outlineWidth: { default: 0,
|
|
42
|
+
outlineWidth: { default: 0, [FOCUS]: '2px' },
|
|
40
43
|
outlineOffset: '-2px',
|
|
41
44
|
// Only the hover colour eases. Focus is often reached with Tab, and a ring
|
|
42
45
|
// that fades in after a key press feels late, so it appears at once.
|
|
43
46
|
transitionProperty: 'border-color',
|
|
44
|
-
transitionDuration: { default: motion.base,
|
|
47
|
+
transitionDuration: { default: motion.base, [FOCUS]: '0ms' },
|
|
45
48
|
transitionTimingFunction: 'ease',
|
|
46
49
|
'::placeholder': {
|
|
47
50
|
color: colors.textSubtle,
|
|
@@ -51,15 +54,15 @@ export const control = stylex.create({
|
|
|
51
54
|
invalid: {
|
|
52
55
|
borderColor: colors.danger,
|
|
53
56
|
boxShadow: {
|
|
54
|
-
default:
|
|
55
|
-
|
|
57
|
+
default: 'none',
|
|
58
|
+
[FOCUS]: `inset 0 0 0 0.5px ${colors.danger}, 0 0 0 3px color-mix(in oklab, ${colors.danger} 22%, transparent)`
|
|
56
59
|
}
|
|
57
60
|
},
|
|
58
61
|
sm: {
|
|
59
62
|
minHeight: '28px',
|
|
60
63
|
paddingInline: '8px',
|
|
61
|
-
borderRadius: radius.
|
|
62
|
-
fontSize: { default: font.
|
|
64
|
+
borderRadius: radius.item,
|
|
65
|
+
fontSize: { default: font.sizeMeta, [media.coarse]: font.sizeReading }
|
|
63
66
|
},
|
|
64
67
|
md: {
|
|
65
68
|
minHeight: '34px',
|
|
@@ -68,7 +71,7 @@ export const control = stylex.create({
|
|
|
68
71
|
lg: {
|
|
69
72
|
minHeight: '40px',
|
|
70
73
|
paddingInline: '12px',
|
|
71
|
-
borderRadius: radius.
|
|
72
|
-
fontSize: font.
|
|
74
|
+
borderRadius: radius.panel,
|
|
75
|
+
fontSize: font.sizeReading
|
|
73
76
|
}
|
|
74
77
|
});
|
package/dist/internal/layer.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const layer: Readonly<{
|
|
|
18
18
|
readonly padding: stylex.StyleXClassNameFor<"padding", "0.25rem">;
|
|
19
19
|
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
20
20
|
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
|
|
21
|
-
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", `inset 0 0 0 1px ${stylex.StyleXVar<string>},
|
|
21
|
+
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", `inset 0 0 0 1px ${stylex.StyleXVar<string>}, 0 16px 40px -12px ${stylex.StyleXVar<string>}`>;
|
|
22
22
|
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
23
23
|
readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
|
|
24
24
|
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
@@ -86,10 +86,8 @@ export declare const layer: Readonly<{
|
|
|
86
86
|
readonly paddingBottom: stylex.StyleXClassNameFor<"paddingBottom", "0.25rem">;
|
|
87
87
|
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.5rem">;
|
|
88
88
|
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
91
|
-
readonly letterSpacing: stylex.StyleXClassNameFor<"letterSpacing", "0.04em">;
|
|
92
|
-
readonly textTransform: stylex.StyleXClassNameFor<"textTransform", "uppercase">;
|
|
89
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
90
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", "500">;
|
|
93
91
|
}>;
|
|
94
92
|
readonly separator: Readonly<{
|
|
95
93
|
readonly height: stylex.StyleXClassNameFor<"height", "1px">;
|
package/dist/internal/layer.js
CHANGED
|
@@ -23,12 +23,12 @@ export const layer = stylex.create({
|
|
|
23
23
|
overscrollBehavior: 'contain',
|
|
24
24
|
padding: '0.25rem',
|
|
25
25
|
// Items are 8px round inside 4px of padding: 12px outside
|
|
26
|
-
borderRadius: radius.
|
|
26
|
+
borderRadius: radius.card,
|
|
27
27
|
backgroundColor: colors.bgRaised,
|
|
28
|
-
boxShadow: `inset 0 0 0 1px ${colors.
|
|
28
|
+
boxShadow: `inset 0 0 0 1px ${colors.borderStrong}, 0 16px 40px -12px ${colors.shadow}`,
|
|
29
29
|
color: colors.text,
|
|
30
30
|
fontFamily: font.body,
|
|
31
|
-
fontSize: font.
|
|
31
|
+
fontSize: font.sizeBody,
|
|
32
32
|
lineHeight: font.leadingSnug,
|
|
33
33
|
scrollbarWidth: 'thin',
|
|
34
34
|
outlineStyle: 'solid',
|
|
@@ -54,7 +54,7 @@ export const layer = stylex.create({
|
|
|
54
54
|
minHeight: '2rem',
|
|
55
55
|
paddingBlock: '0.375rem',
|
|
56
56
|
paddingInline: '0.5rem',
|
|
57
|
-
borderRadius: radius.
|
|
57
|
+
borderRadius: radius.control,
|
|
58
58
|
color: { default: colors.text, [DISABLED]: colors.textSubtle },
|
|
59
59
|
cursor: { default: 'default', [DISABLED]: 'not-allowed' },
|
|
60
60
|
userSelect: 'none',
|
|
@@ -63,7 +63,7 @@ export const layer = stylex.create({
|
|
|
63
63
|
// row, so it moves at once
|
|
64
64
|
backgroundColor: {
|
|
65
65
|
default: 'transparent',
|
|
66
|
-
[HIGHLIGHTED]: { default: colors.
|
|
66
|
+
[HIGHLIGHTED]: { default: colors.fillHover, [media.forcedColors]: 'Highlight' }
|
|
67
67
|
},
|
|
68
68
|
forcedColorAdjust: 'none'
|
|
69
69
|
},
|
|
@@ -99,7 +99,7 @@ export const layer = stylex.create({
|
|
|
99
99
|
marginInlineStart: 'auto',
|
|
100
100
|
paddingInlineStart: '1rem',
|
|
101
101
|
color: colors.textSubtle,
|
|
102
|
-
fontSize: font.
|
|
102
|
+
fontSize: font.sizeCaption,
|
|
103
103
|
fontVariantNumeric: 'tabular-nums'
|
|
104
104
|
},
|
|
105
105
|
heading: {
|
|
@@ -107,21 +107,19 @@ export const layer = stylex.create({
|
|
|
107
107
|
paddingBottom: '0.25rem',
|
|
108
108
|
paddingInline: '0.5rem',
|
|
109
109
|
color: colors.textSubtle,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
letterSpacing: '0.04em',
|
|
113
|
-
textTransform: 'uppercase'
|
|
110
|
+
fontSize: font.sizeCaption,
|
|
111
|
+
fontWeight: '500'
|
|
114
112
|
},
|
|
115
113
|
separator: {
|
|
116
114
|
height: '1px',
|
|
117
115
|
marginBlock: '0.25rem',
|
|
118
116
|
marginInline: '-0.25rem',
|
|
119
|
-
backgroundColor: colors.
|
|
117
|
+
backgroundColor: colors.border
|
|
120
118
|
},
|
|
121
119
|
hoverable: {
|
|
122
120
|
backgroundColor: {
|
|
123
121
|
default: 'transparent',
|
|
124
|
-
':hover': { default: null, [media.hover]: colors.
|
|
122
|
+
':hover': { default: null, [media.hover]: colors.fillHover }
|
|
125
123
|
}
|
|
126
124
|
}
|
|
127
125
|
});
|
|
@@ -8,7 +8,15 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
8
8
|
export declare const messageMarker: Readonly<{
|
|
9
9
|
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
10
10
|
}>;
|
|
11
|
+
/** Placed around a Markdown table, so its copy button appears while the table is hovered or holds focus. */
|
|
12
|
+
export declare const markdownTableMarker: Readonly<{
|
|
13
|
+
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
14
|
+
}>;
|
|
11
15
|
/** Placed on Sidebar.Item, so its actions appear and its trailing note steps aside on hover. */
|
|
12
16
|
export declare const sidebarItemMarker: Readonly<{
|
|
13
17
|
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
14
18
|
}>;
|
|
19
|
+
/** A tab of a TabStrip: its close button shows while the pointer or focus is in the tab. */
|
|
20
|
+
export declare const tabStripTabMarker: Readonly<{
|
|
21
|
+
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
22
|
+
}>;
|
|
@@ -6,5 +6,9 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
6
6
|
*/
|
|
7
7
|
/** Placed on Message.Root, so its actions can appear while the message is hovered. */
|
|
8
8
|
export const messageMarker = stylex.defineMarker();
|
|
9
|
+
/** Placed around a Markdown table, so its copy button appears while the table is hovered or holds focus. */
|
|
10
|
+
export const markdownTableMarker = stylex.defineMarker();
|
|
9
11
|
/** Placed on Sidebar.Item, so its actions appear and its trailing note steps aside on hover. */
|
|
10
12
|
export const sidebarItemMarker = stylex.defineMarker();
|
|
13
|
+
/** A tab of a TabStrip: its close button shows while the pointer or focus is in the tab. */
|
|
14
|
+
export const tabStripTabMarker = stylex.defineMarker();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws when `narvi()` is listed before the Svelte plugin. It would then be handed raw
|
|
3
|
+
* `.svelte` source, and the build would stop at StyleX's parser with "Unexpected token" in
|
|
4
|
+
* every component, which says nothing about the cause.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertAfterSvelte(plugins: ReadonlyArray<{
|
|
7
|
+
name: string;
|
|
8
|
+
}>, self: unknown): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** What the Svelte plugin calls the step that compiles `.svelte` files. Older versions have one plugin for everything. */
|
|
2
|
+
const SVELTE_COMPILE = ['vite-plugin-svelte:compile', 'vite-plugin-svelte'];
|
|
3
|
+
/**
|
|
4
|
+
* Throws when `narvi()` is listed before the Svelte plugin. It would then be handed raw
|
|
5
|
+
* `.svelte` source, and the build would stop at StyleX's parser with "Unexpected token" in
|
|
6
|
+
* every component, which says nothing about the cause.
|
|
7
|
+
*/
|
|
8
|
+
export function assertAfterSvelte(plugins, self) {
|
|
9
|
+
const own = plugins.indexOf(self);
|
|
10
|
+
const svelte = SVELTE_COMPILE.map((name) => plugins.findIndex((plugin) => plugin.name === name)).find((index) => index >= 0);
|
|
11
|
+
if (own < 0 || svelte === undefined || own > svelte)
|
|
12
|
+
return;
|
|
13
|
+
throw new Error('[narvi] narvi() is listed before the Svelte plugin. Move it after sveltekit(), or after svelte() in a plain Vite app:\n\n' +
|
|
14
|
+
' plugins: [sveltekit(), narvi()]\n\n' +
|
|
15
|
+
'It compiles the styles in components the Svelte compiler has already processed.');
|
|
16
|
+
}
|
package/dist/internal/roving.js
CHANGED
|
@@ -3,7 +3,10 @@ const isTyping = (target) => target instanceof HTMLElement &&
|
|
|
3
3
|
export function roving({ selector, orientation = 'vertical' }) {
|
|
4
4
|
return (container) => {
|
|
5
5
|
let last = null;
|
|
6
|
-
const items = () => [...container.querySelectorAll(selector)].filter((item) => !item.hasAttribute('disabled') &&
|
|
6
|
+
const items = () => [...container.querySelectorAll(selector)].filter((item) => !item.hasAttribute('disabled') &&
|
|
7
|
+
item.getClientRects().length > 0 &&
|
|
8
|
+
// Folded away: still laid out, but inert, so focus would not take
|
|
9
|
+
!item.closest('[inert]'));
|
|
7
10
|
const settle = () => {
|
|
8
11
|
const all = items();
|
|
9
12
|
const stop = (last && all.includes(last) && last) ||
|
|
@@ -54,7 +57,7 @@ export function roving({ selector, orientation = 'vertical' }) {
|
|
|
54
57
|
childList: true,
|
|
55
58
|
subtree: true,
|
|
56
59
|
attributes: true,
|
|
57
|
-
attributeFilter: ['aria-current', 'disabled', 'hidden']
|
|
60
|
+
attributeFilter: ['aria-current', 'disabled', 'hidden', 'inert']
|
|
58
61
|
});
|
|
59
62
|
container.addEventListener('focusin', onfocusin);
|
|
60
63
|
container.addEventListener('keydown', onkeydown);
|
|
@@ -11,6 +11,13 @@ export declare const shared: Readonly<{
|
|
|
11
11
|
readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "2px" | "-1px">;
|
|
12
12
|
readonly WebkitAppRegion: stylex.StyleXClassNameFor<"WebkitAppRegion", "no-drag">;
|
|
13
13
|
}>;
|
|
14
|
+
readonly spin: Readonly<{
|
|
15
|
+
readonly animationName: stylex.StyleXClassNameFor<"animationName", string>;
|
|
16
|
+
readonly animationDuration: stylex.StyleXClassNameFor<"animationDuration", "600ms" | "2.4s">;
|
|
17
|
+
readonly animationTimingFunction: stylex.StyleXClassNameFor<"animationTimingFunction", "linear">;
|
|
18
|
+
readonly animationIterationCount: stylex.StyleXClassNameFor<"animationIterationCount", "infinite">;
|
|
19
|
+
readonly animationPlayState: stylex.StyleXClassNameFor<"animationPlayState", string>;
|
|
20
|
+
}>;
|
|
14
21
|
readonly dragRegion: Readonly<{
|
|
15
22
|
readonly WebkitAppRegion: stylex.StyleXClassNameFor<"WebkitAppRegion", "drag">;
|
|
16
23
|
readonly WebkitUserSelect: stylex.StyleXClassNameFor<"WebkitUserSelect", "none">;
|
|
@@ -22,7 +29,7 @@ export declare const shared: Readonly<{
|
|
|
22
29
|
readonly eyebrow: Readonly<{
|
|
23
30
|
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
24
31
|
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
25
|
-
readonly fontSize: stylex.StyleXClassNameFor<"fontSize",
|
|
32
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
26
33
|
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", "500">;
|
|
27
34
|
readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", 1.2>;
|
|
28
35
|
readonly fontVariantNumeric: stylex.StyleXClassNameFor<"fontVariantNumeric", "tabular-nums">;
|
package/dist/internal/shared.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
|
-
import { colors } from '../tokens.stylex.js';
|
|
2
|
+
import { colors, font, play } from '../tokens.stylex.js';
|
|
3
|
+
import { media } from '../media.stylex.js';
|
|
4
|
+
const turn = stylex.keyframes({ to: { rotate: '1turn' } });
|
|
5
|
+
// Focus as the keyboard gives it, or as the catalog shows it without a keyboard
|
|
6
|
+
const FOCUS = ':is(:focus-visible, [data-preview~="focus"])';
|
|
3
7
|
/**
|
|
4
8
|
* Edges in Narvi are drawn with shadows, which forced-colours mode removes.
|
|
5
9
|
* A transparent outline costs nothing normally and becomes the edge there.
|
|
@@ -8,13 +12,25 @@ export const shared = stylex.create({
|
|
|
8
12
|
// For anything that can take focus: the same outline turns into the focus ring.
|
|
9
13
|
focusable: {
|
|
10
14
|
outlineStyle: 'solid',
|
|
11
|
-
outlineWidth: { default: '1px',
|
|
12
|
-
outlineColor: { default: 'transparent',
|
|
13
|
-
outlineOffset: { default: '-1px',
|
|
15
|
+
outlineWidth: { default: '1px', [FOCUS]: '2px' },
|
|
16
|
+
outlineColor: { default: 'transparent', [FOCUS]: colors.focusRing },
|
|
17
|
+
outlineOffset: { default: '-1px', [FOCUS]: '2px' },
|
|
14
18
|
// In an Electron title bar, a control must not drag the window: it would
|
|
15
19
|
// never receive the click. Ignored everywhere else.
|
|
16
20
|
WebkitAppRegion: 'no-drag'
|
|
17
21
|
},
|
|
22
|
+
// A spinner's turn. It animates `rotate` and nothing else, so the compositor turns it,
|
|
23
|
+
// smoothly and at the display's rate, with no style or paint on the main thread. Narvi's
|
|
24
|
+
// other loops are stepped; a stepped spinner reads as slow. Slower, not still, for people
|
|
25
|
+
// who have asked for less motion: it still has to read as progress. Attach `whileVisible`
|
|
26
|
+
// to what takes this, so it turns only while it can be seen.
|
|
27
|
+
spin: {
|
|
28
|
+
animationName: turn,
|
|
29
|
+
animationDuration: { default: '2.4s', [media.motion]: '600ms' },
|
|
30
|
+
animationTimingFunction: 'linear',
|
|
31
|
+
animationIterationCount: 'infinite',
|
|
32
|
+
animationPlayState: play.whileVisible
|
|
33
|
+
},
|
|
18
34
|
// The parts of a window's title bar that drag the window, in Electron
|
|
19
35
|
dragRegion: {
|
|
20
36
|
WebkitAppRegion: 'drag',
|
|
@@ -29,7 +45,7 @@ export const shared = stylex.create({
|
|
|
29
45
|
eyebrow: {
|
|
30
46
|
margin: 0,
|
|
31
47
|
color: colors.textSubtle,
|
|
32
|
-
fontSize:
|
|
48
|
+
fontSize: font.sizeCaption,
|
|
33
49
|
fontWeight: '500',
|
|
34
50
|
lineHeight: 1.2,
|
|
35
51
|
fontVariantNumeric: 'tabular-nums'
|
package/dist/internal/sx.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StyleXArray, StyleXClassNameFor, StyleXStyles } from '@stylexjs/stylex';
|
|
2
2
|
import type { ClassValue } from 'svelte/elements';
|
|
3
3
|
/**
|
|
4
|
-
* A style that only sets custom properties, such as `{ '--primary': colors.
|
|
4
|
+
* A style that only sets custom properties, such as `{ '--primary': colors.accent }`.
|
|
5
5
|
* `StyleXStyles` lists the CSS properties it knows, and TypeScript rejects an object
|
|
6
6
|
* that shares none of them, so a style of custom properties alone needs its own type.
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
3
|
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
-
*
|
|
4
|
+
* the accent, the one colour that marks state, as Composer's toggles are.
|
|
5
5
|
*/
|
|
6
6
|
import * as stylex from '@stylexjs/stylex';
|
|
7
7
|
export declare const toggle: Readonly<{
|
|
@@ -15,7 +15,6 @@ export declare const toggle: Readonly<{
|
|
|
15
15
|
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
16
16
|
readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 0>;
|
|
17
17
|
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string | null>;
|
|
18
|
-
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", "none" | `inset 0 0 0 1px color-mix(in oklab, ${stylex.StyleXVar<string>} 35%, transparent)`>;
|
|
19
18
|
readonly color: stylex.StyleXClassNameFor<"color", string | null>;
|
|
20
19
|
readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
|
|
21
20
|
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
package/dist/internal/toggle.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
3
|
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
-
*
|
|
4
|
+
* the accent, the one colour that marks state, as Composer's toggles are.
|
|
5
5
|
*/
|
|
6
6
|
import * as stylex from '@stylexjs/stylex';
|
|
7
7
|
import { colors, font, motion, radius } from '../tokens.stylex.js';
|
|
@@ -20,20 +20,16 @@ export const toggle = stylex.create({
|
|
|
20
20
|
borderWidth: 0,
|
|
21
21
|
backgroundColor: {
|
|
22
22
|
default: 'transparent',
|
|
23
|
-
':hover': { default: null, [media.hover]: colors.
|
|
23
|
+
':hover': { default: null, [media.hover]: colors.fillHover },
|
|
24
24
|
[ON]: {
|
|
25
|
-
default: colors.
|
|
25
|
+
default: colors.accentSoft,
|
|
26
26
|
':hover': { default: null, [media.hover]: colors.focusHalo }
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
boxShadow: {
|
|
30
|
-
default: 'none',
|
|
31
|
-
[ON]: `inset 0 0 0 1px color-mix(in oklab, ${colors.ithil} 35%, transparent)`
|
|
32
|
-
},
|
|
33
29
|
color: {
|
|
34
30
|
default: colors.textMuted,
|
|
35
31
|
':hover': { default: null, [media.hover]: colors.text },
|
|
36
|
-
[ON]: { default: colors.
|
|
32
|
+
[ON]: { default: colors.accent, ':hover': colors.accent, [media.forcedColors]: 'Highlight' }
|
|
37
33
|
},
|
|
38
34
|
fontFamily: font.body,
|
|
39
35
|
fontWeight: font.weightMedium,
|
|
@@ -70,16 +66,16 @@ export const toggle = stylex.create({
|
|
|
70
66
|
minHeight: '1.75rem',
|
|
71
67
|
paddingInline: '0.625rem',
|
|
72
68
|
gap: '0.375rem',
|
|
73
|
-
borderRadius: radius.
|
|
74
|
-
fontSize: font.
|
|
69
|
+
borderRadius: radius.item,
|
|
70
|
+
fontSize: font.sizeMeta,
|
|
75
71
|
'::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-6px' }
|
|
76
72
|
},
|
|
77
73
|
md: {
|
|
78
74
|
minHeight: '2rem',
|
|
79
75
|
paddingInline: '0.75rem',
|
|
80
76
|
gap: '0.4375rem',
|
|
81
|
-
borderRadius: radius.
|
|
82
|
-
fontSize: font.
|
|
77
|
+
borderRadius: radius.control,
|
|
78
|
+
fontSize: font.sizeBody,
|
|
83
79
|
'::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-4px' }
|
|
84
80
|
},
|
|
85
81
|
iconSm: { width: '1.75rem', paddingInline: 0 },
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lets an animation that never ends run only while it can be seen.
|
|
3
|
+
*
|
|
4
|
+
* Such an animation costs something for as long as it runs: a shimmer three
|
|
5
|
+
* screens up the conversation, or in a window behind another, is paid for and
|
|
6
|
+
* never looked at. So every one of Narvi's reads its play state from a custom
|
|
7
|
+
* property, and this sets that property: running while the element is in the
|
|
8
|
+
* viewport and the document is showing, paused otherwise.
|
|
9
|
+
*
|
|
10
|
+
* The animations themselves are stepped (`steps(30)` over two seconds, say), so
|
|
11
|
+
* the compositor draws a handful of frames a second, not one for every refresh
|
|
12
|
+
* of the display. A spinner is the exception: it has to turn smoothly, so it is
|
|
13
|
+
* a plain rotation, and only the pausing applies to it.
|
|
14
|
+
*
|
|
15
|
+
* Without this the animation runs: the property's fallback is `running`.
|
|
16
|
+
*
|
|
17
|
+
* ```svelte
|
|
18
|
+
* <span {@attach whileVisible} {...stylex.attrs(styles.pulse)}></span>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* pulse: {
|
|
23
|
+
* animationName: pulse,
|
|
24
|
+
* animationDuration: '2s',
|
|
25
|
+
* animationTimingFunction: 'steps(12)',
|
|
26
|
+
* animationIterationCount: 'infinite',
|
|
27
|
+
* animationPlayState: play.whileVisible // from tokens.stylex.js
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import type { Attachment } from 'svelte/attachments';
|
|
32
|
+
export declare const whileVisible: Attachment<HTMLElement | SVGElement>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const watched = new Map();
|
|
2
|
+
let observer = null;
|
|
3
|
+
function apply(item) {
|
|
4
|
+
const running = item.inView && !document.hidden;
|
|
5
|
+
item.element.style.setProperty('--narvi-play', running ? 'running' : 'paused');
|
|
6
|
+
}
|
|
7
|
+
function applyAll() {
|
|
8
|
+
for (const item of watched.values())
|
|
9
|
+
apply(item);
|
|
10
|
+
}
|
|
11
|
+
export const whileVisible = (element) => {
|
|
12
|
+
// Nothing to watch with: leave the animation running, as it would without this
|
|
13
|
+
if (typeof IntersectionObserver === 'undefined')
|
|
14
|
+
return;
|
|
15
|
+
if (observer === null) {
|
|
16
|
+
observer = new IntersectionObserver((entries) => {
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const item = watched.get(entry.target);
|
|
19
|
+
if (!item)
|
|
20
|
+
continue;
|
|
21
|
+
item.inView = entry.isIntersecting;
|
|
22
|
+
apply(item);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
document.addEventListener('visibilitychange', applyAll);
|
|
26
|
+
}
|
|
27
|
+
const item = { element, inView: false };
|
|
28
|
+
watched.set(element, item);
|
|
29
|
+
// Paused until the observer has looked, which it does before the next frame is drawn
|
|
30
|
+
apply(item);
|
|
31
|
+
observer.observe(element);
|
|
32
|
+
return () => {
|
|
33
|
+
if (watched.get(element) !== item)
|
|
34
|
+
return;
|
|
35
|
+
watched.delete(element);
|
|
36
|
+
observer?.unobserve(element);
|
|
37
|
+
element.style.removeProperty('--narvi-play');
|
|
38
|
+
if (watched.size === 0) {
|
|
39
|
+
observer?.disconnect();
|
|
40
|
+
observer = null;
|
|
41
|
+
document.removeEventListener('visibilitychange', applyAll);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|