maverick-wave-astro 1.48.0 → 1.49.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/dist/story/base.d.ts +1 -1
- package/dist/story/base.js +10 -8
- package/package.json +1 -1
package/dist/story/base.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export interface Stage {
|
|
|
78
78
|
bottom: number;
|
|
79
79
|
height: number;
|
|
80
80
|
}
|
|
81
|
-
export declare const loadLook: (options: LookOptions) => Promise<{
|
|
81
|
+
export declare const loadLook: (options: LookOptions, source?: Element) => Promise<{
|
|
82
82
|
colors: {
|
|
83
83
|
primary: string;
|
|
84
84
|
secondary: string;
|
package/dist/story/base.js
CHANGED
|
@@ -219,14 +219,14 @@ const readableOn = (fill, ...candidates) => {
|
|
|
219
219
|
};
|
|
220
220
|
// Inside a light theme box: the image is seen on other phones and does not
|
|
221
221
|
// follow the dark mode of the one it was made on.
|
|
222
|
-
const readPage = () => {
|
|
222
|
+
const readPage = (source) => {
|
|
223
223
|
const box = document.createElement('div');
|
|
224
224
|
box.className = 'mw-theme-light';
|
|
225
225
|
box.hidden = true;
|
|
226
226
|
const probe = document.createElement('span');
|
|
227
227
|
const heading = document.createElement('h2');
|
|
228
228
|
box.append(probe, heading);
|
|
229
|
-
|
|
229
|
+
source.append(box);
|
|
230
230
|
const color = (token) => {
|
|
231
231
|
probe.style.color = `var(${token})`;
|
|
232
232
|
return getComputedStyle(probe).color;
|
|
@@ -244,7 +244,7 @@ const readPage = () => {
|
|
|
244
244
|
shadowNear: color('--mw-shadow-near'),
|
|
245
245
|
shadowFar: color('--mw-shadow-far'),
|
|
246
246
|
headingFamily: getComputedStyle(heading).fontFamily,
|
|
247
|
-
bodyFamily: getComputedStyle(
|
|
247
|
+
bodyFamily: getComputedStyle(box).fontFamily,
|
|
248
248
|
};
|
|
249
249
|
box.remove();
|
|
250
250
|
return page;
|
|
@@ -278,8 +278,8 @@ const readColors = (page) => ({
|
|
|
278
278
|
// that off, in the story the silhouette stays on purpose. As in the framework:
|
|
279
279
|
// radius-sharp() takes the scale squared, radius('xl') linearly, both with
|
|
280
280
|
// radius('xs') as the floor.
|
|
281
|
-
const cardRadii = () => {
|
|
282
|
-
const raw = getComputedStyle(
|
|
281
|
+
const cardRadii = (source) => {
|
|
282
|
+
const raw = getComputedStyle(source)
|
|
283
283
|
.getPropertyValue('--mw-radius-scale')
|
|
284
284
|
.trim();
|
|
285
285
|
const scale = raw === '' || !Number.isFinite(Number(raw)) ? 1 : Number(raw);
|
|
@@ -359,13 +359,15 @@ const settled = async (promise) => {
|
|
|
359
359
|
return null;
|
|
360
360
|
}
|
|
361
361
|
};
|
|
362
|
-
|
|
362
|
+
// A page can show a brand other than its own in one element - that one is the
|
|
363
|
+
// source then.
|
|
364
|
+
export const loadLook = async (options, source = document.body) => {
|
|
363
365
|
// Safari runs module scripts before slow stylesheets have arrived - read
|
|
364
366
|
// that early, the brand colours come out black and the fonts as Times.
|
|
365
367
|
if (document.readyState !== 'complete') {
|
|
366
368
|
await new Promise(resolve => addEventListener('load', resolve, { once: true }));
|
|
367
369
|
}
|
|
368
|
-
const page = readPage();
|
|
370
|
+
const page = readPage(source);
|
|
369
371
|
const font = (size, weight = 400) => `${weight} ${size}px ${page.bodyFamily}`;
|
|
370
372
|
const heading = (size, weight = 700) => `${weight} ${size}px ${page.headingFamily}`;
|
|
371
373
|
// Without the wait the canvas draws the fallback font - it knows no
|
|
@@ -388,7 +390,7 @@ export const loadLook = async (options) => {
|
|
|
388
390
|
colors,
|
|
389
391
|
font,
|
|
390
392
|
heading,
|
|
391
|
-
radii: cardRadii(),
|
|
393
|
+
radii: cardRadii(source),
|
|
392
394
|
logo,
|
|
393
395
|
icons: onCard,
|
|
394
396
|
whiteIcons: onDark,
|
package/package.json
CHANGED