vizmatic 0.3.0 → 0.3.1
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 +21 -3
- package/dist/cli.js +15 -8
- package/dist/index.cjs +48 -35
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +47 -35
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -223,7 +223,7 @@ function getReadableToneColor(tone, c, background = c.bgCard, backdrop = c.bgCar
|
|
|
223
223
|
return colorContrast(color, background, backdrop) >= 4.5 ? color : getReadableTextColor(background, c, backdrop);
|
|
224
224
|
}
|
|
225
225
|
function getToneFill(tone, c) {
|
|
226
|
-
if (c.preset !== "engineering") return
|
|
226
|
+
if (c.preset !== "engineering") return withColorAlpha(getToneColor(tone, c), 22 / 255);
|
|
227
227
|
return {
|
|
228
228
|
blue: "#cddcfa",
|
|
229
229
|
purple: "#dfcff8",
|
|
@@ -360,6 +360,17 @@ function parseColor(color) {
|
|
|
360
360
|
alpha: parsed.alpha
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
|
+
function withColorAlpha(color, opacity) {
|
|
364
|
+
if (typeof color !== "string" || !Number.isFinite(opacity)) return "transparent";
|
|
365
|
+
const parsed = parseColor(color);
|
|
366
|
+
if (!parsed) return "transparent";
|
|
367
|
+
const alpha = Math.min(1, Math.max(0, parsed.alpha * Math.min(1, Math.max(0, opacity))));
|
|
368
|
+
const hex = color.trim();
|
|
369
|
+
if (/^#[\da-f]{6}$/i.test(hex)) {
|
|
370
|
+
return `${hex}${Math.round(alpha * 255).toString(16).padStart(2, "0")}`;
|
|
371
|
+
}
|
|
372
|
+
return `rgba(${parsed.channels.join(", ")}, ${Number(alpha.toFixed(6))})`;
|
|
373
|
+
}
|
|
363
374
|
function colorLuminance(color, backdrop) {
|
|
364
375
|
const parsed = parseColor(color);
|
|
365
376
|
if (!parsed) return void 0;
|
|
@@ -1274,10 +1285,10 @@ function Box({
|
|
|
1274
1285
|
style.backgroundColor = "transparent";
|
|
1275
1286
|
} else if (gradient) {
|
|
1276
1287
|
style.backgroundImage = gradientBg;
|
|
1277
|
-
style.boxShadow = `0 4px 20px ${solidColor}
|
|
1288
|
+
style.boxShadow = `0 4px 20px ${withColorAlpha(solidColor, 48 / 255)}`;
|
|
1278
1289
|
} else {
|
|
1279
1290
|
style.backgroundColor = solidColor;
|
|
1280
|
-
style.boxShadow = `0 4px 20px ${solidColor}
|
|
1291
|
+
style.boxShadow = `0 4px 20px ${withColorAlpha(solidColor, 48 / 255)}`;
|
|
1281
1292
|
}
|
|
1282
1293
|
return React2.createElement(
|
|
1283
1294
|
"div",
|
|
@@ -1299,7 +1310,7 @@ function Box({
|
|
|
1299
1310
|
style: {
|
|
1300
1311
|
fontSize: fontSize - 2,
|
|
1301
1312
|
fontWeight: 400,
|
|
1302
|
-
color: outlined ? c.textMuted : gradient ?
|
|
1313
|
+
color: outlined ? c.textMuted : gradient ? withColorAlpha(c.textOnColor, 179 / 255) : solidTextColor,
|
|
1303
1314
|
fontFamily: c.fontMono,
|
|
1304
1315
|
textAlign: "center"
|
|
1305
1316
|
}
|
|
@@ -1829,8 +1840,8 @@ function BadgePill({
|
|
|
1829
1840
|
...height != null ? { height } : {},
|
|
1830
1841
|
padding,
|
|
1831
1842
|
borderRadius: engineering ? Math.min(radius, 5) : radius,
|
|
1832
|
-
...engineering ? { backgroundColor: getToneFill(tone, c) } : filled ? { backgroundImage: getToneGradient(tone) } : { backgroundColor:
|
|
1833
|
-
border: `1px solid ${engineering ? accent : filled ?
|
|
1843
|
+
...engineering ? { backgroundColor: getToneFill(tone, c) } : filled ? { backgroundImage: getToneGradient(tone) } : { backgroundColor: withColorAlpha(accent, 24 / 255) },
|
|
1844
|
+
border: `1px solid ${engineering ? accent : filled ? withColorAlpha(accent, 0) : withColorAlpha(accent, 85 / 255)}`,
|
|
1834
1845
|
color: engineering ? c.textPrimary : filled ? c.textOnColor : accentText,
|
|
1835
1846
|
fontSize,
|
|
1836
1847
|
fontWeight: 800,
|
|
@@ -1932,7 +1943,7 @@ function StepCard({
|
|
|
1932
1943
|
radius: engineering ? 5 : radius,
|
|
1933
1944
|
shadow: engineering ? false : shadow,
|
|
1934
1945
|
background: engineering ? getToneFill(tone, c) : void 0,
|
|
1935
|
-
borderColor: engineering ? accent :
|
|
1946
|
+
borderColor: engineering ? accent : withColorAlpha(accent, 136 / 255),
|
|
1936
1947
|
children: React3.createElement(
|
|
1937
1948
|
"div",
|
|
1938
1949
|
{
|
|
@@ -2008,7 +2019,7 @@ function MetricCard({
|
|
|
2008
2019
|
padding,
|
|
2009
2020
|
radius,
|
|
2010
2021
|
shadow,
|
|
2011
|
-
borderColor:
|
|
2022
|
+
borderColor: withColorAlpha(accent, 102 / 255),
|
|
2012
2023
|
children: React3.createElement(
|
|
2013
2024
|
"div",
|
|
2014
2025
|
{
|
|
@@ -2258,7 +2269,7 @@ function DetailList({
|
|
|
2258
2269
|
padding,
|
|
2259
2270
|
borderRadius: 8,
|
|
2260
2271
|
backgroundColor: c.bgSubtle,
|
|
2261
|
-
border: `1px solid ${tone ?
|
|
2272
|
+
border: `1px solid ${tone ? withColorAlpha(accent, 68 / 255) : c.borderSubtle}`,
|
|
2262
2273
|
color: c.textSecondary,
|
|
2263
2274
|
fontSize,
|
|
2264
2275
|
lineHeight: 1.3,
|
|
@@ -2322,7 +2333,7 @@ function Tile({
|
|
|
2322
2333
|
padding,
|
|
2323
2334
|
radius,
|
|
2324
2335
|
shadow,
|
|
2325
|
-
borderColor:
|
|
2336
|
+
borderColor: withColorAlpha(accent, 136 / 255),
|
|
2326
2337
|
children: React4.createElement(
|
|
2327
2338
|
"div",
|
|
2328
2339
|
{
|
|
@@ -2456,7 +2467,7 @@ function CodeBlock({
|
|
|
2456
2467
|
width: "100%",
|
|
2457
2468
|
padding: accent ? "3px 7px" : "1px 0",
|
|
2458
2469
|
borderRadius: accent ? 5 : 0,
|
|
2459
|
-
...accent ? { backgroundColor:
|
|
2470
|
+
...accent ? { backgroundColor: withColorAlpha(accent, 31 / 255) } : {},
|
|
2460
2471
|
boxSizing: "border-box"
|
|
2461
2472
|
}
|
|
2462
2473
|
},
|
|
@@ -2512,7 +2523,7 @@ function CodeBlock({
|
|
|
2512
2523
|
padding,
|
|
2513
2524
|
borderRadius: radius,
|
|
2514
2525
|
backgroundColor: background ?? c.bgSubtle,
|
|
2515
|
-
border: `1px solid ${tone ?
|
|
2526
|
+
border: `1px solid ${tone ? withColorAlpha(headerAccent, 68 / 255) : c.borderSubtle}`,
|
|
2516
2527
|
boxSizing: "border-box",
|
|
2517
2528
|
...shadow ? { boxShadow: `0 9px 24px ${c.shadow}` } : {}
|
|
2518
2529
|
}
|
|
@@ -2874,7 +2885,7 @@ function StatusRow({
|
|
|
2874
2885
|
const markerAlpha = 38 / 255;
|
|
2875
2886
|
const rowAlpha = boxed ? 18 / 255 : 0;
|
|
2876
2887
|
const markerBackgroundAlpha = Math.round((rowAlpha + markerAlpha * (1 - rowAlpha)) * 255);
|
|
2877
|
-
const markerBackground =
|
|
2888
|
+
const markerBackground = withColorAlpha(accent, markerBackgroundAlpha / 255);
|
|
2878
2889
|
const accentText = getReadableToneColor(resolvedTone, c, markerBackground, c.bgCard);
|
|
2879
2890
|
const glyph = statusGlyphs[status];
|
|
2880
2891
|
const marker = React5.createElement("div", {
|
|
@@ -2886,7 +2897,7 @@ function StatusRow({
|
|
|
2886
2897
|
height: 18,
|
|
2887
2898
|
flexShrink: 0,
|
|
2888
2899
|
borderRadius: 999,
|
|
2889
|
-
backgroundColor: status === "dot" ? accent :
|
|
2900
|
+
backgroundColor: status === "dot" ? accent : withColorAlpha(accent, 38 / 255),
|
|
2890
2901
|
border: `1px solid ${accent}`,
|
|
2891
2902
|
color: accentText,
|
|
2892
2903
|
fontFamily: "Inter",
|
|
@@ -2907,8 +2918,8 @@ function StatusRow({
|
|
|
2907
2918
|
...boxed ? {
|
|
2908
2919
|
padding: "7px 10px",
|
|
2909
2920
|
borderRadius: 8,
|
|
2910
|
-
backgroundColor:
|
|
2911
|
-
border: `1px solid ${accent}
|
|
2921
|
+
backgroundColor: withColorAlpha(accent, 18 / 255),
|
|
2922
|
+
border: `1px solid ${withColorAlpha(accent, 58 / 255)}`
|
|
2912
2923
|
} : { padding: "3px 0" }
|
|
2913
2924
|
}
|
|
2914
2925
|
},
|
|
@@ -2973,7 +2984,7 @@ function renderTimelineCard(event, c, math, width) {
|
|
|
2973
2984
|
...typeof resolvedWidth === "string" ? { minWidth: 0 } : {},
|
|
2974
2985
|
padding: "10px 12px",
|
|
2975
2986
|
borderRadius: 8,
|
|
2976
|
-
border: `1px solid ${accent}
|
|
2987
|
+
border: `1px solid ${withColorAlpha(accent, 68 / 255)}`,
|
|
2977
2988
|
backgroundColor: c.bgCard,
|
|
2978
2989
|
boxShadow: `0 7px 18px ${c.shadow}`,
|
|
2979
2990
|
boxSizing: "border-box"
|
|
@@ -3851,10 +3862,10 @@ function LayeredNetwork({
|
|
|
3851
3862
|
width: nodeSize + 28,
|
|
3852
3863
|
height: nodeSize + 28,
|
|
3853
3864
|
borderRadius: 999,
|
|
3854
|
-
backgroundColor:
|
|
3865
|
+
backgroundColor: withColorAlpha(c.warningLight, 46 / 255),
|
|
3855
3866
|
border: `4px solid ${c.warningLight}`,
|
|
3856
3867
|
boxSizing: "border-box",
|
|
3857
|
-
boxShadow: `0 0 18px ${c.warningLight}
|
|
3868
|
+
boxShadow: `0 0 18px ${withColorAlpha(c.warningLight, 102 / 255)}`
|
|
3858
3869
|
}
|
|
3859
3870
|
}),
|
|
3860
3871
|
React6.createElement("div", {
|
|
@@ -3873,7 +3884,7 @@ function LayeredNetwork({
|
|
|
3873
3884
|
color: getReadableTextColor(color, c),
|
|
3874
3885
|
border: active ? `3px solid ${c.warningLight}` : `1.5px solid ${color}`,
|
|
3875
3886
|
boxSizing: "border-box",
|
|
3876
|
-
boxShadow: active ? `0 0 16px ${c.warningLight}
|
|
3887
|
+
boxShadow: active ? `0 0 16px ${withColorAlpha(c.warningLight, 112 / 255)}` : `0 8px 14px ${c.shadow}`,
|
|
3877
3888
|
fontFamily: "JetBrains Mono",
|
|
3878
3889
|
fontSize: 16,
|
|
3879
3890
|
fontWeight: 900,
|
|
@@ -4447,8 +4458,8 @@ function GraphDiagram({
|
|
|
4447
4458
|
display: "flex",
|
|
4448
4459
|
boxSizing: "border-box",
|
|
4449
4460
|
borderRadius: c.preset === "engineering" ? 6 : 12,
|
|
4450
|
-
border: `${c.preset === "engineering" ? 1.25 : 1.5}px ${group.muted ? "dashed" : "solid"} ${accent
|
|
4451
|
-
backgroundColor:
|
|
4461
|
+
border: `${c.preset === "engineering" ? 1.25 : 1.5}px ${group.muted ? "dashed" : "solid"} ${withColorAlpha(accent, (group.muted ? 85 : 119) / 255)}`,
|
|
4462
|
+
backgroundColor: withColorAlpha(accent, (c.preset === "engineering" ? 8 : 13) / 255),
|
|
4452
4463
|
opacity: group.muted ? 0.68 : 1
|
|
4453
4464
|
}
|
|
4454
4465
|
}, React6.createElement(
|
|
@@ -4618,7 +4629,7 @@ function GraphDiagram({
|
|
|
4618
4629
|
boxSizing: "border-box",
|
|
4619
4630
|
borderRadius: c.preset === "engineering" ? 5 : 10,
|
|
4620
4631
|
backgroundColor: node.muted ? c.bgSubtle : fill,
|
|
4621
|
-
border: `${c.preset === "engineering" ? 1.25 : 1.5}px solid ${node.muted ? c.borderLight :
|
|
4632
|
+
border: `${c.preset === "engineering" ? 1.25 : 1.5}px solid ${node.muted ? c.borderLight : c.preset === "engineering" ? accent : withColorAlpha(accent, 136 / 255)}`,
|
|
4622
4633
|
...!node.muted && c.preset !== "engineering" ? { boxShadow: `0 8px 18px ${c.shadow}` } : {},
|
|
4623
4634
|
opacity: node.muted ? 0.62 : 1,
|
|
4624
4635
|
color: c.preset === "engineering" ? c.textPrimary : accentText,
|
|
@@ -4842,7 +4853,7 @@ function TreeDiagram({
|
|
|
4842
4853
|
boxSizing: "border-box",
|
|
4843
4854
|
borderRadius: 8,
|
|
4844
4855
|
backgroundColor: node.muted ? c.bgSubtle : c.bgCard,
|
|
4845
|
-
border: `1.5px solid ${node.muted ? c.borderLight :
|
|
4856
|
+
border: `1.5px solid ${node.muted ? c.borderLight : withColorAlpha(accent, 136 / 255)}`,
|
|
4846
4857
|
...!node.muted ? { boxShadow: `0 8px 18px ${c.shadow}` } : {},
|
|
4847
4858
|
opacity: node.muted ? 0.62 : 1,
|
|
4848
4859
|
color: accentText,
|
|
@@ -4902,7 +4913,7 @@ function CalloutCard({
|
|
|
4902
4913
|
padding,
|
|
4903
4914
|
borderRadius: engineering ? 5 : 10,
|
|
4904
4915
|
boxSizing: "border-box",
|
|
4905
|
-
...engineering ? { backgroundColor: getToneFill(tone, c), color: c.textPrimary, border: `1px solid ${accent}` } : filled ? { backgroundImage: getToneGradient(tone), color: c.textOnColor, border: `1px solid ${accent}
|
|
4916
|
+
...engineering ? { backgroundColor: getToneFill(tone, c), color: c.textPrimary, border: `1px solid ${accent}` } : filled ? { backgroundImage: getToneGradient(tone), color: c.textOnColor, border: `1px solid ${withColorAlpha(accent, 0)}` } : { backgroundColor: c.bgCard, color: c.textPrimary, border: `1px solid ${withColorAlpha(accent, 102 / 255)}` },
|
|
4906
4917
|
display: "flex",
|
|
4907
4918
|
flexDirection: "column",
|
|
4908
4919
|
alignItems: align === "center" ? "center" : "flex-start",
|
|
@@ -5248,8 +5259,8 @@ function SequenceDiagram({
|
|
|
5248
5259
|
height: spanHeight,
|
|
5249
5260
|
display: "flex",
|
|
5250
5261
|
boxSizing: "border-box",
|
|
5251
|
-
border: `1.25px ${span.fragment.muted ? "dotted" : "dashed"} ${accent
|
|
5252
|
-
backgroundColor:
|
|
5262
|
+
border: `1.25px ${span.fragment.muted ? "dotted" : "dashed"} ${withColorAlpha(accent, (span.fragment.muted ? 85 : 153) / 255)}`,
|
|
5263
|
+
backgroundColor: withColorAlpha(accent, 11 / 255),
|
|
5253
5264
|
borderRadius: c.preset === "engineering" ? 4 : 8,
|
|
5254
5265
|
pointerEvents: "none"
|
|
5255
5266
|
}
|
|
@@ -5399,7 +5410,7 @@ function SequenceDiagram({
|
|
|
5399
5410
|
padding: "6px 9px",
|
|
5400
5411
|
borderRadius: c.preset === "engineering" ? 3 : 7,
|
|
5401
5412
|
backgroundColor: note.muted ? c.bgSubtle : getToneFill(tone, c),
|
|
5402
|
-
border: `1px solid ${accent
|
|
5413
|
+
border: `1px solid ${withColorAlpha(accent, (note.muted ? 102 : 153) / 255)}`,
|
|
5403
5414
|
color: note.muted ? c.textMuted : getReadableTextColor(getToneFill(tone, c), c),
|
|
5404
5415
|
fontFamily: c.fontSans,
|
|
5405
5416
|
fontSize: 11,
|
|
@@ -6574,8 +6585,8 @@ function TiledMatrix({
|
|
|
6574
6585
|
height: cellSize,
|
|
6575
6586
|
boxSizing: "border-box",
|
|
6576
6587
|
borderRadius: Math.max(2, Math.min(6, Math.round(cellSize * 0.18))),
|
|
6577
|
-
backgroundColor: region ?
|
|
6578
|
-
border: `1px solid ${region ?
|
|
6588
|
+
backgroundColor: region ? withColorAlpha(accent, 66 / 255) : muted ? c.bgSubtle : withColorAlpha(baseAccent, 15 / 255),
|
|
6589
|
+
border: `1px solid ${region ? withColorAlpha(accent, 170 / 255) : c.borderSubtle}`,
|
|
6579
6590
|
opacity: muted ? 0.55 : 1
|
|
6580
6591
|
}
|
|
6581
6592
|
});
|
|
@@ -6750,7 +6761,7 @@ function Grid({
|
|
|
6750
6761
|
const config = isGridCell(cell) ? cell : {};
|
|
6751
6762
|
const toneColor = config.tone ? getToneColor(config.tone, c) : void 0;
|
|
6752
6763
|
const isHeader = rowIndex < headerRows || colIndex < headerCols;
|
|
6753
|
-
const backgroundColor = config.backgroundColor ?? (toneColor ?
|
|
6764
|
+
const backgroundColor = config.backgroundColor ?? (toneColor ? withColorAlpha(toneColor, 34 / 255) : isHeader ? c.bgSubtle : c.bgHover);
|
|
6754
6765
|
const toneTextColor = config.tone ? getReadableToneColor(config.tone, c, backgroundColor, c.bgHover) : void 0;
|
|
6755
6766
|
return {
|
|
6756
6767
|
width: cellWidth,
|
|
@@ -6760,7 +6771,7 @@ function Grid({
|
|
|
6760
6771
|
justifyContent: "center",
|
|
6761
6772
|
borderRadius: radius,
|
|
6762
6773
|
backgroundColor,
|
|
6763
|
-
border: `1px solid ${config.borderColor ?? (toneColor ?
|
|
6774
|
+
border: `1px solid ${config.borderColor ?? (toneColor ? withColorAlpha(toneColor, 85 / 255) : c.borderSubtle)}`,
|
|
6764
6775
|
color: config.color ?? (toneTextColor ?? (isHeader ? c.textPrimary : c.textSecondary)),
|
|
6765
6776
|
...config.opacity !== void 0 ? { opacity: config.opacity } : {},
|
|
6766
6777
|
fontFamily: "JetBrains Mono",
|
|
@@ -8908,14 +8919,14 @@ function Badge({ label, c, color = "primary" }) {
|
|
|
8908
8919
|
display: "flex",
|
|
8909
8920
|
alignItems: "center",
|
|
8910
8921
|
justifyContent: "center",
|
|
8911
|
-
backgroundColor:
|
|
8922
|
+
backgroundColor: withColorAlpha(solidColor, 32 / 255),
|
|
8912
8923
|
color: solidColor,
|
|
8913
8924
|
borderRadius: 999,
|
|
8914
8925
|
padding: "4px 12px",
|
|
8915
8926
|
fontSize: 11,
|
|
8916
8927
|
fontWeight: 600,
|
|
8917
8928
|
fontFamily: "Inter",
|
|
8918
|
-
border: `1px solid ${solidColor}
|
|
8929
|
+
border: `1px solid ${withColorAlpha(solidColor, 64 / 255)}`
|
|
8919
8930
|
}
|
|
8920
8931
|
}, label);
|
|
8921
8932
|
}
|
|
@@ -8934,7 +8945,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
|
|
|
8934
8945
|
height: size,
|
|
8935
8946
|
borderRadius: "50%",
|
|
8936
8947
|
backgroundColor: color,
|
|
8937
|
-
boxShadow: `0 0 14px ${color}
|
|
8948
|
+
boxShadow: `0 0 14px ${withColorAlpha(color, 80 / 255)}`,
|
|
8938
8949
|
display: "flex"
|
|
8939
8950
|
}
|
|
8940
8951
|
}),
|
|
@@ -12047,6 +12058,7 @@ export {
|
|
|
12047
12058
|
toneGradients,
|
|
12048
12059
|
tween,
|
|
12049
12060
|
typography,
|
|
12061
|
+
withColorAlpha,
|
|
12050
12062
|
wrapWithBrand,
|
|
12051
12063
|
wrapWithWatermark
|
|
12052
12064
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vizmatic",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Theme-aware visual primitives and a headless renderer for diagrams, figures, and presentation frames.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"site:serve": "node scripts/serve-docs.mjs docs 4173",
|
|
83
83
|
"sync:plugin-versions": "node scripts/sync-plugin-versions.mjs",
|
|
84
84
|
"security:audit": "pnpm audit --audit-level low",
|
|
85
|
-
"deps:check": "pnpm security:audit && pnpm assets:check && publint && tsx scripts/check-package.ts",
|
|
85
|
+
"deps:check": "pnpm security:audit && pnpm assets:check && publint && tsx scripts/check-package.ts && node scripts/check-consumer.mjs",
|
|
86
86
|
"verify": "pnpm lint && pnpm test && pnpm render:examples && pnpm check:examples && pnpm docs:check && pnpm deps:check",
|
|
87
87
|
"prepublishOnly": "pnpm verify"
|
|
88
88
|
},
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"gifenc": "^1.0.3",
|
|
93
93
|
"parse-css-color": "0.2.1",
|
|
94
94
|
"react": "^19.2.8",
|
|
95
|
-
"satori": "
|
|
95
|
+
"satori": "0.35.0",
|
|
96
96
|
"tsx": "^4.23.12"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|