@dumiflex/wp-kit 0.6.0 → 0.7.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/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/BundlePreview.vue +254 -0
- package/src/CombinePreview.vue +150 -0
- package/src/ConstraintMatrixPreview.vue +6 -22
- package/src/ConstraintPreview.vue +259 -0
- package/src/DerivationCondition.vue +68 -0
- package/src/DerivationPreview.vue +345 -0
- package/src/FixedValuesPreview.vue +184 -0
- package/src/IconPicker.vue +31 -102
- package/src/IconPickerPanel.vue +132 -0
- package/src/LoadingMark.vue +6 -61
- package/src/PayloadPreview.vue +154 -0
- package/src/PostDetailSkeleton.vue +65 -0
- package/src/PostGridSkeleton.vue +61 -0
- package/src/PreviewGroup.vue +75 -0
- package/src/ProfileSkeleton.vue +73 -0
- package/src/RichText.vue +61 -0
- package/src/SelectionBar.vue +90 -0
- package/src/SettingGroup.vue +57 -0
- package/src/SettingRow.vue +127 -0
- package/src/WildcardPreview.vue +607 -0
- package/src/WorkingLine.vue +38 -124
- package/src/canvas-motion.ts +251 -0
- package/src/kind-colour.ts +24 -1
- package/src/linkify.ts +142 -0
- package/src/loading-mark-motion.ts +12 -155
- package/src/matrix-axis.ts +28 -0
- package/src/pi-icons.ts +51 -0
- package/src/preview-readers.ts +401 -0
- package/src/preview.css +194 -0
- package/src/tokens.ts +8 -2
- package/src/working-line-motion.ts +135 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkingLine's marks, drawn on a canvas (see `canvas-motion.ts` for why).
|
|
3
|
+
* The same keyframes, delays and easings the marks had in CSS; `period` is
|
|
4
|
+
* the tempo's loop (2.8 s slow, 2.2 s mid, 1.5 s fast).
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
EASE_IN_OUT,
|
|
8
|
+
SMOOTH,
|
|
9
|
+
begin,
|
|
10
|
+
cubicBezier,
|
|
11
|
+
fillAround,
|
|
12
|
+
loop,
|
|
13
|
+
mix,
|
|
14
|
+
track,
|
|
15
|
+
type Stop,
|
|
16
|
+
} from "./canvas-motion";
|
|
17
|
+
import { C_A, C_B, C_BIG, shapes } from "./loading-mark-motion";
|
|
18
|
+
|
|
19
|
+
export type WorkingVariant = "typing" | "shuffle" | "orbit" | "burst";
|
|
20
|
+
|
|
21
|
+
/** Loop length per tempo, in ms. */
|
|
22
|
+
export const TEMPO_MS = { slow: 2800, mid: 2200, fast: 1500 } as const;
|
|
23
|
+
|
|
24
|
+
const SPIN_EASE = cubicBezier(0.5, 0.1, 0.5, 0.9);
|
|
25
|
+
const BURST_EASE = cubicBezier(0.3, 0, 0.2, 1);
|
|
26
|
+
|
|
27
|
+
/** A typing star's hop: [lift (units), scale]. */
|
|
28
|
+
const HOP: readonly Stop[] = [[0, [0, 1]], [0.2, [-110, 1.12]], [0.4, [0, 1]], [1, [0, 1]]];
|
|
29
|
+
const SWAP: readonly Stop[] = [[0, [0]], [0.15, [0]], [0.5, [180]], [0.65, [180]], [1, [360]]];
|
|
30
|
+
/** The big star's dip: [scale, turn]. */
|
|
31
|
+
const DIP: readonly Stop[] = [[0, [1, 0]], [0.15, [1, 0]], [0.32, [0.7, 45]], [0.5, [1, 90]], [1, [1, 90]]];
|
|
32
|
+
/** An orbit node's twinkle: [opacity, scale]. */
|
|
33
|
+
const TWINKLE: readonly Stop[] = [[0, [1, 1]], [0.5, [0.35, 0.6]], [1, [1, 1]]];
|
|
34
|
+
const BREATHE: readonly Stop[] = [[0, [1]], [0.5, [0.86]], [1, [1]]];
|
|
35
|
+
/** The big star's pop under a burst. */
|
|
36
|
+
const POP: readonly Stop[] = [[0, [1.1]], [0.4, [0.8]], [1, [1.1]]];
|
|
37
|
+
/** Burst, per property as CSS reads it: how far out (1 = flown out), scale, opacity. */
|
|
38
|
+
const BURST_F: readonly Stop[] = [[0, [1]], [0.45, [0]], [0.75, [0]], [1, [1]]];
|
|
39
|
+
const BURST_S: readonly Stop[] = [[0, [0]], [0.45, [1.15]], [0.75, [1.15]], [1, [0]]];
|
|
40
|
+
const BURST_O: readonly Stop[] = [[0, [0]], [0.15, [1]], [0.75, [1]], [1, [0]]];
|
|
41
|
+
|
|
42
|
+
/** [big star, star A, star B] colours. */
|
|
43
|
+
export type Colours = readonly [string, string, string];
|
|
44
|
+
|
|
45
|
+
/** The orbit's four nodes: position and colour (steps between the brand's). */
|
|
46
|
+
export function orbitNodes([big, a, b]: Colours): [number, number, string][] {
|
|
47
|
+
return [[911, 512, b], [512, 911, mix(b, a, 0.7)], [113, 512, mix(big, a, 0.6)], [512, 113, a]];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Typing stars: the big sparkle drawn small three times in a row. */
|
|
51
|
+
export const TYPING_X = [250, 512, 774] as const;
|
|
52
|
+
|
|
53
|
+
let dot: Path2D | null = null;
|
|
54
|
+
|
|
55
|
+
/** Draws one frame of a WorkingLine mark. */
|
|
56
|
+
export function drawWorking(ctx: CanvasRenderingContext2D, width: number, ms: number, variant: WorkingVariant, period: number, colours: Colours): void {
|
|
57
|
+
const [big, a, b] = colours;
|
|
58
|
+
const p = shapes();
|
|
59
|
+
begin(ctx, width);
|
|
60
|
+
if (variant === "typing") {
|
|
61
|
+
const fills = [a, big, b];
|
|
62
|
+
TYPING_X.forEach((x, k) => {
|
|
63
|
+
const [lift = 0, s = 1] = track(HOP, loop(ms, period, period * k * 0.15), EASE_IN_OUT);
|
|
64
|
+
ctx.save();
|
|
65
|
+
// The big star at half size, its centre moved to (x, 512).
|
|
66
|
+
ctx.translate(x - 512, lift);
|
|
67
|
+
fillAround(ctx, C_BIG, 0.5 * s, 0, p.big, fills[k] ?? big);
|
|
68
|
+
ctx.restore();
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (variant === "shuffle") {
|
|
73
|
+
ctx.translate(512, 512);
|
|
74
|
+
ctx.scale(1.45, 1.45);
|
|
75
|
+
ctx.translate(-512, -512);
|
|
76
|
+
const [ds = 1, dr = 0] = track(DIP, loop(ms, period), SMOOTH);
|
|
77
|
+
fillAround(ctx, C_BIG, ds, dr, p.big, big);
|
|
78
|
+
const [sr = 0] = track(SWAP, loop(ms, period * 2), SMOOTH);
|
|
79
|
+
ctx.save();
|
|
80
|
+
ctx.translate(512, 512);
|
|
81
|
+
ctx.rotate((sr * Math.PI) / 180);
|
|
82
|
+
ctx.translate(-512, -512);
|
|
83
|
+
ctx.fillStyle = a;
|
|
84
|
+
ctx.fill(p.a);
|
|
85
|
+
ctx.fillStyle = b;
|
|
86
|
+
ctx.fill(p.b);
|
|
87
|
+
ctx.restore();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (variant === "orbit") {
|
|
91
|
+
dot ??= circle();
|
|
92
|
+
const [spin = 0] = track([[0, [0]], [1, [360]]], loop(ms, period * 2), SPIN_EASE);
|
|
93
|
+
ctx.save();
|
|
94
|
+
ctx.translate(512, 512);
|
|
95
|
+
ctx.rotate((spin * Math.PI) / 180);
|
|
96
|
+
ctx.translate(-512, -512);
|
|
97
|
+
orbitNodes(colours).forEach(([x, y, c], k) => {
|
|
98
|
+
const [o = 1, s = 1] = track(TWINKLE, loop(ms + period * k * 0.25, period), EASE_IN_OUT);
|
|
99
|
+
ctx.save();
|
|
100
|
+
ctx.translate(x, y);
|
|
101
|
+
ctx.scale(s, s);
|
|
102
|
+
ctx.globalAlpha = o;
|
|
103
|
+
ctx.fillStyle = c;
|
|
104
|
+
ctx.fill(dot ?? circle());
|
|
105
|
+
ctx.restore();
|
|
106
|
+
});
|
|
107
|
+
ctx.restore();
|
|
108
|
+
const [bs = 1] = track(BREATHE, loop(ms, period), EASE_IN_OUT);
|
|
109
|
+
fillAround(ctx, C_BIG, bs, 0, p.big, big);
|
|
110
|
+
fillAround(ctx, C_A, 1, 0, p.a, a);
|
|
111
|
+
fillAround(ctx, C_B, 1, 0, p.b, b);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
ctx.translate(512, 512);
|
|
115
|
+
ctx.scale(1.3, 1.3);
|
|
116
|
+
ctx.translate(-512, -512);
|
|
117
|
+
const pp = loop(ms, period);
|
|
118
|
+
const [ps = 1] = track(POP, pp, EASE_IN_OUT);
|
|
119
|
+
fillAround(ctx, C_BIG, ps, 0, p.big, big);
|
|
120
|
+
const [f = 0] = track(BURST_F, pp, BURST_EASE);
|
|
121
|
+
const [s = 0] = track(BURST_S, pp, BURST_EASE);
|
|
122
|
+
const [o = 0] = track(BURST_O, pp, BURST_EASE);
|
|
123
|
+
for (const [centre, path, fill, dx, dy] of [[C_A, p.a, a, 152, -152], [C_B, p.b, b, -152, 152]] as const) {
|
|
124
|
+
ctx.save();
|
|
125
|
+
ctx.translate(dx * f, dy * f);
|
|
126
|
+
fillAround(ctx, centre, s, 0, path, fill, o);
|
|
127
|
+
ctx.restore();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function circle(): Path2D {
|
|
132
|
+
const c = new Path2D();
|
|
133
|
+
c.arc(0, 0, 70, 0, Math.PI * 2);
|
|
134
|
+
return c;
|
|
135
|
+
}
|