@diegopluna/narvi 0.0.2 → 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 +17 -6
- package/dist/base.css +96 -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 +10 -13
- 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 +23 -3
- package/dist/index.js +21 -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 +30 -3
- 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/tokens.stylex.d.ts +15 -0
- package/dist/tokens.stylex.js +20 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +10 -2
- package/package.json +7 -2
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Eases its content up into place as it is scrolled to. It hides the content itself, once its
|
|
3
|
+
script runs, and only when it starts below the fold: a page without script, or opened halfway
|
|
4
|
+
down, shows everything at once and never flickers. Readers who ask for less motion see no move.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts" module>
|
|
7
|
+
import * as stylex from '@stylexjs/stylex';
|
|
8
|
+
import type { Snippet } from 'svelte';
|
|
9
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
10
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
11
|
+
import { media } from '../../media.stylex.js';
|
|
12
|
+
import { pageMotion } from '../../tokens.stylex.js';
|
|
13
|
+
|
|
14
|
+
export type RevealProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
15
|
+
/** Element to render. */
|
|
16
|
+
as?: 'div' | 'section' | 'article' | 'header' | 'footer' | 'figure' | 'li' | 'p' | 'span';
|
|
17
|
+
/**
|
|
18
|
+
* How long after it is reached it starts, in milliseconds: `index * 80` staggers a row.
|
|
19
|
+
* Styles from `revealed` inside it wait as long.
|
|
20
|
+
*/
|
|
21
|
+
delay?: number;
|
|
22
|
+
sx?: Sx;
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const HIDDEN = ':is([data-reveal=hidden])';
|
|
27
|
+
const SHOWN = ':is([data-reveal=shown])';
|
|
28
|
+
|
|
29
|
+
const styles = stylex.create({
|
|
30
|
+
root: {
|
|
31
|
+
opacity: { default: null, [HIDDEN]: 0 },
|
|
32
|
+
translate: { default: null, [HIDDEN]: '0 1.25rem' },
|
|
33
|
+
transitionProperty: 'opacity, translate',
|
|
34
|
+
// It moves only on the way in: hiding is instant
|
|
35
|
+
transitionDuration: {
|
|
36
|
+
default: '0s',
|
|
37
|
+
[SHOWN]: { default: '0s', [media.motion]: pageMotion.base }
|
|
38
|
+
},
|
|
39
|
+
transitionTimingFunction: pageMotion.ease,
|
|
40
|
+
transitionDelay: { default: '0s', [SHOWN]: 'var(--narvi-reveal-delay)' }
|
|
41
|
+
},
|
|
42
|
+
// Always set, so a Reveal never takes the delay of one around it
|
|
43
|
+
noDelay: { '--narvi-reveal-delay': '0ms' },
|
|
44
|
+
delay: (delay: string) => ({ '--narvi-reveal-delay': delay })
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/** Where above the bottom of the viewport it counts as reached: a tenth of the way up. */
|
|
48
|
+
const ROOT_MARGIN = '0px 0px -10% 0px';
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<script lang="ts">
|
|
52
|
+
let { as = 'div', delay = 0, sx, class: className, children, ...rest }: RevealProps = $props();
|
|
53
|
+
|
|
54
|
+
function watch(element: HTMLElement) {
|
|
55
|
+
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
|
56
|
+
// Already in view, or above it: leave it be
|
|
57
|
+
if (element.getBoundingClientRect().top < innerHeight) return;
|
|
58
|
+
|
|
59
|
+
element.dataset.reveal = 'hidden';
|
|
60
|
+
const observer = new IntersectionObserver(
|
|
61
|
+
([entry]) => {
|
|
62
|
+
if (!entry?.isIntersecting) return;
|
|
63
|
+
element.dataset.reveal = 'shown';
|
|
64
|
+
observer.disconnect();
|
|
65
|
+
},
|
|
66
|
+
{ rootMargin: ROOT_MARGIN }
|
|
67
|
+
);
|
|
68
|
+
observer.observe(element);
|
|
69
|
+
return () => observer.disconnect();
|
|
70
|
+
}
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<svelte:element
|
|
74
|
+
this={as}
|
|
75
|
+
data-slot="reveal"
|
|
76
|
+
{...rest}
|
|
77
|
+
{@attach watch}
|
|
78
|
+
{...attrs(
|
|
79
|
+
[
|
|
80
|
+
styles.root,
|
|
81
|
+
delay > 0 ? styles.delay(`${delay}ms`) : styles.noDelay,
|
|
82
|
+
stylex.defaultMarker(),
|
|
83
|
+
sx
|
|
84
|
+
],
|
|
85
|
+
className
|
|
86
|
+
)}
|
|
87
|
+
>
|
|
88
|
+
{@render children?.()}
|
|
89
|
+
</svelte:element>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
export type RevealProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
5
|
+
/** Element to render. */
|
|
6
|
+
as?: 'div' | 'section' | 'article' | 'header' | 'footer' | 'figure' | 'li' | 'p' | 'span';
|
|
7
|
+
/**
|
|
8
|
+
* How long after it is reached it starts, in milliseconds: `index * 80` staggers a row.
|
|
9
|
+
* Styles from `revealed` inside it wait as long.
|
|
10
|
+
*/
|
|
11
|
+
delay?: number;
|
|
12
|
+
sx?: Sx;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
};
|
|
15
|
+
declare const Reveal: import("svelte").Component<RevealProps, {}, "">;
|
|
16
|
+
type Reveal = ReturnType<typeof Reveal>;
|
|
17
|
+
export default Reveal;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
/**
|
|
3
|
+
* Styles for what sits inside a `Reveal`, which follow it in as it is reached. Each moves
|
|
4
|
+
* only on the way in, so hiding below the fold is instant, and only for readers who have
|
|
5
|
+
* not asked for less motion. Each also waits for the Reveal's own `delay`.
|
|
6
|
+
*
|
|
7
|
+
* Apply them with `sx` on a component, or spread `sx(...)` onto an element:
|
|
8
|
+
* `<path pathLength="1" {...sx(revealed.drawIn)} />`.
|
|
9
|
+
*
|
|
10
|
+
* Fine-tune them with custom properties, set on the element or anywhere above it:
|
|
11
|
+
* - `--narvi-draw-delay`, `--narvi-fade-delay` and `--narvi-sweep-delay`: a wait of its own,
|
|
12
|
+
* after the Reveal's
|
|
13
|
+
* - `--narvi-sweep-from`: where a sweep starts, as a dash offset (`1`, a whole turn, by default)
|
|
14
|
+
*/
|
|
15
|
+
export declare const revealed: Readonly<{
|
|
16
|
+
readonly drawIn: Readonly<{
|
|
17
|
+
readonly strokeDasharray: stylex.StyleXClassNameFor<"strokeDasharray", 1>;
|
|
18
|
+
readonly strokeDashoffset: stylex.StyleXClassNameFor<"strokeDashoffset", 0 | 1>;
|
|
19
|
+
readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "stroke-dashoffset">;
|
|
20
|
+
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
21
|
+
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
|
|
22
|
+
readonly transitionDelay: stylex.StyleXClassNameFor<"transitionDelay", "0s" | "calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-draw-delay, 0ms))">;
|
|
23
|
+
}>;
|
|
24
|
+
readonly fadeAfter: Readonly<{
|
|
25
|
+
readonly opacity: stylex.StyleXClassNameFor<"opacity", 0 | null>;
|
|
26
|
+
readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "opacity">;
|
|
27
|
+
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
28
|
+
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
|
|
29
|
+
readonly transitionDelay: stylex.StyleXClassNameFor<"transitionDelay", "0s" | `calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-fade-delay, ${stylex.StyleXVar<string>}))`>;
|
|
30
|
+
}>;
|
|
31
|
+
readonly sweep: Readonly<{
|
|
32
|
+
readonly strokeDashoffset: stylex.StyleXClassNameFor<"strokeDashoffset", 0 | "var(--narvi-sweep-from, 1)">;
|
|
33
|
+
readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "stroke-dashoffset">;
|
|
34
|
+
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
35
|
+
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
|
|
36
|
+
readonly transitionDelay: stylex.StyleXClassNameFor<"transitionDelay", "0s" | "calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-sweep-delay, 0ms))">;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import { media } from '../../media.stylex.js';
|
|
3
|
+
import { pageMotion } from '../../tokens.stylex.js';
|
|
4
|
+
/**
|
|
5
|
+
* Styles for what sits inside a `Reveal`, which follow it in as it is reached. Each moves
|
|
6
|
+
* only on the way in, so hiding below the fold is instant, and only for readers who have
|
|
7
|
+
* not asked for less motion. Each also waits for the Reveal's own `delay`.
|
|
8
|
+
*
|
|
9
|
+
* Apply them with `sx` on a component, or spread `sx(...)` onto an element:
|
|
10
|
+
* `<path pathLength="1" {...sx(revealed.drawIn)} />`.
|
|
11
|
+
*
|
|
12
|
+
* Fine-tune them with custom properties, set on the element or anywhere above it:
|
|
13
|
+
* - `--narvi-draw-delay`, `--narvi-fade-delay` and `--narvi-sweep-delay`: a wait of its own,
|
|
14
|
+
* after the Reveal's
|
|
15
|
+
* - `--narvi-sweep-from`: where a sweep starts, as a dash offset (`1`, a whole turn, by default)
|
|
16
|
+
*/
|
|
17
|
+
export const revealed = stylex.create({
|
|
18
|
+
/**
|
|
19
|
+
* Draws a stroke in, end to end. Give the path, line or circle `pathLength="1"`, so its
|
|
20
|
+
* length is 1 whatever its size.
|
|
21
|
+
*/
|
|
22
|
+
drawIn: {
|
|
23
|
+
strokeDasharray: 1,
|
|
24
|
+
strokeDashoffset: { default: 0, [stylex.when.ancestor('[data-reveal=hidden]')]: 1 },
|
|
25
|
+
transitionProperty: 'stroke-dashoffset',
|
|
26
|
+
transitionDuration: {
|
|
27
|
+
default: '0s',
|
|
28
|
+
[stylex.when.ancestor('[data-reveal=shown]')]: {
|
|
29
|
+
default: '0s',
|
|
30
|
+
[media.motion]: pageMotion.longest
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
transitionTimingFunction: pageMotion.ease,
|
|
34
|
+
transitionDelay: {
|
|
35
|
+
default: '0s',
|
|
36
|
+
[stylex.when.ancestor('[data-reveal=shown]')]: 'calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-draw-delay, 0ms))'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
/** Fades in once a drawing is well under way: a mark or a label that sits on it. */
|
|
40
|
+
fadeAfter: {
|
|
41
|
+
opacity: { default: null, [stylex.when.ancestor('[data-reveal=hidden]')]: 0 },
|
|
42
|
+
transitionProperty: 'opacity',
|
|
43
|
+
transitionDuration: {
|
|
44
|
+
default: '0s',
|
|
45
|
+
[stylex.when.ancestor('[data-reveal=shown]')]: {
|
|
46
|
+
default: '0s',
|
|
47
|
+
[media.motion]: pageMotion.long
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
transitionTimingFunction: pageMotion.ease,
|
|
51
|
+
transitionDelay: {
|
|
52
|
+
default: '0s',
|
|
53
|
+
[stylex.when.ancestor('[data-reveal=shown]')]: `calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-fade-delay, ${pageMotion.long}))`
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Runs a dash round its path into place. Give it `pathLength="1"` and a dash of your own,
|
|
58
|
+
* such as `stroke-dasharray="0.25 0.75"`: a lit stretch of a ring, or a comet on a line.
|
|
59
|
+
*/
|
|
60
|
+
sweep: {
|
|
61
|
+
strokeDashoffset: {
|
|
62
|
+
default: 0,
|
|
63
|
+
[stylex.when.ancestor('[data-reveal=hidden]')]: 'var(--narvi-sweep-from, 1)'
|
|
64
|
+
},
|
|
65
|
+
transitionProperty: 'stroke-dashoffset',
|
|
66
|
+
transitionDuration: {
|
|
67
|
+
default: '0s',
|
|
68
|
+
[stylex.when.ancestor('[data-reveal=shown]')]: {
|
|
69
|
+
default: '0s',
|
|
70
|
+
[media.motion]: pageMotion.longest
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
transitionTimingFunction: pageMotion.ease,
|
|
74
|
+
transitionDelay: {
|
|
75
|
+
default: '0s',
|
|
76
|
+
[stylex.when.ancestor('[data-reveal=shown]')]: 'calc(var(--narvi-reveal-delay, 0ms) + var(--narvi-sweep-delay, 0ms))'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
4
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
5
5
|
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
6
|
+
import { media } from '../../media.stylex.js';
|
|
6
7
|
|
|
7
8
|
export type SegmentedOption = { value: string; label: string; disabled?: boolean };
|
|
8
9
|
|
|
@@ -17,11 +18,6 @@
|
|
|
17
18
|
sx?: Sx;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
// StyleX needs these in the same file to evaluate them at build time
|
|
21
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
22
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
23
|
-
const FORCED = '@media (forced-colors: active)';
|
|
24
|
-
|
|
25
21
|
const styles = stylex.create({
|
|
26
22
|
root: {
|
|
27
23
|
WebkitAppRegion: 'no-drag',
|
|
@@ -54,16 +50,16 @@
|
|
|
54
50
|
':dir(rtl)': 'calc(var(--narvi-seg-index) * -100%) 0'
|
|
55
51
|
},
|
|
56
52
|
borderRadius: radius.sm,
|
|
57
|
-
backgroundColor: { default: colors.surfaceRaised, [
|
|
53
|
+
backgroundColor: { default: colors.surfaceRaised, [media.forcedColors]: 'Canvas' },
|
|
58
54
|
boxShadow: `inset 0 0 0 1px ${colors.lineStrong}, inset 0 1px 0 ${colors.highlight}, 0 1px 3px ${colors.shade}`,
|
|
59
55
|
outlineStyle: 'solid',
|
|
60
56
|
outlineWidth: '2px',
|
|
61
57
|
outlineOffset: '-2px',
|
|
62
|
-
outlineColor: { default: 'transparent', [
|
|
58
|
+
outlineColor: { default: 'transparent', [media.forcedColors]: 'Highlight' },
|
|
63
59
|
forcedColorAdjust: 'none'
|
|
64
60
|
},
|
|
65
61
|
thumbSlides: {
|
|
66
|
-
transitionProperty: { default: 'none', [
|
|
62
|
+
transitionProperty: { default: 'none', [media.motion]: 'translate' },
|
|
67
63
|
transitionDuration: motion.slow,
|
|
68
64
|
transitionTimingFunction: motion.easeInOut
|
|
69
65
|
},
|
|
@@ -95,7 +91,7 @@
|
|
|
95
91
|
borderRadius: radius.sm,
|
|
96
92
|
color: {
|
|
97
93
|
default: colors.textMuted,
|
|
98
|
-
':hover': { default: null, [
|
|
94
|
+
':hover': { default: null, [media.hover]: colors.text },
|
|
99
95
|
[stylex.when.siblingBefore(':checked')]: colors.text
|
|
100
96
|
},
|
|
101
97
|
fontSize: font.sizeMd,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { Dialog } from 'bits-ui';
|
|
3
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import Glyph from '../../internal/Glyph.svelte';
|
|
6
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
|
+
import Button from '../button/Button.svelte';
|
|
8
|
+
import { dialog } from '../dialog/styles.js';
|
|
9
|
+
import { sheet } from './styles.js';
|
|
10
|
+
|
|
11
|
+
export type SheetSide = 'start' | 'end' | 'top' | 'bottom';
|
|
12
|
+
|
|
13
|
+
export type SheetContentProps = Omit<Dialog.ContentProps, 'children' | 'child'> & {
|
|
14
|
+
/** The edge it slides in from. `start` and `end` follow the writing direction. */
|
|
15
|
+
side?: SheetSide;
|
|
16
|
+
/** How wide a sheet along the start or end is: 20, 26 or 36rem. */
|
|
17
|
+
size?: 'sm' | 'md' | 'lg';
|
|
18
|
+
/** Accessible name of the close button in the corner. `null` leaves it out. */
|
|
19
|
+
closeLabel?: string | null;
|
|
20
|
+
sx?: Sx;
|
|
21
|
+
/** A Sheet.Header, a Sheet.Body and a Sheet.Footer. */
|
|
22
|
+
children?: Snippet;
|
|
23
|
+
};
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
let {
|
|
28
|
+
side = 'end',
|
|
29
|
+
size = 'md',
|
|
30
|
+
closeLabel = 'Close',
|
|
31
|
+
ref = $bindable(null),
|
|
32
|
+
sx,
|
|
33
|
+
class: className,
|
|
34
|
+
children,
|
|
35
|
+
...rest
|
|
36
|
+
}: SheetContentProps = $props();
|
|
37
|
+
|
|
38
|
+
const across = $derived(side === 'start' || side === 'end');
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<Dialog.Portal>
|
|
42
|
+
<Dialog.Overlay data-slot="sheet-overlay" {...stylex.attrs(dialog.overlay)} />
|
|
43
|
+
<Dialog.Content
|
|
44
|
+
bind:ref
|
|
45
|
+
data-slot="sheet"
|
|
46
|
+
data-side={side}
|
|
47
|
+
{...rest}
|
|
48
|
+
{...attrs([dialog.content, sheet.sheet, across && sheet[size], sheet[side], sx], className)}
|
|
49
|
+
>
|
|
50
|
+
{@render children?.()}
|
|
51
|
+
{#if closeLabel}
|
|
52
|
+
<span {...stylex.attrs(dialog.close)}>
|
|
53
|
+
<Dialog.Close>
|
|
54
|
+
{#snippet child({ props })}
|
|
55
|
+
<Button {...props} variant="ghost" size="sm" iconOnly aria-label={closeLabel}>
|
|
56
|
+
<Glyph name="close" />
|
|
57
|
+
</Button>
|
|
58
|
+
{/snippet}
|
|
59
|
+
</Dialog.Close>
|
|
60
|
+
</span>
|
|
61
|
+
{/if}
|
|
62
|
+
</Dialog.Content>
|
|
63
|
+
</Dialog.Portal>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Dialog } from 'bits-ui';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
export type SheetSide = 'start' | 'end' | 'top' | 'bottom';
|
|
5
|
+
export type SheetContentProps = Omit<Dialog.ContentProps, 'children' | 'child'> & {
|
|
6
|
+
/** The edge it slides in from. `start` and `end` follow the writing direction. */
|
|
7
|
+
side?: SheetSide;
|
|
8
|
+
/** How wide a sheet along the start or end is: 20, 26 or 36rem. */
|
|
9
|
+
size?: 'sm' | 'md' | 'lg';
|
|
10
|
+
/** Accessible name of the close button in the corner. `null` leaves it out. */
|
|
11
|
+
closeLabel?: string | null;
|
|
12
|
+
sx?: Sx;
|
|
13
|
+
/** A Sheet.Header, a Sheet.Body and a Sheet.Footer. */
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
};
|
|
16
|
+
declare const SheetContent: import("svelte").Component<SheetContentProps, {}, "ref">;
|
|
17
|
+
type SheetContent = ReturnType<typeof SheetContent>;
|
|
18
|
+
export default SheetContent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dialog } from 'bits-ui';
|
|
2
|
+
import Body from '../dialog/DialogBody.svelte';
|
|
3
|
+
import Description from '../dialog/DialogDescription.svelte';
|
|
4
|
+
import Footer from '../dialog/DialogFooter.svelte';
|
|
5
|
+
import Header from '../dialog/DialogHeader.svelte';
|
|
6
|
+
import Title from '../dialog/DialogTitle.svelte';
|
|
7
|
+
import Content from './SheetContent.svelte';
|
|
8
|
+
declare const Root: import("svelte").Component<import("bits-ui").AlertDialogRootPropsWithoutHTML, {}, "open">;
|
|
9
|
+
declare const Trigger: import("svelte").Component<Dialog.TriggerProps, {}, "ref">;
|
|
10
|
+
declare const Close: import("svelte").Component<Dialog.TriggerProps, {}, "ref">;
|
|
11
|
+
export { Root, Trigger, Content, Header, Title, Description, Body, Footer, Close };
|
|
12
|
+
export type { SheetContentProps, SheetSide } from './SheetContent.svelte';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dialog } from 'bits-ui';
|
|
2
|
+
import Body from '../dialog/DialogBody.svelte';
|
|
3
|
+
import Description from '../dialog/DialogDescription.svelte';
|
|
4
|
+
import Footer from '../dialog/DialogFooter.svelte';
|
|
5
|
+
import Header from '../dialog/DialogHeader.svelte';
|
|
6
|
+
import Title from '../dialog/DialogTitle.svelte';
|
|
7
|
+
import Content from './SheetContent.svelte';
|
|
8
|
+
// A sheet is a dialog along an edge: the same behaviour and the same parts
|
|
9
|
+
const Root = Dialog.Root;
|
|
10
|
+
const Trigger = Dialog.Trigger;
|
|
11
|
+
const Close = Dialog.Close;
|
|
12
|
+
export { Root, Trigger, Content, Header, Title, Description, Body, Footer, Close };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
/** Laid over Dialog's content: a panel along one edge of the window, which it slides in from. */
|
|
3
|
+
export declare const sheet: Readonly<{
|
|
4
|
+
readonly sheet: Readonly<{
|
|
5
|
+
readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "none">;
|
|
6
|
+
readonly marginInline: stylex.StyleXClassNameFor<"marginInline", 0>;
|
|
7
|
+
readonly translate: stylex.StyleXClassNameFor<"translate", "none">;
|
|
8
|
+
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", 0>;
|
|
9
|
+
readonly scale: stylex.StyleXClassNameFor<"scale", null>;
|
|
10
|
+
readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "opacity" | "opacity, translate">;
|
|
11
|
+
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
12
|
+
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", "cubic-bezier(0.32, 0.72, 0, 1)">;
|
|
13
|
+
}>;
|
|
14
|
+
readonly sm: Readonly<{
|
|
15
|
+
readonly width: stylex.StyleXClassNameFor<"width", "min(20rem, calc(100vw - 2rem))">;
|
|
16
|
+
}>;
|
|
17
|
+
readonly md: Readonly<{
|
|
18
|
+
readonly width: stylex.StyleXClassNameFor<"width", "min(26rem, calc(100vw - 2rem))">;
|
|
19
|
+
}>;
|
|
20
|
+
readonly lg: Readonly<{
|
|
21
|
+
readonly width: stylex.StyleXClassNameFor<"width", "min(36rem, calc(100vw - 2rem))">;
|
|
22
|
+
}>;
|
|
23
|
+
readonly end: Readonly<{
|
|
24
|
+
readonly top: stylex.StyleXClassNameFor<"top", 0>;
|
|
25
|
+
readonly bottom: stylex.StyleXClassNameFor<"bottom", 0>;
|
|
26
|
+
readonly insetInlineStart: stylex.StyleXClassNameFor<"insetInlineStart", "auto">;
|
|
27
|
+
readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", 0>;
|
|
28
|
+
readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "100% 0" | null>;
|
|
29
|
+
}>;
|
|
30
|
+
readonly start: Readonly<{
|
|
31
|
+
readonly top: stylex.StyleXClassNameFor<"top", 0>;
|
|
32
|
+
readonly bottom: stylex.StyleXClassNameFor<"bottom", 0>;
|
|
33
|
+
readonly insetInlineStart: stylex.StyleXClassNameFor<"insetInlineStart", 0>;
|
|
34
|
+
readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", "auto">;
|
|
35
|
+
readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "-100% 0" | null>;
|
|
36
|
+
}>;
|
|
37
|
+
readonly top: Readonly<{
|
|
38
|
+
readonly top: stylex.StyleXClassNameFor<"top", 0>;
|
|
39
|
+
readonly bottom: stylex.StyleXClassNameFor<"bottom", "auto">;
|
|
40
|
+
readonly width: stylex.StyleXClassNameFor<"width", "100%">;
|
|
41
|
+
readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "calc(100dvh - 4rem)">;
|
|
42
|
+
readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "0 -100%" | null>;
|
|
43
|
+
}>;
|
|
44
|
+
readonly bottom: Readonly<{
|
|
45
|
+
readonly top: stylex.StyleXClassNameFor<"top", "auto">;
|
|
46
|
+
readonly bottom: stylex.StyleXClassNameFor<"bottom", 0>;
|
|
47
|
+
readonly width: stylex.StyleXClassNameFor<"width", "100%">;
|
|
48
|
+
readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "calc(100dvh - 4rem)">;
|
|
49
|
+
readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "0 100%" | null>;
|
|
50
|
+
}>;
|
|
51
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import { motion } from '../../tokens.stylex.js';
|
|
3
|
+
import { media } from '../../media.stylex.js';
|
|
4
|
+
const CLOSED = ':is([data-state="closed"])';
|
|
5
|
+
// iOS's drawer curve: it leaves the edge quickly and settles long
|
|
6
|
+
const DRAWER = 'cubic-bezier(0.32, 0.72, 0, 1)';
|
|
7
|
+
/** Laid over Dialog's content: a panel along one edge of the window, which it slides in from. */
|
|
8
|
+
export const sheet = stylex.create({
|
|
9
|
+
sheet: {
|
|
10
|
+
maxHeight: 'none',
|
|
11
|
+
marginInline: 0,
|
|
12
|
+
translate: 'none',
|
|
13
|
+
borderRadius: 0,
|
|
14
|
+
scale: null,
|
|
15
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, translate' },
|
|
16
|
+
transitionDuration: { default: motion.slow, [CLOSED]: motion.base },
|
|
17
|
+
transitionTimingFunction: DRAWER
|
|
18
|
+
},
|
|
19
|
+
// Widths of a sheet along the start or end
|
|
20
|
+
sm: { width: 'min(20rem, calc(100vw - 2rem))' },
|
|
21
|
+
md: { width: 'min(26rem, calc(100vw - 2rem))' },
|
|
22
|
+
lg: { width: 'min(36rem, calc(100vw - 2rem))' },
|
|
23
|
+
end: {
|
|
24
|
+
top: 0,
|
|
25
|
+
bottom: 0,
|
|
26
|
+
insetInlineStart: 'auto',
|
|
27
|
+
insetInlineEnd: 0,
|
|
28
|
+
translate: {
|
|
29
|
+
default: null,
|
|
30
|
+
[media.motion]: { default: '0 0', '@starting-style': '100% 0', [CLOSED]: '100% 0' }
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
start: {
|
|
34
|
+
top: 0,
|
|
35
|
+
bottom: 0,
|
|
36
|
+
insetInlineStart: 0,
|
|
37
|
+
insetInlineEnd: 'auto',
|
|
38
|
+
translate: {
|
|
39
|
+
default: null,
|
|
40
|
+
[media.motion]: { default: '0 0', '@starting-style': '-100% 0', [CLOSED]: '-100% 0' }
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
// Along the top or bottom it runs the full width, as tall as its content, and
|
|
44
|
+
// never more than the window less 4rem, so the page it covers still shows
|
|
45
|
+
top: {
|
|
46
|
+
top: 0,
|
|
47
|
+
bottom: 'auto',
|
|
48
|
+
width: '100%',
|
|
49
|
+
maxHeight: 'calc(100dvh - 4rem)',
|
|
50
|
+
translate: {
|
|
51
|
+
default: null,
|
|
52
|
+
[media.motion]: { default: '0 0', '@starting-style': '0 -100%', [CLOSED]: '0 -100%' }
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
bottom: {
|
|
56
|
+
top: 'auto',
|
|
57
|
+
bottom: 0,
|
|
58
|
+
width: '100%',
|
|
59
|
+
maxHeight: 'calc(100dvh - 4rem)',
|
|
60
|
+
translate: {
|
|
61
|
+
default: null,
|
|
62
|
+
[media.motion]: { default: '0 0', '@starting-style': '0 100%', [CLOSED]: '0 100%' }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { loop } from '../../internal/loop.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
import { colors } from '../../tokens.stylex.js';
|
|
8
|
+
import { media } from '../../media.stylex.js';
|
|
8
9
|
|
|
9
10
|
export type ShimmerProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
|
|
10
11
|
/** Turn it off to show the text plainly, for example once the work is done. */
|
|
@@ -13,9 +14,6 @@
|
|
|
13
14
|
children?: Snippet;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const REDUCE = '@media (prefers-reduced-motion: reduce)';
|
|
17
|
-
const FORCED = '@media (forced-colors: active)';
|
|
18
|
-
|
|
19
17
|
const styles = stylex.create({
|
|
20
18
|
// Inline, so it wraps and truncates like the text around it
|
|
21
19
|
base: {
|
|
@@ -23,11 +21,15 @@
|
|
|
23
21
|
},
|
|
24
22
|
// Ithildin: the letters are only half there until moonlight passes over them
|
|
25
23
|
active: {
|
|
26
|
-
color: {
|
|
24
|
+
color: {
|
|
25
|
+
default: 'transparent',
|
|
26
|
+
[media.reducedMotion]: colors.textMuted,
|
|
27
|
+
[media.forcedColors]: 'CanvasText'
|
|
28
|
+
},
|
|
27
29
|
backgroundImage: {
|
|
28
30
|
default: `linear-gradient(90deg, ${colors.textSubtle} 0%, ${colors.textSubtle} 40%, ${colors.ithil} 50%, ${colors.textSubtle} 60%, ${colors.textSubtle} 100%)`,
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
+
[media.reducedMotion]: 'none',
|
|
32
|
+
[media.forcedColors]: 'none'
|
|
31
33
|
},
|
|
32
34
|
backgroundSize: '300% 100%',
|
|
33
35
|
backgroundClip: 'text',
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import Collapse from '../../internal/Collapse.svelte';
|
|
7
7
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
8
8
|
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
9
|
+
import { media } from '../../media.stylex.js';
|
|
9
10
|
|
|
10
11
|
export type SidebarGroupProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
11
12
|
/** The group's name: a project, or "Today". */
|
|
@@ -21,8 +22,6 @@
|
|
|
21
22
|
children?: Snippet;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
25
|
-
|
|
26
25
|
const styles = stylex.create({
|
|
27
26
|
group: { display: 'flex', flexDirection: 'column', paddingTop: '0.75rem' },
|
|
28
27
|
head: {
|
|
@@ -44,7 +43,10 @@
|
|
|
44
43
|
borderWidth: 0,
|
|
45
44
|
borderRadius: radius.xs,
|
|
46
45
|
backgroundColor: 'transparent',
|
|
47
|
-
color: {
|
|
46
|
+
color: {
|
|
47
|
+
default: colors.textSubtle,
|
|
48
|
+
':hover': { default: null, [media.hover]: colors.textMuted }
|
|
49
|
+
},
|
|
48
50
|
fontFamily: font.mono,
|
|
49
51
|
fontSize: '0.6875rem',
|
|
50
52
|
letterSpacing: '0.04em',
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { sidebarItemMarker } from '../../internal/markers.stylex.js';
|
|
11
11
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
12
12
|
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
13
|
+
import { media } from '../../media.stylex.js';
|
|
13
14
|
|
|
14
15
|
export type SidebarItemProps = Omit<HTMLAnchorAttributes, 'children'> & {
|
|
15
16
|
/** A link to go to. Without it the row is a button; listen with `onclick`. */
|
|
@@ -33,8 +34,6 @@
|
|
|
33
34
|
children?: Snippet;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
37
|
-
const FORCED = '@media (forced-colors: active)';
|
|
38
37
|
// StyleX reads `when` only where it is written inline, in the keys below
|
|
39
38
|
|
|
40
39
|
const styles = stylex.create({
|
|
@@ -56,7 +55,7 @@
|
|
|
56
55
|
borderRadius: radius.lg,
|
|
57
56
|
backgroundColor: {
|
|
58
57
|
default: 'transparent',
|
|
59
|
-
':hover': { default: null, [
|
|
58
|
+
':hover': { default: null, [media.hover]: colors.hover }
|
|
60
59
|
},
|
|
61
60
|
color: colors.text,
|
|
62
61
|
fontFamily: 'inherit',
|
|
@@ -68,7 +67,7 @@
|
|
|
68
67
|
WebkitTapHighlightColor: 'transparent',
|
|
69
68
|
WebkitAppRegion: 'no-drag',
|
|
70
69
|
outlineStyle: 'solid',
|
|
71
|
-
outlineWidth: { default: 0, ':focus-visible': '2px', [
|
|
70
|
+
outlineWidth: { default: 0, ':focus-visible': '2px', [media.forcedColors]: '1px' },
|
|
72
71
|
outlineColor: { default: 'transparent', ':focus-visible': colors.focusRing },
|
|
73
72
|
outlineOffset: '-2px',
|
|
74
73
|
transitionProperty: 'background-color, color',
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
bottom: '25%',
|
|
91
90
|
width: '2px',
|
|
92
91
|
borderRadius: '2px',
|
|
93
|
-
backgroundColor: { default: colors.ithil, [
|
|
92
|
+
backgroundColor: { default: colors.ithil, [media.forcedColors]: 'Highlight' },
|
|
94
93
|
boxShadow: `0 0 8px ${colors.glow}`,
|
|
95
94
|
forcedColorAdjust: 'none'
|
|
96
95
|
}
|
|
@@ -129,7 +128,7 @@
|
|
|
129
128
|
trailHides: {
|
|
130
129
|
opacity: {
|
|
131
130
|
default: 1,
|
|
132
|
-
[
|
|
131
|
+
[media.hover]: { default: 1, [stylex.when.ancestor(':hover', sidebarItemMarker)]: 0 },
|
|
133
132
|
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 0
|
|
134
133
|
}
|
|
135
134
|
},
|
|
@@ -157,12 +156,15 @@
|
|
|
157
156
|
boxShadow: `inset 0 0 0 1px ${colors.line}, 0 2px 6px -2px ${colors.shade}`,
|
|
158
157
|
opacity: {
|
|
159
158
|
default: 1,
|
|
160
|
-
[
|
|
159
|
+
[media.hover]: { default: 0, [stylex.when.ancestor(':hover', sidebarItemMarker)]: 1 },
|
|
161
160
|
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 1
|
|
162
161
|
},
|
|
163
162
|
pointerEvents: {
|
|
164
163
|
default: 'auto',
|
|
165
|
-
[
|
|
164
|
+
[media.hover]: {
|
|
165
|
+
default: 'none',
|
|
166
|
+
[stylex.when.ancestor(':hover', sidebarItemMarker)]: 'auto'
|
|
167
|
+
},
|
|
166
168
|
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 'auto'
|
|
167
169
|
},
|
|
168
170
|
transitionProperty: 'opacity',
|