@diegopluna/narvi 0.3.8 → 0.3.10
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/dist/components/shimmer/Shimmer.svelte +34 -8
- package/dist/components/shimmer/Shimmer.svelte.d.ts +7 -0
- package/dist/components/tab-strip/TabStrip.svelte +10 -2
- package/dist/index.d.ts +1 -1
- package/dist/internal/visible.d.ts +5 -0
- package/dist/internal/visible.js +16 -1
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +1 -1
- package/skills/building-ui/references/components.md +2 -2
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +3 -2
- package/skills/theming/SKILL.md +1 -1
|
@@ -7,9 +7,17 @@
|
|
|
7
7
|
import { colors, play } from '../../tokens.stylex.js';
|
|
8
8
|
import { media } from '../../media.stylex.js';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* The colour of the band. `neutral`, the default, is the text's own colour passing over
|
|
12
|
+
* quieter letters; `accent` is a band of the accent, for the one thing that is live.
|
|
13
|
+
*/
|
|
14
|
+
export type ShimmerTone = 'neutral' | 'accent';
|
|
15
|
+
|
|
10
16
|
export type ShimmerProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
|
|
11
17
|
/** Turn it off to show the text plainly, for example once the work is done. */
|
|
12
18
|
active?: boolean | undefined;
|
|
19
|
+
/** The colour of the band that passes over the letters. */
|
|
20
|
+
tone?: ShimmerTone | undefined;
|
|
13
21
|
sx?: Sx | undefined;
|
|
14
22
|
children?: Snippet | undefined;
|
|
15
23
|
};
|
|
@@ -35,18 +43,13 @@
|
|
|
35
43
|
base: {
|
|
36
44
|
display: 'inline'
|
|
37
45
|
},
|
|
38
|
-
// The letters are only half there until a band of
|
|
46
|
+
// The letters are only half there until a band of light passes over them
|
|
39
47
|
active: {
|
|
40
48
|
color: {
|
|
41
49
|
default: 'transparent',
|
|
42
50
|
[media.reducedMotion]: colors.textMuted,
|
|
43
51
|
[media.forcedColors]: 'CanvasText'
|
|
44
52
|
},
|
|
45
|
-
backgroundImage: {
|
|
46
|
-
default: `linear-gradient(90deg, ${colors.textSubtle} 0%, ${colors.textSubtle} 40%, ${colors.accent} 50%, ${colors.textSubtle} 60%, ${colors.textSubtle} 100%)`,
|
|
47
|
-
[media.reducedMotion]: 'none',
|
|
48
|
-
[media.forcedColors]: 'none'
|
|
49
|
-
},
|
|
50
53
|
backgroundSize: '300% 100%',
|
|
51
54
|
backgroundClip: 'text',
|
|
52
55
|
WebkitBackgroundClip: 'text',
|
|
@@ -62,19 +65,42 @@
|
|
|
62
65
|
animationTimingFunction: { default: 'steps(30)', [media.reducedMotion]: 'steps(12)' },
|
|
63
66
|
animationIterationCount: 'infinite',
|
|
64
67
|
animationPlayState: play.whileVisible
|
|
68
|
+
},
|
|
69
|
+
// The band: the text's own colour over its quieter one, or the accent
|
|
70
|
+
neutral: {
|
|
71
|
+
backgroundImage: {
|
|
72
|
+
default: `linear-gradient(90deg, ${colors.textSubtle} 0%, ${colors.textSubtle} 40%, ${colors.text} 50%, ${colors.textSubtle} 60%, ${colors.textSubtle} 100%)`,
|
|
73
|
+
[media.reducedMotion]: 'none',
|
|
74
|
+
[media.forcedColors]: 'none'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
accent: {
|
|
78
|
+
backgroundImage: {
|
|
79
|
+
default: `linear-gradient(90deg, ${colors.textSubtle} 0%, ${colors.textSubtle} 40%, ${colors.accent} 50%, ${colors.textSubtle} 60%, ${colors.textSubtle} 100%)`,
|
|
80
|
+
[media.reducedMotion]: 'none',
|
|
81
|
+
[media.forcedColors]: 'none'
|
|
82
|
+
}
|
|
65
83
|
}
|
|
66
84
|
});
|
|
67
85
|
</script>
|
|
68
86
|
|
|
69
87
|
<script lang="ts">
|
|
70
|
-
let {
|
|
88
|
+
let {
|
|
89
|
+
active = true,
|
|
90
|
+
tone = 'neutral',
|
|
91
|
+
sx,
|
|
92
|
+
class: className,
|
|
93
|
+
children,
|
|
94
|
+
...rest
|
|
95
|
+
}: ShimmerProps = $props();
|
|
71
96
|
</script>
|
|
72
97
|
|
|
73
98
|
<span
|
|
74
99
|
data-slot="shimmer"
|
|
75
100
|
data-active={active || undefined}
|
|
101
|
+
data-tone={tone}
|
|
76
102
|
{...rest}
|
|
77
|
-
{...attrs([styles.base, active && styles.active, sx], className)}
|
|
103
|
+
{...attrs([styles.base, active && styles.active, active && styles[tone], sx], className)}
|
|
78
104
|
{@attach active && whileVisible}
|
|
79
105
|
>
|
|
80
106
|
{@render children?.()}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
/**
|
|
5
|
+
* The colour of the band. `neutral`, the default, is the text's own colour passing over
|
|
6
|
+
* quieter letters; `accent` is a band of the accent, for the one thing that is live.
|
|
7
|
+
*/
|
|
8
|
+
export type ShimmerTone = 'neutral' | 'accent';
|
|
4
9
|
export type ShimmerProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
|
|
5
10
|
/** Turn it off to show the text plainly, for example once the work is done. */
|
|
6
11
|
active?: boolean | undefined;
|
|
12
|
+
/** The colour of the band that passes over the letters. */
|
|
13
|
+
tone?: ShimmerTone | undefined;
|
|
7
14
|
sx?: Sx | undefined;
|
|
8
15
|
children?: Snippet | undefined;
|
|
9
16
|
};
|
|
@@ -253,8 +253,16 @@
|
|
|
253
253
|
[stylex.when.ancestor(':focus-within', tabStripTabMarker)]: 0
|
|
254
254
|
}
|
|
255
255
|
},
|
|
256
|
-
// Where nothing hovers, the open tab shows its close button in the icon's place
|
|
257
|
-
|
|
256
|
+
// Where nothing hovers, the open tab shows its close button in the icon's place; where
|
|
257
|
+
// something does, its icon steps aside under the pointer as any tab's does. The whole
|
|
258
|
+
// rule again, since a style replaces the one before it rather than merging with it
|
|
259
|
+
leadIconSelected: {
|
|
260
|
+
opacity: {
|
|
261
|
+
default: 0,
|
|
262
|
+
[media.hover]: { default: 1, [stylex.when.ancestor(':hover', tabStripTabMarker)]: 0 },
|
|
263
|
+
[stylex.when.ancestor(':focus-within', tabStripTabMarker)]: 0
|
|
264
|
+
}
|
|
265
|
+
},
|
|
258
266
|
leadMark: { gridArea: '1 / 1' },
|
|
259
267
|
start: {
|
|
260
268
|
position: 'absolute',
|
package/dist/index.d.ts
CHANGED
|
@@ -111,7 +111,7 @@ export type { SettingsGroupProps } from './components/settings-group/SettingsGro
|
|
|
111
111
|
export { default as SettingsRow } from './components/settings-row/SettingsRow.svelte';
|
|
112
112
|
export type { SettingsRowControl, SettingsRowProps } from './components/settings-row/SettingsRow.svelte';
|
|
113
113
|
export { default as Shimmer } from './components/shimmer/Shimmer.svelte';
|
|
114
|
-
export type { ShimmerProps } from './components/shimmer/Shimmer.svelte';
|
|
114
|
+
export type { ShimmerProps, ShimmerTone } from './components/shimmer/Shimmer.svelte';
|
|
115
115
|
export * as Sheet from './components/sheet/index.js';
|
|
116
116
|
export type { SheetContentProps, SheetSide, SheetSize } from './components/sheet/index.js';
|
|
117
117
|
export * as Sidebar from './components/sidebar/index.js';
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
* of the display. A spinner is the exception: it has to turn smoothly, so it is
|
|
19
19
|
* a plain rotation, and only the pausing applies to it.
|
|
20
20
|
*
|
|
21
|
+
* Each time one starts to run, it is set to where the page's clock puts it, as if every
|
|
22
|
+
* animation had started as the page loaded. So animations alike move together however late each
|
|
23
|
+
* came into view: the spinners of a list of rows turn as one, rather than each from the moment
|
|
24
|
+
* its row scrolled in.
|
|
25
|
+
*
|
|
21
26
|
* Without this the animation runs: the property's fallback is `running`.
|
|
22
27
|
*
|
|
23
28
|
* ```svelte
|
package/dist/internal/visible.js
CHANGED
|
@@ -2,9 +2,24 @@ const watched = new Map();
|
|
|
2
2
|
let observer = null;
|
|
3
3
|
// Hidden by the host's word, whatever the document says
|
|
4
4
|
let hiddenByHost = false;
|
|
5
|
+
// Each of the element's animations to where the page's clock puts it: its time since the page
|
|
6
|
+
// loaded, within one cycle. Seeking a CSS animation leaves its play state to the stylesheet.
|
|
7
|
+
function align(element) {
|
|
8
|
+
const now = document.timeline.currentTime;
|
|
9
|
+
if (typeof now !== 'number')
|
|
10
|
+
return;
|
|
11
|
+
for (const animation of element.getAnimations()) {
|
|
12
|
+
const { duration } = animation.effect?.getComputedTiming() ?? {};
|
|
13
|
+
if (typeof duration === 'number' && duration > 0)
|
|
14
|
+
animation.currentTime = now % duration;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
5
17
|
function apply(item) {
|
|
6
18
|
const running = item.inView && !document.hidden && !hiddenByHost;
|
|
7
19
|
item.element.style.setProperty('--narvi-play', running ? 'running' : 'paused');
|
|
20
|
+
if (running && !item.running)
|
|
21
|
+
align(item.element);
|
|
22
|
+
item.running = running;
|
|
8
23
|
}
|
|
9
24
|
function applyAll() {
|
|
10
25
|
for (const item of watched.values())
|
|
@@ -48,7 +63,7 @@ export const whileVisible = (element) => {
|
|
|
48
63
|
});
|
|
49
64
|
document.addEventListener('visibilitychange', applyAll);
|
|
50
65
|
}
|
|
51
|
-
const item = { element, inView: false };
|
|
66
|
+
const item = { element, inView: false, running: false };
|
|
52
67
|
watched.set(element, item);
|
|
53
68
|
// Paused until the observer has looked, which it does before the next frame is drawn
|
|
54
69
|
apply(item);
|
package/package.json
CHANGED
|
@@ -106,7 +106,7 @@ errors with an `Announcer` too.
|
|
|
106
106
|
| `Progress` | How far along a task is | `progress` |
|
|
107
107
|
| `Spinner` | Something in progress | `spinner` |
|
|
108
108
|
| `Skeleton` | A stand-in for content on its way | `skeleton` |
|
|
109
|
-
| `Shimmer` | Text that says work is under way
|
|
109
|
+
| `Shimmer` | Text that says work is under way (`tone` `neutral` by default, or `accent` for the one live thing) | `shimmer` |
|
|
110
110
|
| `RollingText` | A phrase that rolls to its next value ("Reading…", "Running…") | none |
|
|
111
111
|
| `Announcer` | Says a short message to screen readers without showing anything | `announcer` |
|
|
112
112
|
| `Avatar.Root`, `.Image`, `.Fallback` | A person: a picture, or initials (`size` `xs` is 20px; `label={null}` beside a written name) | `avatar` |
|
|
@@ -268,7 +268,7 @@ your own for it. `outputLabels` renames it.
|
|
|
268
268
|
|
|
269
269
|
- `sx()`, `classes()` and the `Sx` type: see the `styling` skill.
|
|
270
270
|
- `resolveColor()` and `resolveRgba()`: see the `theming` skill.
|
|
271
|
-
- `whileVisible`: an attachment that runs an animation that never ends only while it can be seen, with `animationPlayState: play.whileVisible` from the tokens. Step the animation itself.
|
|
271
|
+
- `whileVisible`: an attachment that runs an animation that never ends only while it can be seen, with `animationPlayState: play.whileVisible` from the tokens. Step the animation itself. Each time it starts to run it is set to the page's clock, so animations alike, such as the spinners down a list, move together; don't stagger them by hand.
|
|
272
272
|
Shimmer, Skeleton, Progress and Markdown's caret run on it, stepped. Spinner pauses with it
|
|
273
273
|
too, but is not stepped: it is a CSS animation of `rotate`, one turn in 600ms, so it stays smooth.
|
|
274
274
|
- `setPageHidden(hidden)`: tells Narvi the host has hidden the page where the document cannot
|
package/skills/markdown/SKILL.md
CHANGED
package/skills/setup/SKILL.md
CHANGED
package/skills/styling/SKILL.md
CHANGED
|
@@ -12,7 +12,7 @@ metadata:
|
|
|
12
12
|
hover, motion and forced-colour preferences.
|
|
13
13
|
type: core
|
|
14
14
|
library: '@diegopluna/narvi'
|
|
15
|
-
library_version: '0.3.
|
|
15
|
+
library_version: '0.3.10'
|
|
16
16
|
requires:
|
|
17
17
|
- setup
|
|
18
18
|
sources:
|
|
@@ -101,7 +101,8 @@ package root) breaks them.
|
|
|
101
101
|
its hairline takes the ring and halo while the field inside is typed into, as a text field's
|
|
102
102
|
does. Don't redraw either with `:focus-visible` styles of your own.
|
|
103
103
|
- `play.whileVisible`: the `animationPlayState` for an animation that never ends. Attach
|
|
104
|
-
`whileVisible` (from the package root) to its element and it runs only while it can be seen
|
|
104
|
+
`whileVisible` (from the package root) to its element and it runs only while it can be seen,
|
|
105
|
+
in step with the page's other animations of the same length.
|
|
105
106
|
Step such an animation (`steps(30)` over two seconds) so it costs a few frames a second.
|
|
106
107
|
- `setPageHidden(hidden)` (from the package root) is the host's word that the page is out of
|
|
107
108
|
sight where `document.hidden` stays false, as in an Electron window with background
|
package/skills/theming/SKILL.md
CHANGED