@ohhwells/bridge 0.1.83 → 0.1.84

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.js CHANGED
@@ -183,6 +183,17 @@ var BRAND_VAR_PREFIX = "--ohw-brand-";
183
183
  var BRAND_VAR_NAMES = ["primary", "accent", "light", "dark", "surface", "border", "muted"].map(
184
184
  (role) => `${BRAND_VAR_PREFIX}${role}`
185
185
  );
186
+ var LEGACY_BRAND_VAR_NAMES = [
187
+ "primary",
188
+ "accent",
189
+ "background",
190
+ "text",
191
+ "text-muted",
192
+ "surface",
193
+ "border",
194
+ "on-primary",
195
+ "navbar-background"
196
+ ].map((role) => `--brand-${role}`);
186
197
  var FONT_VARS = {
187
198
  heading: ["--font-heading", "--font-display", "--brand-font-heading"],
188
199
  body: ["--font-body", "--brand-font-body"]
@@ -191,14 +202,29 @@ var BRAND_FONT_LINK_ID = "ohw-brand-fonts";
191
202
  function brandColorVars(kit) {
192
203
  const { dark, primary, accent, light } = kit.palette;
193
204
  const mix = (a, aPct, b) => `color-mix(in srgb, ${a} ${aPct}%, ${b})`;
205
+ const surface = mix(light, 95, dark);
206
+ const border = mix(light, 85, dark);
207
+ const muted = mix(dark, 62, light);
194
208
  return {
195
209
  [`${BRAND_VAR_PREFIX}primary`]: primary,
196
210
  [`${BRAND_VAR_PREFIX}accent`]: accent,
197
211
  [`${BRAND_VAR_PREFIX}light`]: light,
198
212
  [`${BRAND_VAR_PREFIX}dark`]: dark,
199
- [`${BRAND_VAR_PREFIX}surface`]: mix(light, 95, dark),
200
- [`${BRAND_VAR_PREFIX}border`]: mix(light, 85, dark),
201
- [`${BRAND_VAR_PREFIX}muted`]: mix(dark, 62, light)
213
+ [`${BRAND_VAR_PREFIX}surface`]: surface,
214
+ [`${BRAND_VAR_PREFIX}border`]: border,
215
+ [`${BRAND_VAR_PREFIX}muted`]: muted,
216
+ // The BrandProvider contract every template actually renders from (see LEGACY_BRAND_VAR_NAMES).
217
+ "--brand-primary": primary,
218
+ "--brand-accent": accent,
219
+ "--brand-background": light,
220
+ "--brand-text": dark,
221
+ "--brand-text-muted": muted,
222
+ "--brand-surface": surface,
223
+ "--brand-border": border,
224
+ // Buttons/bands painted in the primary colour assume it's dark/saturated enough to need
225
+ // light text on top — the same assumption LOGO_IMAGE's light-on-dark navbar mark makes.
226
+ "--brand-on-primary": light,
227
+ "--brand-navbar-background": dark
202
228
  };
203
229
  }
204
230
  function parseBrandKit(raw) {
@@ -239,7 +265,7 @@ function loadBrandFonts(families) {
239
265
  function applyBrandToDom(kit) {
240
266
  const root = document.documentElement;
241
267
  if (!kit) {
242
- for (const name of BRAND_VAR_NAMES) root.style.removeProperty(name);
268
+ for (const name of [...BRAND_VAR_NAMES, ...LEGACY_BRAND_VAR_NAMES]) root.style.removeProperty(name);
243
269
  for (const name of [...FONT_VARS.heading, ...FONT_VARS.body]) root.style.removeProperty(name);
244
270
  document.getElementById(BRAND_FONT_LINK_ID)?.remove();
245
271
  return;
@@ -7359,6 +7385,9 @@ function applyFieldType(wrapper, type) {
7359
7385
  el.style.removeProperty("min-height");
7360
7386
  el.style.removeProperty("resize");
7361
7387
  el.removeAttribute("rows");
7388
+ if (el.className) {
7389
+ el.className = el.className.split(/\s+/).filter((token) => !/textarea/i.test(token)).join(" ");
7390
+ }
7362
7391
  };
7363
7392
  const applyDefaults = (el) => {
7364
7393
  el.setAttribute("placeholder", defaults.placeholder);
@@ -11609,7 +11638,7 @@ function applySocialsDisplayToRow(row, display) {
11609
11638
  const icon = item.querySelector(ICON_SELECTOR);
11610
11639
  if (label) label.style.display = display.text ? "" : "none";
11611
11640
  if (icon) icon.style.display = display.icon ? "" : "none";
11612
- layOutIconAndLabel(item, Boolean(display.text && display.icon));
11641
+ layOutIconAndLabel(item, Boolean(display.text));
11613
11642
  });
11614
11643
  allowRowToWrap(row);
11615
11644
  }
@@ -11621,6 +11650,9 @@ function layOutIconAndLabel(item, on) {
11621
11650
  item.style.gap = "";
11622
11651
  item.style.whiteSpace = "";
11623
11652
  item.style.flex = "";
11653
+ item.style.width = "";
11654
+ item.style.height = "";
11655
+ item.style.padding = "";
11624
11656
  return;
11625
11657
  }
11626
11658
  item.style.display = on ? "inline-flex" : "";
@@ -11628,6 +11660,9 @@ function layOutIconAndLabel(item, on) {
11628
11660
  item.style.gap = on ? "8px" : "";
11629
11661
  item.style.whiteSpace = on ? "nowrap" : "";
11630
11662
  item.style.flex = on ? "0 0 auto" : "";
11663
+ item.style.width = on ? "auto" : "";
11664
+ item.style.height = on ? "auto" : "";
11665
+ item.style.padding = on ? "0 12px" : "";
11631
11666
  }
11632
11667
  function allowRowToWrap(row) {
11633
11668
  const display = row.ownerDocument.defaultView?.getComputedStyle(row).display ?? "";
@@ -12583,6 +12618,15 @@ function resolveLogoDisplayText(text) {
12583
12618
  function isFooterLogoRoot(root) {
12584
12619
  return Boolean(root.closest("footer") || root.closest('[data-ohw-section="footer"]'));
12585
12620
  }
12621
+ var NAV_IMAGE_KEYS = ["nav-logo-image", "logo-image"];
12622
+ var FOOTER_IMAGE_KEYS = ["footer-logo", "footer-logo-image", "footer-logo-img"];
12623
+ function firstNonEmptyContentValue(content, keys) {
12624
+ for (const key of keys) {
12625
+ const value = content[key];
12626
+ if (typeof value === "string" && value.trim()) return value.trim();
12627
+ }
12628
+ return null;
12629
+ }
12586
12630
  function imageKeyForRoot(root) {
12587
12631
  return isFooterLogoRoot(root) ? "footer-logo" : "nav-logo-image";
12588
12632
  }
@@ -12632,9 +12676,10 @@ function applyLogoIdentity(text, isPlaceholder) {
12632
12676
  });
12633
12677
  return display;
12634
12678
  }
12635
- function applyLogoImage(url, alt) {
12679
+ function applyLogoImage(url, alt, placement) {
12636
12680
  const displayAlt = resolveLogoDisplayText(alt);
12637
12681
  document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]').forEach((root) => {
12682
+ if (placement && (isFooterLogoRoot(root) ? "footer" : "navbar") !== placement) return;
12638
12683
  ensureLogoHrefKey(root);
12639
12684
  const imageKey = imageKeyForRoot(root);
12640
12685
  const textKey = textKeyForRoot(root);
@@ -12755,7 +12800,12 @@ function applyLogoFromContent(content) {
12755
12800
  const logoImageUrl = typeof rawLogoImage === "string" && rawLogoImage.trim() ? rawLogoImage.trim() : null;
12756
12801
  const imageExplicitlyCleared = LOGO_IMAGE_KEYS.some((key) => key in content) && !logoImageUrl;
12757
12802
  const logoIsPlaceholder = LOGO_PLACEHOLDER_KEY in content ? content[LOGO_PLACEHOLDER_KEY] !== "false" : !logoImageUrl && (!logoText.trim() || logoText === PLACEHOLDER_BUSINESS_NAME);
12758
- if (logoImageUrl) {
12803
+ const navImageUrl = firstNonEmptyContentValue(content, NAV_IMAGE_KEYS);
12804
+ const footerImageUrl = firstNonEmptyContentValue(content, FOOTER_IMAGE_KEYS);
12805
+ if (navImageUrl && footerImageUrl && navImageUrl !== footerImageUrl) {
12806
+ applyLogoImage(navImageUrl, logoAlt, "navbar");
12807
+ applyLogoImage(footerImageUrl, logoAlt, "footer");
12808
+ } else if (logoImageUrl) {
12759
12809
  applyLogoImage(logoImageUrl, logoAlt);
12760
12810
  } else {
12761
12811
  if (imageExplicitlyCleared) applyLogoImage(null, logoAlt);
@@ -18138,6 +18188,8 @@ function OhhwellsBridge() {
18138
18188
  };
18139
18189
  const t1 = setTimeout(measure, 50);
18140
18190
  const t2 = setTimeout(measure, 500);
18191
+ const ro = new ResizeObserver(schedule);
18192
+ ro.observe(document.body);
18141
18193
  let lastWidth = window.innerWidth;
18142
18194
  let resizeTimers = [];
18143
18195
  const clearResizeTimers = () => {
@@ -18155,6 +18207,7 @@ function OhhwellsBridge() {
18155
18207
  clearTimeout(t1);
18156
18208
  clearTimeout(t2);
18157
18209
  if (raf != null) cancelAnimationFrame(raf);
18210
+ ro.disconnect();
18158
18211
  clearResizeTimers();
18159
18212
  window.removeEventListener("resize", handleResize);
18160
18213
  };
@@ -21027,7 +21080,7 @@ function OhhwellsBridge() {
21027
21080
  postToParent2({
21028
21081
  type: "ow:ready",
21029
21082
  version: "1",
21030
- bridgeVersion: "0.1.82",
21083
+ bridgeVersion: "0.1.83",
21031
21084
  path: pathname,
21032
21085
  nodes: collectEditableNodes(editContentRef.current),
21033
21086
  sections