@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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { loop } from '../../internal/loop.js';
|
|
5
5
|
import type { Sx } from '../../internal/sx.js';
|
|
6
6
|
import { colors, motion, radius } from '../../tokens.stylex.js';
|
|
7
|
+
import { media } from '../../media.stylex.js';
|
|
7
8
|
import Button, { type ButtonProps } from '../button/Button.svelte';
|
|
8
9
|
import { useComposer } from './context.js';
|
|
9
10
|
|
|
@@ -19,8 +20,6 @@
|
|
|
19
20
|
ref?: HTMLButtonElement | null;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
23
|
-
|
|
24
23
|
// While the reply has not started, an arc circles the square, on the shared clock
|
|
25
24
|
const spin = loop(
|
|
26
25
|
(reduced) => (reduced ? 2400 : 900),
|
|
@@ -54,14 +53,14 @@
|
|
|
54
53
|
gridArea: '1 / 1',
|
|
55
54
|
display: 'grid',
|
|
56
55
|
placeItems: 'center',
|
|
57
|
-
transitionProperty: { default: 'opacity', [
|
|
56
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale, filter' },
|
|
58
57
|
transitionDuration: motion.slow,
|
|
59
58
|
transitionTimingFunction: motion.easeOut
|
|
60
59
|
},
|
|
61
60
|
gone: {
|
|
62
61
|
opacity: 0,
|
|
63
|
-
scale: { default: null, [
|
|
64
|
-
filter: { default: null, [
|
|
62
|
+
scale: { default: null, [media.motion]: 0.5 },
|
|
63
|
+
filter: { default: null, [media.motion]: 'blur(2px)' }
|
|
65
64
|
},
|
|
66
65
|
// While the reply has not started, an arc circles the square
|
|
67
66
|
ring: {
|
|
@@ -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 ComposerToggleProps = Omit<HTMLButtonAttributes, 'children'> & {
|
|
@@ -16,10 +17,6 @@
|
|
|
16
17
|
children?: Snippet;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
20
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
21
|
-
const FORCED = '@media (forced-colors: active)';
|
|
22
|
-
|
|
23
20
|
const styles = stylex.create({
|
|
24
21
|
toggle: {
|
|
25
22
|
display: 'inline-flex',
|
|
@@ -33,12 +30,12 @@
|
|
|
33
30
|
borderRadius: `calc(${radius.xl} * 4 / 3)`,
|
|
34
31
|
backgroundColor: {
|
|
35
32
|
default: 'transparent',
|
|
36
|
-
':hover': { default: null, [
|
|
33
|
+
':hover': { default: null, [media.hover]: colors.hover }
|
|
37
34
|
},
|
|
38
35
|
boxShadow: `inset 0 0 0 1px ${colors.line}`,
|
|
39
36
|
color: {
|
|
40
37
|
default: colors.textMuted,
|
|
41
|
-
':hover': { default: null, [
|
|
38
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
42
39
|
},
|
|
43
40
|
fontFamily: 'inherit',
|
|
44
41
|
fontSize: font.sizeSm,
|
|
@@ -48,13 +45,16 @@
|
|
|
48
45
|
cursor: { default: 'pointer', ':disabled': 'not-allowed' },
|
|
49
46
|
opacity: { default: 1, ':disabled': 0.5 },
|
|
50
47
|
WebkitTapHighlightColor: 'transparent',
|
|
51
|
-
scale: { default: null, ':active': { default: null, [
|
|
48
|
+
scale: { default: null, ':active': { default: null, [media.motion]: 0.96 } },
|
|
52
49
|
transitionProperty: {
|
|
53
50
|
default: 'background-color, color, box-shadow',
|
|
54
|
-
[
|
|
51
|
+
[media.motion]: 'scale, background-color, color, box-shadow'
|
|
55
52
|
},
|
|
56
53
|
transitionDuration: motion.base,
|
|
57
|
-
transitionTimingFunction: {
|
|
54
|
+
transitionTimingFunction: {
|
|
55
|
+
default: 'ease',
|
|
56
|
+
[media.motion]: `${motion.easeOut}, ease, ease, ease`
|
|
57
|
+
}
|
|
58
58
|
},
|
|
59
59
|
// The icon leads, so the pill is a touch tighter on that side
|
|
60
60
|
withIcon: { paddingInlineStart: '0.5rem' },
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
on: {
|
|
63
63
|
backgroundColor: {
|
|
64
64
|
default: colors.ithilSoft,
|
|
65
|
-
':hover': { default: null, [
|
|
65
|
+
':hover': { default: null, [media.hover]: colors.focusHalo }
|
|
66
66
|
},
|
|
67
67
|
boxShadow: `inset 0 0 0 1px color-mix(in oklab, ${colors.ithil} 35%, transparent)`,
|
|
68
|
-
color: { default: colors.ithil, ':hover': colors.ithil, [
|
|
68
|
+
color: { default: colors.ithil, ':hover': colors.ithil, [media.forcedColors]: 'Highlight' }
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
</script>
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { shared } from '../../internal/shared.js';
|
|
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
|
import { useConversation } from './context.js';
|
|
10
11
|
|
|
11
12
|
export type ConversationScrollButtonProps = Omit<HTMLButtonAttributes, 'children'> & {
|
|
@@ -17,9 +18,6 @@
|
|
|
17
18
|
children?: Snippet;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
21
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
22
|
-
|
|
23
21
|
const styles = stylex.create({
|
|
24
22
|
button: {
|
|
25
23
|
position: 'absolute',
|
|
@@ -40,7 +38,7 @@
|
|
|
40
38
|
backgroundColor: colors.bgRaised,
|
|
41
39
|
color: {
|
|
42
40
|
default: colors.textMuted,
|
|
43
|
-
':hover': { default: null, [
|
|
41
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
44
42
|
},
|
|
45
43
|
boxShadow: `inset 0 0 0 1px ${colors.lineStrong}, inset 0 1px 0 ${colors.highlight}, 0 1px 2px ${colors.shade}, 0 8px 20px -8px ${colors.shade}`,
|
|
46
44
|
fontFamily: font.body,
|
|
@@ -53,10 +51,10 @@
|
|
|
53
51
|
// It rises into place, and drops away a little faster than it came
|
|
54
52
|
opacity: 1,
|
|
55
53
|
translate: '0 0',
|
|
56
|
-
scale: { default: null, ':active': { default: null, [
|
|
54
|
+
scale: { default: null, ':active': { default: null, [media.motion]: 0.96 } },
|
|
57
55
|
transitionProperty: {
|
|
58
56
|
default: 'opacity, color',
|
|
59
|
-
[
|
|
57
|
+
[media.motion]: 'opacity, translate, scale, color'
|
|
60
58
|
},
|
|
61
59
|
transitionDuration: motion.slow,
|
|
62
60
|
transitionTimingFunction: motion.easeOut
|
|
@@ -67,8 +65,8 @@
|
|
|
67
65
|
},
|
|
68
66
|
hidden: {
|
|
69
67
|
opacity: 0,
|
|
70
|
-
translate: { default: null, [
|
|
71
|
-
scale: { default: null, [
|
|
68
|
+
translate: { default: null, [media.motion]: '0 8px' },
|
|
69
|
+
scale: { default: null, [media.motion]: 0.94 },
|
|
72
70
|
pointerEvents: 'none',
|
|
73
71
|
transitionDuration: motion.base
|
|
74
72
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import Glyph from '../../internal/Glyph.svelte';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
import Button from '../button/Button.svelte';
|
|
8
|
+
import { sheet } from '../sheet/styles.js';
|
|
8
9
|
import { dialog } from './styles.js';
|
|
9
10
|
|
|
10
11
|
export type DialogContentProps = Omit<Dialog.ContentProps, 'children' | 'child'> & {
|
|
@@ -37,7 +38,10 @@
|
|
|
37
38
|
<Dialog.Content
|
|
38
39
|
data-slot="dialog-content"
|
|
39
40
|
{...rest}
|
|
40
|
-
{...attrs(
|
|
41
|
+
{...attrs(
|
|
42
|
+
[dialog.content, side ? [sheet.sheet, sheet.md, sheet[side]] : dialog[size], sx],
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
41
45
|
>
|
|
42
46
|
{@render children?.()}
|
|
43
47
|
{#if closeLabel}
|
|
@@ -48,29 +48,6 @@ export declare const dialog: Readonly<{
|
|
|
48
48
|
readonly lg: Readonly<{
|
|
49
49
|
readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "44rem">;
|
|
50
50
|
}>;
|
|
51
|
-
readonly sheet: Readonly<{
|
|
52
|
-
readonly top: stylex.StyleXClassNameFor<"top", 0>;
|
|
53
|
-
readonly bottom: stylex.StyleXClassNameFor<"bottom", 0>;
|
|
54
|
-
readonly width: stylex.StyleXClassNameFor<"width", "min(26rem, calc(100vw - 2rem))">;
|
|
55
|
-
readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "none">;
|
|
56
|
-
readonly marginInline: stylex.StyleXClassNameFor<"marginInline", 0>;
|
|
57
|
-
readonly translate: stylex.StyleXClassNameFor<"translate", "none">;
|
|
58
|
-
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", 0>;
|
|
59
|
-
readonly scale: stylex.StyleXClassNameFor<"scale", null>;
|
|
60
|
-
readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "opacity" | "opacity, translate">;
|
|
61
|
-
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
62
|
-
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", "cubic-bezier(0.32, 0.72, 0, 1)">;
|
|
63
|
-
}>;
|
|
64
|
-
readonly end: Readonly<{
|
|
65
|
-
readonly insetInlineStart: stylex.StyleXClassNameFor<"insetInlineStart", "auto">;
|
|
66
|
-
readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", 0>;
|
|
67
|
-
readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "100% 0" | null>;
|
|
68
|
-
}>;
|
|
69
|
-
readonly start: Readonly<{
|
|
70
|
-
readonly insetInlineStart: stylex.StyleXClassNameFor<"insetInlineStart", 0>;
|
|
71
|
-
readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", "auto">;
|
|
72
|
-
readonly translate: stylex.StyleXClassNameFor<"translate", "0 0" | "-100% 0" | null>;
|
|
73
|
-
}>;
|
|
74
51
|
readonly header: Readonly<{
|
|
75
52
|
readonly display: stylex.StyleXClassNameFor<"display", "flex">;
|
|
76
53
|
readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
2
|
import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
|
|
3
|
-
|
|
4
|
-
const FORCED = '@media (forced-colors: active)';
|
|
3
|
+
import { media } from '../../media.stylex.js';
|
|
5
4
|
const CLOSED = ':is([data-state="closed"])';
|
|
6
5
|
export const dialog = stylex.create({
|
|
7
6
|
overlay: {
|
|
@@ -36,56 +35,21 @@ export const dialog = stylex.create({
|
|
|
36
35
|
fontSize: font.sizeMd,
|
|
37
36
|
lineHeight: font.leadingNormal,
|
|
38
37
|
outlineStyle: 'solid',
|
|
39
|
-
outlineWidth: { default: 0, [
|
|
38
|
+
outlineWidth: { default: 0, [media.forcedColors]: '1px' },
|
|
40
39
|
outlineColor: 'CanvasText',
|
|
41
40
|
// A modal is not tied to a trigger, so it grows from its own centre
|
|
42
41
|
opacity: { default: 1, '@starting-style': 0, [CLOSED]: 0 },
|
|
43
|
-
scale: {
|
|
44
|
-
|
|
42
|
+
scale: {
|
|
43
|
+
default: null,
|
|
44
|
+
[media.motion]: { default: 1, '@starting-style': 0.96, [CLOSED]: 0.98 }
|
|
45
|
+
},
|
|
46
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale' },
|
|
45
47
|
transitionDuration: { default: motion.base, [CLOSED]: motion.fast },
|
|
46
48
|
transitionTimingFunction: motion.easeOut
|
|
47
49
|
},
|
|
48
50
|
sm: { maxWidth: '24rem' },
|
|
49
51
|
md: { maxWidth: '32rem' },
|
|
50
52
|
lg: { maxWidth: '44rem' },
|
|
51
|
-
// A sheet: the full height of the window, along one edge
|
|
52
|
-
sheet: {
|
|
53
|
-
top: 0,
|
|
54
|
-
bottom: 0,
|
|
55
|
-
width: 'min(26rem, calc(100vw - 2rem))',
|
|
56
|
-
maxHeight: 'none',
|
|
57
|
-
marginInline: 0,
|
|
58
|
-
translate: 'none',
|
|
59
|
-
borderRadius: 0,
|
|
60
|
-
scale: null,
|
|
61
|
-
transitionProperty: { default: 'opacity', [MOTION]: 'opacity, translate' },
|
|
62
|
-
transitionDuration: { default: motion.slow, [CLOSED]: motion.base },
|
|
63
|
-
transitionTimingFunction: 'cubic-bezier(0.32, 0.72, 0, 1)'
|
|
64
|
-
},
|
|
65
|
-
end: {
|
|
66
|
-
insetInlineStart: 'auto',
|
|
67
|
-
insetInlineEnd: 0,
|
|
68
|
-
translate: {
|
|
69
|
-
default: null,
|
|
70
|
-
[MOTION]: {
|
|
71
|
-
default: '0 0',
|
|
72
|
-
'@starting-style': '100% 0',
|
|
73
|
-
[CLOSED]: '100% 0'
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
start: {
|
|
78
|
-
insetInlineStart: 0,
|
|
79
|
-
insetInlineEnd: 'auto',
|
|
80
|
-
translate: {
|
|
81
|
-
default: null,
|
|
82
|
-
[MOTION]: {
|
|
83
|
-
default: '0 0',
|
|
84
|
-
'@starting-style': '-100% 0',
|
|
85
|
-
[CLOSED]: '-100% 0'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
53
|
header: {
|
|
90
54
|
display: 'flex',
|
|
91
55
|
flexDirection: 'column',
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import * as stylex from '@stylexjs/stylex';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
|
+
import {
|
|
6
|
+
alignStyles,
|
|
7
|
+
columnsStyles,
|
|
8
|
+
gapStyles,
|
|
9
|
+
type Align,
|
|
10
|
+
type Columns,
|
|
11
|
+
type Gap
|
|
12
|
+
} from '../../internal/layout.js';
|
|
13
|
+
import {
|
|
14
|
+
breakpoints,
|
|
15
|
+
isByBreakpoint,
|
|
16
|
+
responsive,
|
|
17
|
+
type Responsive
|
|
18
|
+
} from '../../internal/responsive.js';
|
|
19
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
20
|
+
|
|
21
|
+
/** Steps on the 4px spacing scale: `4` is 16px. */
|
|
22
|
+
export type GridGap = Gap;
|
|
23
|
+
export type GridAlign = Align;
|
|
24
|
+
/**
|
|
25
|
+
* A number of equal columns, from 1 to 12, or a `grid-template-columns` value of your own,
|
|
26
|
+
* such as `'1.15fr 1fr'` or `'repeat(auto-fill, minmax(14rem, 1fr))'`.
|
|
27
|
+
*/
|
|
28
|
+
export type GridColumns = Columns | (string & {});
|
|
29
|
+
|
|
30
|
+
export type GridProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
31
|
+
/** Element to render. A `ul` or `ol` loses its markers and indent. */
|
|
32
|
+
as?: 'div' | 'section' | 'article' | 'nav' | 'header' | 'footer' | 'main' | 'ul' | 'ol' | 'li';
|
|
33
|
+
/** Columns. Like every layout prop, a value or values by breakpoint. */
|
|
34
|
+
columns?: Responsive<GridColumns>;
|
|
35
|
+
gap?: Responsive<GridGap>;
|
|
36
|
+
/** Alignment of each item in its cell, on the block axis. Items stretch by default. */
|
|
37
|
+
align?: Responsive<GridAlign>;
|
|
38
|
+
sx?: Sx;
|
|
39
|
+
children?: Snippet;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const styles = stylex.create({
|
|
43
|
+
base: {
|
|
44
|
+
display: 'grid',
|
|
45
|
+
boxSizing: 'border-box',
|
|
46
|
+
minWidth: 0,
|
|
47
|
+
margin: 0,
|
|
48
|
+
padding: 0,
|
|
49
|
+
listStyleType: 'none'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// A template of your own cannot be known at build time. It is set as a custom property,
|
|
54
|
+
// inline, and read by the same static rules as a count. (Always a custom property: StyleX's
|
|
55
|
+
// `attrs` misnames the inline variable of a dynamic style on a camel-cased property.)
|
|
56
|
+
const templates = stylex.create({
|
|
57
|
+
default: (template: string) => ({ '--narvi-columns': template }),
|
|
58
|
+
sm: (template: string) => ({ '--narvi-columns-sm': template }),
|
|
59
|
+
md: (template: string) => ({ '--narvi-columns-md': template }),
|
|
60
|
+
lg: (template: string) => ({ '--narvi-columns-lg': template }),
|
|
61
|
+
xl: (template: string) => ({ '--narvi-columns-xl': template })
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const isCount = (value: GridColumns): value is Columns => typeof value === 'number';
|
|
65
|
+
|
|
66
|
+
function columnStyles(columns: Responsive<GridColumns> | undefined) {
|
|
67
|
+
if (!isByBreakpoint(columns)) {
|
|
68
|
+
const value = columns ?? 1;
|
|
69
|
+
return isCount(value)
|
|
70
|
+
? [columnsStyles.fixed[value]]
|
|
71
|
+
: [columnsStyles.chain, templates.default(value)];
|
|
72
|
+
}
|
|
73
|
+
const result: unknown[] = [columnsStyles.chain];
|
|
74
|
+
for (const at of ['default', ...breakpoints] as const) {
|
|
75
|
+
const value = at === 'default' ? (columns.default ?? 1) : columns[at];
|
|
76
|
+
if (value === undefined) continue;
|
|
77
|
+
result.push(isCount(value) ? columnsStyles.set[at][value] : templates[at](value));
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<script lang="ts">
|
|
84
|
+
let {
|
|
85
|
+
as = 'div',
|
|
86
|
+
columns = 1,
|
|
87
|
+
gap = 4,
|
|
88
|
+
align,
|
|
89
|
+
sx,
|
|
90
|
+
class: className,
|
|
91
|
+
children,
|
|
92
|
+
...rest
|
|
93
|
+
}: GridProps = $props();
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<svelte:element
|
|
97
|
+
this={as}
|
|
98
|
+
{...rest}
|
|
99
|
+
{...attrs(
|
|
100
|
+
[
|
|
101
|
+
styles.base,
|
|
102
|
+
columnStyles(columns) as ReadonlyArray<Readonly<Record<string, unknown>>>,
|
|
103
|
+
responsive(gap, 4, gapStyles),
|
|
104
|
+
responsive(align, undefined, alignStyles),
|
|
105
|
+
sx
|
|
106
|
+
],
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
{@render children?.()}
|
|
111
|
+
</svelte:element>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Align, type Columns, type Gap } from '../../internal/layout.js';
|
|
4
|
+
import { type Responsive } from '../../internal/responsive.js';
|
|
5
|
+
import { type Sx } from '../../internal/sx.js';
|
|
6
|
+
/** Steps on the 4px spacing scale: `4` is 16px. */
|
|
7
|
+
export type GridGap = Gap;
|
|
8
|
+
export type GridAlign = Align;
|
|
9
|
+
/**
|
|
10
|
+
* A number of equal columns, from 1 to 12, or a `grid-template-columns` value of your own,
|
|
11
|
+
* such as `'1.15fr 1fr'` or `'repeat(auto-fill, minmax(14rem, 1fr))'`.
|
|
12
|
+
*/
|
|
13
|
+
export type GridColumns = Columns | (string & {});
|
|
14
|
+
export type GridProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
15
|
+
/** Element to render. A `ul` or `ol` loses its markers and indent. */
|
|
16
|
+
as?: 'div' | 'section' | 'article' | 'nav' | 'header' | 'footer' | 'main' | 'ul' | 'ol' | 'li';
|
|
17
|
+
/** Columns. Like every layout prop, a value or values by breakpoint. */
|
|
18
|
+
columns?: Responsive<GridColumns>;
|
|
19
|
+
gap?: Responsive<GridGap>;
|
|
20
|
+
/** Alignment of each item in its cell, on the block axis. Items stretch by default. */
|
|
21
|
+
align?: Responsive<GridAlign>;
|
|
22
|
+
sx?: Sx;
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
};
|
|
25
|
+
declare const Grid: import("svelte").Component<GridProps, {}, "">;
|
|
26
|
+
type Grid = ReturnType<typeof Grid>;
|
|
27
|
+
export default Grid;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { LinkPreview } from 'bits-ui';
|
|
3
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { layer } from '../../internal/layer.js';
|
|
6
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
|
+
|
|
8
|
+
export type HoverCardContentProps = Omit<LinkPreview.ContentProps, 'children' | 'child'> & {
|
|
9
|
+
sx?: Sx;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const styles = stylex.create({
|
|
14
|
+
// A card of its own content: a preview of a thread, a file, a person
|
|
15
|
+
card: {
|
|
16
|
+
width: '20rem',
|
|
17
|
+
minWidth: 0,
|
|
18
|
+
padding: '0.75rem'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
let {
|
|
25
|
+
side = 'bottom',
|
|
26
|
+
sideOffset = 6,
|
|
27
|
+
collisionPadding = 8,
|
|
28
|
+
align = 'start',
|
|
29
|
+
ref = $bindable(null),
|
|
30
|
+
sx,
|
|
31
|
+
class: className,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
}: HoverCardContentProps = $props();
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<LinkPreview.Portal>
|
|
38
|
+
<LinkPreview.Content
|
|
39
|
+
bind:ref
|
|
40
|
+
{side}
|
|
41
|
+
{sideOffset}
|
|
42
|
+
{collisionPadding}
|
|
43
|
+
{align}
|
|
44
|
+
data-slot="hover-card"
|
|
45
|
+
{...rest}
|
|
46
|
+
{...attrs([layer.surface, styles.card, sx], className)}
|
|
47
|
+
>
|
|
48
|
+
{@render children?.()}
|
|
49
|
+
</LinkPreview.Content>
|
|
50
|
+
</LinkPreview.Portal>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LinkPreview } from 'bits-ui';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
export type HoverCardContentProps = Omit<LinkPreview.ContentProps, 'children' | 'child'> & {
|
|
5
|
+
sx?: Sx;
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
};
|
|
8
|
+
declare const HoverCardContent: import("svelte").Component<HoverCardContentProps, {}, "ref">;
|
|
9
|
+
type HoverCardContent = ReturnType<typeof HoverCardContent>;
|
|
10
|
+
export default HoverCardContent;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { LinkPreview } from 'bits-ui';
|
|
3
|
+
|
|
4
|
+
export type HoverCardRootProps = LinkPreview.RootProps;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
// A card should not spring up as the pointer crosses on its way somewhere
|
|
9
|
+
// else, so it waits half a second; it lingers a moment on the way out, so the
|
|
10
|
+
// pointer can travel from the trigger into it.
|
|
11
|
+
let {
|
|
12
|
+
open = $bindable(false),
|
|
13
|
+
openDelay = 500,
|
|
14
|
+
closeDelay = 150,
|
|
15
|
+
children,
|
|
16
|
+
...rest
|
|
17
|
+
}: HoverCardRootProps = $props();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<LinkPreview.Root bind:open {openDelay} {closeDelay} {...rest}>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</LinkPreview.Root>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LinkPreview } from 'bits-ui';
|
|
2
|
+
export type HoverCardRootProps = LinkPreview.RootProps;
|
|
3
|
+
declare const HoverCardRoot: import("svelte").Component<import("bits-ui").LinkPreviewRootPropsWithoutHTML, {}, "open">;
|
|
4
|
+
type HoverCardRoot = ReturnType<typeof HoverCardRoot>;
|
|
5
|
+
export default HoverCardRoot;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LinkPreview } from 'bits-ui';
|
|
2
|
+
import Content from './HoverCardContent.svelte';
|
|
3
|
+
import Root from './HoverCardRoot.svelte';
|
|
4
|
+
declare const Trigger: import("svelte").Component<LinkPreview.TriggerProps, {}, "ref">;
|
|
5
|
+
export { Root, Trigger, Content };
|
|
6
|
+
export type { HoverCardContentProps } from './HoverCardContent.svelte';
|
|
7
|
+
export type { HoverCardRootProps } from './HoverCardRoot.svelte';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LinkPreview } from 'bits-ui';
|
|
2
|
+
import Content from './HoverCardContent.svelte';
|
|
3
|
+
import Root from './HoverCardRoot.svelte';
|
|
4
|
+
// Behaviour only: bits-ui's own part. It renders a link; pass `child` to make
|
|
5
|
+
// another element the trigger.
|
|
6
|
+
const Trigger = LinkPreview.Trigger;
|
|
7
|
+
export { Root, Trigger, Content };
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
5
5
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
6
|
import { colors, motion } from '../../tokens.stylex.js';
|
|
7
|
+
import { media } from '../../media.stylex.js';
|
|
7
8
|
|
|
8
9
|
export type LinkProps = Omit<HTMLAnchorAttributes, 'children'> & {
|
|
9
10
|
href: string;
|
|
@@ -16,9 +17,6 @@
|
|
|
16
17
|
children?: Snippet;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
// StyleX needs this in the same file to evaluate it at build time
|
|
20
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
21
|
-
|
|
22
20
|
const styles = stylex.create({
|
|
23
21
|
base: {
|
|
24
22
|
borderRadius: '0.1875rem',
|
|
@@ -28,7 +26,7 @@
|
|
|
28
26
|
textUnderlineOffset: '0.2em',
|
|
29
27
|
textDecorationColor: {
|
|
30
28
|
default: 'color-mix(in oklch, currentColor 35%, transparent)',
|
|
31
|
-
':hover': { default: null, [
|
|
29
|
+
':hover': { default: null, [media.hover]: 'currentColor' }
|
|
32
30
|
},
|
|
33
31
|
outlineWidth: '2px',
|
|
34
32
|
outlineStyle: { default: 'none', ':focus-visible': 'solid' },
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import type { Sx } from '../../internal/sx.js';
|
|
5
5
|
import { colors } from '../../tokens.stylex.js';
|
|
6
|
+
import { media } from '../../media.stylex.js';
|
|
6
7
|
import Button, { type ButtonProps } from '../button/Button.svelte';
|
|
7
8
|
|
|
8
9
|
export type MessageActionProps = Omit<
|
|
@@ -19,14 +20,12 @@
|
|
|
19
20
|
children?: Snippet;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
const HOVER = '@media (hover: hover) and (pointer: fine)';
|
|
23
|
-
|
|
24
23
|
const styles = stylex.create({
|
|
25
24
|
// Quieter than a ghost button: these sit under every reply
|
|
26
25
|
action: {
|
|
27
26
|
color: {
|
|
28
27
|
default: colors.textSubtle,
|
|
29
|
-
':hover': { default: null, [
|
|
28
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
30
29
|
}
|
|
31
30
|
},
|
|
32
31
|
pressed: {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { messageMarker } from '../../internal/markers.stylex.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
import { motion } from '../../tokens.stylex.js';
|
|
8
|
+
import { media } from '../../media.stylex.js';
|
|
8
9
|
import { getMessageContext } from './context.js';
|
|
9
10
|
|
|
10
11
|
export type MessageActionsProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
@@ -21,8 +22,6 @@
|
|
|
21
22
|
children?: Snippet;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
const FINE = '@media (hover: hover) and (pointer: fine)';
|
|
25
|
-
|
|
26
25
|
const styles = stylex.create({
|
|
27
26
|
actions: {
|
|
28
27
|
display: 'flex',
|
|
@@ -36,7 +35,7 @@
|
|
|
36
35
|
hover: {
|
|
37
36
|
opacity: {
|
|
38
37
|
default: 1,
|
|
39
|
-
[
|
|
38
|
+
[media.hover]: {
|
|
40
39
|
default: 0,
|
|
41
40
|
':focus-within': 1,
|
|
42
41
|
[stylex.when.ancestor(':hover', messageMarker)]: 1
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Glyph from '../../internal/Glyph.svelte';
|
|
4
4
|
import type { Sx } from '../../internal/sx.js';
|
|
5
5
|
import { colors, motion } from '../../tokens.stylex.js';
|
|
6
|
+
import { media } from '../../media.stylex.js';
|
|
6
7
|
import MessageAction, { type MessageActionProps } from './MessageAction.svelte';
|
|
7
8
|
|
|
8
9
|
export type MessageCopyProps = Omit<
|
|
@@ -20,8 +21,6 @@
|
|
|
20
21
|
sx?: Sx;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
const MOTION = '@media (prefers-reduced-motion: no-preference)';
|
|
24
|
-
|
|
25
24
|
const styles = stylex.create({
|
|
26
25
|
stack: {
|
|
27
26
|
display: 'grid',
|
|
@@ -32,14 +31,14 @@
|
|
|
32
31
|
icon: {
|
|
33
32
|
gridArea: '1 / 1',
|
|
34
33
|
display: 'grid',
|
|
35
|
-
transitionProperty: { default: 'opacity', [
|
|
34
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale, filter' },
|
|
36
35
|
transitionDuration: motion.base,
|
|
37
36
|
transitionTimingFunction: motion.easeOut
|
|
38
37
|
},
|
|
39
38
|
gone: {
|
|
40
39
|
opacity: 0,
|
|
41
|
-
scale: { default: null, [
|
|
42
|
-
filter: { default: null, [
|
|
40
|
+
scale: { default: null, [media.motion]: 0.6 },
|
|
41
|
+
filter: { default: null, [media.motion]: 'blur(2px)' }
|
|
43
42
|
},
|
|
44
43
|
check: { color: colors.text },
|
|
45
44
|
status: {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { messageMarker } from '../../internal/markers.stylex.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
import { colors, font } from '../../tokens.stylex.js';
|
|
8
|
+
import { media } from '../../media.stylex.js';
|
|
8
9
|
import { setMessageContext, type MessageFrom } from './context.js';
|
|
9
10
|
|
|
10
11
|
export type MessageRootProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
@@ -21,8 +22,6 @@
|
|
|
21
22
|
children?: Snippet;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
const FINE = '@media (hover: hover) and (pointer: fine)';
|
|
25
|
-
|
|
26
25
|
const styles = stylex.create({
|
|
27
26
|
root: {
|
|
28
27
|
display: 'flex',
|
|
@@ -37,8 +36,8 @@
|
|
|
37
36
|
// actions sit beside the bubble, at its foot, so they take no height.
|
|
38
37
|
user: {
|
|
39
38
|
alignItems: 'flex-end',
|
|
40
|
-
flexDirection: { default: 'column', [
|
|
41
|
-
gap: { default: '0.375rem', [
|
|
39
|
+
flexDirection: { default: 'column', [media.hover]: 'row-reverse' },
|
|
40
|
+
gap: { default: '0.375rem', [media.hover]: '0.25rem' },
|
|
42
41
|
marginBlockStart: { default: '1.5rem', ':first-child': 0 }
|
|
43
42
|
},
|
|
44
43
|
assistant: { alignItems: 'stretch' }
|