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