maverick-wave-astro 1.37.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/dist/story/base.d.ts +3 -1
- package/dist/story/base.js +5 -2
- package/dist/story/event.js +19 -7
- package/package.json +1 -1
- 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
|
|
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/package.json
CHANGED
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;
|