@wix/himalaya-cli 0.2009.0 → 0.2010.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.
- package/dist/cli.mjs +138 -36
- package/guides/one-app-section-mappings.md +1 -1
- package/guides/one-app-to-himi-app.md +3 -0
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/_shared/himi-store-facets.ts +2 -7
- package/templates/beauty-salon/tier5-src/_shared/store-ribbon.ts +11 -0
- package/templates/branded-lite/l10n/ar.json +20 -0
- package/templates/branded-lite/l10n/cs.json +20 -0
- package/templates/branded-lite/l10n/da.json +20 -0
- package/templates/branded-lite/l10n/de.json +20 -0
- package/templates/branded-lite/l10n/el.json +20 -0
- package/templates/branded-lite/l10n/es.json +20 -0
- package/templates/branded-lite/l10n/fi.json +20 -0
- package/templates/branded-lite/l10n/fr.json +20 -0
- package/templates/branded-lite/l10n/he.json +16 -0
- package/templates/branded-lite/l10n/hu.json +20 -0
- package/templates/branded-lite/l10n/id.json +20 -0
- package/templates/branded-lite/l10n/it.json +20 -0
- package/templates/branded-lite/l10n/ja.json +20 -0
- package/templates/branded-lite/l10n/ko.json +20 -0
- package/templates/branded-lite/l10n/lt.json +20 -0
- package/templates/branded-lite/l10n/nl.json +20 -0
- package/templates/branded-lite/l10n/no.json +20 -0
- package/templates/branded-lite/l10n/pl.json +20 -0
- package/templates/branded-lite/l10n/pt.json +20 -0
- package/templates/branded-lite/l10n/ru.json +20 -0
- package/templates/branded-lite/l10n/sv.json +20 -0
- package/templates/branded-lite/l10n/th.json +20 -0
- package/templates/branded-lite/l10n/tr.json +20 -0
- package/templates/branded-lite/l10n/uk.json +20 -0
- package/templates/branded-lite/l10n/vi.json +20 -0
- package/templates/branded-lite/l10n/zh.json +20 -0
- package/templates/branded-lite/recipes/members-carousel.json +55 -3
- package/templates/branded-lite/recipes/plans-card.json +630 -3
- package/templates/branded-lite/recipes/products-carousel.json +74 -10
- package/templates/branded-lite/recipes/products-grid.json +74 -10
- package/templates/branded-lite/recipes/programs-filters.json +51 -2
- package/templates/branded-lite/tier5-src/_shared/himi-store-facets.ts +2 -7
- package/templates/branded-lite/tier5-src/_shared/member-row-extras.ts +18 -17
- package/templates/branded-lite/tier5-src/_shared/members-directory-view.ts +12 -0
- package/templates/branded-lite/tier5-src/_shared/members-directory.ts +26 -13
- package/templates/branded-lite/tier5-src/_shared/plan-facts.ts +15 -6
- package/templates/branded-lite/tier5-src/_shared/plans-section.ts +32 -6
- package/templates/branded-lite/tier5-src/_shared/products-section.ts +5 -0
- package/templates/branded-lite/tier5-src/_shared/programs-section.ts +19 -16
- package/templates/branded-lite/tier5-src/_shared/store-ribbon.ts +11 -0
- package/templates/gym-fitness/tier5-src/_shared/himi-store-facets.ts +2 -7
- package/templates/gym-fitness/tier5-src/_shared/store-ribbon.ts +11 -0
- package/templates/portfolio-creative/tier5-src/_shared/himi-store-facets.ts +2 -7
- package/templates/portfolio-creative/tier5-src/_shared/store-ribbon.ts +11 -0
- package/templates/retail-store/tier5-src/_shared/himi-store-facets.ts +2 -7
- package/templates/retail-store/tier5-src/_shared/store-ribbon.ts +11 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// The INLINE plans section: the site's pricing plans as cards (name, pitch, price, cadence, validity, the
|
|
1
|
+
// The INLINE plans section: the site's pricing plans as cards (name, pitch, price, cadence, validity, the benefits list or a
|
|
2
|
+
// "Show Benefits" disclosure over it), hosted by
|
|
2
3
|
// any worker that wants them next to other sections. It is data only and read-only: a card opens the plan's own screen
|
|
3
4
|
// (`himi_plan`), which is where joining and paying live. The `plans-card` recipe is the card that reads it,
|
|
4
5
|
// bound as `$service:<serviceName>.*`.
|
|
@@ -19,6 +20,9 @@ export interface PlansSectionOptions {
|
|
|
19
20
|
showBenefits?: boolean;
|
|
20
21
|
/** The order of the published plans when none is selected (a selection keeps the source's own order); absent: the site's order. */
|
|
21
22
|
order?: "oldest-first" | "newest-first";
|
|
23
|
+
/** How the benefits show: listed on the card ("list", the default), or folded under a disclosure the reader opens
|
|
24
|
+
* ("disclosure", the One App paid-plans card's "Show Benefits"). */
|
|
25
|
+
benefits?: "list" | "disclosure";
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export interface PlansSectionRow {
|
|
@@ -28,10 +32,14 @@ export interface PlansSectionRow {
|
|
|
28
32
|
priceLine: string; noPrice: boolean;
|
|
29
33
|
/** How the plan is paid ("per month", "one-time"). */
|
|
30
34
|
periodLine: string; noPeriod: boolean;
|
|
31
|
-
/** How long access lasts ("
|
|
35
|
+
/** How long access lasts ("Until canceled", "for 10 years"), apart from the cadence. */
|
|
32
36
|
validityLine: string; noValidity: boolean;
|
|
33
37
|
badge: string; noBadge: boolean;
|
|
34
38
|
perks: string[];
|
|
39
|
+
/** The benefits listed on the card (list layout, the plan has some). */
|
|
40
|
+
noPerkList: boolean;
|
|
41
|
+
/** The benefits folded under the disclosure (disclosure layout, the plan has some), and whether the reader opened it. */
|
|
42
|
+
noPerkDisclosure: boolean; benefitsOpen: boolean;
|
|
35
43
|
[perk: `perk${number}`]: string;
|
|
36
44
|
[flag: `noPerk${number}`]: boolean;
|
|
37
45
|
}
|
|
@@ -51,7 +59,7 @@ function money(plan: WixPlan): string {
|
|
|
51
59
|
try { return formatCurrency(Number(raw), price?.currency || "USD"); } catch { return `${raw}`; }
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
export function plansSectionRow(plan: WixPlan, showBenefits = true): PlansSectionRow {
|
|
62
|
+
export function plansSectionRow(plan: WixPlan, showBenefits = true, benefits: PlansSectionOptions["benefits"] = "list"): PlansSectionRow {
|
|
55
63
|
const perks = showBenefits
|
|
56
64
|
? (plan.perks?.values ?? []).map((perk) => (perk ?? "").trim()).filter(Boolean).slice(0, PLANS_SECTION_MAX_PERKS)
|
|
57
65
|
: [];
|
|
@@ -63,6 +71,7 @@ export function plansSectionRow(plan: WixPlan, showBenefits = true): PlansSectio
|
|
|
63
71
|
return {
|
|
64
72
|
id: plan.id || "", name: (plan.name || copyParam("plans.planFallbackName", "Plan")).trim(),
|
|
65
73
|
description, noDescription: !description, priceLine, noPrice: !priceLine, periodLine, noPeriod: !periodLine, validityLine, noValidity: !validityLine, badge, noBadge: !badge, perks,
|
|
74
|
+
noPerkList: !perks.length || benefits === "disclosure", noPerkDisclosure: !perks.length || benefits !== "disclosure", benefitsOpen: false,
|
|
66
75
|
...planPerkFields(perks),
|
|
67
76
|
};
|
|
68
77
|
}
|
|
@@ -97,22 +106,39 @@ export function selectPlans(plans: readonly WixPlan[], planIds: readonly string[
|
|
|
97
106
|
return live.filter((plan) => rank.has(plan.id)).sort((a, b) => (rank.get(a.id) ?? 0) - (rank.get(b.id) ?? 0));
|
|
98
107
|
}
|
|
99
108
|
|
|
109
|
+
/** The rows with one plan's benefits disclosure opened or closed (the reader's tap); any other row is kept as it is. */
|
|
110
|
+
export function toggleBenefits(rows: readonly PlansSectionRow[], id: unknown): PlansSectionRow[] {
|
|
111
|
+
if (typeof id !== "string" || !id) return [...rows];
|
|
112
|
+
return rows.map((row) => row.id === id && !row.noPerkDisclosure ? { ...row, benefitsOpen: !row.benefitsOpen } : row);
|
|
113
|
+
}
|
|
114
|
+
|
|
100
115
|
export function registerPlansSection(serviceName: string, options: PlansSectionOptions = {}) {
|
|
101
116
|
const showBenefits = options.showBenefits !== false;
|
|
117
|
+
const benefits = options.benefits === "disclosure" ? "disclosure" : "list";
|
|
102
118
|
const planIds = (options.planIds ?? []).filter((id) => typeof id === "string" && id);
|
|
103
|
-
return defineService<PlansSectionState, {
|
|
119
|
+
return defineService<PlansSectionState, {
|
|
120
|
+
load: (state: PlansSectionState, arg?: unknown) => Promise<PlansSectionState>;
|
|
121
|
+
toggleBenefits: (state: PlansSectionState, arg?: unknown) => PlansSectionState;
|
|
122
|
+
}>(serviceName, {
|
|
104
123
|
state: derive("loading", []),
|
|
105
124
|
actions: {
|
|
106
|
-
load: async (
|
|
125
|
+
load: async (state, arg) => {
|
|
107
126
|
stashCopy(arg);
|
|
127
|
+
// The section reads again each time it reappears (back from a plan): a disclosure the reader opened stays open.
|
|
128
|
+
const open = new Set(state.rows.filter((row) => row.benefitsOpen).map((row) => row.id));
|
|
108
129
|
try {
|
|
109
130
|
const response = await listPublicPlans();
|
|
110
|
-
return derive("ready", selectPlans(response.plans ?? [], planIds, options.order).map((plan) =>
|
|
131
|
+
return derive("ready", selectPlans(response.plans ?? [], planIds, options.order).map((plan) => {
|
|
132
|
+
const row = plansSectionRow(plan, showBenefits, benefits);
|
|
133
|
+
return open.has(row.id) && !row.noPerkDisclosure ? { ...row, benefitsOpen: true } : row;
|
|
134
|
+
}));
|
|
111
135
|
} catch (error) {
|
|
112
136
|
console.warn("plans_section: the plans could not be read", error);
|
|
113
137
|
return derive("error", []);
|
|
114
138
|
}
|
|
115
139
|
},
|
|
140
|
+
// The card's "Show Benefits" disclosure: only the tapped plan opens or closes.
|
|
141
|
+
toggleBenefits: (state, arg) => derive(state.status, toggleBenefits(state.rows, (arg as { id?: unknown } | undefined)?.id)),
|
|
116
142
|
},
|
|
117
143
|
});
|
|
118
144
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { defineService } from "@himalaya/state";
|
|
7
7
|
import { searchStoreProducts, productImage, productPrice, type StoreProduct } from "./himi-store.js";
|
|
8
8
|
import { copyParam, stashCopy } from "./himi-copy.js";
|
|
9
|
+
import { ribbonText } from "./store-ribbon.js";
|
|
9
10
|
|
|
10
11
|
export interface ProductsSectionOptions {
|
|
11
12
|
/** The source collection's id; unset reads the whole catalog. */
|
|
@@ -17,6 +18,8 @@ export interface ProductsSectionOptions {
|
|
|
17
18
|
export interface ProductRow {
|
|
18
19
|
id: string; name: string; price: string;
|
|
19
20
|
image: string; initial: string; hasImage: boolean; noImage: boolean;
|
|
21
|
+
/** The merchant's ribbon on the product ("Best Seller"), on the tile's image; a product without one keeps a plain tile. */
|
|
22
|
+
ribbon: string; noRibbon: boolean;
|
|
20
23
|
/** The product screen a tile opens; the tile binds `id` as its nav param. */
|
|
21
24
|
detailScreenId: string;
|
|
22
25
|
}
|
|
@@ -37,9 +40,11 @@ const TILE_IMAGE = { width: 480, height: 480, quality: 85 };
|
|
|
37
40
|
function rowOf(product: StoreProduct): ProductRow {
|
|
38
41
|
const name = (product.name ?? "").trim();
|
|
39
42
|
const image = productImage(product, TILE_IMAGE);
|
|
43
|
+
const ribbon = ribbonText(product);
|
|
40
44
|
return {
|
|
41
45
|
id: product.id ?? "", name, price: productPrice(product),
|
|
42
46
|
image, initial: (name[0] ?? "#").toUpperCase(), hasImage: !!image, noImage: !image,
|
|
47
|
+
ribbon, noRibbon: !ribbon,
|
|
43
48
|
detailScreenId: "himi_product",
|
|
44
49
|
};
|
|
45
50
|
}
|
|
@@ -104,6 +104,8 @@ export interface State {
|
|
|
104
104
|
identityLine: string;
|
|
105
105
|
needsSignIn: boolean;
|
|
106
106
|
noSignIn: boolean;
|
|
107
|
+
/** The guest's Sign in button on a signed-out "Programs I joined". */
|
|
108
|
+
signInLabel: string;
|
|
107
109
|
nextCursor: string;
|
|
108
110
|
noMore: boolean;
|
|
109
111
|
noPageError: boolean;
|
|
@@ -291,10 +293,11 @@ function programContent(o: { program: WixProgram; participant?: WixParticipant;
|
|
|
291
293
|
const countFull = capped && o.participants !== undefined && o.participants >= maxParticipants(p);
|
|
292
294
|
// Not knowing the count of a capped program, or whether an application exists, the card claims neither
|
|
293
295
|
// "Join" nor "Program is full": View, and the detail screen decides.
|
|
294
|
-
// A failed participations read leaves every unjoined-looking card unknown too: the member may be in it.
|
|
295
|
-
|
|
296
|
+
// A failed participations read leaves every unjoined-looking card unknown too: the member may be in it. That holds
|
|
297
|
+
// for a guest as well: a signed-in member whose id is not resolved yet reads as a guest with unknown participations.
|
|
298
|
+
const standingUnknown = standing === "none"
|
|
296
299
|
&& (!!o.applicationUnknown || !!o.participationsUnknown || (capped && o.participants === undefined));
|
|
297
|
-
// "Full" only
|
|
300
|
+
// "Full" only when the viewer's own standing is known: an unknown one may already be in it.
|
|
298
301
|
const limitReached = countFull && !standingUnknown;
|
|
299
302
|
const commercePrice = commercePriceOf(p);
|
|
300
303
|
const descriptionLine = standing === "completed" ? copyParam("memberPrograms.line.completed", "Completed")
|
|
@@ -306,9 +309,8 @@ function programContent(o: { program: WixProgram; participant?: WixParticipant;
|
|
|
306
309
|
: standing === "suspended" ? copyParam("memberPrograms.line.suspended", "Your participation is paused")
|
|
307
310
|
: "";
|
|
308
311
|
// An invitation is accepted on the website (joinProgram cannot accept one), so an invited card's CTA is View.
|
|
309
|
-
// A
|
|
310
|
-
const actionLabel = !o.member &&
|
|
311
|
-
: !o.member && standing !== "none" ? copyParam("memberPrograms.action.view", "View")
|
|
312
|
+
// A guest is invited to join as well, as on the source card: the tap opens the program, which asks them to sign in.
|
|
313
|
+
const actionLabel = !o.member && standing !== "none" ? copyParam("memberPrograms.action.view", "View")
|
|
312
314
|
: display.card && joined ? copyParam("memberPrograms.action.continue", "Continue")
|
|
313
315
|
: limitReached ? copyParam("memberPrograms.action.full", "Program is full")
|
|
314
316
|
: joined || over || closed || standing === "pending" || standing === "invited" || standingUnknown ? copyParam("memberPrograms.action.view", "View")
|
|
@@ -333,8 +335,8 @@ function programContent(o: { program: WixProgram; participant?: WixParticipant;
|
|
|
333
335
|
hasProgress: started, noProgress: !started,
|
|
334
336
|
pricable: !joined && !over && !closed && !descriptionLine,
|
|
335
337
|
commercePrice, free: !commercePrice,
|
|
336
|
-
//
|
|
337
|
-
actionLabel, actionDisabled: limitReached
|
|
338
|
+
// A full program offers nobody a join; the card itself still opens the program.
|
|
339
|
+
actionLabel, actionDisabled: limitReached,
|
|
338
340
|
// A member in the program opens the participant page; everyone else the program page.
|
|
339
341
|
detailScreenId: programScreenFor(inProgram(standing, o.participant), DETAIL_SCREEN, PARTICIPANT_SCREEN),
|
|
340
342
|
categoryIds: categoryIdsOf(p),
|
|
@@ -617,7 +619,7 @@ export function registerProgramsSection(serviceName: string, options: ProgramsSe
|
|
|
617
619
|
|
|
618
620
|
const INITIAL_STATE: State = {
|
|
619
621
|
status: "loading", rows: [], isLoading: true, notLoading: false, isErrored: false, notErrored: true, noEmpty: true, hideList: true,
|
|
620
|
-
emptyText: "", errorText: "", identityLine: "", needsSignIn: false, noSignIn: true, nextCursor: "", noMore: true, noPageError: true, loadingMore: false,
|
|
622
|
+
emptyText: "", errorText: "", identityLine: "", needsSignIn: false, noSignIn: true, signInLabel: "", nextCursor: "", noMore: true, noPageError: true, loadingMore: false,
|
|
621
623
|
statusFilter: "all", statusOptions: [], hideStatusFilter: true, categoryId: "", categoryChips: [], hideCategoryFilter: true,
|
|
622
624
|
noSeeAll: true, hidePriceRetry: true, priceRetryText: "", summary: "", hasRows: false, noRows: true,
|
|
623
625
|
};
|
|
@@ -668,19 +670,20 @@ export function registerProgramsSection(serviceName: string, options: ProgramsSe
|
|
|
668
670
|
emptyText,
|
|
669
671
|
errorText: status === "error" ? (current?.error || copyParam("memberPrograms.errorText", "Programs could not be loaded.")) : "",
|
|
670
672
|
identityLine: meta.email ? copyTemplate("memberPrograms.identityLine", "Signed in as {email}", { email: meta.email ?? "" }) : "",
|
|
671
|
-
needsSignIn, noSignIn: !needsSignIn,
|
|
673
|
+
needsSignIn, noSignIn: !needsSignIn, signInLabel: copyParam("memberPrograms.signInCta", "Sign in"),
|
|
672
674
|
nextCursor: current && !current.pageError && !current.loadingMore ? current.nextCursor : "",
|
|
673
675
|
noMore: !current?.nextCursor || current.pageError || current.loadingMore,
|
|
674
676
|
noPageError: !current?.pageError,
|
|
675
677
|
loadingMore: !!current?.loadingMore,
|
|
676
678
|
statusFilter, statusOptions,
|
|
677
|
-
//
|
|
678
|
-
//
|
|
679
|
-
|
|
680
|
-
hideStatusFilter: options.filters?.status === false || (!member && statusFilter !== "joined"),
|
|
679
|
+
// The source's filter menu is shown to a guest too, also with one program: "Programs I joined" then asks them
|
|
680
|
+
// to sign in (needsSignIn). It stays up while a filter switch or a refresh reloads, so it never flickers away.
|
|
681
|
+
hideStatusFilter: options.filters?.status === false,
|
|
681
682
|
categoryId, categoryChips,
|
|
682
|
-
//
|
|
683
|
-
|
|
683
|
+
// A site with no categories still shows "All categories", as the source does. A section scoped to categories
|
|
684
|
+
// offers the ones the site still has: one (or none) left is the whole list, and choosing among one is not a
|
|
685
|
+
// filter. Unread categories offer nothing to pick.
|
|
686
|
+
hideCategoryFilter: options.filters?.category === false || categoriesFailed || !categories || (sectionCategories.length > 0 && categories.length <= 1),
|
|
684
687
|
// See all only for an inline (limited) list that has programs past the cards it shows.
|
|
685
688
|
noSeeAll: !(inlineLimit && status === "ready" && meta.more === true),
|
|
686
689
|
hidePriceRetry: status !== "ready" || !views.some((view) => view && view.route !== "disabled" && (scopeIncomplete || view.retryable)),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The merchant's ribbon on a product ("New", "Best Seller"…), on its own so a section that shows only tiles (products-section) reads it
|
|
2
|
+
// without the shop's sort, filter and saved-products code (himi-store-facets re-exports it).
|
|
3
|
+
import type { StoreProduct } from "./himi-store.js";
|
|
4
|
+
|
|
5
|
+
/** The ribbon the merchant set, whichever catalog answered: V3 `{ id, name }`, V1 a plain string. Read through a
|
|
6
|
+
* local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
|
|
7
|
+
export function ribbonText(p: StoreProduct): string {
|
|
8
|
+
const ribbon = (p as { ribbon?: unknown }).ribbon;
|
|
9
|
+
const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
|
|
10
|
+
return name.trim();
|
|
11
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// retitles them like any other worker string.
|
|
12
12
|
import { normalizeFormattedPrice, productImage, productOptions, productPrice, type StoreProduct } from "./himi-store.js";
|
|
13
13
|
import { readSavedProducts, toggleSavedProduct } from "./himi-store-saved.js";
|
|
14
|
+
import { ribbonText } from "./store-ribbon.js";
|
|
14
15
|
import { cleanTitle, initials } from "./himi-text.js";
|
|
15
16
|
import { copyParam, copyTemplate } from "./himi-copy.js";
|
|
16
17
|
import { formatCurrency } from "./engine-intl.js";
|
|
@@ -185,13 +186,7 @@ function swatchFields(hexes: string[], onSale: boolean) {
|
|
|
185
186
|
};
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
|
|
189
|
-
* local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
|
|
190
|
-
export function ribbonText(p: StoreProduct): string {
|
|
191
|
-
const ribbon = (p as { ribbon?: unknown }).ribbon;
|
|
192
|
-
const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
|
|
193
|
-
return name.trim();
|
|
194
|
-
}
|
|
189
|
+
export { ribbonText };
|
|
195
190
|
|
|
196
191
|
/** What the tag row (Sale tag, ribbon, swatches) shows. One rule for every screen that rebuilds it, including
|
|
197
192
|
* after the App Store presentation changes `onSale`: the ribbon wins over the Sale tag, so a product never
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The merchant's ribbon on a product ("New", "Best Seller"…), on its own so a section that shows only tiles (products-section) reads it
|
|
2
|
+
// without the shop's sort, filter and saved-products code (himi-store-facets re-exports it).
|
|
3
|
+
import type { StoreProduct } from "./himi-store.js";
|
|
4
|
+
|
|
5
|
+
/** The ribbon the merchant set, whichever catalog answered: V3 `{ id, name }`, V1 a plain string. Read through a
|
|
6
|
+
* local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
|
|
7
|
+
export function ribbonText(p: StoreProduct): string {
|
|
8
|
+
const ribbon = (p as { ribbon?: unknown }).ribbon;
|
|
9
|
+
const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
|
|
10
|
+
return name.trim();
|
|
11
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// retitles them like any other worker string.
|
|
12
12
|
import { normalizeFormattedPrice, productImage, productOptions, productPrice, type StoreProduct } from "./himi-store.js";
|
|
13
13
|
import { readSavedProducts, toggleSavedProduct } from "./himi-store-saved.js";
|
|
14
|
+
import { ribbonText } from "./store-ribbon.js";
|
|
14
15
|
import { cleanTitle, initials } from "./himi-text.js";
|
|
15
16
|
import { copyParam, copyTemplate } from "./himi-copy.js";
|
|
16
17
|
import { formatCurrency } from "./engine-intl.js";
|
|
@@ -185,13 +186,7 @@ function swatchFields(hexes: string[], onSale: boolean) {
|
|
|
185
186
|
};
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
|
|
189
|
-
* local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
|
|
190
|
-
export function ribbonText(p: StoreProduct): string {
|
|
191
|
-
const ribbon = (p as { ribbon?: unknown }).ribbon;
|
|
192
|
-
const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
|
|
193
|
-
return name.trim();
|
|
194
|
-
}
|
|
189
|
+
export { ribbonText };
|
|
195
190
|
|
|
196
191
|
/** What the tag row (Sale tag, ribbon, swatches) shows. One rule for every screen that rebuilds it, including
|
|
197
192
|
* after the App Store presentation changes `onSale`: the ribbon wins over the Sale tag, so a product never
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The merchant's ribbon on a product ("New", "Best Seller"…), on its own so a section that shows only tiles (products-section) reads it
|
|
2
|
+
// without the shop's sort, filter and saved-products code (himi-store-facets re-exports it).
|
|
3
|
+
import type { StoreProduct } from "./himi-store.js";
|
|
4
|
+
|
|
5
|
+
/** The ribbon the merchant set, whichever catalog answered: V3 `{ id, name }`, V1 a plain string. Read through a
|
|
6
|
+
* local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
|
|
7
|
+
export function ribbonText(p: StoreProduct): string {
|
|
8
|
+
const ribbon = (p as { ribbon?: unknown }).ribbon;
|
|
9
|
+
const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
|
|
10
|
+
return name.trim();
|
|
11
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// retitles them like any other worker string.
|
|
12
12
|
import { normalizeFormattedPrice, productImage, productOptions, productPrice, type StoreProduct } from "./himi-store.js";
|
|
13
13
|
import { readSavedProducts, toggleSavedProduct } from "./himi-store-saved.js";
|
|
14
|
+
import { ribbonText } from "./store-ribbon.js";
|
|
14
15
|
import { cleanTitle, initials } from "./himi-text.js";
|
|
15
16
|
import { copyParam, copyTemplate } from "./himi-copy.js";
|
|
16
17
|
import { formatCurrency } from "./engine-intl.js";
|
|
@@ -185,13 +186,7 @@ function swatchFields(hexes: string[], onSale: boolean) {
|
|
|
185
186
|
};
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
|
|
189
|
-
* local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
|
|
190
|
-
export function ribbonText(p: StoreProduct): string {
|
|
191
|
-
const ribbon = (p as { ribbon?: unknown }).ribbon;
|
|
192
|
-
const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
|
|
193
|
-
return name.trim();
|
|
194
|
-
}
|
|
189
|
+
export { ribbonText };
|
|
195
190
|
|
|
196
191
|
/** What the tag row (Sale tag, ribbon, swatches) shows. One rule for every screen that rebuilds it, including
|
|
197
192
|
* after the App Store presentation changes `onSale`: the ribbon wins over the Sale tag, so a product never
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The merchant's ribbon on a product ("New", "Best Seller"…), on its own so a section that shows only tiles (products-section) reads it
|
|
2
|
+
// without the shop's sort, filter and saved-products code (himi-store-facets re-exports it).
|
|
3
|
+
import type { StoreProduct } from "./himi-store.js";
|
|
4
|
+
|
|
5
|
+
/** The ribbon the merchant set, whichever catalog answered: V3 `{ id, name }`, V1 a plain string. Read through a
|
|
6
|
+
* local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
|
|
7
|
+
export function ribbonText(p: StoreProduct): string {
|
|
8
|
+
const ribbon = (p as { ribbon?: unknown }).ribbon;
|
|
9
|
+
const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
|
|
10
|
+
return name.trim();
|
|
11
|
+
}
|