@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.d.cts CHANGED
@@ -89,6 +89,11 @@ interface TemplateButtonStyle {
89
89
  fontWeight: string;
90
90
  letterSpacing: string;
91
91
  textTransform: string;
92
+ /** Measured fill/label pair of the template's primary CTA — a template may fill its buttons
93
+ * with any token (hvac uses accent, not primary), so the pair travels together. Absent when
94
+ * the page's only buttons are unfilled (ghost/outline). */
95
+ background?: string;
96
+ color?: string;
92
97
  }
93
98
  /** Section System defaults — used when a site has no brand kit override. */
94
99
  declare const AI_DEFAULT_BRAND: AiBrandKit;
package/dist/index.d.ts CHANGED
@@ -89,6 +89,11 @@ interface TemplateButtonStyle {
89
89
  fontWeight: string;
90
90
  letterSpacing: string;
91
91
  textTransform: string;
92
+ /** Measured fill/label pair of the template's primary CTA — a template may fill its buttons
93
+ * with any token (hvac uses accent, not primary), so the pair travels together. Absent when
94
+ * the page's only buttons are unfilled (ghost/outline). */
95
+ background?: string;
96
+ color?: string;
92
97
  }
93
98
  /** Section System defaults — used when a site has no brand kit override. */
94
99
  declare const AI_DEFAULT_BRAND: AiBrandKit;
package/dist/index.js CHANGED
@@ -1307,7 +1307,12 @@ function ButtonEl({
1307
1307
  textDecoration: "none",
1308
1308
  cursor: "pointer",
1309
1309
  ...buttonShellStyle(ctx, fullWidth),
1310
- ...secondary ? { border: `1px solid ${ctx.brand.palette.dark}`, color: ctx.brand.palette.dark } : { background: ctx.brand.palette.primary, color: ctx.buttonLabel ?? primaryButtonLabel(ctx.brand) }
1310
+ ...secondary ? { border: `1px solid ${ctx.brand.palette.dark}`, color: ctx.brand.palette.dark } : (
1311
+ // Off-band, prefer the template button's measured fill/label pair — a template may
1312
+ // fill its CTAs with any token (hvac: accent bg, primary text). On an accent band
1313
+ // the flipped palette keeps contrast, so the brand-driven colours stay.
1314
+ !ctx.buttonLabel && ctx.buttonStyle?.background ? { background: ctx.buttonStyle.background, color: ctx.buttonStyle.color } : { background: ctx.brand.palette.primary, color: ctx.buttonLabel ?? primaryButtonLabel(ctx.brand) }
1315
+ )
1311
1316
  },
1312
1317
  children: /* @__PURE__ */ jsx("span", { ...path ? textAttrs(ctx, `${path}.label`) : {}, children: str(slots.label) })
1313
1318
  }
@@ -2379,10 +2384,12 @@ function renderNode(node, ctx, path) {
2379
2384
  cursor: "pointer",
2380
2385
  // Shape/padding/typography follow the host template's own buttons.
2381
2386
  ...buttonShellStyle(ctx),
2382
- // Brand-styled: primary fill, brand-derived label colour (not a fixed token) so it
2383
- // reads correctly on custom palettes.
2384
- background: ctx.brand.palette.primary,
2385
- color: ctx.buttonLabel ?? primaryButtonLabel(ctx.brand)
2387
+ // Brand-styled: the template button's measured fill/label pair off-band, else
2388
+ // primary fill with a brand-derived label so it reads on custom palettes.
2389
+ ...!ctx.buttonLabel && ctx.buttonStyle?.background ? { background: ctx.buttonStyle.background, color: ctx.buttonStyle.color } : {
2390
+ background: ctx.brand.palette.primary,
2391
+ color: ctx.buttonLabel ?? primaryButtonLabel(ctx.brand)
2392
+ }
2386
2393
  },
2387
2394
  children: /* @__PURE__ */ jsx("span", { ...textAttrs(ctx, `${path}.c${i}.label`), children: str(cs.label) })
2388
2395
  },
@@ -2589,11 +2596,19 @@ function deriveTemplateBrand() {
2589
2596
  }
2590
2597
  function deriveTemplateButtonStyle() {
2591
2598
  if (typeof document === "undefined") return null;
2592
- const btn = Array.from(document.querySelectorAll('[data-ohw-role="button"]')).find(
2593
- (el) => !el.closest(`[${CONTAINER_ATTR}]`)
2594
- );
2599
+ const candidates = Array.from(
2600
+ document.querySelectorAll('[data-ohw-role="button"]')
2601
+ ).filter((el) => !el.closest(`[${CONTAINER_ATTR}]`));
2602
+ const isFilled = (el) => {
2603
+ const bg = getComputedStyle(el).backgroundColor;
2604
+ if (!bg || bg === "transparent") return false;
2605
+ const alpha = bg.match(/rgba?\([^)]*,\s*([\d.]+)\)$/);
2606
+ return !alpha || parseFloat(alpha[1]) > 0;
2607
+ };
2608
+ const btn = candidates.find(isFilled) ?? candidates[0];
2595
2609
  if (!btn) return null;
2596
2610
  const cs = getComputedStyle(btn);
2611
+ const filled = isFilled(btn);
2597
2612
  const corners = [
2598
2613
  cs.borderTopLeftRadius,
2599
2614
  cs.borderTopRightRadius,
@@ -2610,6 +2625,7 @@ function deriveTemplateButtonStyle() {
2610
2625
  return {
2611
2626
  radius: radius || "10px",
2612
2627
  padding: `${padY}px ${padX}px`,
2628
+ ...filled ? { background: cs.backgroundColor, color: cs.color } : {},
2613
2629
  fontFamily: cs.fontFamily || "",
2614
2630
  fontSize: cs.fontSize || "",
2615
2631
  fontWeight: cs.fontWeight || "",
@@ -22178,7 +22194,7 @@ function OhhwellsBridge() {
22178
22194
  postToParent2({
22179
22195
  type: "ow:ready",
22180
22196
  version: "1",
22181
- bridgeVersion: "0.1.100",
22197
+ bridgeVersion: "0.1.101",
22182
22198
  path: pathname,
22183
22199
  nodes: collectEditableNodes(editContentRef.current),
22184
22200
  sections