@neowhale/storefront 0.2.20 → 0.2.25

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.
@@ -2594,35 +2594,56 @@ function GallerySection({ section, theme }) {
2594
2594
  ) }, i)) }) });
2595
2595
  }
2596
2596
  function CTASection({ section, theme, tracking }) {
2597
- const { buttons } = section.content;
2597
+ const { title, subtitle, buttons } = section.content;
2598
2598
  if (!buttons || buttons.length === 0) return null;
2599
- return /* @__PURE__ */ jsx("div", { style: { padding: "2rem 1.5rem", maxWidth: 480, margin: "0 auto", display: "flex", flexDirection: "column", gap: "0.75rem" }, children: buttons.map((btn, i) => {
2600
- const isPrimary = btn.style !== "outline";
2601
- return /* @__PURE__ */ jsx(
2602
- "a",
2603
- {
2604
- href: btn.url,
2605
- onClick: () => trackClick(tracking, btn.text, btn.url, i),
2606
- style: {
2607
- display: "block",
2608
- width: "100%",
2609
- padding: "0.875rem",
2610
- background: isPrimary ? theme.fg : "transparent",
2611
- color: isPrimary ? theme.bg : theme.fg,
2612
- border: isPrimary ? "none" : `1px solid ${theme.fg}20`,
2613
- fontSize: "0.85rem",
2614
- fontWeight: 500,
2615
- textAlign: "center",
2616
- textDecoration: "none",
2617
- boxSizing: "border-box",
2618
- letterSpacing: "0.08em",
2619
- textTransform: "uppercase"
2599
+ return /* @__PURE__ */ jsxs("div", { style: { padding: "2rem 1.5rem", maxWidth: 480, margin: "0 auto", display: "flex", flexDirection: "column", gap: "0.75rem" }, children: [
2600
+ title && /* @__PURE__ */ jsx("h2", { style: {
2601
+ fontSize: "clamp(1.25rem, 4vw, 1.5rem)",
2602
+ fontWeight: 300,
2603
+ fontFamily: theme.fontDisplay || "inherit",
2604
+ margin: "0 0 0.25rem",
2605
+ lineHeight: 1.2,
2606
+ letterSpacing: "-0.02em",
2607
+ color: theme.fg,
2608
+ textAlign: "center"
2609
+ }, children: title }),
2610
+ subtitle && /* @__PURE__ */ jsx("p", { style: {
2611
+ fontSize: "0.8rem",
2612
+ color: theme.accent,
2613
+ margin: "0 0 0.75rem",
2614
+ lineHeight: 1.6,
2615
+ textTransform: "uppercase",
2616
+ letterSpacing: "0.15em",
2617
+ textAlign: "center"
2618
+ }, children: subtitle }),
2619
+ buttons.map((btn, i) => {
2620
+ const isPrimary = btn.style !== "outline";
2621
+ return /* @__PURE__ */ jsx(
2622
+ "a",
2623
+ {
2624
+ href: btn.url,
2625
+ onClick: () => trackClick(tracking, btn.text, btn.url, i),
2626
+ style: {
2627
+ display: "block",
2628
+ width: "100%",
2629
+ padding: "0.875rem",
2630
+ background: isPrimary ? theme.fg : "transparent",
2631
+ color: isPrimary ? theme.bg : theme.fg,
2632
+ border: isPrimary ? "none" : `1px solid ${theme.fg}20`,
2633
+ fontSize: "0.85rem",
2634
+ fontWeight: 500,
2635
+ textAlign: "center",
2636
+ textDecoration: "none",
2637
+ boxSizing: "border-box",
2638
+ letterSpacing: "0.08em",
2639
+ textTransform: "uppercase"
2640
+ },
2641
+ children: btn.text
2620
2642
  },
2621
- children: btn.text
2622
- },
2623
- i
2624
- );
2625
- }) });
2643
+ i
2644
+ );
2645
+ })
2646
+ ] });
2626
2647
  }
2627
2648
  function StatsSection({ section, theme }) {
2628
2649
  const { stats } = section.content;
@@ -3126,13 +3147,24 @@ function buildDefaultSections(data) {
3126
3147
  config: { align: "center" }
3127
3148
  });
3128
3149
  }
3150
+ const totalMg = toNum(cf?.total_mg_per_package ?? cf?.total_mg);
3151
+ const mgPerPiece = toNum(cf?.mg_per_piece);
3152
+ const piecesPerPkg = toNum(cf?.pieces_per_package);
3153
+ const isEdible = totalMg != null || mgPerPiece != null || piecesPerPkg != null;
3129
3154
  const thca = toNum(cf?.thca_percentage);
3130
3155
  const thc = toNum(cf?.d9_percentage);
3131
3156
  const cbd = toNum(cf?.cbd_total);
3132
3157
  const stats = [];
3133
- if (thca != null) stats.push({ label: "THCa", value: `${thca.toFixed(thca >= 1 ? 1 : 2)}%` });
3134
- if (thc != null) stats.push({ label: "\u03949 THC", value: `${thc.toFixed(thc >= 1 ? 1 : 2)}%` });
3135
- if (cbd != null) stats.push({ label: "CBD", value: `${cbd.toFixed(cbd >= 1 ? 1 : 2)}%` });
3158
+ if (isEdible) {
3159
+ if (totalMg != null) stats.push({ label: "Total MG", value: `${fmtMg(totalMg)}` });
3160
+ if (mgPerPiece != null) stats.push({ label: "Per Piece", value: `${fmtMg(mgPerPiece)}mg` });
3161
+ if (piecesPerPkg != null) stats.push({ label: "Pieces", value: `${piecesPerPkg}` });
3162
+ if (thc != null) stats.push({ label: "\u03949 THC", value: `${thc.toFixed(thc >= 1 ? 1 : 2)}%` });
3163
+ } else {
3164
+ if (thca != null) stats.push({ label: "THCa", value: `${thca.toFixed(thca >= 1 ? 1 : 2)}%` });
3165
+ if (thc != null) stats.push({ label: "\u03949 THC", value: `${thc.toFixed(thc >= 1 ? 1 : 2)}%` });
3166
+ if (cbd != null) stats.push({ label: "CBD", value: `${cbd.toFixed(cbd >= 1 ? 1 : 2)}%` });
3167
+ }
3136
3168
  if (stats.length > 0) {
3137
3169
  sections.push({
3138
3170
  id: "auto-stats",
@@ -3141,6 +3173,24 @@ function buildDefaultSections(data) {
3141
3173
  content: { stats }
3142
3174
  });
3143
3175
  }
3176
+ if (isEdible) {
3177
+ const servingDetails = [];
3178
+ const servingSize = toStr(cf?.serving_size);
3179
+ const ingredients = toStr(cf?.ingredients);
3180
+ const allergens = toStr(cf?.allergens);
3181
+ if (servingSize) servingDetails.push({ label: "Serving Size", value: servingSize });
3182
+ if (ingredients) servingDetails.push({ label: "Ingredients", value: ingredients });
3183
+ if (allergens) servingDetails.push({ label: "Allergens", value: allergens });
3184
+ if (servingDetails.length > 0) {
3185
+ sections.push({
3186
+ id: "auto-serving",
3187
+ type: "stats",
3188
+ order: order++,
3189
+ content: { stats: servingDetails },
3190
+ config: { layout: "list" }
3191
+ });
3192
+ }
3193
+ }
3144
3194
  const profileDetails = [];
3145
3195
  const genetics = toStr(cf?.genetics);
3146
3196
  const terpenes = toStr(cf?.terpenes);
@@ -3212,6 +3262,9 @@ function toNum(v) {
3212
3262
  const n = Number(v);
3213
3263
  return Number.isFinite(n) ? n : null;
3214
3264
  }
3265
+ function fmtMg(mg) {
3266
+ return mg === Math.floor(mg) ? `${mg}mg` : `${mg.toFixed(1)}mg`;
3267
+ }
3215
3268
  function toStr(v) {
3216
3269
  if (v == null || v === "") return null;
3217
3270
  return String(v);