@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,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout props that take a value, or one value per breakpoint:
|
|
3
|
+
* `gap={4}` or `gap={{ default: 4, lg: 8 }}`.
|
|
4
|
+
*
|
|
5
|
+
* StyleX merges styles one property at a time, so a style for `lg` cannot sit on top of
|
|
6
|
+
* the default: it would replace it. A responsive prop therefore applies one static rule
|
|
7
|
+
* that reads custom properties, one per breakpoint, each falling back to the one below:
|
|
8
|
+
*
|
|
9
|
+
* ```css
|
|
10
|
+
* gap: var(--narvi-gap);
|
|
11
|
+
* @media (min-width: 640px) { gap: var(--narvi-gap-sm, var(--narvi-gap)) }
|
|
12
|
+
* …
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* and one static class per value and breakpoint, which sets one of those properties. The
|
|
16
|
+
* same rule resets every one of them to `initial`, so a layout never inherits its parent's.
|
|
17
|
+
* No styles are made at runtime. A plain value takes a plain class, as before.
|
|
18
|
+
*/
|
|
19
|
+
export const breakpoints = ['sm', 'md', 'lg', 'xl'];
|
|
20
|
+
export function isByBreakpoint(value) {
|
|
21
|
+
return typeof value === 'object' && value !== null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The styles for one prop. `fallback` stands in for a missing value, and for a missing
|
|
25
|
+
* `default` in values by breakpoint.
|
|
26
|
+
*/
|
|
27
|
+
export function responsive(value, fallback, styles) {
|
|
28
|
+
if (!isByBreakpoint(value)) {
|
|
29
|
+
const resolved = value ?? fallback;
|
|
30
|
+
return resolved === undefined ? [] : [styles.fixed[resolved]];
|
|
31
|
+
}
|
|
32
|
+
const result = [styles.chain];
|
|
33
|
+
const base = value.default ?? fallback;
|
|
34
|
+
if (base !== undefined)
|
|
35
|
+
result.push(styles.set.default[base]);
|
|
36
|
+
for (const breakpoint of breakpoints) {
|
|
37
|
+
const at = value[breakpoint];
|
|
38
|
+
if (at !== undefined)
|
|
39
|
+
result.push(styles.set[breakpoint][at]);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
package/dist/internal/sx.d.ts
CHANGED
|
@@ -8,9 +8,21 @@ import type { ClassValue } from 'svelte/elements';
|
|
|
8
8
|
type CustomProperties = Readonly<{
|
|
9
9
|
[name: `--${string}`]: StyleXClassNameFor<string, unknown>;
|
|
10
10
|
}>;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A marker, from `stylex.defaultMarker()` or a `stylex.defineMarker()` of your own. On an
|
|
13
|
+
* element, it makes that element the ancestor that `stylex.when.ancestor(':hover', marker)`
|
|
14
|
+
* in a descendant's styles waits on: a hover group.
|
|
15
|
+
*/
|
|
16
|
+
export type Marker = Readonly<{
|
|
17
|
+
marker: StyleXClassNameFor<'marker', unknown>;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Styles a consumer can pass to a component's `sx` prop: compiled StyleX styles, styles of
|
|
21
|
+
* custom properties alone, and markers, nested in arrays as deep as you like. `false`, `null`
|
|
22
|
+
* and `undefined` are skipped, so `cond && styles.x` works.
|
|
23
|
+
*/
|
|
24
|
+
export type Sx = StyleXArray<StyleXStyles | CustomProperties | Marker>;
|
|
25
|
+
type StyleArg = Sx | Readonly<Record<string, unknown>> | ReadonlyArray<StyleArg>;
|
|
14
26
|
/**
|
|
15
27
|
* Resolves StyleX styles to element attributes and appends a consumer `class`.
|
|
16
28
|
* Later styles win, so pass the consumer's `sx` last.
|
|
@@ -19,4 +31,19 @@ export declare function attrs(styles: ReadonlyArray<StyleArg>, className?: Class
|
|
|
19
31
|
class?: ClassValue;
|
|
20
32
|
style?: string;
|
|
21
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Styles as attributes to spread onto an element or a component that takes `class` and
|
|
36
|
+
* `style` but no `sx`: `<Mark {...sx(styles.mark, active && styles.lit)} />`. Like `sx`,
|
|
37
|
+
* it takes markers, and later styles win.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sx(...styles: ReadonlyArray<Sx>): {
|
|
40
|
+
class?: string;
|
|
41
|
+
style?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Styles as one class string, for a prop that takes only a class, such as `iconClass`, or
|
|
45
|
+
* for joining with classes of your own. Empty when no style applies. Dynamic styles (those
|
|
46
|
+
* created from a function) also set inline `style`, which this drops; use `sx()` for those.
|
|
47
|
+
*/
|
|
48
|
+
export declare function classes(...styles: ReadonlyArray<Sx>): string;
|
|
22
49
|
export {};
|
package/dist/internal/sx.js
CHANGED
|
@@ -9,3 +9,20 @@ export function attrs(styles, className) {
|
|
|
9
9
|
return resolved;
|
|
10
10
|
return { ...resolved, class: [resolved.class, className] };
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Styles as attributes to spread onto an element or a component that takes `class` and
|
|
14
|
+
* `style` but no `sx`: `<Mark {...sx(styles.mark, active && styles.lit)} />`. Like `sx`,
|
|
15
|
+
* it takes markers, and later styles win.
|
|
16
|
+
*/
|
|
17
|
+
export function sx(...styles) {
|
|
18
|
+
const { class: className, style } = stylex.attrs(...styles);
|
|
19
|
+
return { ...(className ? { class: className } : {}), ...(style ? { style } : {}) };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Styles as one class string, for a prop that takes only a class, such as `iconClass`, or
|
|
23
|
+
* for joining with classes of your own. Empty when no style applies. Dynamic styles (those
|
|
24
|
+
* created from a function) also set inline `style`, which this drops; use `sx()` for those.
|
|
25
|
+
*/
|
|
26
|
+
export function classes(...styles) {
|
|
27
|
+
return stylex.attrs(...styles).class ?? '';
|
|
28
|
+
}
|
|
@@ -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/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
|
@@ -125,3 +125,23 @@ export const motion = stylex.defineVars({
|
|
|
125
125
|
// For something that travels across the screen, such as a sliding thumb
|
|
126
126
|
easeInOut: 'cubic-bezier(0.77, 0, 0.175, 1)'
|
|
127
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
|
@@ -23,6 +23,8 @@ export type NarviOptions = StylexOptions & {
|
|
|
23
23
|
};
|
|
24
24
|
/** The cascade layer that holds all of Narvi's styles, and any StyleX of your own. */
|
|
25
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";
|
|
26
28
|
/**
|
|
27
29
|
* Vite plugin that compiles Narvi's styles (and any StyleX you write yourself).
|
|
28
30
|
*
|
package/dist/vite.js
CHANGED
|
@@ -3,6 +3,8 @@ import { Features } from 'lightningcss';
|
|
|
3
3
|
const PACKAGE = '@diegopluna/narvi';
|
|
4
4
|
/** The cascade layer that holds all of Narvi's styles, and any StyleX of your own. */
|
|
5
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`;
|
|
6
8
|
/**
|
|
7
9
|
* Vite plugin that compiles Narvi's styles (and any StyleX you write yourself).
|
|
8
10
|
*
|
|
@@ -18,9 +20,15 @@ export function narvi({ tailwind = false, ...options } = {}) {
|
|
|
18
20
|
const plugin = stylex.vite({
|
|
19
21
|
// StyleX orders its rules in layers of its own, `priority1` and up. They are
|
|
20
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.
|
|
21
25
|
useCSSLayers: tailwind
|
|
22
|
-
? {
|
|
23
|
-
|
|
26
|
+
? {
|
|
27
|
+
before: ['theme', 'base', BASE_LAYER],
|
|
28
|
+
prefix: NARVI_LAYER,
|
|
29
|
+
after: ['components', 'utilities']
|
|
30
|
+
}
|
|
31
|
+
: { before: [BASE_LAYER], prefix: NARVI_LAYER },
|
|
24
32
|
...options,
|
|
25
33
|
// Narvi ships StyleX source, which must reach the compiler: Vite's dependency
|
|
26
34
|
// pre-bundling would hand the page `stylex.create` calls that throw at runtime.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopluna/narvi",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"packageManager": "pnpm@12.18.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"types": "./dist/tokens.stylex.d.ts",
|
|
40
40
|
"default": "./dist/tokens.stylex.js"
|
|
41
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",
|
|
42
47
|
"./vite": {
|
|
43
48
|
"types": "./dist/vite.d.ts",
|
|
44
49
|
"default": "./dist/vite.js"
|
|
@@ -52,7 +57,7 @@
|
|
|
52
57
|
"scripts": {
|
|
53
58
|
"dev": "vite dev",
|
|
54
59
|
"build": "pnpm run build:lib && pnpm run build:docs",
|
|
55
|
-
"build:lib": "svelte-kit sync && svelte-package && publint",
|
|
60
|
+
"build:lib": "node scripts/base-css.js && svelte-kit sync && svelte-package && publint",
|
|
56
61
|
"build:docs": "vite build",
|
|
57
62
|
"preview": "vite preview",
|
|
58
63
|
"prepare": "svelte-kit sync || echo ''",
|