maverick-wave-astro 1.36.0 → 1.38.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/components/StoryCards.astro +5 -18
- package/components/Testimonial.astro +45 -2
- package/dist/story/base.d.ts +3 -1
- package/dist/story/base.js +5 -2
- package/dist/story/event.js +19 -7
- package/dist/text.d.ts +8 -0
- package/dist/text.js +14 -0
- package/package.json +3 -3
- package/styles/story-cards.css +6 -38
|
@@ -59,8 +59,6 @@ interface Props extends StoryLook {
|
|
|
59
59
|
save?: string;
|
|
60
60
|
shareVideo?: string;
|
|
61
61
|
saveVideo?: string;
|
|
62
|
-
// The second button on a video story, for the still image.
|
|
63
|
-
stillImage?: string;
|
|
64
62
|
empty?: string;
|
|
65
63
|
soldOut?: string;
|
|
66
64
|
free?: string;
|
|
@@ -109,7 +107,6 @@ const {
|
|
|
109
107
|
save = german ? 'Bild speichern' : 'Save image',
|
|
110
108
|
shareVideo = german ? 'Video teilen' : 'Share video',
|
|
111
109
|
saveVideo = german ? 'Video speichern' : 'Save video',
|
|
112
|
-
stillImage = german ? 'Als Bild' : 'As image',
|
|
113
110
|
empty = german
|
|
114
111
|
? 'Gerade gibt es nichts zu teilen.'
|
|
115
112
|
: 'Nothing to share right now.',
|
|
@@ -263,7 +260,6 @@ const look: LookOptions = {
|
|
|
263
260
|
data-save={save}
|
|
264
261
|
data-share-video={shareVideo}
|
|
265
262
|
data-save-video={saveVideo}
|
|
266
|
-
data-still-image={stillImage}
|
|
267
263
|
data-share-settings={JSON.stringify({
|
|
268
264
|
place: sharePlace,
|
|
269
265
|
hashtags: storyLook?.config.hashtags ?? '',
|
|
@@ -286,12 +282,12 @@ const look: LookOptions = {
|
|
|
286
282
|
role="img"
|
|
287
283
|
aria-label={story.label}
|
|
288
284
|
/>
|
|
289
|
-
<button
|
|
290
|
-
type="button"
|
|
291
|
-
class="mw-btn mw-btn-primary mw-btn-lg mwa-story-card-btn"
|
|
292
|
-
data-story-save
|
|
293
|
-
/>
|
|
294
285
|
</div>
|
|
286
|
+
<button
|
|
287
|
+
type="button"
|
|
288
|
+
class="mw-btn mw-btn-primary mw-btn-lg mwa-story-card-btn"
|
|
289
|
+
data-story-save
|
|
290
|
+
/>
|
|
295
291
|
<details
|
|
296
292
|
class="mwa-story-share"
|
|
297
293
|
data-story-share={JSON.stringify(story.share)}
|
|
@@ -781,7 +777,6 @@ const look: LookOptions = {
|
|
|
781
777
|
once: boolean;
|
|
782
778
|
video?: File;
|
|
783
779
|
button: HTMLButtonElement | null;
|
|
784
|
-
stillButton?: HTMLButtonElement;
|
|
785
780
|
}
|
|
786
781
|
|
|
787
782
|
const piecesOf = (ctx: CanvasRenderingContext2D, story: Story) =>
|
|
@@ -873,7 +868,6 @@ const look: LookOptions = {
|
|
|
873
868
|
story.moves = false;
|
|
874
869
|
story.scene = null;
|
|
875
870
|
busy(story.stage, false);
|
|
876
|
-
story.stillButton?.remove();
|
|
877
871
|
if (story.button) {
|
|
878
872
|
story.button.textContent = label;
|
|
879
873
|
story.button.disabled = false;
|
|
@@ -1057,13 +1051,6 @@ const look: LookOptions = {
|
|
|
1057
1051
|
if (story.video) await save(story.video, canShareVideo);
|
|
1058
1052
|
else await saveStill(story);
|
|
1059
1053
|
});
|
|
1060
|
-
const stillButton = document.createElement('button');
|
|
1061
|
-
stillButton.type = 'button';
|
|
1062
|
-
stillButton.className = 'mw-btn mw-btn-sm mwa-story-card-still';
|
|
1063
|
-
stillButton.textContent = root.dataset.stillImage ?? '';
|
|
1064
|
-
onTap(stillButton, () => saveStill(story));
|
|
1065
|
-
stage.append(stillButton);
|
|
1066
|
-
story.stillButton = stillButton;
|
|
1067
1054
|
}
|
|
1068
1055
|
}
|
|
1069
1056
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
// A quote with its source. featured stands above the grid, the rest go into
|
|
3
|
-
// mw-columns-3. A date ages the quote - only where the voices stay fresh.
|
|
3
|
+
// mw-columns-3. A date ages the quote - only where the voices stay fresh. With
|
|
4
|
+
// `more` a long quote folds at a sentence end and the rest opens on a click;
|
|
5
|
+
// the featured one always stays whole.
|
|
4
6
|
import { siteLocale } from '../dist/config.js';
|
|
7
|
+
import { cutAtSentence, slug } from '../dist/text.js';
|
|
5
8
|
|
|
6
9
|
interface Props {
|
|
7
10
|
quote: string;
|
|
@@ -11,6 +14,10 @@ interface Props {
|
|
|
11
14
|
date?: string;
|
|
12
15
|
locale?: string;
|
|
13
16
|
featured?: boolean;
|
|
17
|
+
// The toggle's label - without it the quote stays whole
|
|
18
|
+
more?: string;
|
|
19
|
+
// The label once open; without it the toggle keeps saying `more`
|
|
20
|
+
less?: string;
|
|
14
21
|
class?: string;
|
|
15
22
|
}
|
|
16
23
|
|
|
@@ -21,6 +28,8 @@ const {
|
|
|
21
28
|
date,
|
|
22
29
|
locale = siteLocale,
|
|
23
30
|
featured = false,
|
|
31
|
+
more,
|
|
32
|
+
less,
|
|
24
33
|
class: className,
|
|
25
34
|
} = Astro.props;
|
|
26
35
|
|
|
@@ -31,16 +40,50 @@ const dateText = date
|
|
|
31
40
|
year: 'numeric',
|
|
32
41
|
})
|
|
33
42
|
: null;
|
|
43
|
+
|
|
44
|
+
const { preview, rest } =
|
|
45
|
+
more && !featured ? cutAtSentence(quote) : { preview: quote, rest: '' };
|
|
46
|
+
// Two voices with the same name tell apart by the length of what they said.
|
|
47
|
+
const bodyId = `quote-${slug(name)}-${quote.length}`;
|
|
34
48
|
---
|
|
35
49
|
|
|
36
50
|
<figure
|
|
37
51
|
class:list={[
|
|
38
52
|
'mw-testimonial',
|
|
39
53
|
featured && 'mw-testimonial-featured',
|
|
54
|
+
rest && 'mw-foldout',
|
|
40
55
|
className,
|
|
41
56
|
]}
|
|
42
57
|
>
|
|
43
|
-
<blockquote>
|
|
58
|
+
<blockquote>
|
|
59
|
+
{preview}
|
|
60
|
+
{
|
|
61
|
+
rest && (
|
|
62
|
+
<div class="mw-foldout-body" id={bodyId}>
|
|
63
|
+
<div class="mw-foldout-body-inner">{rest}</div>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
</blockquote>
|
|
68
|
+
{
|
|
69
|
+
rest && (
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
class="mw-link mw-foldout-toggle"
|
|
73
|
+
aria-expanded="false"
|
|
74
|
+
aria-controls={bodyId}
|
|
75
|
+
>
|
|
76
|
+
{less ? (
|
|
77
|
+
<>
|
|
78
|
+
<span class="mw-foldout-more">{more}</span>
|
|
79
|
+
<span class="mw-foldout-less">{less}</span>
|
|
80
|
+
</>
|
|
81
|
+
) : (
|
|
82
|
+
more
|
|
83
|
+
)}
|
|
84
|
+
</button>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
44
87
|
<figcaption class="mw-testimonial-source">
|
|
45
88
|
{name}{
|
|
46
89
|
detail && (
|
package/dist/story/base.d.ts
CHANGED
|
@@ -156,7 +156,9 @@ interface TextStyle {
|
|
|
156
156
|
/** Tried from the first on - the largest at which the text fits wins. */
|
|
157
157
|
sizes: number[];
|
|
158
158
|
lineHeight: number;
|
|
159
|
-
maxLines
|
|
159
|
+
maxLines?: number;
|
|
160
|
+
/** Caps the lines per size as well - at a smaller size more of them fit. */
|
|
161
|
+
maxHeight?: number;
|
|
160
162
|
letterSpacing?: number;
|
|
161
163
|
}
|
|
162
164
|
export declare const textBlock: (ctx: CanvasRenderingContext2D, text: string, style: TextStyle, gap: number, { x, maxWidth, align, }?: {
|
package/dist/story/base.js
CHANGED
|
@@ -498,6 +498,9 @@ const clampLines = (ctx, lines, maxLines, maxWidth) => {
|
|
|
498
498
|
kept[maxLines - 1] = last.endsWith('…') ? last : `${last} …`;
|
|
499
499
|
return kept;
|
|
500
500
|
};
|
|
501
|
+
const linesAllowed = (style, size) => Math.min(style.maxLines ?? Number.POSITIVE_INFINITY, style.maxHeight === undefined
|
|
502
|
+
? Number.POSITIVE_INFINITY
|
|
503
|
+
: Math.floor(style.maxHeight / Math.round(size * style.lineHeight)));
|
|
501
504
|
// A block of text that never leaves its room. Of the sizes it takes the
|
|
502
505
|
// largest that fits without cutting a word, then the largest that fits at all,
|
|
503
506
|
// and only at the smallest does it cut the last line it may have.
|
|
@@ -507,12 +510,12 @@ export const textBlock = (ctx, text, style, gap, { x = LEFT, maxWidth = CONTENT_
|
|
|
507
510
|
ctx.font = style.font(size);
|
|
508
511
|
return { size, ...wrapLines(ctx, text, maxWidth) };
|
|
509
512
|
});
|
|
510
|
-
const fitting = tries.filter(({ lines }) => lines.length <= style
|
|
513
|
+
const fitting = tries.filter(({ size, lines }) => lines.length <= linesAllowed(style, size));
|
|
511
514
|
const { size, lines: wrapped } = fitting.find(({ forced }) => !forced) ??
|
|
512
515
|
fitting[0] ??
|
|
513
516
|
tries[tries.length - 1];
|
|
514
517
|
ctx.font = style.font(size);
|
|
515
|
-
const lines = clampLines(ctx, wrapped, style
|
|
518
|
+
const lines = clampLines(ctx, wrapped, linesAllowed(style, size), maxWidth);
|
|
516
519
|
const width = Math.max(0, ...lines.map(line => ctx.measureText(line).width));
|
|
517
520
|
spaced(ctx, 0);
|
|
518
521
|
const lineHeight = Math.round(size * style.lineHeight);
|
package/dist/story/event.js
CHANGED
|
@@ -17,7 +17,11 @@ const WEEKDAY_SIZES = [
|
|
|
17
17
|
];
|
|
18
18
|
const TILE_HEIGHT = 262;
|
|
19
19
|
const BAND = 70;
|
|
20
|
-
|
|
20
|
+
// The text at its full size, then smaller before a line has to be cut.
|
|
21
|
+
const TEXT_SIZES = [40, 36, 32];
|
|
22
|
+
const TEXT_LEADING = 1.5;
|
|
23
|
+
const TEXT_LINE = TEXT_SIZES[0] * TEXT_LEADING;
|
|
24
|
+
const TEXT_GAP = 28;
|
|
21
25
|
// Below a run of rows, before the next block.
|
|
22
26
|
const AFTER_ROWS = 48;
|
|
23
27
|
const drawTile = (ctx, look, stamp, x, y) => {
|
|
@@ -225,16 +229,24 @@ const column = (ctx, look, frame, ink, blocks, space, minLead) => {
|
|
|
225
229
|
add(price, 'price', [block], block.above, block.below);
|
|
226
230
|
}
|
|
227
231
|
else if (block.style === 'p') {
|
|
228
|
-
const
|
|
229
|
-
|
|
232
|
+
const free = space - used - opening(block.above);
|
|
233
|
+
// The rows after the text keep their room, so the text shrinks before
|
|
234
|
+
// it pushes them off - unless that leaves it less than two full lines.
|
|
235
|
+
const rows = rowsAfter(blocks, i);
|
|
236
|
+
const reserved = rows.length
|
|
237
|
+
? Math.max(0, TEXT_GAP + (rows[0].above ?? 0)) +
|
|
238
|
+
totalHeight(rows.map(row => rowBlock(ctx, look, ink, row, room)))
|
|
239
|
+
: 0;
|
|
240
|
+
const maxHeight = free - reserved >= 2 * TEXT_LINE ? free - reserved : free;
|
|
241
|
+
if (maxHeight < Math.round(TEXT_SIZES.at(-1) * TEXT_LEADING))
|
|
230
242
|
break;
|
|
231
243
|
add(textBlock(ctx, block.text, {
|
|
232
244
|
font: size => look.font(size, 400),
|
|
233
245
|
color: inkOf(ink, block.color),
|
|
234
|
-
sizes:
|
|
235
|
-
lineHeight:
|
|
236
|
-
|
|
237
|
-
},
|
|
246
|
+
sizes: TEXT_SIZES,
|
|
247
|
+
lineHeight: TEXT_LEADING,
|
|
248
|
+
maxHeight,
|
|
249
|
+
}, TEXT_GAP, room), 'text', [block], block.above, block.below);
|
|
238
250
|
}
|
|
239
251
|
else {
|
|
240
252
|
const heading = HEADINGS[block.style];
|
package/dist/text.d.ts
CHANGED
|
@@ -7,3 +7,11 @@ export declare const priceParts: (amount: number, locale: string) => {
|
|
|
7
7
|
whole: string;
|
|
8
8
|
fraction: string;
|
|
9
9
|
};
|
|
10
|
+
export declare const cutAtSentence: (text: string, { from, to, leftover }?: {
|
|
11
|
+
from?: number | undefined;
|
|
12
|
+
to?: number | undefined;
|
|
13
|
+
leftover?: number | undefined;
|
|
14
|
+
}) => {
|
|
15
|
+
preview: string;
|
|
16
|
+
rest: string;
|
|
17
|
+
};
|
package/dist/text.js
CHANGED
|
@@ -99,3 +99,17 @@ export const priceParts = (amount, locale) => {
|
|
|
99
99
|
fraction: join(parts.slice(decimal)),
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
+
// The cut sits on a sentence end inside the window, so the preview reads as a
|
|
103
|
+
// whole thought and the fold-out starts a new one. Too little left over, and
|
|
104
|
+
// the text stays whole - a toggle for one line is not worth the click.
|
|
105
|
+
export const cutAtSentence = (text, { from = 140, to = 280, leftover = 80 } = {}) => {
|
|
106
|
+
let cut = 0;
|
|
107
|
+
for (const match of text.matchAll(/[.!?]["“”]?(?=\s)/g)) {
|
|
108
|
+
const end = match.index + match[0].length;
|
|
109
|
+
if (end >= from && end <= to)
|
|
110
|
+
cut = end;
|
|
111
|
+
}
|
|
112
|
+
if (!cut || text.length - cut < leftover)
|
|
113
|
+
return { preview: text, rest: '' };
|
|
114
|
+
return { preview: text.slice(0, cut), rest: text.slice(cut).trim() };
|
|
115
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maverick-wave-astro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "Shared frame for static Astro homepages built with MaverickWave: layout, SEO, design variants, schedule, building blocks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"astro": "^7.2.0",
|
|
56
|
-
"maverick-wave": "^6.
|
|
56
|
+
"maverick-wave": "^6.22.0",
|
|
57
57
|
"vite": "^8.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"eslint-plugin-astro": "^1.5.0",
|
|
70
70
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
71
71
|
"globals": "^16.5.0",
|
|
72
|
-
"maverick-wave": "^6.
|
|
72
|
+
"maverick-wave": "^6.22.0",
|
|
73
73
|
"playwright-core": "^1.64.0",
|
|
74
74
|
"prettier": "^3.6.2",
|
|
75
75
|
"prettier-plugin-astro": "^0.14.1",
|
package/styles/story-cards.css
CHANGED
|
@@ -25,7 +25,8 @@ html:has(.mwa-story-cards) {
|
|
|
25
25
|
|
|
26
26
|
@media (min-width: 900px) and (orientation: landscape) {
|
|
27
27
|
.mwa-story-cards {
|
|
28
|
-
|
|
28
|
+
/* Story, button and the closed texts below fit on one screen. */
|
|
29
|
+
--mwa-story-height: calc(100svh - 10rem);
|
|
29
30
|
|
|
30
31
|
/* A fixed upper bound: sized by content, the track would take the 1080px
|
|
31
32
|
of the canvas. */
|
|
@@ -62,7 +63,7 @@ html:has(.mwa-story-cards-preview) {
|
|
|
62
63
|
|
|
63
64
|
.mwa-story-card-stage {
|
|
64
65
|
position: relative;
|
|
65
|
-
/* The
|
|
66
|
+
/* The spinner scales with the story it sits on. */
|
|
66
67
|
container-type: inline-size;
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -77,22 +78,10 @@ html:has(.mwa-story-cards-preview) {
|
|
|
77
78
|
box-shadow: var(--mw-elevation-3);
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
/*
|
|
81
|
-
controls - so the button does not get in the way in a screenshot either. */
|
|
81
|
+
/* Below the story, as wide as it is - the image stays clean. */
|
|
82
82
|
.mwa-story-card-btn {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
left: 50%;
|
|
86
|
-
/* translate instead of transform: mw-btn puts a translateY on transform when
|
|
87
|
-
pressed, and that would drag the centre along here. */
|
|
88
|
-
translate: -50%;
|
|
89
|
-
padding-inline: min(1.35rem, 5.5cqi);
|
|
90
|
-
font-size: min(1.3rem, 5.4cqi);
|
|
91
|
-
white-space: nowrap;
|
|
92
|
-
/* The button sits on the image and not on the page: ring and shadow set it
|
|
93
|
-
apart from a gradient that may come close to the primary colour. */
|
|
94
|
-
border: 2px solid rgb(255 255 255 / 0.85);
|
|
95
|
-
box-shadow: 0 8px 26px rgb(0 0 0 / 0.4);
|
|
83
|
+
width: 100%;
|
|
84
|
+
margin-top: 0.75rem;
|
|
96
85
|
}
|
|
97
86
|
|
|
98
87
|
/* The still image stays visible under the spinner while the layers and the
|
|
@@ -127,27 +116,6 @@ html:has(.mwa-story-cards-preview) {
|
|
|
127
116
|
}
|
|
128
117
|
}
|
|
129
118
|
|
|
130
|
-
.mwa-story-card-stage[data-busy] .mwa-story-card-btn {
|
|
131
|
-
opacity: 0.6;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/* Up in the strip Instagram covers anyway, like the button down below. Dark
|
|
135
|
-
glass, so it reads on a light story as well as on a dark one. */
|
|
136
|
-
.mwa-story-card-still {
|
|
137
|
-
position: absolute;
|
|
138
|
-
top: 3%;
|
|
139
|
-
right: 4%;
|
|
140
|
-
font-size: min(0.95rem, 4cqi);
|
|
141
|
-
color: #fff;
|
|
142
|
-
background: rgb(0 0 0 / 0.45);
|
|
143
|
-
border: 1px solid rgb(255 255 255 / 0.6);
|
|
144
|
-
backdrop-filter: blur(6px);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.mwa-story-card-stage[data-busy] .mwa-story-card-still {
|
|
148
|
-
display: none;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
119
|
.mwa-story-cards-empty {
|
|
152
120
|
grid-column: 1 / -1;
|
|
153
121
|
display: grid;
|