@ohhwells/bridge 0.1.101 → 0.1.103
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/index.cjs +25 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1380,7 +1380,12 @@ function ButtonEl({
|
|
|
1380
1380
|
textDecoration: "none",
|
|
1381
1381
|
cursor: "pointer",
|
|
1382
1382
|
...buttonShellStyle(ctx, fullWidth),
|
|
1383
|
-
...secondary ? { border: `1px solid ${ctx.brand.palette.dark}`, color: ctx.brand.palette.dark } :
|
|
1383
|
+
...secondary ? { border: `1px solid ${ctx.brand.palette.dark}`, color: ctx.brand.palette.dark } : (
|
|
1384
|
+
// Off-band, prefer the template button's measured fill/label pair — a template may
|
|
1385
|
+
// fill its CTAs with any token (hvac: accent bg, primary text). On an accent band
|
|
1386
|
+
// the flipped palette keeps contrast, so the brand-driven colours stay.
|
|
1387
|
+
!ctx.buttonLabel && ctx.buttonStyle?.background ? { background: ctx.buttonStyle.background, color: ctx.buttonStyle.color } : { background: ctx.brand.palette.primary, color: ctx.buttonLabel ?? primaryButtonLabel(ctx.brand) }
|
|
1388
|
+
)
|
|
1384
1389
|
},
|
|
1385
1390
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ...path ? textAttrs(ctx, `${path}.label`) : {}, children: str(slots.label) })
|
|
1386
1391
|
}
|
|
@@ -2452,10 +2457,12 @@ function renderNode(node, ctx, path) {
|
|
|
2452
2457
|
cursor: "pointer",
|
|
2453
2458
|
// Shape/padding/typography follow the host template's own buttons.
|
|
2454
2459
|
...buttonShellStyle(ctx),
|
|
2455
|
-
// Brand-styled:
|
|
2456
|
-
// reads
|
|
2457
|
-
background: ctx.
|
|
2458
|
-
|
|
2460
|
+
// Brand-styled: the template button's measured fill/label pair off-band, else
|
|
2461
|
+
// primary fill with a brand-derived label so it reads on custom palettes.
|
|
2462
|
+
...!ctx.buttonLabel && ctx.buttonStyle?.background ? { background: ctx.buttonStyle.background, color: ctx.buttonStyle.color } : {
|
|
2463
|
+
background: ctx.brand.palette.primary,
|
|
2464
|
+
color: ctx.buttonLabel ?? primaryButtonLabel(ctx.brand)
|
|
2465
|
+
}
|
|
2459
2466
|
},
|
|
2460
2467
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ...textAttrs(ctx, `${path}.c${i}.label`), children: str(cs.label) })
|
|
2461
2468
|
},
|
|
@@ -2662,11 +2669,19 @@ function deriveTemplateBrand() {
|
|
|
2662
2669
|
}
|
|
2663
2670
|
function deriveTemplateButtonStyle() {
|
|
2664
2671
|
if (typeof document === "undefined") return null;
|
|
2665
|
-
const
|
|
2666
|
-
|
|
2667
|
-
);
|
|
2672
|
+
const candidates = Array.from(
|
|
2673
|
+
document.querySelectorAll('[data-ohw-role="button"]')
|
|
2674
|
+
).filter((el) => !el.closest(`[${CONTAINER_ATTR}]`));
|
|
2675
|
+
const isFilled = (el) => {
|
|
2676
|
+
const bg = getComputedStyle(el).backgroundColor;
|
|
2677
|
+
if (!bg || bg === "transparent") return false;
|
|
2678
|
+
const alpha = bg.match(/rgba?\([^)]*,\s*([\d.]+)\)$/);
|
|
2679
|
+
return !alpha || parseFloat(alpha[1]) > 0;
|
|
2680
|
+
};
|
|
2681
|
+
const btn = candidates.find(isFilled) ?? candidates[0];
|
|
2668
2682
|
if (!btn) return null;
|
|
2669
2683
|
const cs = getComputedStyle(btn);
|
|
2684
|
+
const filled = isFilled(btn);
|
|
2670
2685
|
const corners = [
|
|
2671
2686
|
cs.borderTopLeftRadius,
|
|
2672
2687
|
cs.borderTopRightRadius,
|
|
@@ -2683,6 +2698,7 @@ function deriveTemplateButtonStyle() {
|
|
|
2683
2698
|
return {
|
|
2684
2699
|
radius: radius || "10px",
|
|
2685
2700
|
padding: `${padY}px ${padX}px`,
|
|
2701
|
+
...filled ? { background: cs.backgroundColor, color: cs.color } : {},
|
|
2686
2702
|
fontFamily: cs.fontFamily || "",
|
|
2687
2703
|
fontSize: cs.fontSize || "",
|
|
2688
2704
|
fontWeight: cs.fontWeight || "",
|
|
@@ -22245,7 +22261,7 @@ function OhhwellsBridge() {
|
|
|
22245
22261
|
postToParent2({
|
|
22246
22262
|
type: "ow:ready",
|
|
22247
22263
|
version: "1",
|
|
22248
|
-
bridgeVersion: "0.1.
|
|
22264
|
+
bridgeVersion: "0.1.101",
|
|
22249
22265
|
path: pathname,
|
|
22250
22266
|
nodes: collectEditableNodes(editContentRef.current),
|
|
22251
22267
|
sections
|