@zoneflow/renderer-dom 0.0.3 → 0.0.5

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.
@@ -1,6 +1,14 @@
1
1
  import { resolveZoneAnchorRect } from "../anchors";
2
2
  import { getZoneDepth, isZoneInputEnabled, isZoneOutputEnabled, } from "@zoneflow/core";
3
3
  const SCENE_PADDING = 64;
4
+ const RENDER_Z_INDEX = {
5
+ zoneBase: 1,
6
+ pathNode: 1,
7
+ pathStatusBadge: 2,
8
+ zoneLayer: 10,
9
+ edgeLayer: 20,
10
+ pathLayer: 30,
11
+ };
4
12
  function applyStyles(el, styles) {
5
13
  for (const [key, value] of Object.entries(styles)) {
6
14
  // @ts-expect-error CSSStyleDeclaration index access
@@ -57,8 +65,9 @@ function resolvePathTargetDisplay(params) {
57
65
  };
58
66
  }
59
67
  function createPathStatusBadge(params) {
60
- const { owner, status } = params;
68
+ const { owner, status, theme } = params;
61
69
  const badge = document.createElement("div");
70
+ const tone = status === "missing" ? theme.status.warning : theme.status.info;
62
71
  const isMissing = status === "missing";
63
72
  badge.title = isMissing ? "Broken path target" : "Path target not set";
64
73
  badge.setAttribute("aria-label", isMissing ? "Broken path target" : "Path target not set");
@@ -73,15 +82,15 @@ function createPathStatusBadge(params) {
73
82
  alignItems: "center",
74
83
  justifyContent: "center",
75
84
  borderRadius: "999px",
76
- border: "1px solid rgba(217, 119, 6, 0.24)",
77
- background: "linear-gradient(180deg, rgba(255,251,235,0.98) 0%, rgba(254,243,199,0.98) 100%)",
78
- color: "#b45309",
79
- boxShadow: "0 6px 14px rgba(180, 83, 9, 0.16)",
85
+ border: tone.border,
86
+ background: tone.background,
87
+ color: tone.color,
88
+ boxShadow: tone.shadow,
80
89
  fontSize: "12px",
81
90
  lineHeight: "1",
82
91
  fontWeight: "700",
83
92
  pointerEvents: "none",
84
- zIndex: 2,
93
+ zIndex: RENDER_Z_INDEX.pathStatusBadge,
85
94
  });
86
95
  owner.appendChild(badge);
87
96
  }
@@ -101,8 +110,10 @@ function getOpacity(emphasis) {
101
110
  function createSvgElement(tag) {
102
111
  return document.createElementNS("http://www.w3.org/2000/svg", tag);
103
112
  }
104
- function getEdgeColor(kind, themePathEdge) {
105
- return kind === "zone-to-path" ? themePathEdge : "#0f766e";
113
+ function getEdgeColor(params) {
114
+ return params.kind === "zone-to-path"
115
+ ? params.theme.pathEdge
116
+ : params.theme.pathInboundEdge;
106
117
  }
107
118
  function getBezierCurvePathD(params) {
108
119
  const { source, target } = params;
@@ -271,9 +282,9 @@ function renderPathFallback(host, slot, context) {
271
282
  applyStyles(host, {
272
283
  ...base,
273
284
  color: targetDisplay.status === "missing"
274
- ? "#b45309"
285
+ ? context.theme.status.warning.color
275
286
  : targetDisplay.status === "unconfigured"
276
- ? "#b45309"
287
+ ? context.theme.status.info.color
277
288
  : context.theme.zoneSubtext,
278
289
  fontSize: "11px",
279
290
  fontWeight: targetDisplay.status === "resolved" ? 500 : 700,
@@ -406,7 +417,10 @@ function drawEdges(params) {
406
417
  if (!visibility?.shouldRenderEdge)
407
418
  continue;
408
419
  for (const edge of edges) {
409
- const stroke = getEdgeColor(edge.kind, input.theme.pathEdge);
420
+ const stroke = getEdgeColor({
421
+ kind: edge.kind,
422
+ theme: input.theme,
423
+ });
410
424
  const path = createSvgElement("path");
411
425
  path.setAttribute("d", getBezierCurvePathD({
412
426
  source: edge.source,
@@ -435,7 +449,7 @@ function drawEdges(params) {
435
449
  }
436
450
  }
437
451
  function createSurfaceChrome(params) {
438
- const { owner, accent, radius, topBandOpacity = 0.64 } = params;
452
+ const { owner, accent, radius, theme, topBandOpacity = 0.64 } = params;
439
453
  const chrome = document.createElement("div");
440
454
  const topBand = document.createElement("div");
441
455
  const cornerGlow = document.createElement("div");
@@ -444,7 +458,7 @@ function createSurfaceChrome(params) {
444
458
  inset: "0",
445
459
  borderRadius: radius,
446
460
  pointerEvents: "none",
447
- background: "linear-gradient(180deg, rgba(255,255,255,0.74) 0%, rgba(255,255,255,0.08) 42%, rgba(255,255,255,0) 100%)",
461
+ background: theme.surface.chrome.overlay,
448
462
  });
449
463
  applyStyles(topBand, {
450
464
  position: "absolute",
@@ -454,7 +468,7 @@ function createSurfaceChrome(params) {
454
468
  height: "44px",
455
469
  borderTopLeftRadius: radius,
456
470
  borderTopRightRadius: radius,
457
- background: `linear-gradient(90deg, ${accent} 0%, rgba(255,255,255,0.04) 72%)`,
471
+ background: `linear-gradient(90deg, ${accent} 0%, ${theme.surface.chrome.accentFade} 72%)`,
458
472
  opacity: topBandOpacity,
459
473
  pointerEvents: "none",
460
474
  });
@@ -465,7 +479,7 @@ function createSurfaceChrome(params) {
465
479
  width: "116px",
466
480
  height: "116px",
467
481
  borderRadius: "999px",
468
- background: "radial-gradient(circle, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.22) 36%, rgba(255,255,255,0) 72%)",
482
+ background: theme.surface.chrome.glow,
469
483
  pointerEvents: "none",
470
484
  });
471
485
  chrome.appendChild(topBand);
@@ -478,8 +492,8 @@ function drawZoneAnchors(params) {
478
492
  ? input.theme.zoneActionBorder
479
493
  : input.theme.zoneContainerBorder;
480
494
  const anchorAccentColor = zone.zone.zoneType === "action"
481
- ? "rgba(245, 158, 11, 0.96)"
482
- : "rgba(37, 99, 235, 0.96)";
495
+ ? input.theme.surface.anchor.actionAccent
496
+ : input.theme.surface.anchor.containerAccent;
483
497
  const shouldRenderAnchor = (kind) => kind === "inlet"
484
498
  ? isZoneInputEnabled(zone.zone)
485
499
  : isZoneOutputEnabled(zone.zone);
@@ -502,11 +516,11 @@ function drawZoneAnchors(params) {
502
516
  width: `${rect.width}px`,
503
517
  height: `${rect.height}px`,
504
518
  borderRadius: "0",
505
- background: "linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(247,250,253,0.98) 100%)",
519
+ background: input.theme.surface.anchor.background,
506
520
  border: `1px solid ${zoneBorderColor}`,
507
521
  borderRight: kind === "inlet" ? "none" : `1px solid ${zoneBorderColor}`,
508
522
  borderLeft: kind === "outlet" ? "none" : `1px solid ${zoneBorderColor}`,
509
- boxShadow: "0 18px 28px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255,255,255,0.9)",
523
+ boxShadow: input.theme.surface.anchor.shadow,
510
524
  boxSizing: "border-box",
511
525
  overflow: "hidden",
512
526
  pointerEvents: "none",
@@ -516,7 +530,7 @@ function drawZoneAnchors(params) {
516
530
  top: "0",
517
531
  bottom: "0",
518
532
  width: "10px",
519
- background: "linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(247,250,253,0.98) 100%)",
533
+ background: input.theme.surface.anchor.background,
520
534
  right: kind === "inlet" ? "0" : "auto",
521
535
  left: kind === "outlet" ? "0" : "auto",
522
536
  });
@@ -590,7 +604,7 @@ export const domDrawEngine = {
590
604
  height: `${sceneBounds.height}px`,
591
605
  overflow: "visible",
592
606
  pointerEvents: "none",
593
- zIndex: 20,
607
+ zIndex: RENDER_Z_INDEX.edgeLayer,
594
608
  });
595
609
  applyStyles(zoneLayer, {
596
610
  position: "absolute",
@@ -598,7 +612,7 @@ export const domDrawEngine = {
598
612
  top: "0",
599
613
  width: `${sceneBounds.width}px`,
600
614
  height: `${sceneBounds.height}px`,
601
- zIndex: 10,
615
+ zIndex: RENDER_Z_INDEX.zoneLayer,
602
616
  });
603
617
  applyStyles(pathLayer, {
604
618
  position: "absolute",
@@ -606,7 +620,7 @@ export const domDrawEngine = {
606
620
  top: "0",
607
621
  width: `${sceneBounds.width}px`,
608
622
  height: `${sceneBounds.height}px`,
609
- zIndex: 30,
623
+ zIndex: RENDER_Z_INDEX.pathLayer,
610
624
  });
611
625
  worldRoot.appendChild(edgeSvg);
612
626
  worldRoot.appendChild(zoneLayer);
@@ -639,7 +653,7 @@ export const domDrawEngine = {
639
653
  height: `${zoneVisual.rect.height}px`,
640
654
  opacity: getOpacity(visibility.emphasis),
641
655
  overflow: "visible",
642
- zIndex: zoneDepth + 1,
656
+ zIndex: zoneDepth + RENDER_Z_INDEX.zoneBase,
643
657
  });
644
658
  applyStyles(zoneBodyEl, {
645
659
  position: "absolute",
@@ -651,9 +665,9 @@ export const domDrawEngine = {
651
665
  border: `1px solid ${zoneVisual.zone.zoneType === "action"
652
666
  ? theme.zoneActionBorder
653
667
  : theme.zoneContainerBorder}`,
654
- background: "linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(248,250,252,0.98) 100%)",
668
+ background: theme.surface.zone.background,
655
669
  boxSizing: "border-box",
656
- boxShadow: "0 18px 34px rgba(15, 23, 42, 0.08), 0 3px 8px rgba(15, 23, 42, 0.05)",
670
+ boxShadow: theme.surface.zone.shadow,
657
671
  overflow: "hidden",
658
672
  });
659
673
  zoneEl.addEventListener("click", (event) => {
@@ -663,9 +677,10 @@ export const domDrawEngine = {
663
677
  createSurfaceChrome({
664
678
  owner: zoneChromeEl,
665
679
  accent: zoneVisual.zone.zoneType === "action"
666
- ? "rgba(245, 158, 11, 0.18)"
667
- : "rgba(37, 99, 235, 0.12)",
680
+ ? theme.surface.zone.actionAccent
681
+ : theme.surface.zone.containerAccent,
668
682
  radius: "0",
683
+ theme,
669
684
  });
670
685
  zoneBodyEl.appendChild(zoneChromeEl);
671
686
  zoneEl.appendChild(zoneBodyEl);
@@ -705,11 +720,11 @@ export const domDrawEngine = {
705
720
  height: `${pathVisual.rect.height}px`,
706
721
  borderRadius: "18px",
707
722
  border: `1px solid ${theme.pathEdge}`,
708
- background: "linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(246,248,252,0.98) 100%)",
723
+ background: theme.surface.path.background,
709
724
  boxSizing: "border-box",
710
- boxShadow: "0 16px 26px rgba(15, 23, 42, 0.08), 0 3px 8px rgba(15, 23, 42, 0.05)",
725
+ boxShadow: theme.surface.path.shadow,
711
726
  opacity: getOpacity(visibility.emphasis),
712
- zIndex: 1,
727
+ zIndex: RENDER_Z_INDEX.pathNode,
713
728
  overflow: "hidden",
714
729
  });
715
730
  pathEl.addEventListener("click", (event) => {
@@ -718,8 +733,9 @@ export const domDrawEngine = {
718
733
  });
719
734
  createSurfaceChrome({
720
735
  owner: pathChromeEl,
721
- accent: "rgba(56, 189, 248, 0.16)",
736
+ accent: theme.surface.path.accent,
722
737
  radius: "18px",
738
+ theme,
723
739
  topBandOpacity: 0.72,
724
740
  });
725
741
  pathEl.appendChild(pathChromeEl);
@@ -731,6 +747,7 @@ export const domDrawEngine = {
731
747
  createPathStatusBadge({
732
748
  owner: pathEl,
733
749
  status: targetDisplay.status,
750
+ theme,
734
751
  });
735
752
  }
736
753
  for (const slot of Object.keys(componentLayout?.slots ?? {})) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./theme";
2
+ export * from "./themes/defaultTheme";
2
3
  export * from "./types";
3
4
  export * from "./anchors";
4
5
  export * from "./pipeline";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./theme";
2
+ export * from "./themes/defaultTheme";
2
3
  export * from "./types";
3
4
  export * from "./anchors";
4
5
  export * from "./pipeline";
package/dist/theme.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export type ZoneflowStatusTone = {
2
+ border: string;
3
+ background: string;
4
+ color: string;
5
+ shadow: string;
6
+ };
1
7
  export type ZoneflowTheme = {
2
8
  background: string;
3
9
  zoneTitle: string;
@@ -7,7 +13,36 @@ export type ZoneflowTheme = {
7
13
  zoneBadgeBg: string;
8
14
  pathLabel: string;
9
15
  pathEdge: string;
16
+ pathInboundEdge: string;
10
17
  selection: string;
18
+ surface: {
19
+ chrome: {
20
+ overlay: string;
21
+ glow: string;
22
+ accentFade: string;
23
+ };
24
+ zone: {
25
+ background: string;
26
+ shadow: string;
27
+ containerAccent: string;
28
+ actionAccent: string;
29
+ };
30
+ path: {
31
+ background: string;
32
+ shadow: string;
33
+ accent: string;
34
+ };
35
+ anchor: {
36
+ background: string;
37
+ shadow: string;
38
+ containerAccent: string;
39
+ actionAccent: string;
40
+ };
41
+ };
42
+ status: {
43
+ info: ZoneflowStatusTone;
44
+ warning: ZoneflowStatusTone;
45
+ };
11
46
  density: {
12
47
  zone: {
13
48
  detail: number;
@@ -10,7 +10,46 @@ export const defaultTheme = {
10
10
  zoneBadgeBg: "#e0f2fe",
11
11
  pathLabel: "#1e293b",
12
12
  pathEdge: "#7a8aa0",
13
+ pathInboundEdge: "#0f766e",
13
14
  selection: "#2e90fa",
15
+ surface: {
16
+ chrome: {
17
+ overlay: "linear-gradient(180deg, rgba(255,255,255,0.74) 0%, rgba(255,255,255,0.08) 42%, rgba(255,255,255,0) 100%)",
18
+ glow: "radial-gradient(circle, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.22) 36%, rgba(255,255,255,0) 72%)",
19
+ accentFade: "rgba(255,255,255,0.04)",
20
+ },
21
+ zone: {
22
+ background: "linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(248,250,252,0.98) 100%)",
23
+ shadow: "0 18px 34px rgba(15, 23, 42, 0.08), 0 3px 8px rgba(15, 23, 42, 0.05)",
24
+ containerAccent: "rgba(37, 99, 235, 0.12)",
25
+ actionAccent: "rgba(245, 158, 11, 0.18)",
26
+ },
27
+ path: {
28
+ background: "linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(246,248,252,0.98) 100%)",
29
+ shadow: "0 16px 26px rgba(15, 23, 42, 0.08), 0 3px 8px rgba(15, 23, 42, 0.05)",
30
+ accent: "rgba(56, 189, 248, 0.16)",
31
+ },
32
+ anchor: {
33
+ background: "linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(247,250,253,0.98) 100%)",
34
+ shadow: "0 18px 28px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255,255,255,0.9)",
35
+ containerAccent: "rgba(37, 99, 235, 0.96)",
36
+ actionAccent: "rgba(245, 158, 11, 0.96)",
37
+ },
38
+ },
39
+ status: {
40
+ info: {
41
+ border: "1px solid rgba(217, 119, 6, 0.24)",
42
+ background: "linear-gradient(180deg, rgba(255,251,235,0.98) 0%, rgba(254,243,199,0.98) 100%)",
43
+ color: "#b45309",
44
+ shadow: "0 6px 14px rgba(180, 83, 9, 0.16)",
45
+ },
46
+ warning: {
47
+ border: "1px solid rgba(217, 119, 6, 0.24)",
48
+ background: "linear-gradient(180deg, rgba(255,251,235,0.98) 0%, rgba(254,243,199,0.98) 100%)",
49
+ color: "#b45309",
50
+ shadow: "0 6px 14px rgba(180, 83, 9, 0.16)",
51
+ },
52
+ },
14
53
  density: {
15
54
  zone: {
16
55
  detail: 200,
@@ -32,6 +71,34 @@ export function resolveTheme(theme) {
32
71
  return {
33
72
  ...defaultTheme,
34
73
  ...theme,
74
+ surface: {
75
+ chrome: {
76
+ ...defaultTheme.surface.chrome,
77
+ ...theme.surface?.chrome,
78
+ },
79
+ zone: {
80
+ ...defaultTheme.surface.zone,
81
+ ...theme.surface?.zone,
82
+ },
83
+ path: {
84
+ ...defaultTheme.surface.path,
85
+ ...theme.surface?.path,
86
+ },
87
+ anchor: {
88
+ ...defaultTheme.surface.anchor,
89
+ ...theme.surface?.anchor,
90
+ },
91
+ },
92
+ status: {
93
+ info: {
94
+ ...defaultTheme.status.info,
95
+ ...theme.status?.info,
96
+ },
97
+ warning: {
98
+ ...defaultTheme.status.warning,
99
+ ...theme.status?.warning,
100
+ },
101
+ },
35
102
  density: {
36
103
  zone: {
37
104
  ...defaultTheme.density.zone,
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@zoneflow/renderer-dom",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
+ "license": "MIT",
4
5
  "description": "Low-level DOM renderer engines for Zoneflow.",
5
6
  "type": "module",
6
7
  "main": "dist/index.js",
@@ -18,7 +19,7 @@
18
19
  "dist"
19
20
  ],
20
21
  "dependencies": {
21
- "@zoneflow/core": "0.0.3"
22
+ "@zoneflow/core": "0.0.5"
22
23
  },
23
24
  "scripts": {
24
25
  "build": "tsc -p tsconfig.json",