@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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
|
+
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
+
* ithildin, the one colour that marks state, as Composer's toggles are.
|
|
5
|
+
*/
|
|
6
|
+
import * as stylex from '@stylexjs/stylex';
|
|
7
|
+
export declare const toggle: Readonly<{
|
|
8
|
+
readonly base: Readonly<{
|
|
9
|
+
readonly position: stylex.StyleXClassNameFor<"position", "relative">;
|
|
10
|
+
readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
|
|
11
|
+
readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
|
|
12
|
+
readonly justifyContent: stylex.StyleXClassNameFor<"justifyContent", "center">;
|
|
13
|
+
readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 0>;
|
|
14
|
+
readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
|
|
15
|
+
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
16
|
+
readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 0>;
|
|
17
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string | null>;
|
|
18
|
+
readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", "none" | `inset 0 0 0 1px color-mix(in oklab, ${stylex.StyleXVar<string>} 35%, transparent)`>;
|
|
19
|
+
readonly color: stylex.StyleXClassNameFor<"color", string | null>;
|
|
20
|
+
readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
|
|
21
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
22
|
+
readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", 1>;
|
|
23
|
+
readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
|
|
24
|
+
readonly cursor: stylex.StyleXClassNameFor<"cursor", "pointer" | "not-allowed">;
|
|
25
|
+
readonly opacity: stylex.StyleXClassNameFor<"opacity", 1 | 0.5>;
|
|
26
|
+
readonly userSelect: stylex.StyleXClassNameFor<"userSelect", "none">;
|
|
27
|
+
readonly appearance: stylex.StyleXClassNameFor<"appearance", "none">;
|
|
28
|
+
readonly WebkitTapHighlightColor: stylex.StyleXClassNameFor<"WebkitTapHighlightColor", "transparent">;
|
|
29
|
+
readonly WebkitAppRegion: stylex.StyleXClassNameFor<"WebkitAppRegion", "no-drag">;
|
|
30
|
+
readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
|
|
31
|
+
readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "1px" | "2px">;
|
|
32
|
+
readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", string>;
|
|
33
|
+
readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "2px" | "-1px">;
|
|
34
|
+
readonly scale: stylex.StyleXClassNameFor<"scale", 0.96 | null>;
|
|
35
|
+
readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "background-color, color, box-shadow" | "scale, background-color, color, box-shadow">;
|
|
36
|
+
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
37
|
+
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", "ease" | `${stylex.StyleXVar<string>}, ease, ease, ease`>;
|
|
38
|
+
}>;
|
|
39
|
+
readonly sm: Readonly<{
|
|
40
|
+
readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "1.75rem">;
|
|
41
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.625rem">;
|
|
42
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", "0.375rem">;
|
|
43
|
+
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
44
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
45
|
+
readonly '::after': stylex.StyleXClassNameFor<"::after", {
|
|
46
|
+
readonly content: "\"\"";
|
|
47
|
+
readonly position: "absolute";
|
|
48
|
+
readonly insetInline: 0;
|
|
49
|
+
readonly insetBlock: "-6px";
|
|
50
|
+
}>;
|
|
51
|
+
}>;
|
|
52
|
+
readonly md: Readonly<{
|
|
53
|
+
readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "2rem">;
|
|
54
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.75rem">;
|
|
55
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", "0.4375rem">;
|
|
56
|
+
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
57
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
58
|
+
readonly '::after': stylex.StyleXClassNameFor<"::after", {
|
|
59
|
+
readonly content: "\"\"";
|
|
60
|
+
readonly position: "absolute";
|
|
61
|
+
readonly insetInline: 0;
|
|
62
|
+
readonly insetBlock: "-4px";
|
|
63
|
+
}>;
|
|
64
|
+
}>;
|
|
65
|
+
readonly iconSm: Readonly<{
|
|
66
|
+
readonly width: stylex.StyleXClassNameFor<"width", "1.75rem">;
|
|
67
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
|
|
68
|
+
}>;
|
|
69
|
+
readonly iconMd: Readonly<{
|
|
70
|
+
readonly width: stylex.StyleXClassNameFor<"width", "2rem">;
|
|
71
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
|
|
72
|
+
}>;
|
|
73
|
+
}>;
|
|
74
|
+
export type ToggleSize = 'sm' | 'md';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
|
+
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
+
* ithildin, the one colour that marks state, as Composer's toggles are.
|
|
5
|
+
*/
|
|
6
|
+
import * as stylex from '@stylexjs/stylex';
|
|
7
|
+
import { colors, font, motion, radius } from '../tokens.stylex.js';
|
|
8
|
+
import { media } from '../media.stylex.js';
|
|
9
|
+
const ON = ':is([data-state="on"])';
|
|
10
|
+
const DISABLED = ':is([data-disabled])';
|
|
11
|
+
export const toggle = stylex.create({
|
|
12
|
+
base: {
|
|
13
|
+
position: 'relative',
|
|
14
|
+
display: 'inline-flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
boxSizing: 'border-box',
|
|
19
|
+
margin: 0,
|
|
20
|
+
borderWidth: 0,
|
|
21
|
+
backgroundColor: {
|
|
22
|
+
default: 'transparent',
|
|
23
|
+
':hover': { default: null, [media.hover]: colors.hover },
|
|
24
|
+
[ON]: {
|
|
25
|
+
default: colors.ithilSoft,
|
|
26
|
+
':hover': { default: null, [media.hover]: colors.focusHalo }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
boxShadow: {
|
|
30
|
+
default: 'none',
|
|
31
|
+
[ON]: `inset 0 0 0 1px color-mix(in oklab, ${colors.ithil} 35%, transparent)`
|
|
32
|
+
},
|
|
33
|
+
color: {
|
|
34
|
+
default: colors.textMuted,
|
|
35
|
+
':hover': { default: null, [media.hover]: colors.text },
|
|
36
|
+
[ON]: { default: colors.ithil, ':hover': colors.ithil, [media.forcedColors]: 'Highlight' }
|
|
37
|
+
},
|
|
38
|
+
fontFamily: font.body,
|
|
39
|
+
fontWeight: font.weightMedium,
|
|
40
|
+
lineHeight: 1,
|
|
41
|
+
whiteSpace: 'nowrap',
|
|
42
|
+
cursor: { default: 'pointer', [DISABLED]: 'not-allowed' },
|
|
43
|
+
opacity: { default: 1, [DISABLED]: 0.5 },
|
|
44
|
+
userSelect: 'none',
|
|
45
|
+
appearance: 'none',
|
|
46
|
+
WebkitTapHighlightColor: 'transparent',
|
|
47
|
+
WebkitAppRegion: 'no-drag',
|
|
48
|
+
// In forced colours a pressed toggle keeps a frame, as the lit wash is gone
|
|
49
|
+
outlineStyle: 'solid',
|
|
50
|
+
outlineWidth: { default: '1px', ':focus-visible': '2px' },
|
|
51
|
+
outlineColor: {
|
|
52
|
+
default: 'transparent',
|
|
53
|
+
[ON]: { default: 'transparent', [media.forcedColors]: 'Highlight' },
|
|
54
|
+
':focus-visible': colors.focusRing
|
|
55
|
+
},
|
|
56
|
+
outlineOffset: { default: '-1px', ':focus-visible': '2px' },
|
|
57
|
+
scale: { default: null, ':active': { default: null, [media.motion]: 0.96 } },
|
|
58
|
+
transitionProperty: {
|
|
59
|
+
default: 'background-color, color, box-shadow',
|
|
60
|
+
[media.motion]: 'scale, background-color, color, box-shadow'
|
|
61
|
+
},
|
|
62
|
+
transitionDuration: motion.base,
|
|
63
|
+
transitionTimingFunction: {
|
|
64
|
+
default: 'ease',
|
|
65
|
+
[media.motion]: `${motion.easeOut}, ease, ease, ease`
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
// The same heights as Button's, and the same 40px reach for a finger
|
|
69
|
+
sm: {
|
|
70
|
+
minHeight: '1.75rem',
|
|
71
|
+
paddingInline: '0.625rem',
|
|
72
|
+
gap: '0.375rem',
|
|
73
|
+
borderRadius: radius.sm,
|
|
74
|
+
fontSize: font.sizeSm,
|
|
75
|
+
'::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-6px' }
|
|
76
|
+
},
|
|
77
|
+
md: {
|
|
78
|
+
minHeight: '2rem',
|
|
79
|
+
paddingInline: '0.75rem',
|
|
80
|
+
gap: '0.4375rem',
|
|
81
|
+
borderRadius: radius.md,
|
|
82
|
+
fontSize: font.sizeMd,
|
|
83
|
+
'::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-4px' }
|
|
84
|
+
},
|
|
85
|
+
iconSm: { width: '1.75rem', paddingInline: 0 },
|
|
86
|
+
iconMd: { width: '2rem', paddingInline: 0 }
|
|
87
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditions as constants, for keys inside `stylex.create`:
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { media } from '@diegopluna/narvi/media.stylex.js';
|
|
6
|
+
*
|
|
7
|
+
* const styles = stylex.create({
|
|
8
|
+
* link: {
|
|
9
|
+
* color: { default: colors.textMuted, ':hover': { default: null, [media.hover]: colors.text } },
|
|
10
|
+
* transitionDuration: { default: '0s', [media.motion]: motion.fast },
|
|
11
|
+
* gap: { default: space.x4, [media.lg]: space.x8 }
|
|
12
|
+
* }
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* StyleX inlines them as it compiles, so they cost nothing at runtime. Import them straight
|
|
17
|
+
* from this file, as with the tokens: StyleX resolves them across files only from a
|
|
18
|
+
* `.stylex.js` module.
|
|
19
|
+
*
|
|
20
|
+
* Breakpoints are minimum widths, mobile first: within one property, a larger breakpoint wins
|
|
21
|
+
* over a smaller one. They are in px because StyleX orders constant breakpoints by width only
|
|
22
|
+
* when they are in px; in rem, `lg` could come before `sm` in the stylesheet and lose to it.
|
|
23
|
+
*
|
|
24
|
+
* StyleX also ranks a constant condition above one written out in full, so for any one
|
|
25
|
+
* property, use these throughout rather than mixing them with `'@media …'` strings.
|
|
26
|
+
*/
|
|
27
|
+
export declare const media: {
|
|
28
|
+
/** A precise pointer that can hover: hover styles go behind this, so touch never sticks. */
|
|
29
|
+
hover: string;
|
|
30
|
+
/** A touch screen or other coarse pointer: larger targets and text. */
|
|
31
|
+
coarse: string;
|
|
32
|
+
/** The reader has not asked for less motion: movement goes behind this. */
|
|
33
|
+
motion: string;
|
|
34
|
+
/** The reader has asked for less motion. */
|
|
35
|
+
reducedMotion: string;
|
|
36
|
+
/**
|
|
37
|
+
* The system is in dark mode. Narvi's colours follow `color-scheme` through `light-dark()`
|
|
38
|
+
* instead, which a `Theme` can force, so prefer the tokens; this is for what tokens cannot
|
|
39
|
+
* hold, such as an image's opacity.
|
|
40
|
+
*/
|
|
41
|
+
dark: string;
|
|
42
|
+
/** Forced-colours mode, such as Windows High Contrast: shadows are gone, outlines stay. */
|
|
43
|
+
forcedColors: string;
|
|
44
|
+
/** 640px: large phones on their side, small tablets. */
|
|
45
|
+
sm: string;
|
|
46
|
+
/** 768px: tablets. */
|
|
47
|
+
md: string;
|
|
48
|
+
/** 1024px: laptops. */
|
|
49
|
+
lg: string;
|
|
50
|
+
/** 1280px: desktops. */
|
|
51
|
+
xl: string;
|
|
52
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
/**
|
|
3
|
+
* Conditions as constants, for keys inside `stylex.create`:
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { media } from '@diegopluna/narvi/media.stylex.js';
|
|
7
|
+
*
|
|
8
|
+
* const styles = stylex.create({
|
|
9
|
+
* link: {
|
|
10
|
+
* color: { default: colors.textMuted, ':hover': { default: null, [media.hover]: colors.text } },
|
|
11
|
+
* transitionDuration: { default: '0s', [media.motion]: motion.fast },
|
|
12
|
+
* gap: { default: space.x4, [media.lg]: space.x8 }
|
|
13
|
+
* }
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* StyleX inlines them as it compiles, so they cost nothing at runtime. Import them straight
|
|
18
|
+
* from this file, as with the tokens: StyleX resolves them across files only from a
|
|
19
|
+
* `.stylex.js` module.
|
|
20
|
+
*
|
|
21
|
+
* Breakpoints are minimum widths, mobile first: within one property, a larger breakpoint wins
|
|
22
|
+
* over a smaller one. They are in px because StyleX orders constant breakpoints by width only
|
|
23
|
+
* when they are in px; in rem, `lg` could come before `sm` in the stylesheet and lose to it.
|
|
24
|
+
*
|
|
25
|
+
* StyleX also ranks a constant condition above one written out in full, so for any one
|
|
26
|
+
* property, use these throughout rather than mixing them with `'@media …'` strings.
|
|
27
|
+
*/
|
|
28
|
+
export const media = stylex.defineConsts({
|
|
29
|
+
/** A precise pointer that can hover: hover styles go behind this, so touch never sticks. */
|
|
30
|
+
hover: '@media (hover: hover) and (pointer: fine)',
|
|
31
|
+
/** A touch screen or other coarse pointer: larger targets and text. */
|
|
32
|
+
coarse: '@media (pointer: coarse)',
|
|
33
|
+
/** The reader has not asked for less motion: movement goes behind this. */
|
|
34
|
+
motion: '@media (prefers-reduced-motion: no-preference)',
|
|
35
|
+
/** The reader has asked for less motion. */
|
|
36
|
+
reducedMotion: '@media (prefers-reduced-motion: reduce)',
|
|
37
|
+
/**
|
|
38
|
+
* The system is in dark mode. Narvi's colours follow `color-scheme` through `light-dark()`
|
|
39
|
+
* instead, which a `Theme` can force, so prefer the tokens; this is for what tokens cannot
|
|
40
|
+
* hold, such as an image's opacity.
|
|
41
|
+
*/
|
|
42
|
+
dark: '@media (prefers-color-scheme: dark)',
|
|
43
|
+
/** Forced-colours mode, such as Windows High Contrast: shadows are gone, outlines stay. */
|
|
44
|
+
forcedColors: '@media (forced-colors: active)',
|
|
45
|
+
/** 640px: large phones on their side, small tablets. */
|
|
46
|
+
sm: '@media (min-width: 640px)',
|
|
47
|
+
/** 768px: tablets. */
|
|
48
|
+
md: '@media (min-width: 768px)',
|
|
49
|
+
/** 1024px: laptops. */
|
|
50
|
+
lg: '@media (min-width: 1024px)',
|
|
51
|
+
/** 1280px: desktops. */
|
|
52
|
+
xl: '@media (min-width: 1280px)'
|
|
53
|
+
});
|
package/dist/preset.js
CHANGED
|
@@ -86,7 +86,7 @@ export const displays = [
|
|
|
86
86
|
{
|
|
87
87
|
id: 'cormorant',
|
|
88
88
|
label: 'Cormorant',
|
|
89
|
-
stack: '"Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',
|
|
89
|
+
stack: '"Cormorant Garamond", "Cormorant Garamond Variable", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',
|
|
90
90
|
package: '@fontsource/cormorant-garamond',
|
|
91
91
|
imports: ['@fontsource/cormorant-garamond/500.css']
|
|
92
92
|
},
|
|
@@ -111,7 +111,7 @@ export const monos = [
|
|
|
111
111
|
{
|
|
112
112
|
id: 'geist-mono',
|
|
113
113
|
label: 'Geist Mono',
|
|
114
|
-
stack: '"Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace',
|
|
114
|
+
stack: '"Geist Mono", "Geist Mono Variable", ui-monospace, "SF Mono", Menlo, Consolas, monospace',
|
|
115
115
|
package: '@fontsource/geist-mono',
|
|
116
116
|
imports: ['@fontsource/geist-mono/400.css']
|
|
117
117
|
},
|
|
@@ -249,6 +249,12 @@ export function fontPackages(preset) {
|
|
|
249
249
|
];
|
|
250
250
|
return [...new Set(faces.flatMap((face) => (face?.package ? [face.package] : [])))];
|
|
251
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Where the generated theme lives, as the layout imports it. Kept out of the template below:
|
|
254
|
+
* `svelte-package` rewrites anything shaped like an import from `$lib`, even inside a string,
|
|
255
|
+
* and would turn the generated layout's import into a path relative to this file.
|
|
256
|
+
*/
|
|
257
|
+
const THEME_MODULE = '$lib/theme.stylex.js';
|
|
252
258
|
/** The files that put a preset into a SvelteKit app. */
|
|
253
259
|
export function presetFiles(preset) {
|
|
254
260
|
const theme = overrides(preset);
|
|
@@ -307,7 +313,7 @@ export const preset = [${groups.map((group) => `${group}Theme`).join(', ')}];
|
|
|
307
313
|
? `<script lang="ts">
|
|
308
314
|
import '../app.css';
|
|
309
315
|
import { DevStyles, Theme } from '@diegopluna/narvi';
|
|
310
|
-
import { preset } from '
|
|
316
|
+
import { preset } from '${THEME_MODULE}';
|
|
311
317
|
|
|
312
318
|
let { children } = $props();
|
|
313
319
|
</script>
|
package/dist/tokens.stylex.d.ts
CHANGED
|
@@ -102,3 +102,18 @@ export declare const motion: stylex.VarGroup<Readonly<{
|
|
|
102
102
|
easeOut: string;
|
|
103
103
|
easeInOut: string;
|
|
104
104
|
}>, symbol>;
|
|
105
|
+
/**
|
|
106
|
+
* Motion for pages, not interfaces. An interface is used again and again, so nothing in it
|
|
107
|
+
* takes longer than `motion.slow`. A page is read once, as it is scrolled, and its motion is
|
|
108
|
+
* there to be seen: a section easing up into place, a line drawn in. Use this scale only
|
|
109
|
+
* there, as `Reveal` and its child styles do, and always behind
|
|
110
|
+
* `prefers-reduced-motion: no-preference`.
|
|
111
|
+
*/
|
|
112
|
+
export declare const pageMotion: stylex.VarGroup<Readonly<{
|
|
113
|
+
stagger: string;
|
|
114
|
+
short: string;
|
|
115
|
+
base: string;
|
|
116
|
+
long: string;
|
|
117
|
+
longest: string;
|
|
118
|
+
ease: string;
|
|
119
|
+
}>, symbol>;
|
package/dist/tokens.stylex.js
CHANGED
|
@@ -95,8 +95,10 @@ export const font = stylex.defineVars({
|
|
|
95
95
|
// Interface text takes the font of the page it is placed on.
|
|
96
96
|
body: 'inherit',
|
|
97
97
|
// Large headings are set in a serif. It falls back to system serifs when Cormorant is not loaded.
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
// Each face is listed under its own name and under the name Fontsource gives its variable
|
|
99
|
+
// build, so either package works without a theme override.
|
|
100
|
+
display: '"Cormorant Garamond", "Cormorant Garamond Variable", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',
|
|
101
|
+
mono: '"Geist Mono", "Geist Mono Variable", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace',
|
|
100
102
|
sizeXs: '0.75rem',
|
|
101
103
|
sizeSm: '0.8125rem',
|
|
102
104
|
sizeMd: '0.875rem',
|
|
@@ -123,3 +125,23 @@ export const motion = stylex.defineVars({
|
|
|
123
125
|
// For something that travels across the screen, such as a sliding thumb
|
|
124
126
|
easeInOut: 'cubic-bezier(0.77, 0, 0.175, 1)'
|
|
125
127
|
});
|
|
128
|
+
/**
|
|
129
|
+
* Motion for pages, not interfaces. An interface is used again and again, so nothing in it
|
|
130
|
+
* takes longer than `motion.slow`. A page is read once, as it is scrolled, and its motion is
|
|
131
|
+
* there to be seen: a section easing up into place, a line drawn in. Use this scale only
|
|
132
|
+
* there, as `Reveal` and its child styles do, and always behind
|
|
133
|
+
* `prefers-reduced-motion: no-preference`.
|
|
134
|
+
*/
|
|
135
|
+
export const pageMotion = stylex.defineVars({
|
|
136
|
+
// Between items of a row that enter one after another
|
|
137
|
+
stagger: '80ms',
|
|
138
|
+
short: '400ms',
|
|
139
|
+
// Something easing up into place as it is reached
|
|
140
|
+
base: '600ms',
|
|
141
|
+
// Something that follows, such as a mark appearing on a finished drawing
|
|
142
|
+
long: '1200ms',
|
|
143
|
+
// A line drawn in, end to end
|
|
144
|
+
longest: '2000ms',
|
|
145
|
+
// Leaves fast and settles slowly, so the end of a long move is never abrupt
|
|
146
|
+
ease: 'cubic-bezier(0.2, 0.75, 0.2, 1)'
|
|
147
|
+
});
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
import stylex from '@stylexjs/unplugin';
|
|
2
2
|
import type { Plugin } from 'vite';
|
|
3
3
|
type StylexOptions = NonNullable<Parameters<typeof stylex.vite>[0]>;
|
|
4
|
-
export type NarviOptions = StylexOptions
|
|
4
|
+
export type NarviOptions = StylexOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* More packages that ship StyleX source, to keep out of Vite's dependency
|
|
7
|
+
* pre-bundling. Narvi is always on the list. (StyleX reads this option, but its
|
|
8
|
+
* types leave it out.)
|
|
9
|
+
*/
|
|
10
|
+
externalPackages?: ReadonlyArray<string>;
|
|
11
|
+
/**
|
|
12
|
+
* For apps that use Tailwind CSS 4. Places Narvi's layer after Tailwind's
|
|
13
|
+
* `base` (so Preflight does not undo Narvi) and before its `components` and
|
|
14
|
+
* `utilities` (so a class such as `hidden sm:inline-flex` overrides a
|
|
15
|
+
* component). Also add this line to the top of your stylesheet, before
|
|
16
|
+
* `@import "tailwindcss"`:
|
|
17
|
+
*
|
|
18
|
+
* ```css
|
|
19
|
+
* @layer theme, base, narvi, components, utilities;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
tailwind?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** The cascade layer that holds all of Narvi's styles, and any StyleX of your own. */
|
|
25
|
+
export declare const NARVI_LAYER = "narvi";
|
|
26
|
+
/** The layer inside it that holds `@diegopluna/narvi/base.css`, below every component. */
|
|
27
|
+
export declare const BASE_LAYER = "narvi.base";
|
|
5
28
|
/**
|
|
6
29
|
* Vite plugin that compiles Narvi's styles (and any StyleX you write yourself).
|
|
7
30
|
*
|
|
8
31
|
* It is a thin preset over `@stylexjs/unplugin`:
|
|
9
32
|
* - runs after the Svelte compiler, so `.svelte` files are handled
|
|
10
|
-
* - emits cascade
|
|
33
|
+
* - emits one cascade layer, `narvi`, so your own unlayered CSS always wins over
|
|
34
|
+
* Narvi's, and a layered framework can be ordered around it
|
|
11
35
|
* - leaves `light-dark()` and `:dir()` alone, which the tokens and components rely on
|
|
12
36
|
*
|
|
13
37
|
* Add it after `sveltekit()` (or `svelte()`) in `vite.config.ts`.
|
|
14
38
|
*/
|
|
15
|
-
export declare function narvi(options?: NarviOptions): Plugin;
|
|
39
|
+
export declare function narvi({ tailwind, ...options }?: NarviOptions): Plugin;
|
|
16
40
|
export default narvi;
|
package/dist/vite.js
CHANGED
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
import stylex from '@stylexjs/unplugin';
|
|
2
2
|
import { Features } from 'lightningcss';
|
|
3
|
+
const PACKAGE = '@diegopluna/narvi';
|
|
4
|
+
/** The cascade layer that holds all of Narvi's styles, and any StyleX of your own. */
|
|
5
|
+
export const NARVI_LAYER = 'narvi';
|
|
6
|
+
/** The layer inside it that holds `@diegopluna/narvi/base.css`, below every component. */
|
|
7
|
+
export const BASE_LAYER = `${NARVI_LAYER}.base`;
|
|
3
8
|
/**
|
|
4
9
|
* Vite plugin that compiles Narvi's styles (and any StyleX you write yourself).
|
|
5
10
|
*
|
|
6
11
|
* It is a thin preset over `@stylexjs/unplugin`:
|
|
7
12
|
* - runs after the Svelte compiler, so `.svelte` files are handled
|
|
8
|
-
* - emits cascade
|
|
13
|
+
* - emits one cascade layer, `narvi`, so your own unlayered CSS always wins over
|
|
14
|
+
* Narvi's, and a layered framework can be ordered around it
|
|
9
15
|
* - leaves `light-dark()` and `:dir()` alone, which the tokens and components rely on
|
|
10
16
|
*
|
|
11
17
|
* Add it after `sveltekit()` (or `svelte()`) in `vite.config.ts`.
|
|
12
18
|
*/
|
|
13
|
-
export function narvi(options = {}) {
|
|
19
|
+
export function narvi({ tailwind = false, ...options } = {}) {
|
|
14
20
|
const plugin = stylex.vite({
|
|
15
|
-
|
|
21
|
+
// StyleX orders its rules in layers of its own, `priority1` and up. They are
|
|
22
|
+
// nested in one `narvi` layer, which other CSS can be placed around.
|
|
23
|
+
// `narvi.base`, which holds `base.css`, is declared first within it, so the base stays
|
|
24
|
+
// below every component whichever stylesheet the browser reads first.
|
|
25
|
+
useCSSLayers: tailwind
|
|
26
|
+
? {
|
|
27
|
+
before: ['theme', 'base', BASE_LAYER],
|
|
28
|
+
prefix: NARVI_LAYER,
|
|
29
|
+
after: ['components', 'utilities']
|
|
30
|
+
}
|
|
31
|
+
: { before: [BASE_LAYER], prefix: NARVI_LAYER },
|
|
16
32
|
...options,
|
|
33
|
+
// Narvi ships StyleX source, which must reach the compiler: Vite's dependency
|
|
34
|
+
// pre-bundling would hand the page `stylex.create` calls that throw at runtime.
|
|
35
|
+
// StyleX looks for such packages itself, but only among the app's direct
|
|
36
|
+
// dependencies, so Narvi is named here and apps need no `optimizeDeps` entry.
|
|
37
|
+
// (Spread in, as StyleX's option types leave the option out.)
|
|
38
|
+
...{ externalPackages: [PACKAGE, ...(options.externalPackages ?? [])] },
|
|
17
39
|
lightningcssOptions: {
|
|
18
40
|
minify: true,
|
|
19
41
|
...options.lightningcssOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopluna/narvi",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"packageManager": "pnpm@12.18.0",
|
|
4
5
|
"publishConfig": {
|
|
5
6
|
"access": "public"
|
|
6
7
|
},
|
|
@@ -38,6 +39,11 @@
|
|
|
38
39
|
"types": "./dist/tokens.stylex.d.ts",
|
|
39
40
|
"default": "./dist/tokens.stylex.js"
|
|
40
41
|
},
|
|
42
|
+
"./media.stylex.js": {
|
|
43
|
+
"types": "./dist/media.stylex.d.ts",
|
|
44
|
+
"default": "./dist/media.stylex.js"
|
|
45
|
+
},
|
|
46
|
+
"./base.css": "./dist/base.css",
|
|
41
47
|
"./vite": {
|
|
42
48
|
"types": "./dist/vite.d.ts",
|
|
43
49
|
"default": "./dist/vite.js"
|
|
@@ -45,12 +51,13 @@
|
|
|
45
51
|
"./preset": {
|
|
46
52
|
"types": "./dist/preset.d.ts",
|
|
47
53
|
"default": "./dist/preset.js"
|
|
48
|
-
}
|
|
54
|
+
},
|
|
55
|
+
"./package.json": "./package.json"
|
|
49
56
|
},
|
|
50
57
|
"scripts": {
|
|
51
58
|
"dev": "vite dev",
|
|
52
59
|
"build": "pnpm run build:lib && pnpm run build:docs",
|
|
53
|
-
"build:lib": "svelte-kit sync && svelte-package && publint",
|
|
60
|
+
"build:lib": "node scripts/base-css.js && svelte-kit sync && svelte-package && publint",
|
|
54
61
|
"build:docs": "vite build",
|
|
55
62
|
"preview": "vite preview",
|
|
56
63
|
"prepare": "svelte-kit sync || echo ''",
|
|
@@ -60,7 +67,8 @@
|
|
|
60
67
|
"lint": "prettier --check . && eslint .",
|
|
61
68
|
"format": "prettier --write .",
|
|
62
69
|
"test:unit": "vitest",
|
|
63
|
-
"test": "npm run test:unit -- --run"
|
|
70
|
+
"test": "npm run test:unit -- --run",
|
|
71
|
+
"deploy": "pnpm build:docs && wrangler deploy"
|
|
64
72
|
},
|
|
65
73
|
"devDependencies": {
|
|
66
74
|
"@codemirror/autocomplete": "^6.20.4",
|
|
@@ -107,7 +115,8 @@
|
|
|
107
115
|
"typescript-eslint": "^8.60.1",
|
|
108
116
|
"vite": "^8.3.0",
|
|
109
117
|
"vitest": "^4.1.8",
|
|
110
|
-
"vitest-browser-svelte": "^2.1.1"
|
|
118
|
+
"vitest-browser-svelte": "^2.1.1",
|
|
119
|
+
"wrangler": "^4.159.0"
|
|
111
120
|
},
|
|
112
121
|
"peerDependencies": {
|
|
113
122
|
"svelte": "^5.20.0",
|