@diegopluna/narvi 0.0.1 → 0.1.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 +27 -8
- package/dist/base.css +96 -0
- package/dist/color.d.ts +38 -0
- package/dist/color.js +88 -0
- package/dist/components/activity/ActivityTrigger.svelte +2 -3
- package/dist/components/app-shell/AppShellHeader.svelte +2 -3
- package/dist/components/app-shell/AppShellSidebar.svelte +6 -6
- package/dist/components/approval/Approval.svelte +8 -4
- package/dist/components/button/Button.svelte +15 -18
- package/dist/components/card/Card.svelte +98 -12
- package/dist/components/card/Card.svelte.d.ts +8 -3
- package/dist/components/checkbox/Checkbox.svelte +16 -13
- 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/styles.js +3 -3
- package/dist/components/composer/ComposerAttachment.svelte +4 -6
- package/dist/components/composer/ComposerModelPicker.svelte +8 -10
- package/dist/components/composer/ComposerRoot.svelte +7 -6
- package/dist/components/composer/ComposerSubmit.svelte +4 -5
- package/dist/components/composer/ComposerToggle.svelte +11 -11
- package/dist/components/conversation/ConversationScrollButton.svelte +6 -8
- package/dist/components/dialog/DialogContent.svelte +5 -1
- package/dist/components/dialog/styles.d.ts +0 -23
- package/dist/components/dialog/styles.js +7 -43
- package/dist/components/grid/Grid.svelte +111 -0
- package/dist/components/grid/Grid.svelte.d.ts +27 -0
- 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/link/Link.svelte +2 -4
- package/dist/components/message/MessageAction.svelte +2 -3
- package/dist/components/message/MessageActions.svelte +2 -3
- package/dist/components/message/MessageCopy.svelte +4 -5
- package/dist/components/message/MessageRoot.svelte +3 -4
- package/dist/components/message/MessageTime.svelte +2 -3
- package/dist/components/plan/Plan.svelte +3 -4
- package/dist/components/progress/Progress.svelte +4 -6
- package/dist/components/rail/RailItem.svelte +9 -9
- package/dist/components/reasoning/ReasoningTrigger.svelte +2 -3
- package/dist/components/resize-handle/ResizeHandle.svelte +3 -5
- 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 +5 -9
- 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 +8 -6
- package/dist/components/sidebar/SidebarGroup.svelte +5 -3
- package/dist/components/sidebar/SidebarItem.svelte +10 -8
- package/dist/components/slider/Slider.svelte +199 -0
- package/dist/components/slider/Slider.svelte.d.ts +55 -0
- package/dist/components/stack/Stack.svelte +37 -44
- package/dist/components/stack/Stack.svelte.d.ts +12 -6
- package/dist/components/suggestions/SuggestionsItem.svelte +7 -9
- package/dist/components/switch/Switch.svelte +8 -12
- package/dist/components/tabs/Tabs.svelte +3 -6
- package/dist/components/text/Text.svelte +47 -5
- package/dist/components/text/Text.svelte.d.ts +8 -2
- package/dist/components/toast/Toaster.svelte +7 -5
- 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/ToolTrigger.svelte +4 -6
- package/dist/components/tooltip/TooltipContent.svelte +6 -3
- package/dist/components/work-fold/WorkFold.svelte +12 -25
- package/dist/components/work-fold/WorkFold.svelte.d.ts +1 -1
- package/dist/index.d.ts +25 -3
- package/dist/index.js +24 -2
- package/dist/internal/Chevron.svelte +2 -3
- package/dist/internal/Collapse.svelte +6 -5
- package/dist/internal/Collapse.svelte.d.ts +2 -1
- package/dist/internal/control.js +4 -4
- package/dist/internal/layer.js +6 -8
- package/dist/internal/layout.d.ts +13 -0
- package/dist/internal/layout.js +453 -0
- package/dist/internal/responsive.d.ts +45 -0
- package/dist/internal/responsive.js +42 -0
- package/dist/internal/sx.d.ts +39 -4
- package/dist/internal/sx.js +17 -0
- package/dist/internal/toggle.d.ts +74 -0
- package/dist/internal/toggle.js +87 -0
- package/dist/media.stylex.d.ts +52 -0
- package/dist/media.stylex.js +53 -0
- package/dist/preset.js +9 -3
- package/dist/tokens.stylex.d.ts +15 -0
- package/dist/tokens.stylex.js +24 -2
- package/dist/vite.d.ts +27 -3
- package/dist/vite.js +25 -3
- package/package.json +14 -5
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import * as stylex from '@stylexjs/stylex';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import type { HTMLAnchorAttributes, HTMLAttributes } from 'svelte/elements';
|
|
5
5
|
import { shared } from '../../internal/shared.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
|
-
import { colors, font, radius, space } from '../../tokens.stylex.js';
|
|
7
|
+
import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
|
|
8
|
+
import { media } from '../../media.stylex.js';
|
|
8
9
|
|
|
9
10
|
export type CardVariant = 'raised' | 'outlined' | 'filled';
|
|
10
11
|
export type CardPadding = 'none' | 'sm' | 'md' | 'lg';
|
|
11
12
|
|
|
12
|
-
export type CardProps = Omit<
|
|
13
|
+
export type CardProps = Omit<
|
|
14
|
+
HTMLAttributes<HTMLDivElement> & HTMLAnchorAttributes,
|
|
15
|
+
'children'
|
|
16
|
+
> & {
|
|
13
17
|
variant?: CardVariant;
|
|
14
18
|
padding?: CardPadding;
|
|
19
|
+
/**
|
|
20
|
+
* Makes the whole card a link. Its text becomes the link's name, so keep it
|
|
21
|
+
* short, and put no other links or buttons inside.
|
|
22
|
+
*/
|
|
23
|
+
href?: string;
|
|
15
24
|
sx?: Sx;
|
|
16
|
-
ref?: HTMLDivElement | null;
|
|
25
|
+
ref?: HTMLDivElement | HTMLAnchorElement | null;
|
|
17
26
|
children?: Snippet;
|
|
18
27
|
};
|
|
19
28
|
|
|
@@ -40,14 +49,77 @@
|
|
|
40
49
|
none: { padding: 0 },
|
|
41
50
|
sm: { padding: space.x3 },
|
|
42
51
|
md: { padding: '1.125rem' },
|
|
43
|
-
lg: { padding: space.x6 }
|
|
52
|
+
lg: { padding: space.x6 },
|
|
53
|
+
|
|
54
|
+
// A card that is a link: a block, in the card's own colours, that answers the pointer
|
|
55
|
+
link: {
|
|
56
|
+
display: 'block',
|
|
57
|
+
textDecoration: 'none',
|
|
58
|
+
cursor: 'pointer',
|
|
59
|
+
WebkitTapHighlightColor: 'transparent',
|
|
60
|
+
// Press feedback, smaller than a button's, as a card is much larger
|
|
61
|
+
scale: { default: null, ':active': { default: null, [media.motion]: 0.99 } },
|
|
62
|
+
transitionProperty: {
|
|
63
|
+
default: 'background-color, box-shadow',
|
|
64
|
+
[media.motion]: 'scale, background-color, box-shadow'
|
|
65
|
+
},
|
|
66
|
+
transitionDuration: motion.base,
|
|
67
|
+
transitionTimingFunction: {
|
|
68
|
+
default: 'ease',
|
|
69
|
+
[media.motion]: `${motion.easeOut}, ease, ease`
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
// On hover the surface lifts a step and its edge firms up, as a control's does
|
|
73
|
+
raisedLink: {
|
|
74
|
+
backgroundColor: {
|
|
75
|
+
default: colors.bgRaised,
|
|
76
|
+
':hover': { default: null, [media.hover]: colors.surfaceRaised }
|
|
77
|
+
},
|
|
78
|
+
boxShadow: {
|
|
79
|
+
default: `inset 0 0 0 1px ${colors.line}, 0 1px 2px ${colors.shade}, 0 12px 24px -16px ${colors.shade}`,
|
|
80
|
+
':hover': {
|
|
81
|
+
default: null,
|
|
82
|
+
[media.hover]: `inset 0 0 0 1px ${colors.lineStrong}, 0 1px 2px ${colors.shade}, 0 14px 28px -16px ${colors.shade}`
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
outlinedLink: {
|
|
87
|
+
backgroundColor: {
|
|
88
|
+
default: colors.bgRaised,
|
|
89
|
+
':hover': { default: null, [media.hover]: colors.surfaceRaised }
|
|
90
|
+
},
|
|
91
|
+
boxShadow: {
|
|
92
|
+
default: `inset 0 0 0 1px ${colors.line}`,
|
|
93
|
+
':hover': { default: null, [media.hover]: `inset 0 0 0 1px ${colors.lineStrong}` }
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
filledLink: {
|
|
97
|
+
backgroundColor: {
|
|
98
|
+
default: colors.well,
|
|
99
|
+
':hover': { default: null, [media.hover]: colors.hover }
|
|
100
|
+
},
|
|
101
|
+
boxShadow: {
|
|
102
|
+
default: `inset 0 0 0 1px ${colors.line}, inset 0 1px 2px ${colors.shade}`,
|
|
103
|
+
':hover': {
|
|
104
|
+
default: null,
|
|
105
|
+
[media.hover]: `inset 0 0 0 1px ${colors.lineStrong}, inset 0 1px 2px ${colors.shade}`
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
44
109
|
});
|
|
110
|
+
|
|
111
|
+
const linkStyles = {
|
|
112
|
+
raised: styles.raisedLink,
|
|
113
|
+
outlined: styles.outlinedLink,
|
|
114
|
+
filled: styles.filledLink
|
|
115
|
+
};
|
|
45
116
|
</script>
|
|
46
117
|
|
|
47
118
|
<script lang="ts">
|
|
48
119
|
let {
|
|
49
120
|
variant = 'raised',
|
|
50
121
|
padding = 'md',
|
|
122
|
+
href,
|
|
51
123
|
sx,
|
|
52
124
|
class: className,
|
|
53
125
|
ref = $bindable(null),
|
|
@@ -56,10 +128,24 @@
|
|
|
56
128
|
}: CardProps = $props();
|
|
57
129
|
</script>
|
|
58
130
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
131
|
+
{#if href !== undefined}
|
|
132
|
+
<a
|
|
133
|
+
bind:this={ref}
|
|
134
|
+
{href}
|
|
135
|
+
{...rest}
|
|
136
|
+
{...attrs(
|
|
137
|
+
[styles.base, shared.focusable, styles.link, linkStyles[variant], styles[padding], sx],
|
|
138
|
+
className
|
|
139
|
+
)}
|
|
140
|
+
>
|
|
141
|
+
{@render children?.()}
|
|
142
|
+
</a>
|
|
143
|
+
{:else}
|
|
144
|
+
<div
|
|
145
|
+
bind:this={ref}
|
|
146
|
+
{...rest}
|
|
147
|
+
{...attrs([styles.base, shared.edged, styles[variant], styles[padding], sx], className)}
|
|
148
|
+
>
|
|
149
|
+
{@render children?.()}
|
|
150
|
+
</div>
|
|
151
|
+
{/if}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { HTMLAnchorAttributes, HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { type Sx } from '../../internal/sx.js';
|
|
4
4
|
export type CardVariant = 'raised' | 'outlined' | 'filled';
|
|
5
5
|
export type CardPadding = 'none' | 'sm' | 'md' | 'lg';
|
|
6
|
-
export type CardProps = Omit<HTMLAttributes<HTMLDivElement
|
|
6
|
+
export type CardProps = Omit<HTMLAttributes<HTMLDivElement> & HTMLAnchorAttributes, 'children'> & {
|
|
7
7
|
variant?: CardVariant;
|
|
8
8
|
padding?: CardPadding;
|
|
9
|
+
/**
|
|
10
|
+
* Makes the whole card a link. Its text becomes the link's name, so keep it
|
|
11
|
+
* short, and put no other links or buttons inside.
|
|
12
|
+
*/
|
|
13
|
+
href?: string;
|
|
9
14
|
sx?: Sx;
|
|
10
|
-
ref?: HTMLDivElement | null;
|
|
15
|
+
ref?: HTMLDivElement | HTMLAnchorElement | null;
|
|
11
16
|
children?: Snippet;
|
|
12
17
|
};
|
|
13
18
|
declare const Card: import("svelte").Component<CardProps, {}, "ref">;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
5
5
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
6
|
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
7
|
+
import { media } from '../../media.stylex.js';
|
|
7
8
|
|
|
8
9
|
export type CheckboxProps = Omit<HTMLInputAttributes, 'type' | 'children'> & {
|
|
9
10
|
checked?: boolean;
|
|
@@ -19,11 +20,6 @@
|
|
|
19
20
|
children?: Snippet;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
// StyleX needs these in the same file to evaluate them at build time
|
|
23
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
24
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
25
|
-
const FORCED = '@media (forced-colors: active)';
|
|
26
|
-
|
|
27
23
|
const CHECK = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.5 5 9l4.5-6'/%3E%3C/svg%3E")`;
|
|
28
24
|
const DASH = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2.5 6h7'/%3E%3C/svg%3E")`;
|
|
29
25
|
|
|
@@ -65,18 +61,18 @@
|
|
|
65
61
|
borderRadius: radius.xs,
|
|
66
62
|
borderColor: {
|
|
67
63
|
default: colors.edge,
|
|
68
|
-
':hover': { default: null, [
|
|
64
|
+
':hover': { default: null, [media.hover]: colors.edgeHover },
|
|
69
65
|
':checked': 'transparent',
|
|
70
66
|
':indeterminate': 'transparent',
|
|
71
|
-
[
|
|
67
|
+
[media.forcedColors]: 'ButtonText'
|
|
72
68
|
},
|
|
73
|
-
backgroundColor: { default: colors.well, [
|
|
69
|
+
backgroundColor: { default: colors.well, [media.forcedColors]: 'Canvas' },
|
|
74
70
|
backgroundOrigin: 'border-box',
|
|
75
71
|
backgroundImage: {
|
|
76
72
|
default: 'none',
|
|
77
73
|
':checked': `linear-gradient(180deg, ${colors.ithil}, ${colors.ithilStrong})`,
|
|
78
74
|
':indeterminate': `linear-gradient(180deg, ${colors.ithil}, ${colors.ithilStrong})`,
|
|
79
|
-
[
|
|
75
|
+
[media.forcedColors]: {
|
|
80
76
|
default: 'none',
|
|
81
77
|
':checked': 'linear-gradient(Highlight, Highlight)',
|
|
82
78
|
':indeterminate': 'linear-gradient(Highlight, Highlight)'
|
|
@@ -102,7 +98,7 @@
|
|
|
102
98
|
content: '""',
|
|
103
99
|
width: '0.625rem',
|
|
104
100
|
height: '0.625rem',
|
|
105
|
-
backgroundColor: { default: colors.onIthil, [
|
|
101
|
+
backgroundColor: { default: colors.onIthil, [media.forcedColors]: 'HighlightText' },
|
|
106
102
|
maskImage: { default: CHECK, ':indeterminate': DASH },
|
|
107
103
|
maskSize: 'contain',
|
|
108
104
|
maskRepeat: 'no-repeat',
|
|
@@ -111,12 +107,19 @@
|
|
|
111
107
|
// The mark settles in from just under full size, with a touch of blur to
|
|
112
108
|
// soften the swap. It never grows from nothing, and it is quick: boxes
|
|
113
109
|
// get ticked many times a day.
|
|
114
|
-
scale: {
|
|
110
|
+
scale: {
|
|
111
|
+
default: null,
|
|
112
|
+
[media.motion]: { default: 0.9, ':checked': 1, ':indeterminate': 1 }
|
|
113
|
+
},
|
|
115
114
|
filter: {
|
|
116
115
|
default: null,
|
|
117
|
-
[
|
|
116
|
+
[media.motion]: {
|
|
117
|
+
default: 'blur(2px)',
|
|
118
|
+
':checked': 'blur(0px)',
|
|
119
|
+
':indeterminate': 'blur(0px)'
|
|
120
|
+
}
|
|
118
121
|
},
|
|
119
|
-
transitionProperty: { default: 'opacity', [
|
|
122
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale, filter' },
|
|
120
123
|
transitionDuration: motion.fast,
|
|
121
124
|
transitionTimingFunction: motion.easeOut
|
|
122
125
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { Collapsible } from 'bits-ui';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import Collapse from '../../internal/Collapse.svelte';
|
|
5
|
+
import type { Sx } from '../../internal/sx.js';
|
|
6
|
+
|
|
7
|
+
export type CollapsibleContentProps = Omit<
|
|
8
|
+
Collapsible.ContentProps,
|
|
9
|
+
'children' | 'child' | 'forceMount' | 'hiddenUntilFound'
|
|
10
|
+
> & {
|
|
11
|
+
/** Styles for the content, inside the fold: padding and gaps go here. */
|
|
12
|
+
sx?: Sx;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
let {
|
|
19
|
+
ref = $bindable(null),
|
|
20
|
+
sx,
|
|
21
|
+
class: className,
|
|
22
|
+
children,
|
|
23
|
+
...rest
|
|
24
|
+
}: CollapsibleContentProps = $props();
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<!--
|
|
28
|
+
Kept in the page while shut, so its height can ease between nothing and its
|
|
29
|
+
content's; Collapse makes it inert meanwhile, out of the tab order and the
|
|
30
|
+
accessibility tree.
|
|
31
|
+
-->
|
|
32
|
+
<Collapsible.Content bind:ref forceMount {...rest}>
|
|
33
|
+
{#snippet child({ props, open })}
|
|
34
|
+
<Collapse {open} data-slot="collapsible-content" {...props} innerSx={sx} innerClass={className}>
|
|
35
|
+
{@render children?.()}
|
|
36
|
+
</Collapse>
|
|
37
|
+
{/snippet}
|
|
38
|
+
</Collapsible.Content>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Collapsible } from 'bits-ui';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { Sx } from '../../internal/sx.js';
|
|
4
|
+
export type CollapsibleContentProps = Omit<Collapsible.ContentProps, 'children' | 'child' | 'forceMount' | 'hiddenUntilFound'> & {
|
|
5
|
+
/** Styles for the content, inside the fold: padding and gaps go here. */
|
|
6
|
+
sx?: Sx;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
};
|
|
9
|
+
declare const CollapsibleContent: import("svelte").Component<CollapsibleContentProps, {}, "ref">;
|
|
10
|
+
type CollapsibleContent = ReturnType<typeof CollapsibleContent>;
|
|
11
|
+
export default CollapsibleContent;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { Collapsible } from 'bits-ui';
|
|
3
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
|
+
import { setCollapsibleContext } from './context.js';
|
|
7
|
+
|
|
8
|
+
export type CollapsibleRootProps = Omit<Collapsible.RootProps, 'children' | 'child'> & {
|
|
9
|
+
sx?: Sx;
|
|
10
|
+
/** A Collapsible.Trigger and a Collapsible.Content, with anything else around them. */
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const styles = stylex.create({
|
|
15
|
+
root: { display: 'flex', flexDirection: 'column', minWidth: 0 }
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
let {
|
|
21
|
+
open = $bindable(false),
|
|
22
|
+
ref = $bindable(null),
|
|
23
|
+
sx,
|
|
24
|
+
class: className,
|
|
25
|
+
children,
|
|
26
|
+
...rest
|
|
27
|
+
}: CollapsibleRootProps = $props();
|
|
28
|
+
|
|
29
|
+
setCollapsibleContext({
|
|
30
|
+
get open() {
|
|
31
|
+
return open;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<Collapsible.Root
|
|
37
|
+
bind:open
|
|
38
|
+
bind:ref
|
|
39
|
+
data-slot="collapsible"
|
|
40
|
+
{...rest}
|
|
41
|
+
{...attrs([styles.root, sx], className)}
|
|
42
|
+
>
|
|
43
|
+
{@render children?.()}
|
|
44
|
+
</Collapsible.Root>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Collapsible } from 'bits-ui';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
export type CollapsibleRootProps = Omit<Collapsible.RootProps, 'children' | 'child'> & {
|
|
5
|
+
sx?: Sx;
|
|
6
|
+
/** A Collapsible.Trigger and a Collapsible.Content, with anything else around them. */
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
};
|
|
9
|
+
declare const CollapsibleRoot: import("svelte").Component<CollapsibleRootProps, {}, "ref" | "open">;
|
|
10
|
+
type CollapsibleRoot = ReturnType<typeof CollapsibleRoot>;
|
|
11
|
+
export default CollapsibleRoot;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { Collapsible } from 'bits-ui';
|
|
3
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import Chevron from '../../internal/Chevron.svelte';
|
|
6
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
|
+
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
8
|
+
import { media } from '../../media.stylex.js';
|
|
9
|
+
import { getCollapsibleContext } from './context.js';
|
|
10
|
+
|
|
11
|
+
export type CollapsibleTriggerProps = Omit<Collapsible.TriggerProps, 'children'> & {
|
|
12
|
+
/** Shows the chevron after the label, pointing down while open. */
|
|
13
|
+
chevron?: boolean;
|
|
14
|
+
sx?: Sx;
|
|
15
|
+
/** The label. Pass `child` instead to make your own control the trigger. */
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const styles = stylex.create({
|
|
20
|
+
// A quiet line of text that names what folds, like Reasoning's and WorkFold's
|
|
21
|
+
trigger: {
|
|
22
|
+
display: 'inline-flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
alignSelf: 'flex-start',
|
|
25
|
+
gap: '0.25rem',
|
|
26
|
+
maxWidth: '100%',
|
|
27
|
+
minHeight: '1.75rem',
|
|
28
|
+
margin: 0,
|
|
29
|
+
padding: 0,
|
|
30
|
+
borderWidth: 0,
|
|
31
|
+
borderRadius: radius.xs,
|
|
32
|
+
backgroundColor: 'transparent',
|
|
33
|
+
color: { default: colors.textMuted, ':hover': { default: null, [media.hover]: colors.text } },
|
|
34
|
+
fontFamily: 'inherit',
|
|
35
|
+
fontSize: font.sizeMd,
|
|
36
|
+
fontWeight: font.weightMedium,
|
|
37
|
+
lineHeight: font.leadingSnug,
|
|
38
|
+
textAlign: 'start',
|
|
39
|
+
cursor: { default: 'pointer', ':disabled': 'not-allowed' },
|
|
40
|
+
opacity: { default: 1, ':disabled': 0.5 },
|
|
41
|
+
WebkitTapHighlightColor: 'transparent',
|
|
42
|
+
WebkitAppRegion: 'no-drag',
|
|
43
|
+
outlineStyle: 'solid',
|
|
44
|
+
outlineWidth: { default: 0, ':focus-visible': '2px' },
|
|
45
|
+
outlineColor: colors.focusRing,
|
|
46
|
+
outlineOffset: '2px',
|
|
47
|
+
transitionProperty: 'color',
|
|
48
|
+
transitionDuration: motion.fast,
|
|
49
|
+
transitionTimingFunction: 'ease'
|
|
50
|
+
},
|
|
51
|
+
chevron: { display: 'grid', color: colors.textSubtle }
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<script lang="ts">
|
|
56
|
+
let {
|
|
57
|
+
chevron = true,
|
|
58
|
+
ref = $bindable(null),
|
|
59
|
+
sx,
|
|
60
|
+
class: className,
|
|
61
|
+
child,
|
|
62
|
+
children,
|
|
63
|
+
...rest
|
|
64
|
+
}: CollapsibleTriggerProps = $props();
|
|
65
|
+
|
|
66
|
+
const collapsible = getCollapsibleContext('Trigger');
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
{#if child}
|
|
70
|
+
<Collapsible.Trigger bind:ref {child} {...rest} />
|
|
71
|
+
{:else}
|
|
72
|
+
<Collapsible.Trigger
|
|
73
|
+
bind:ref
|
|
74
|
+
data-slot="collapsible-trigger"
|
|
75
|
+
{...rest}
|
|
76
|
+
{...attrs([styles.trigger, sx], className)}
|
|
77
|
+
>
|
|
78
|
+
{@render children?.()}
|
|
79
|
+
{#if chevron}
|
|
80
|
+
<span {...stylex.attrs(styles.chevron)}><Chevron open={collapsible.open} size={12} /></span>
|
|
81
|
+
{/if}
|
|
82
|
+
</Collapsible.Trigger>
|
|
83
|
+
{/if}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Collapsible } from 'bits-ui';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
export type CollapsibleTriggerProps = Omit<Collapsible.TriggerProps, 'children'> & {
|
|
5
|
+
/** Shows the chevron after the label, pointing down while open. */
|
|
6
|
+
chevron?: boolean;
|
|
7
|
+
sx?: Sx;
|
|
8
|
+
/** The label. Pass `child` instead to make your own control the trigger. */
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
};
|
|
11
|
+
declare const CollapsibleTrigger: import("svelte").Component<CollapsibleTriggerProps, {}, "ref">;
|
|
12
|
+
type CollapsibleTrigger = ReturnType<typeof CollapsibleTrigger>;
|
|
13
|
+
export default CollapsibleTrigger;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const KEY = Symbol('narvi.collapsible');
|
|
3
|
+
export function setCollapsibleContext(context) {
|
|
4
|
+
setContext(KEY, context);
|
|
5
|
+
}
|
|
6
|
+
export function getCollapsibleContext(part) {
|
|
7
|
+
const context = getContext(KEY);
|
|
8
|
+
if (!context)
|
|
9
|
+
throw new Error(`<Collapsible.${part}> must be placed inside <Collapsible.Root>.`);
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Content from './CollapsibleContent.svelte';
|
|
2
|
+
import Root from './CollapsibleRoot.svelte';
|
|
3
|
+
import Trigger from './CollapsibleTrigger.svelte';
|
|
4
|
+
export { Root, Trigger, Content };
|
|
5
|
+
export type { CollapsibleContentProps } from './CollapsibleContent.svelte';
|
|
6
|
+
export type { CollapsibleRootProps } from './CollapsibleRoot.svelte';
|
|
7
|
+
export type { CollapsibleTriggerProps } from './CollapsibleTrigger.svelte';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
2
|
import { colors, font, radius, space } from '../../tokens.stylex.js';
|
|
3
|
+
import { media } from '../../media.stylex.js';
|
|
3
4
|
const SELECTED = ':is([data-selected])';
|
|
4
|
-
const FORCED = '@media (forced-colors: active)';
|
|
5
5
|
export const command = stylex.create({
|
|
6
6
|
root: {
|
|
7
7
|
display: 'flex',
|
|
@@ -56,7 +56,7 @@ export const command = stylex.create({
|
|
|
56
56
|
userSelect: 'none',
|
|
57
57
|
backgroundColor: {
|
|
58
58
|
default: 'transparent',
|
|
59
|
-
[SELECTED]: { default: colors.hover, [
|
|
59
|
+
[SELECTED]: { default: colors.hover, [media.forcedColors]: 'Highlight' }
|
|
60
60
|
},
|
|
61
61
|
forcedColorAdjust: 'none'
|
|
62
62
|
},
|
|
@@ -101,7 +101,7 @@ export const command = stylex.create({
|
|
|
101
101
|
backgroundColor: colors.bgRaised,
|
|
102
102
|
boxShadow: `inset 0 0 0 1px ${colors.lineStrong}, inset 0 1px 0 ${colors.highlight}, 0 32px 80px -16px rgb(0 0 0 / 0.55)`,
|
|
103
103
|
outlineStyle: 'solid',
|
|
104
|
-
outlineWidth: { default: 0, [
|
|
104
|
+
outlineWidth: { default: 0, [media.forcedColors]: '1px' },
|
|
105
105
|
outlineColor: 'CanvasText'
|
|
106
106
|
},
|
|
107
107
|
overlay: {
|
|
@@ -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 { useComposer } from './context.js';
|
|
9
10
|
|
|
10
11
|
export type ComposerAttachmentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
@@ -21,9 +22,6 @@
|
|
|
21
22
|
return `${(bytes / 1_000_000).toFixed(1)} MB`;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
25
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
26
|
-
|
|
27
25
|
const styles = stylex.create({
|
|
28
26
|
// A chip: the thumbnail's radius plus the padding, so the corners sit concentric
|
|
29
27
|
chip: {
|
|
@@ -42,8 +40,8 @@
|
|
|
42
40
|
boxShadow: `inset 0 0 0 1px ${colors.line}`,
|
|
43
41
|
cursor: 'default',
|
|
44
42
|
opacity: { default: 1, '@starting-style': 0 },
|
|
45
|
-
scale: { default: null, [
|
|
46
|
-
transitionProperty: { default: 'opacity', [
|
|
43
|
+
scale: { default: null, [media.motion]: { default: 1, '@starting-style': 0.94 } },
|
|
44
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale' },
|
|
47
45
|
transitionDuration: motion.base,
|
|
48
46
|
transitionTimingFunction: motion.easeOut
|
|
49
47
|
},
|
|
@@ -103,7 +101,7 @@
|
|
|
103
101
|
boxShadow: `inset 0 0 0 1px ${colors.lineStrong}, 0 1px 2px ${colors.shade}`,
|
|
104
102
|
color: {
|
|
105
103
|
default: colors.textMuted,
|
|
106
|
-
':hover': { default: null, [
|
|
104
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
107
105
|
},
|
|
108
106
|
cursor: 'pointer',
|
|
109
107
|
WebkitTapHighlightColor: 'transparent',
|
|
@@ -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 { getComposerContext } from './context.js';
|
|
9
10
|
|
|
10
11
|
export type ComposerModel = {
|
|
@@ -31,9 +32,6 @@
|
|
|
31
32
|
ref?: HTMLButtonElement | null;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
35
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
36
|
-
const FORCED = '@media (forced-colors: active)';
|
|
37
35
|
const GAP = 6;
|
|
38
36
|
const MARGIN = 8;
|
|
39
37
|
|
|
@@ -52,11 +50,11 @@
|
|
|
52
50
|
borderRadius: `calc(${radius.xl} * 4 / 3)`,
|
|
53
51
|
backgroundColor: {
|
|
54
52
|
default: 'transparent',
|
|
55
|
-
':hover': { default: null, [
|
|
53
|
+
':hover': { default: null, [media.hover]: colors.hover }
|
|
56
54
|
},
|
|
57
55
|
color: {
|
|
58
56
|
default: colors.textMuted,
|
|
59
|
-
':hover': { default: null, [
|
|
57
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
60
58
|
},
|
|
61
59
|
fontFamily: 'inherit',
|
|
62
60
|
fontSize: font.sizeSm,
|
|
@@ -103,17 +101,17 @@
|
|
|
103
101
|
fontFamily: font.body,
|
|
104
102
|
scrollbarWidth: 'thin',
|
|
105
103
|
outlineStyle: 'solid',
|
|
106
|
-
outlineWidth: { default: 0, [
|
|
104
|
+
outlineWidth: { default: 0, [media.forcedColors]: '1px' },
|
|
107
105
|
outlineColor: 'CanvasText',
|
|
108
106
|
transformOrigin: 'var(--narvi-picker-origin, top left)',
|
|
109
107
|
opacity: { default: 0, ':popover-open': { default: 1, '@starting-style': 0 } },
|
|
110
108
|
scale: {
|
|
111
109
|
default: null,
|
|
112
|
-
[
|
|
110
|
+
[media.motion]: { default: 0.97, ':popover-open': { default: 1, '@starting-style': 0.97 } }
|
|
113
111
|
},
|
|
114
112
|
transitionProperty: {
|
|
115
113
|
default: 'opacity, display, overlay',
|
|
116
|
-
[
|
|
114
|
+
[media.motion]: 'opacity, scale, display, overlay'
|
|
117
115
|
},
|
|
118
116
|
transitionBehavior: 'allow-discrete',
|
|
119
117
|
transitionDuration: { default: '100ms', ':popover-open': '160ms' },
|
|
@@ -158,8 +156,8 @@
|
|
|
158
156
|
// The option the keyboard or pointer is on. No transition: it follows the
|
|
159
157
|
// arrow keys, which are pressed many times in a row.
|
|
160
158
|
active: {
|
|
161
|
-
backgroundColor: { default: colors.hover, [
|
|
162
|
-
color: { default: null, [
|
|
159
|
+
backgroundColor: { default: colors.hover, [media.forcedColors]: 'Highlight' },
|
|
160
|
+
color: { default: null, [media.forcedColors]: 'HighlightText' },
|
|
163
161
|
forcedColorAdjust: 'none'
|
|
164
162
|
},
|
|
165
163
|
optionDisabled: {
|
|
@@ -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 {
|
|
9
10
|
accepts,
|
|
10
11
|
setComposerContext,
|
|
@@ -49,9 +50,6 @@
|
|
|
49
50
|
children?: Snippet;
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
const FORCED = '@media (forced-colors: active)';
|
|
53
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
54
|
-
|
|
55
53
|
const styles = stylex.create({
|
|
56
54
|
root: {
|
|
57
55
|
position: 'relative',
|
|
@@ -74,7 +72,10 @@
|
|
|
74
72
|
':focus-within': `inset 0 0 0 1px ${colors.edge}, inset 0 1px 0 ${colors.highlight}, 0 1px 2px ${colors.shade}, 0 16px 32px -20px ${colors.shade}`
|
|
75
73
|
},
|
|
76
74
|
// In forced colours the shadow is gone; the outline is the edge, and thickens with focus
|
|
77
|
-
outlineWidth: {
|
|
75
|
+
outlineWidth: {
|
|
76
|
+
default: '1px',
|
|
77
|
+
[media.forcedColors]: { default: '1px', ':focus-within': '2px' }
|
|
78
|
+
},
|
|
78
79
|
transitionProperty: 'box-shadow',
|
|
79
80
|
transitionDuration: motion.base,
|
|
80
81
|
transitionTimingFunction: 'ease'
|
|
@@ -99,8 +100,8 @@
|
|
|
99
100
|
fontWeight: font.weightMedium,
|
|
100
101
|
pointerEvents: 'none',
|
|
101
102
|
opacity: { default: 1, '@starting-style': 0 },
|
|
102
|
-
scale: { default: null, [
|
|
103
|
-
transitionProperty: { default: 'opacity', [
|
|
103
|
+
scale: { default: null, [media.motion]: { default: 1, '@starting-style': 0.98 } },
|
|
104
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale' },
|
|
104
105
|
transitionDuration: motion.base,
|
|
105
106
|
transitionTimingFunction: motion.easeOut
|
|
106
107
|
},
|