@mdbase-dev/ui 0.1.0-beta.213 → 0.1.0-beta.216
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 +45 -0
- package/css/brand.css +27 -0
- package/css/comments.css +2 -1
- package/css/live-preview.css +33 -0
- package/css/motion.css +27 -15
- package/css/screens.css +98 -36
- package/dist/live-preview/blocks.js +9 -0
- package/dist/live-preview/diagram.d.ts +22 -0
- package/dist/live-preview/diagram.js +159 -0
- package/dist/locales/de/messages.json +1 -1
- package/dist/locales/en/messages.json +1 -1
- package/dist/locales/es/messages.json +1 -1
- package/dist/locales/fr/messages.json +1 -1
- package/dist/locales/it/messages.json +1 -1
- package/dist/locales/ja/messages.json +1 -1
- package/dist/locales/ko/messages.json +1 -1
- package/dist/locales/pt/messages.json +1 -1
- package/dist/locales/ru/messages.json +1 -1
- package/dist/locales/zh/messages.json +1 -1
- package/dist/opening-page.d.ts +40 -0
- package/dist/opening-page.js +104 -0
- package/dist/screens.d.ts +8 -16
- package/dist/screens.js +53 -194
- package/package.json +8 -3
- package/dist/flock.d.ts +0 -63
- package/dist/flock.js +0 -140
package/dist/flock.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { type MdbaseMarkRect } from "./brand.js";
|
|
2
|
-
/**
|
|
3
|
-
* The launch flock: small birds fly in from the edges of the screen, land on the
|
|
4
|
-
* Frontmatter mark as two rows of dots per bar, and close up into the solid bars.
|
|
5
|
-
* Everything here is a pure function of time, so a frame can be drawn at any moment
|
|
6
|
-
* and tests can check where the birds end up.
|
|
7
|
-
*/
|
|
8
|
-
/** Seconds. The mark is solid at `solid`; the entrance hands over to the real mark at `end`. */
|
|
9
|
-
export declare const FLOCK_TIMING: {
|
|
10
|
-
/** Spread of start times; each bird leaves within this window. */
|
|
11
|
-
readonly spread: 0.45;
|
|
12
|
-
/** How long each bird is in the air. */
|
|
13
|
-
readonly flight: 0.85;
|
|
14
|
-
/** When the first bars start closing up. */
|
|
15
|
-
readonly close: 1.2;
|
|
16
|
-
/** Spread of the bars' close-up times, top to bottom with the highlight last. */
|
|
17
|
-
readonly closeStagger: 0.2;
|
|
18
|
-
/** How long one bar takes to close up. */
|
|
19
|
-
readonly closeDuration: 0.3;
|
|
20
|
-
readonly solid: 1.8;
|
|
21
|
-
readonly end: 2;
|
|
22
|
-
};
|
|
23
|
-
type FlockBird = Readonly<{
|
|
24
|
-
/** Index of the bar this bird belongs to in `flockBars`. */
|
|
25
|
-
bar: number;
|
|
26
|
-
accent: boolean;
|
|
27
|
-
/** Landed dot, in mark units (the 120-unit board the mark's rects use). */
|
|
28
|
-
dotX: number;
|
|
29
|
-
dotY: number;
|
|
30
|
-
/** The share of its bar the bird grows into when the bar closes up. */
|
|
31
|
-
cell: MdbaseMarkRect;
|
|
32
|
-
seed: number;
|
|
33
|
-
}>;
|
|
34
|
-
type FlockBar = Readonly<{
|
|
35
|
-
rect: MdbaseMarkRect;
|
|
36
|
-
accent: boolean;
|
|
37
|
-
}>;
|
|
38
|
-
export declare const flockBars: readonly FlockBar[];
|
|
39
|
-
/** Two rows of dots per bar; each dot's cell tiles its bar exactly. */
|
|
40
|
-
export declare const flockBirds: readonly FlockBird[];
|
|
41
|
-
/** Where the mark sits on screen: its 84-unit artboard (viewBox 18 18 84 84) in pixels. */
|
|
42
|
-
type FlockStage = Readonly<{
|
|
43
|
-
width: number;
|
|
44
|
-
height: number;
|
|
45
|
-
markLeft: number;
|
|
46
|
-
markTop: number;
|
|
47
|
-
markSize: number;
|
|
48
|
-
}>;
|
|
49
|
-
type FlockFrame = Readonly<{
|
|
50
|
-
/** One rectangle per bird still drawn as a bird, in screen pixels. */
|
|
51
|
-
birds: readonly (MdbaseMarkRect & {
|
|
52
|
-
accent: boolean;
|
|
53
|
-
})[];
|
|
54
|
-
/** Bars that have closed up completely, drawn as the real rectangles. */
|
|
55
|
-
bars: readonly (MdbaseMarkRect & {
|
|
56
|
-
accent: boolean;
|
|
57
|
-
})[];
|
|
58
|
-
}>;
|
|
59
|
-
/** How far bar `index` has closed up at time `t`, 0 to 1. */
|
|
60
|
-
export declare function flockBarClosed(index: number, t: number): number;
|
|
61
|
-
/** Everything to draw at time `t` seconds into the entrance. */
|
|
62
|
-
export declare function flockFrame(stage: FlockStage, t: number): FlockFrame;
|
|
63
|
-
export {};
|
package/dist/flock.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { mdbaseMarkAccentRect, mdbaseMarkInkRects } from "./brand.js";
|
|
2
|
-
/**
|
|
3
|
-
* The launch flock: small birds fly in from the edges of the screen, land on the
|
|
4
|
-
* Frontmatter mark as two rows of dots per bar, and close up into the solid bars.
|
|
5
|
-
* Everything here is a pure function of time, so a frame can be drawn at any moment
|
|
6
|
-
* and tests can check where the birds end up.
|
|
7
|
-
*/
|
|
8
|
-
/** Seconds. The mark is solid at `solid`; the entrance hands over to the real mark at `end`. */
|
|
9
|
-
export const FLOCK_TIMING = {
|
|
10
|
-
/** Spread of start times; each bird leaves within this window. */
|
|
11
|
-
spread: 0.45,
|
|
12
|
-
/** How long each bird is in the air. */
|
|
13
|
-
flight: 0.85,
|
|
14
|
-
/** When the first bars start closing up. */
|
|
15
|
-
close: 1.2,
|
|
16
|
-
/** Spread of the bars' close-up times, top to bottom with the highlight last. */
|
|
17
|
-
closeStagger: 0.2,
|
|
18
|
-
/** How long one bar takes to close up. */
|
|
19
|
-
closeDuration: 0.3,
|
|
20
|
-
solid: 1.8,
|
|
21
|
-
end: 2.0
|
|
22
|
-
};
|
|
23
|
-
const DOT = 3.4;
|
|
24
|
-
const PITCH = 5;
|
|
25
|
-
export const flockBars = [...mdbaseMarkInkRects.map(rect => ({
|
|
26
|
-
rect,
|
|
27
|
-
accent: false
|
|
28
|
-
})), {
|
|
29
|
-
rect: mdbaseMarkAccentRect,
|
|
30
|
-
accent: true
|
|
31
|
-
}];
|
|
32
|
-
function seeded(n) {
|
|
33
|
-
const s = Math.sin(n * 127.1) * 43758.5453;
|
|
34
|
-
return s - Math.floor(s);
|
|
35
|
-
}
|
|
36
|
-
const smooth = x => {
|
|
37
|
-
const t = Math.min(1, Math.max(0, x));
|
|
38
|
-
return t * t * (3 - 2 * t);
|
|
39
|
-
};
|
|
40
|
-
/** Two rows of dots per bar; each dot's cell tiles its bar exactly. */
|
|
41
|
-
export const flockBirds = flockBars.flatMap(({
|
|
42
|
-
rect,
|
|
43
|
-
accent
|
|
44
|
-
}, bar) => {
|
|
45
|
-
const columns = Math.max(2, Math.round((rect.width - DOT) / PITCH) + 1);
|
|
46
|
-
const span = (rect.width - DOT) / (columns - 1);
|
|
47
|
-
const cellWidth = rect.width / columns;
|
|
48
|
-
const cellHeight = rect.height / 2;
|
|
49
|
-
return Array.from({
|
|
50
|
-
length: columns * 2
|
|
51
|
-
}, (_, index) => {
|
|
52
|
-
const row = Math.floor(index / columns);
|
|
53
|
-
const column = index % columns;
|
|
54
|
-
return {
|
|
55
|
-
bar,
|
|
56
|
-
accent,
|
|
57
|
-
dotX: rect.x + column * span,
|
|
58
|
-
dotY: rect.y + 1 + row * 4.6,
|
|
59
|
-
cell: {
|
|
60
|
-
x: rect.x + column * cellWidth,
|
|
61
|
-
y: rect.y + row * cellHeight,
|
|
62
|
-
width: cellWidth,
|
|
63
|
-
height: cellHeight
|
|
64
|
-
},
|
|
65
|
-
seed: bar * 31 + index
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
/** How far bar `index` has closed up at time `t`, 0 to 1. */
|
|
70
|
-
export function flockBarClosed(index, t) {
|
|
71
|
-
const {
|
|
72
|
-
rect,
|
|
73
|
-
accent
|
|
74
|
-
} = flockBars[index];
|
|
75
|
-
const order = accent ? 1 : (rect.y - 22) / 66 * 0.7;
|
|
76
|
-
return smooth((t - FLOCK_TIMING.close - order * FLOCK_TIMING.closeStagger) / FLOCK_TIMING.closeDuration);
|
|
77
|
-
}
|
|
78
|
-
/** Everything to draw at time `t` seconds into the entrance. */
|
|
79
|
-
export function flockFrame(stage, t) {
|
|
80
|
-
const scale = stage.markSize / 84;
|
|
81
|
-
const toX = x => stage.markLeft + (x - 18) * scale;
|
|
82
|
-
const toY = y => stage.markTop + (y - 18) * scale;
|
|
83
|
-
const closed = flockBars.map((_, index) => flockBarClosed(index, t));
|
|
84
|
-
const dot = DOT * scale;
|
|
85
|
-
const centreX = stage.width / 2;
|
|
86
|
-
const centreY = stage.height / 2;
|
|
87
|
-
const margin = 12;
|
|
88
|
-
const birds = flockBirds.flatMap(bird => {
|
|
89
|
-
const close = closed[bird.bar];
|
|
90
|
-
if (close >= 1) return [];
|
|
91
|
-
const landX = toX(bird.dotX);
|
|
92
|
-
const landY = toY(bird.dotY);
|
|
93
|
-
// Each bird comes in roughly from the side of the screen nearest its spot, with a wide spread.
|
|
94
|
-
const outward = Math.atan2(landY + dot / 2 - centreY, landX + dot / 2 - centreX);
|
|
95
|
-
const angle = outward + (seeded(bird.seed + 11) - 0.5) * 2.6;
|
|
96
|
-
const ux = Math.cos(angle);
|
|
97
|
-
const uy = Math.sin(angle);
|
|
98
|
-
const edge = Math.min(ux > 0 ? (stage.width + margin - landX) / ux : ux < 0 ? (landX + margin) / -ux : Infinity, uy > 0 ? (stage.height + margin - landY) / uy : uy < 0 ? (landY + margin) / -uy : Infinity);
|
|
99
|
-
const reach = edge + seeded(bird.seed + 13) * Math.min(stage.width, stage.height) * 0.15;
|
|
100
|
-
const startX = landX + ux * reach;
|
|
101
|
-
const startY = landY + uy * reach;
|
|
102
|
-
const bend = (seeded(bird.seed + 19) - 0.5) * reach * 0.45;
|
|
103
|
-
const midX = (startX + landX) / 2 - uy * bend;
|
|
104
|
-
const midY = (startY + landY) / 2 + ux * bend;
|
|
105
|
-
const order = seeded(bird.seed + 7) * 0.8 + seeded(bird.seed + 41) * 0.2;
|
|
106
|
-
const u = Math.min(1, Math.max(0, (t - order * FLOCK_TIMING.spread) / FLOCK_TIMING.flight));
|
|
107
|
-
const e = 1 - (1 - u) ** 3;
|
|
108
|
-
const x = (1 - e) ** 2 * startX + 2 * (1 - e) * e * midX + e * e * landX;
|
|
109
|
-
const y = (1 - e) ** 2 * startY + 2 * (1 - e) * e * midY + e * e * landY;
|
|
110
|
-
// Small in flight, full size on landing; never thinner than 2px so it stays visible.
|
|
111
|
-
const landed = smooth((u - 0.6) / 0.4);
|
|
112
|
-
const size = Math.max(dot * (0.4 + 0.6 * landed), Math.min(dot, 2));
|
|
113
|
-
const left = x + (dot - size) / 2;
|
|
114
|
-
const top = y + (dot - size) / 2;
|
|
115
|
-
// Closing up grows the dot into its share of the bar.
|
|
116
|
-
const cellX = toX(bird.cell.x);
|
|
117
|
-
const cellY = toY(bird.cell.y);
|
|
118
|
-
return [{
|
|
119
|
-
x: left + (cellX - left) * close,
|
|
120
|
-
y: top + (cellY - top) * close,
|
|
121
|
-
width: size + (bird.cell.width * scale - size) * close,
|
|
122
|
-
height: size + (bird.cell.height * scale - size) * close,
|
|
123
|
-
accent: bird.accent
|
|
124
|
-
}];
|
|
125
|
-
});
|
|
126
|
-
const bars = flockBars.flatMap(({
|
|
127
|
-
rect,
|
|
128
|
-
accent
|
|
129
|
-
}, index) => closed[index] < 1 ? [] : [{
|
|
130
|
-
x: toX(rect.x),
|
|
131
|
-
y: toY(rect.y),
|
|
132
|
-
width: rect.width * scale,
|
|
133
|
-
height: rect.height * scale,
|
|
134
|
-
accent
|
|
135
|
-
}]);
|
|
136
|
-
return {
|
|
137
|
-
birds,
|
|
138
|
-
bars
|
|
139
|
-
};
|
|
140
|
-
}
|