@swiftbrowser/web 0.6.0 → 0.6.2
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/package.json +1 -1
- package/src/animation.ts +44 -12
- package/src/chartDom.ts +6 -2
- package/src/layout/engine.ts +164 -50
- package/src/layout/index.ts +1 -1
- package/src/layoutDom.ts +40 -33
- package/src/press.ts +51 -13
- package/src/protocol.ts +16 -0
- package/src/renderer.ts +48 -1
- package/src/styles.css +109 -58
- package/src/styles.ts +18 -5
- package/src/symbols.ts +15 -7
package/src/symbols.ts
CHANGED
|
@@ -501,6 +501,9 @@ const BOOKS_VERTICAL_FILL: IconNode = [
|
|
|
501
501
|
['rect', { x: '17.8', y: '4.5', width: '4', height: '16', rx: '1.2', stroke: 'none', transform: 'rotate(-14 19.8 12.5)' }],
|
|
502
502
|
];
|
|
503
503
|
|
|
504
|
+
/** Marks a `knockout` glyph's inner shape that is filled, not only stroked (`enclosed`). */
|
|
505
|
+
const SOLID_MARK = 'data-sb-knockout-solid';
|
|
506
|
+
|
|
504
507
|
/** Color used for inner marks of `knockout` glyphs; styles.css sets the variable. */
|
|
505
508
|
const KNOCKOUT_COLOR = 'var(--sb-icon-knockout, var(--sb-color-system-background, #fff))';
|
|
506
509
|
|
|
@@ -957,8 +960,6 @@ export const SF_SYMBOLS: Readonly<Record<string, SymbolGlyph>> = {
|
|
|
957
960
|
'cloud.snow': outline(CloudSnow),
|
|
958
961
|
'cloud.sun': outline(CloudSun),
|
|
959
962
|
'cloud.sun.fill': solid(CloudSun),
|
|
960
|
-
'moon.circle.fill': solid(Moon),
|
|
961
|
-
'sun.max.circle.fill': solid(Sun),
|
|
962
963
|
'person.3': outline(Users),
|
|
963
964
|
'person.3.fill': solid(Users),
|
|
964
965
|
'chart.line.uptrend.xyaxis': outline(TrendingUp),
|
|
@@ -1326,7 +1327,9 @@ function resolveVariant(systemName: string): SymbolGlyph | undefined {
|
|
|
1326
1327
|
} else {
|
|
1327
1328
|
const base = parts.slice(0, -1).join('.');
|
|
1328
1329
|
const glyph = GENERIC_SHAPES.has(base) ? undefined : lookupSymbol(base);
|
|
1329
|
-
|
|
1330
|
+
// A base whose filled form is a silhouette (`moon.fill`) is knocked
|
|
1331
|
+
// out solid, as `moon.circle.fill` draws its moon.
|
|
1332
|
+
if (glyph) return enclosed(glyph.icon, enclosure, fill, fill && lookupSymbol(`${base}.fill`)?.fill === 'solid');
|
|
1330
1333
|
}
|
|
1331
1334
|
}
|
|
1332
1335
|
const bases: string[] = [];
|
|
@@ -1350,13 +1353,17 @@ function resolveVariant(systemName: string): SymbolGlyph | undefined {
|
|
|
1350
1353
|
/**
|
|
1351
1354
|
* `icon` at 55% inside a circle or rounded square: outlined (`X.circle`), or
|
|
1352
1355
|
* filled with the glyph knocked out of it (`X.circle.fill`), as SF Symbols
|
|
1353
|
-
* draw their enclosed forms
|
|
1356
|
+
* draw their enclosed forms; `solid`, the glyph's shapes are knocked out
|
|
1357
|
+
* whole rather than as strokes.
|
|
1354
1358
|
*/
|
|
1355
|
-
function enclosed(icon: IconNode, enclosure: 'circle' | 'square', fill: boolean): SymbolGlyph {
|
|
1359
|
+
function enclosed(icon: IconNode, enclosure: 'circle' | 'square', fill: boolean, solid = false): SymbolGlyph {
|
|
1356
1360
|
const outer: IconNode[number] =
|
|
1357
1361
|
enclosure === 'circle' ? ['circle', { cx: '12', cy: '12', r: '10' }] : ['rect', { x: '3', y: '3', width: '18', height: '18', rx: '4' }];
|
|
1358
1362
|
// Scaled about the center; the stroke is widened to keep its weight.
|
|
1359
|
-
const inner = icon.map(
|
|
1363
|
+
const inner = icon.map(
|
|
1364
|
+
([tag, attrs]) =>
|
|
1365
|
+
[tag, { ...attrs, transform: 'translate(5.4 5.4) scale(0.55)', 'stroke-width': '3.3', ...(solid ? { [SOLID_MARK]: '' } : {}) }] as IconNode[number],
|
|
1366
|
+
);
|
|
1360
1367
|
return { icon: [outer, ...inner], fill: fill ? 'knockout' : 'outline' };
|
|
1361
1368
|
}
|
|
1362
1369
|
|
|
@@ -1421,7 +1428,8 @@ export function renderSymbol(systemName: string): SVGElement | null {
|
|
|
1421
1428
|
shape.setAttribute('fill', 'currentColor');
|
|
1422
1429
|
} else {
|
|
1423
1430
|
shape.setAttribute('stroke', KNOCKOUT_COLOR);
|
|
1424
|
-
shape.setAttribute('fill', 'none');
|
|
1431
|
+
shape.setAttribute('fill', shape.hasAttribute(SOLID_MARK) ? KNOCKOUT_COLOR : 'none');
|
|
1432
|
+
shape.removeAttribute(SOLID_MARK);
|
|
1425
1433
|
}
|
|
1426
1434
|
});
|
|
1427
1435
|
}
|