@bettercms-ai/astro 0.26.0 → 0.27.0

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.
@@ -352,6 +352,20 @@ const pass = { forms, components, turnstileSiteKey, nested: true, fieldAddresses
352
352
  );
353
353
  }
354
354
  case "button":
355
+ // The site's script owns the click: a `<button type="button">`, never an anchor with an invented href.
356
+ if (p.action === "code") return (
357
+ <button
358
+ type="button"
359
+ class={`bcms-btn bcms-btn-${buttonVariantOf(p.variant)}${p.size === "sm" || p.size === "lg" ? ` bcms-btn-${p.size}` : ""}${p.fullWidth === true ? " bcms-btn-full" : ""}`}
360
+ style={buttonPaintAttr(block)}
361
+ {...bind(block.id, "text", "text", bctx)}
362
+ {...blockAttrs}
363
+ >
364
+ {buttonIconOf(p.icon) && <Fragment set:html={buttonIconSvg(buttonIconOf(p.icon)!, "bcms-btn-icon")} />}
365
+ {p.text}
366
+ {p.arrow === true && <Fragment set:html={buttonIconSvg("arrow-right", "bcms-btn-arrow")} />}
367
+ </button>
368
+ );
355
369
  return (
356
370
  <a
357
371
  class={`bcms-btn bcms-btn-${buttonVariantOf(p.variant)}${p.size === "sm" || p.size === "lg" ? ` bcms-btn-${p.size}` : ""}${p.fullWidth === true ? " bcms-btn-full" : ""}`}
@@ -1,17 +1,21 @@
1
1
  ---
2
2
  /**
3
3
  * <BcmsButton> — render a `button` field ({ label, href, variant?, size?, arrow?, icon?,
4
- * newTab? }) as one editable button, the way the BetterCMS visual editor and in-place publishing
4
+ * newTab?, fullWidth? }) as one editable button, the way the BetterCMS visual editor and in-place publishing
5
5
  * expect to find it:
6
6
  *
7
- * <a data-bcms-button="<path>" data-variant data-size href [target rel] data-bcms-props="<path>.href|url|href">
7
+ * <a data-bcms-button="<path>" data-variant data-size [data-full-width] href [target rel] data-bcms-props="<path>.href|url|href">
8
8
  * [<svg class="bcms-btn-icon">]<span data-bcms-field="<path>.label">Label</span>[<svg class="bcms-btn-arrow">]
9
9
  * </a>
10
10
  *
11
+ * A value with `action: "code"` (no href: the site's script handles the click) renders the same
12
+ * children in `<button type="button" data-bcms-button="<path>" data-variant data-size>`.
13
+ *
11
14
  * Style it by `data-variant` (primary · secondary · tertiary · brand · dark · light · outline ·
12
15
  * link) and `data-size` (sm · md · lg) in your own CSS: the editor repaints those attributes as the
13
16
  * author picks, and publishing writes them into the live page, so your stylesheet decides what a
14
- * look looks like. `class` is passed through untouched.
17
+ * look looks like. A full-width button also carries `display:flex;width:100%;justify-content:center`
18
+ * inline, so it stretches across its column with no rule of yours. `class` is passed through untouched.
15
19
  *
16
20
  * <BcmsButton path="hero.cta" value={page.hero.cta} class="btn" />
17
21
  */
@@ -27,13 +31,21 @@ interface Props {
27
31
  const { path, value, class: className } = Astro.props;
28
32
  const b = readButtonValue(value);
29
33
  ---
30
- {b.label && (
34
+ {b.label && b.action === "code" && (
35
+ <button type="button" class={className} data-bcms-button={path} data-variant={b.variant} data-size={b.size} {...(b.fullWidth ? { "data-full-width": "", style: "display:flex;width:100%;justify-content:center" } : {})}>
36
+ {b.icon && <Fragment set:html={buttonIconSvg(b.icon, "bcms-btn-icon")} />}
37
+ <span data-bcms-field={`${path}.label`} data-bcms-kind="text">{b.label}</span>
38
+ {b.arrow && <Fragment set:html={buttonIconSvg("arrow-right", "bcms-btn-arrow")} />}
39
+ </button>
40
+ )}
41
+ {b.label && b.action !== "code" && (
31
42
  <a
32
43
  class={className}
33
44
  href={b.href || "#"}
34
45
  data-bcms-button={path}
35
46
  data-variant={b.variant}
36
47
  data-size={b.size}
48
+ {...(b.fullWidth ? { "data-full-width": "", style: "display:flex;width:100%;justify-content:center" } : {})}
37
49
  data-bcms-props={formatPropsAttribute([{ address: `${path}.href`, kind: "url", attr: "href" }])}
38
50
  {...(b.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {})}
39
51
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettercms-ai/astro",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "type": "module",
5
5
  "description": "The BetterCMS adapter for Astro — a `bettercms()` integration, a `bettercms:client` virtual module, typed content loaders, draft preview, and native .astro rendering components.",
6
6
  "main": "./dist/index.js",
@@ -61,11 +61,11 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@bettercms-ai/image-url": "^0.4.0",
64
- "@bettercms-ai/next": "^0.25.0",
64
+ "@bettercms-ai/next": "^0.26.0",
65
65
  "@bettercms-ai/richtext": "^0.8.2",
66
66
  "@bettercms-ai/sdk": "^1.29.0",
67
- "@bettercms-ai/types": "^1.42.0",
68
- "@bettercms-ai/ui": "^0.15.1",
67
+ "@bettercms-ai/types": "^1.43.0",
68
+ "@bettercms-ai/ui": "^0.16.0",
69
69
  "libphonenumber-js": "^1.13.13"
70
70
  },
71
71
  "peerDependencies": {