@caartzee/theme-sdk 0.0.0-stage → 1.2.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.
Files changed (179) hide show
  1. package/README.md +222 -2
  2. package/dist/bin/caartzee-theme.js +9223 -0
  3. package/dist/lib/index.js +11614 -0
  4. package/dist/types/src/auth/credentials-store.d.ts +18 -0
  5. package/dist/types/src/auth/index.d.ts +2 -0
  6. package/dist/types/src/auth/oauth-client.d.ts +39 -0
  7. package/dist/types/src/blocks/block-contract.d.ts +242 -0
  8. package/dist/types/src/candy/compatibility-matrix.d.ts +10 -0
  9. package/dist/types/src/candy/context-builder.d.ts +31 -0
  10. package/dist/types/src/candy/engine.d.ts +69 -0
  11. package/dist/types/src/candy/filters.d.ts +32 -0
  12. package/dist/types/src/candy/ide-support.d.ts +20 -0
  13. package/dist/types/src/candy/index.d.ts +9 -0
  14. package/dist/types/src/candy/schema-parser.d.ts +13 -0
  15. package/dist/types/src/candy/security.d.ts +54 -0
  16. package/dist/types/src/candy/tags.d.ts +11 -0
  17. package/dist/types/src/candy/types.d.ts +185 -0
  18. package/dist/types/src/cli/caartzee-cli.d.ts +9 -0
  19. package/dist/types/src/cli/candy-mcp.d.ts +2 -0
  20. package/dist/types/src/cli/candy-tool-server.d.ts +39 -0
  21. package/dist/types/src/cli/index.d.ts +1 -0
  22. package/dist/types/src/cli/mcp/component-tools.d.ts +2 -0
  23. package/dist/types/src/cli/mcp/docs-tools.d.ts +89 -0
  24. package/dist/types/src/cli/mcp/editor-tools.d.ts +22 -0
  25. package/dist/types/src/cli/mcp/resources-and-prompts.d.ts +2 -0
  26. package/dist/types/src/cli/mcp/testing-tools.d.ts +54 -0
  27. package/dist/types/src/cli/sdk-client.d.ts +12 -0
  28. package/dist/types/src/contracts/category-selection.d.ts +15 -0
  29. package/dist/types/src/contracts/commerce.d.ts +282 -0
  30. package/dist/types/src/contracts/footer-builder.d.ts +125 -0
  31. package/dist/types/src/contracts/hooks.d.ts +37 -0
  32. package/dist/types/src/contracts/manifest.d.ts +3127 -0
  33. package/dist/types/src/contracts/navigation.d.ts +39 -0
  34. package/dist/types/src/contracts/order-tracking.d.ts +40 -0
  35. package/dist/types/src/contracts/page.d.ts +262 -0
  36. package/dist/types/src/contracts/storefront-content.d.ts +60 -0
  37. package/dist/types/src/contracts/style-document.d.ts +2 -0
  38. package/dist/types/src/contracts/styles.d.ts +2002 -0
  39. package/dist/types/src/contracts/theme.d.ts +35 -0
  40. package/dist/types/src/dev-server/catalog-preview.d.ts +25 -0
  41. package/dist/types/src/dev-server/dev-server.d.ts +25 -0
  42. package/dist/types/src/dev-server/index.d.ts +1 -0
  43. package/dist/types/src/dev-server/local-commerce-runtime.d.ts +76 -0
  44. package/dist/types/src/dev-server/local-editor-server.d.ts +22 -0
  45. package/dist/types/src/dev-server/theme-preview.d.ts +8 -0
  46. package/dist/types/src/index.d.ts +27 -0
  47. package/dist/types/src/mock/index.d.ts +10 -0
  48. package/dist/types/src/mock/mock-categories.d.ts +2 -0
  49. package/dist/types/src/mock/mock-commerce.d.ts +55 -0
  50. package/dist/types/src/mock/mock-customer.d.ts +47 -0
  51. package/dist/types/src/mock/mock-hooks.d.ts +2 -0
  52. package/dist/types/src/mock/mock-products.d.ts +3 -0
  53. package/dist/types/src/rendering/commerce-pages.d.ts +16 -0
  54. package/dist/types/src/rendering/raw-html.d.ts +12 -0
  55. package/dist/types/src/rendering/section-wrapper.d.ts +30 -0
  56. package/dist/types/src/scaffold/candy-starter-assets.d.ts +2 -0
  57. package/dist/types/src/scaffold/commerce-generator.d.ts +3 -0
  58. package/dist/types/src/scaffold/index.d.ts +2 -0
  59. package/dist/types/src/scaffold/template-generator.d.ts +21 -0
  60. package/dist/types/src/sections/section-contract.d.ts +350 -0
  61. package/dist/types/src/settings/global-settings.d.ts +25 -0
  62. package/dist/types/src/templates/json-template.d.ts +991 -0
  63. package/dist/types/src/validation/package-validator.d.ts +53 -0
  64. package/dist/types/src/validation/rich-text.d.ts +24 -0
  65. package/package.json +29 -3
  66. package/templates/commerce/README.md +165 -0
  67. package/templates/commerce/assets/theme.css +1 -0
  68. package/templates/commerce/manifest.json +1 -0
  69. package/templates/commerce/src/blocks/index.ts +184 -0
  70. package/templates/commerce/src/config/settings-defaults.ts +25 -0
  71. package/templates/commerce/src/config/settings-schema.ts +102 -0
  72. package/templates/commerce/src/index.ts +90 -0
  73. package/templates/commerce/src/layouts/default.ts +275 -0
  74. package/templates/commerce/src/manifest.ts +976 -0
  75. package/templates/commerce/src/pages/account/components.ts +369 -0
  76. package/templates/commerce/src/pages/account/tabs.ts +792 -0
  77. package/templates/commerce/src/pages/account.ts +55 -0
  78. package/templates/commerce/src/pages/campaign.ts +423 -0
  79. package/templates/commerce/src/pages/cart.ts +261 -0
  80. package/templates/commerce/src/pages/category-detail.ts +124 -0
  81. package/templates/commerce/src/pages/category-list.ts +87 -0
  82. package/templates/commerce/src/pages/checkout.ts +712 -0
  83. package/templates/commerce/src/pages/commerce.ts +45 -0
  84. package/templates/commerce/src/pages/home.ts +160 -0
  85. package/templates/commerce/src/pages/index.ts +99 -0
  86. package/templates/commerce/src/pages/login.ts +204 -0
  87. package/templates/commerce/src/pages/order-success.ts +80 -0
  88. package/templates/commerce/src/pages/product-detail.ts +489 -0
  89. package/templates/commerce/src/pages/product-list.ts +125 -0
  90. package/templates/commerce/src/pages/search.ts +88 -0
  91. package/templates/commerce/src/pages/signup.ts +253 -0
  92. package/templates/commerce/src/pages/status.ts +7 -0
  93. package/templates/commerce/src/pages/theme-layout.ts +491 -0
  94. package/templates/commerce/src/pages/track-order.ts +196 -0
  95. package/templates/commerce/src/pages/wishlist.ts +83 -0
  96. package/templates/commerce/src/sections/about-story.ts +117 -0
  97. package/templates/commerce/src/sections/announcement-bar.ts +101 -0
  98. package/templates/commerce/src/sections/banner-grid.ts +319 -0
  99. package/templates/commerce/src/sections/campaign-banners.ts +158 -0
  100. package/templates/commerce/src/sections/category-slider.ts +144 -0
  101. package/templates/commerce/src/sections/content-builder.ts +123 -0
  102. package/templates/commerce/src/sections/content-controls.ts +45 -0
  103. package/templates/commerce/src/sections/custom-form.ts +59 -0
  104. package/templates/commerce/src/sections/faq-accordion.ts +123 -0
  105. package/templates/commerce/src/sections/footer.ts +728 -0
  106. package/templates/commerce/src/sections/header.ts +439 -0
  107. package/templates/commerce/src/sections/hero-slider.ts +492 -0
  108. package/templates/commerce/src/sections/hero.ts +137 -0
  109. package/templates/commerce/src/sections/index.ts +102 -0
  110. package/templates/commerce/src/sections/mobile-slider.ts +102 -0
  111. package/templates/commerce/src/sections/newsletter.ts +43 -0
  112. package/templates/commerce/src/sections/product-grid.ts +191 -0
  113. package/templates/commerce/src/sections/raw-html.ts +1 -0
  114. package/templates/commerce/src/sections/rich-text.ts +26 -0
  115. package/templates/commerce/src/sections/services-features.ts +211 -0
  116. package/templates/commerce/src/sections/testimonials.ts +194 -0
  117. package/templates/commerce/src/snippets/product-card.ts +178 -0
  118. package/templates/commerce/src/snippets/product-price.ts +46 -0
  119. package/templates/commerce/src/snippets/responsive-image.ts +29 -0
  120. package/templates/commerce/src/styles.ts +477 -0
  121. package/templates/commerce/src/templates/404.json +26 -0
  122. package/templates/commerce/src/templates/account.json +17 -0
  123. package/templates/commerce/src/templates/cart.json +17 -0
  124. package/templates/commerce/src/templates/category.json +16 -0
  125. package/templates/commerce/src/templates/checkout.json +15 -0
  126. package/templates/commerce/src/templates/collection.json +16 -0
  127. package/templates/commerce/src/templates/index.json +180 -0
  128. package/templates/commerce/src/templates/login.json +17 -0
  129. package/templates/commerce/src/templates/order-success.json +17 -0
  130. package/templates/commerce/src/templates/page.json +17 -0
  131. package/templates/commerce/src/templates/product.json +17 -0
  132. package/templates/commerce/src/templates/search.json +18 -0
  133. package/templates/commerce/src/templates/signup.json +17 -0
  134. package/templates/commerce/src/templates/track-order.json +17 -0
  135. package/templates/commerce/src/templates/wishlist.json +17 -0
  136. package/templates/commerce/src/templates.ts +510 -0
  137. package/templates/commerce/src/tokens.ts +22 -0
  138. package/templates/theme-candy-boilerplate/.editorconfig +14 -0
  139. package/templates/theme-candy-boilerplate/.gitattributes +1 -0
  140. package/templates/theme-candy-boilerplate/.vscode/extensions.json +7 -0
  141. package/templates/theme-candy-boilerplate/.vscode/settings.json +17 -0
  142. package/templates/theme-candy-boilerplate/assets/theme.css +78 -0
  143. package/templates/theme-candy-boilerplate/assets/theme.js +7 -0
  144. package/templates/theme-candy-boilerplate/candy.config.json +40 -0
  145. package/templates/theme-candy-boilerplate/index.ts +39 -0
  146. package/templates/theme-candy-boilerplate/layout/theme.candy +25 -0
  147. package/templates/theme-candy-boilerplate/locales/en.default.json +37 -0
  148. package/templates/theme-candy-boilerplate/manifest.json +123 -0
  149. package/templates/theme-candy-boilerplate/package.json +16 -0
  150. package/templates/theme-candy-boilerplate/schemas/settings_schema.json +36 -0
  151. package/templates/theme-candy-boilerplate/sections/featured-products.candy +89 -0
  152. package/templates/theme-candy-boilerplate/sections/footer.candy +50 -0
  153. package/templates/theme-candy-boilerplate/sections/header.candy +116 -0
  154. package/templates/theme-candy-boilerplate/sections/hero-banner.candy +135 -0
  155. package/templates/theme-candy-boilerplate/sections/image-with-text.candy +85 -0
  156. package/templates/theme-candy-boilerplate/snippets/price.candy +19 -0
  157. package/templates/theme-candy-boilerplate/snippets/product-card.candy +43 -0
  158. package/templates/theme-candy-boilerplate/templates/404.candy +12 -0
  159. package/templates/theme-candy-boilerplate/templates/cart.candy +51 -0
  160. package/templates/theme-candy-boilerplate/templates/collection.candy +51 -0
  161. package/templates/theme-candy-boilerplate/templates/index.candy +7 -0
  162. package/templates/theme-candy-boilerplate/templates/page.candy +10 -0
  163. package/templates/theme-candy-boilerplate/templates/product.candy +59 -0
  164. package/templates/theme-candy-boilerplate/templates/search.candy +40 -0
  165. package/templates/vscode-candy/LICENSE +21 -0
  166. package/templates/vscode-candy/README.md +22 -0
  167. package/templates/vscode-candy/extension.js +689 -0
  168. package/templates/vscode-candy/icons/candy-dark.svg +23 -0
  169. package/templates/vscode-candy/icons/candy-light.svg +23 -0
  170. package/templates/vscode-candy/icons/candy-logo.png +0 -0
  171. package/templates/vscode-candy/icons/candy-sweet-dark.svg +23 -0
  172. package/templates/vscode-candy/icons/candy-sweet-light.svg +23 -0
  173. package/templates/vscode-candy/language-configuration.json +47 -0
  174. package/templates/vscode-candy/package.json +118 -0
  175. package/templates/vscode-candy/schemas/candy-config.schema.json +56 -0
  176. package/templates/vscode-candy/schemas/candy-settings.schema.json +70 -0
  177. package/templates/vscode-candy/snippets/candy.code-snippets +270 -0
  178. package/templates/vscode-candy/syntaxes/candy.tmLanguage.json +296 -0
  179. package/templates/vscode-candy/vim/ftdetect/candy.vim +5 -0
@@ -0,0 +1,261 @@
1
+ import type { CartPageData } from '@caartzee/theme-sdk';
2
+ import { resolveCheckoutItemImageUrl, DEFAULT_PRODUCT_PLACEHOLDER } from './checkout';
3
+ import { getThemePageProfile } from './theme-layout';
4
+
5
+ function escapeHtml(str: any): string {
6
+ return String(str ?? '')
7
+ .replace(/&/g, '&')
8
+ .replace(/</g, '&lt;')
9
+ .replace(/>/g, '&gt;')
10
+ .replace(/"/g, '&quot;')
11
+ .replace(/'/g, '&#039;');
12
+ }
13
+
14
+ /**
15
+ * Starter Theme - Shopping Cart Page (Tailwind CSS Edition)
16
+ *
17
+ * Features:
18
+ * - Clean responsive 2-column layout (items left, summary right)
19
+ * - Individual item cards with remove hook (.js-remove-cart-item)
20
+ * - Sticky order summary with checkout CTA
21
+ */
22
+ export function renderBoilerplateCartPage(data: CartPageData): string {
23
+ const currencySymbol = data.currencyInfo?.symbol || '$';
24
+ const rawCart = data.cart;
25
+ const cartObj = rawCart?.cart || rawCart?.data?.cart || rawCart?.data || rawCart || {};
26
+ const items = Array.isArray(cartObj.items) ? cartObj.items : (Array.isArray(rawCart?.items) ? rawCart.items : []);
27
+
28
+ let calculatedSubtotal = 0;
29
+ let calculatedOriginalSubtotal = 0;
30
+ let calculatedSavings = 0;
31
+ let hasCampaignItem = false;
32
+ for (const it of items) {
33
+ const qty = Number(it.quantity || it.qty || 1);
34
+ const price = Number(it.price || 0);
35
+ const compareAt = Number(it.originalPrice || it.original_price || it.compareAtPrice || it.compare_at_price || price);
36
+ calculatedSubtotal += price * qty;
37
+ if (compareAt > price) {
38
+ calculatedOriginalSubtotal += compareAt * qty;
39
+ calculatedSavings += (compareAt - price) * qty;
40
+ } else {
41
+ calculatedOriginalSubtotal += price * qty;
42
+ }
43
+
44
+ const cName = String(it.campaignName || it.campaign_name || '').trim();
45
+ const isCampBadge = /^\d+%\s*off$/i.test(cName) || cName.toLowerCase() === 'sale' || cName.toLowerCase() === 'new';
46
+ if (it.campaignId || it.campaign_id || it.isCampaign || it.is_campaign || (cName && !isCampBadge)) {
47
+ hasCampaignItem = true;
48
+ }
49
+ }
50
+ const subtotal = Number(cartObj.subtotal ?? cartObj.total ?? calculatedSubtotal);
51
+ const originalSubtotal = Number(cartObj.originalSubtotal ?? cartObj.original_subtotal ?? calculatedOriginalSubtotal);
52
+ const totalSavings = Number(cartObj.totalDiscount ?? cartObj.total_discount ?? calculatedSavings);
53
+ const hasSavings = totalSavings > 0 || originalSubtotal > subtotal;
54
+
55
+ const formattedSubtotal = `${currencySymbol}${subtotal.toFixed(2)}`;
56
+ const formattedOriginalSubtotal = `${currencySymbol}${originalSubtotal.toFixed(2)}`;
57
+ const formattedSavings = `${currencySymbol}${totalSavings.toFixed(2)}`;
58
+ const themeSlug = (data as any).themeSlug as string | undefined;
59
+ const profile = getThemePageProfile(themeSlug);
60
+ const isReversed = profile.slug === 'apex';
61
+
62
+ return `
63
+ <section class="sf-boilerplate-cart min-h-[calc(100vh-80px)] py-12 lg:py-16 bg-[var(--sf-color-bg)]">
64
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
65
+
66
+ ${profile.checkoutBannerHtml}
67
+
68
+ <!-- Page Title & Stepper Header -->
69
+ <div class="mb-10 pb-6 border-b border-[var(--sf-color-border)] flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
70
+ <div>
71
+ <h1 class="text-3xl ${profile.headingStyleClass} text-[var(--sf-color-text)] font-heading">
72
+ Your Shopping Bag
73
+ </h1>
74
+ <p class="text-sm text-[var(--sf-color-text-muted)] mt-1">
75
+ ${items.length} ${items.length === 1 ? 'item' : 'items'} in your active session
76
+ </p>
77
+ </div>
78
+ <a href="/products" class="inline-flex items-center gap-2 text-sm font-semibold text-[var(--sf-color-primary)] hover:underline">
79
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M15 19l-7-7 7-7" /></svg>
80
+ Continue Shopping
81
+ </a>
82
+ </div>
83
+
84
+ ${items.length > 0 ? `
85
+ <div class="grid grid-cols-1 lg:grid-cols-12 gap-8 lg:gap-12 items-start">
86
+
87
+ <!-- Items List (Left Column) -->
88
+ <div class="lg:col-span-8 ${isReversed ? 'lg:order-2' : ''} bg-[var(--sf-color-surface)] ${profile.cardRadiusClass} border border-[var(--sf-color-border)] shadow-sm overflow-hidden p-6 sm:p-8">
89
+ <div class="divide-y divide-[var(--sf-color-border)]">
90
+ ${items.map((it: any) => {
91
+ const id = it.productId || it.product_id || it.id;
92
+ const name = it.name || it.title || 'Product';
93
+ const price = Number(it.price || 0);
94
+ const compareAt = Number(it.originalPrice || it.original_price || it.compareAtPrice || it.compare_at_price || price);
95
+ const hasItemDiscount = compareAt > price;
96
+ const discountPercent = it.discountPercentage || it.discount_percentage || (hasItemDiscount ? Math.round(((compareAt - price) / compareAt) * 100) : 0);
97
+ const rawCampName = it.campaignName || it.campaign_name || '';
98
+ const isCampBadge = /^\d+%\s*off$/i.test(rawCampName) || rawCampName.toLowerCase() === 'sale' || rawCampName.toLowerCase() === 'new';
99
+ const campaignName = !isCampBadge ? rawCampName : '';
100
+ const qty = Number(it.quantity || it.qty || 1);
101
+ const variant = it.variantId || it.variant_id || it.options?.variant_id || '';
102
+ const rawImg = it.imageUrl || it.image || it.img_url || it.image_url || it.options?.image || it.product?.imageUrl || it.product?.image || '';
103
+ const image = resolveCheckoutItemImageUrl(rawImg, (data as any).tenantId);
104
+ const lineTotal = `${currencySymbol}${(price * qty).toFixed(2)}`;
105
+ const originalLineTotal = `${currencySymbol}${(compareAt * qty).toFixed(2)}`;
106
+
107
+ return `
108
+ <div class="py-6 first:pt-0 last:pb-0 flex flex-col sm:flex-row gap-5 items-start sm:items-center justify-between">
109
+ <div class="flex items-center gap-4 flex-1 min-w-0">
110
+ <img
111
+ src="${escapeHtml(image)}"
112
+ alt="${escapeHtml(name)}"
113
+ onerror="this.onerror=null;this.src='${DEFAULT_PRODUCT_PLACEHOLDER}';"
114
+ class="w-20 h-20 sm:w-24 sm:h-24 object-cover ${profile.cardRadiusClass} bg-[var(--sf-color-bg)] border border-[var(--sf-color-border)] shrink-0"
115
+ loading="lazy"
116
+ />
117
+ <div class="min-w-0 flex-1">
118
+ <h3 class="text-base font-bold text-[var(--sf-color-text)] truncate">
119
+ ${escapeHtml(name)}
120
+ </h3>
121
+ <div class="flex items-center gap-2 flex-wrap mt-1">
122
+ <span class="text-sm font-semibold text-[var(--sf-color-text)]">
123
+ ${currencySymbol}${price.toFixed(2)}
124
+ </span>
125
+ ${hasItemDiscount ? `
126
+ <span class="text-xs text-[var(--sf-color-text-muted)] line-through">
127
+ ${currencySymbol}${compareAt.toFixed(2)}
128
+ </span>
129
+ ` : ''}
130
+ ${discountPercent > 0 ? `
131
+ <span class="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-bold bg-rose-500/10 text-rose-600 border border-rose-500/20">
132
+ ${discountPercent}% OFF
133
+ </span>
134
+ ` : ''}
135
+ ${campaignName ? `
136
+ <span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-500/10 text-amber-700 border border-amber-500/20">
137
+ ⚡ ${escapeHtml(campaignName)}
138
+ </span>
139
+ ` : ''}
140
+ </div>
141
+ <div class="mt-2 inline-flex items-center px-2.5 py-1 ${profile.buttonRadiusClass} bg-[var(--sf-color-bg)] border border-[var(--sf-color-border)] text-xs font-semibold text-[var(--sf-color-text)]">
142
+ <button type="button" class="js-cart-qty-btn cursor-pointer" data-product-id="${escapeHtml(String(id))}" data-variant-id="${escapeHtml(String(variant))}" data-qty="${qty}" data-action="decrease" aria-label="Decrease quantity" ${qty<=1?'disabled':''}>−</button><span style="padding:0 12px">${qty}</span><button type="button" class="js-cart-qty-btn cursor-pointer" data-product-id="${escapeHtml(String(id))}" data-variant-id="${escapeHtml(String(variant))}" data-qty="${qty}" data-action="increase" aria-label="Increase quantity">+</button>
143
+ </div>
144
+ </div>
145
+ </div>
146
+
147
+ <div class="flex sm:flex-col items-center sm:items-end justify-between w-full sm:w-auto gap-1 pt-2 sm:pt-0 border-t sm:border-t-0 border-[var(--sf-color-border)]">
148
+ <span class="text-lg font-black text-[var(--sf-color-text)]">
149
+ ${escapeHtml(lineTotal)}
150
+ </span>
151
+ ${hasItemDiscount ? `
152
+ <span class="text-xs text-[var(--sf-color-text-muted)] line-through">
153
+ ${escapeHtml(originalLineTotal)}
154
+ </span>
155
+ ` : ''}
156
+
157
+ <!-- Remove button calling BFF Island proxy -->
158
+ <button
159
+ type="button"
160
+ class="text-xs font-semibold text-rose-500 hover:text-rose-600 hover:underline flex items-center gap-1 cursor-pointer js-remove-cart-item mt-1 sm:mt-2"
161
+ data-product-id="${escapeHtml(String(id))}"
162
+ data-variant-id="${escapeHtml(String(variant))}"
163
+ title="Remove item"
164
+ >
165
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg>
166
+ Remove
167
+ </button>
168
+ </div>
169
+ </div>
170
+ `;
171
+ }).join('')}
172
+ </div>
173
+ </div>
174
+
175
+ <!-- Sticky Order Summary Card (Right Column) -->
176
+ <div class="lg:col-span-4 ${isReversed ? 'lg:order-1' : ''} bg-[var(--sf-color-surface)] ${profile.cardRadiusClass} border border-[var(--sf-color-border)] shadow-sm p-6 sm:p-8 sticky top-24">
177
+ <h2 class="text-lg font-bold tracking-tight text-[var(--sf-color-text)] font-heading mb-6">
178
+ Order Summary
179
+ </h2>
180
+
181
+ <div class="space-y-4 text-sm text-[var(--sf-color-text-muted)] mb-6 pb-6 border-b border-[var(--sf-color-border)]">
182
+ ${hasSavings ? `
183
+ <div class="flex justify-between text-[var(--sf-color-text-muted)]">
184
+ <span>Original Price</span>
185
+ <span class="line-through">${escapeHtml(formattedOriginalSubtotal)}</span>
186
+ </div>
187
+ <div class="flex justify-between font-semibold text-emerald-600">
188
+ <span class="flex items-center gap-1">
189
+ <span>${hasCampaignItem ? '⚡ Promotional Savings' : 'Savings'}</span>
190
+ </span>
191
+ <span>-${escapeHtml(formattedSavings)}</span>
192
+ </div>
193
+ ` : ''}
194
+ <div class="flex justify-between">
195
+ <span>Subtotal</span>
196
+ <span class="font-bold text-[var(--sf-color-text)]">${escapeHtml(formattedSubtotal)}</span>
197
+ </div>
198
+ <div class="flex justify-between">
199
+ <span>Shipping Estimation</span>
200
+ <span class="font-semibold text-emerald-600">Calculated next step</span>
201
+ </div>
202
+ <div class="flex justify-between">
203
+ <span>Taxes</span>
204
+ <span class="text-[var(--sf-color-text-muted)]">Calculated next step</span>
205
+ </div>
206
+ </div>
207
+
208
+ ${hasSavings ? `
209
+ <div class="mb-6 p-3.5 ${profile.cardRadiusClass} bg-emerald-50 border border-emerald-200 text-xs text-emerald-800 flex items-center gap-2 font-medium">
210
+ <span class="text-base">🎉</span>
211
+ <span>You're saving <strong>${escapeHtml(formattedSavings)}</strong> on this order${hasCampaignItem ? ' with promotional pricing' : ''}!</span>
212
+ </div>
213
+ ` : ''}
214
+
215
+ <div class="flex justify-between items-center text-lg font-black text-[var(--sf-color-text)] mb-6">
216
+ <span>Estimated Total</span>
217
+ <span class="text-[var(--sf-color-primary)]">${escapeHtml(formattedSubtotal)}</span>
218
+ </div>
219
+
220
+ <a
221
+ href="/checkout"
222
+ class="sf-btn sf-btn--primary w-full py-4 px-6 ${profile.buttonRadiusClass} bg-[var(--sf-color-primary)] hover:bg-[var(--sf-color-secondary)] active:scale-95 text-[var(--sf-color-primary-text)] hover:text-white font-bold text-sm shadow-md transition-all text-center flex items-center justify-center gap-2"
223
+ >
224
+ <span>Proceed to Checkout</span>
225
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path d="M14 5l7 7m0 0l-7 7m7-7H3" /></svg>
226
+ </a>
227
+
228
+ <div class="mt-6 flex items-center justify-center gap-2 text-xs text-[var(--sf-color-text-muted)]">
229
+ <svg class="w-4 h-4 text-[var(--sf-color-primary)]" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" /></svg>
230
+ <span>Encrypted 256-bit SSL Checkout</span>
231
+ </div>
232
+ </div>
233
+
234
+ </div>
235
+ ` : `
236
+ <!-- Empty Cart State -->
237
+ <div class="max-w-md mx-auto text-center py-20 px-6 bg-[var(--sf-color-surface)] ${profile.cardRadiusClass} border border-[var(--sf-color-border)] shadow-sm">
238
+ <div class="w-20 h-20 rounded-full bg-[var(--sf-color-bg)] border border-[var(--sf-color-border)] text-[var(--sf-color-primary)] mx-auto flex items-center justify-center mb-6">
239
+ <svg class="w-10 h-10" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24">
240
+ <path d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" />
241
+ </svg>
242
+ </div>
243
+ <h2 class="text-2xl font-bold tracking-tight text-[var(--sf-color-text)] font-heading mb-2">
244
+ Your bag is currently empty
245
+ </h2>
246
+ <p class="text-sm text-[var(--sf-color-text-muted)] mb-8 max-w-sm mx-auto leading-relaxed">
247
+ Explore our newest arrivals and trending essentials to discover items that suit your taste.
248
+ </p>
249
+ <a
250
+ href="/products"
251
+ class="sf-btn sf-btn--primary inline-flex items-center justify-center px-8 py-3.5 ${profile.buttonRadiusClass} bg-[var(--sf-color-primary)] hover:bg-[var(--sf-color-secondary)] active:scale-95 text-[var(--sf-color-primary-text)] hover:text-white font-bold text-sm shadow-md transition-all"
252
+ >
253
+ Explore Products
254
+ </a>
255
+ </div>
256
+ `}
257
+
258
+ </div>
259
+ </section>
260
+ `;
261
+ }
@@ -0,0 +1,124 @@
1
+ import type { CategoryDetailPageData, StorefrontProduct } from '@caartzee/theme-sdk';
2
+ import { getThemePageProfile } from './theme-layout';
3
+
4
+ function escapeHtml(str: string | null | undefined): string {
5
+ if (!str) return '';
6
+ return String(str)
7
+ .replace(/&/g, '&amp;')
8
+ .replace(/</g, '&lt;')
9
+ .replace(/>/g, '&gt;')
10
+ .replace(/"/g, '&quot;')
11
+ .replace(/'/g, '&#39;');
12
+ }
13
+
14
+ /**
15
+ * Starter Theme — Category Detail Page (Tailwind CSS Edition)
16
+ * Themed category header + responsive product grid, with pagination.
17
+ */
18
+ export function renderBoilerplateCategoryDetailPage(data: CategoryDetailPageData): string {
19
+ const { category, products = [], pagination, categories = [] } = data;
20
+ const isCollectionRoute = Boolean(data.collectionPath?.startsWith('/collection'));
21
+ const parentHref = isCollectionRoute ? '/collections' : '/categories';
22
+ const parentTitle = isCollectionRoute ? 'All Collections' : 'All Categories';
23
+ const childLinks=(data.subcategories || []).map(sub=>`<a href="${parentHref}/${encodeURIComponent(String(category.id))}/${encodeURIComponent(String(sub.id))}">${escapeHtml(sub.name)}</a>`).join(' · ');
24
+ const name = category?.name || (isCollectionRoute ? 'Collection' : 'Category');
25
+ const description = category?.description || '';
26
+ const count = pagination?.totalItems ?? products.length;
27
+ const themeSlug = (data as any).themeSlug as string | undefined;
28
+ const profile = getThemePageProfile(themeSlug);
29
+
30
+ const productCard = (p: StorefrontProduct) => {
31
+ const slug = p.slug || String(p.id ?? '');
32
+ const hasPrice = p.price != null || p.salePrice != null;
33
+ const priceLabel = p.priceFormatted || p.formattedPrice || String(p.price ?? '');
34
+ const img =
35
+ p.imageUrl ||
36
+ (Array.isArray((p as any).images) && (p as any).images[0]) ||
37
+ 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&auto=format&fit=crop&q=80';
38
+
39
+ return `
40
+ <a
41
+ href="/products/${encodeURIComponent(slug)}"
42
+ class="group flex flex-col ${profile.cardRadiusClass} bg-[var(--sf-color-surface)] border border-[var(--sf-color-border)] overflow-hidden hover:shadow-lg hover:-translate-y-1 transition-all duration-300"
43
+ >
44
+ <div class="aspect-square overflow-hidden bg-[var(--sf-color-bg)] relative">
45
+ <img
46
+ src="${escapeHtml(img)}"
47
+ alt="${escapeHtml(p.name || p.title)}"
48
+ class="w-full h-full object-cover object-center group-hover:scale-105 transition-transform duration-500 ease-out"
49
+ loading="lazy"
50
+ />
51
+ </div>
52
+ <div class="p-4 flex flex-col gap-1">
53
+ <h3 class="text-sm font-semibold text-[var(--sf-color-text)] group-hover:text-[var(--sf-color-primary)] transition-colors line-clamp-2">
54
+ ${escapeHtml(p.name || p.title)}
55
+ </h3>
56
+ ${hasPrice && priceLabel ? `<span class="text-sm font-bold text-[var(--sf-color-text)]">${escapeHtml(priceLabel)}</span>` : ''}
57
+ </div>
58
+ </a>
59
+ `;
60
+ };
61
+
62
+ const canPrev = (pagination?.currentPage ?? 1) > 1;
63
+ const canNext = (pagination?.currentPage ?? 1) < (pagination?.totalPages ?? 1);
64
+
65
+ return `
66
+ <section class="sf-boilerplate-category-detail min-h-[calc(100vh-80px)] py-12 lg:py-16 bg-[var(--sf-color-bg)]">
67
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
68
+
69
+ ${profile.plpBannerHtml}
70
+
71
+ <!-- Category Header -->
72
+ <div class="flex flex-col gap-2 mb-10">
73
+ ${
74
+ categories.length > 0
75
+ ? `
76
+ <nav class="text-xs text-[var(--sf-color-text-muted)] flex items-center gap-2 mb-3">
77
+ <a href="${parentHref}" class="hover:text-[var(--sf-color-primary)]">${parentTitle}</a>
78
+ <span>/</span>
79
+ <span class="text-[var(--sf-color-text)] font-medium">${escapeHtml(name)}</span>
80
+ </nav>
81
+ `
82
+ : ''
83
+ }
84
+ <h1 class="text-3xl sm:text-4xl ${profile.headingStyleClass} text-[var(--sf-color-text)] font-heading">
85
+ ${escapeHtml(name)}
86
+ </h1>
87
+ ${description ? `<p class="text-base sm:text-lg text-[var(--sf-color-text-muted)] max-w-2xl">${escapeHtml(description)}</p>` : ''}
88
+ <span class="text-xs font-semibold text-[var(--sf-color-text-muted)] mt-1">${count} Products</span>
89
+ </div>
90
+
91
+ ${childLinks ? `<nav aria-label="Subcategories" style="margin-bottom:24px">${childLinks}</nav>` : ''}
92
+ ${
93
+ products.length > 0
94
+ ? `
95
+ <div class="grid ${profile.plpGridClass}">
96
+ ${products.map((p) => productCard(p)).join('')}
97
+ </div>
98
+ `
99
+ : `
100
+ <div class="text-center py-20 bg-[var(--sf-color-surface)] ${profile.cardRadiusClass} border border-[var(--sf-color-border)]">
101
+ <p class="text-[var(--sf-color-text-muted)]">No products in this category yet.</p>
102
+ <a href="/products" class="inline-block mt-4 text-sm font-semibold text-[var(--sf-color-primary)] hover:underline">Browse all products</a>
103
+ </div>
104
+ `
105
+ }
106
+
107
+ ${(canPrev || canNext) && products.length > 0 ? `
108
+ <div class="flex items-center justify-center gap-3 mt-10">
109
+ ${
110
+ canPrev
111
+ ? `<a href="${escapeHtml(data.collectionPath || '/categories/'+encodeURIComponent(category?.slug || name))}?page=${(pagination?.currentPage ?? 1) - 1}" class="px-4 py-2 ${profile.buttonRadiusClass} text-xs font-semibold border border-[var(--sf-color-border)] bg-[var(--sf-color-surface)] text-[var(--sf-color-text)] hover:border-[var(--sf-color-primary)]">← Previous</a>`
112
+ : ''
113
+ }
114
+ ${
115
+ canNext
116
+ ? `<a href="${escapeHtml(data.collectionPath || '/categories/'+encodeURIComponent(category?.slug || name))}?page=${(pagination?.currentPage ?? 1) + 1}" class="px-4 py-2 ${profile.buttonRadiusClass} text-xs font-semibold bg-[var(--sf-color-primary)] text-[var(--sf-color-primary-text)] hover:opacity-90">Next →</a>`
117
+ : ''
118
+ }
119
+ </div>
120
+ ` : ''}
121
+ </div>
122
+ </section>
123
+ `;
124
+ }
@@ -0,0 +1,87 @@
1
+ import type { CategoryListPageData, StorefrontCategory } from '@caartzee/theme-sdk';
2
+ import { getThemePageProfile } from './theme-layout';
3
+
4
+ function escapeHtml(str: string): string {
5
+ return str
6
+ .replace(/&/g, '&amp;')
7
+ .replace(/</g, '&lt;')
8
+ .replace(/>/g, '&gt;')
9
+ .replace(/"/g, '&quot;')
10
+ .replace(/'/g, '&#039;');
11
+ }
12
+
13
+ /**
14
+ * Starter Theme - Categories Showcase Page (Tailwind CSS Edition)
15
+ */
16
+ export function renderBoilerplateCategoryListPage(data: CategoryListPageData): string {
17
+ const categories = data.categories || [];
18
+ const isCollections = Boolean(data.isCollections || data.collectionPath?.startsWith('/collection'));
19
+ const heading = isCollections ? 'Browse All Collections' : 'Browse All Categories';
20
+ const subtitle = isCollections
21
+ ? 'Explore curated collections and departments crafted for modern living.'
22
+ : 'Explore curated categories and departments crafted for modern living.';
23
+ const itemBaseHref = isCollections ? '/collections' : '/categories';
24
+ const themeSlug = (data as any).themeSlug as string | undefined;
25
+ const profile = getThemePageProfile(themeSlug);
26
+
27
+ return `
28
+ <section class="sf-boilerplate-categories min-h-[calc(100vh-80px)] py-12 lg:py-16 bg-[var(--sf-color-bg)]">
29
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
30
+
31
+ ${profile.plpBannerHtml}
32
+
33
+ <!-- Header -->
34
+ <div class="text-center max-w-2xl mx-auto mb-14">
35
+ <h1 class="text-3xl sm:text-4xl ${profile.headingStyleClass} text-[var(--sf-color-text)] font-heading mb-3">
36
+ ${escapeHtml(heading)}
37
+ </h1>
38
+ <p class="text-base sm:text-lg text-[var(--sf-color-text-muted)]">
39
+ ${escapeHtml(subtitle)}
40
+ </p>
41
+ </div>
42
+
43
+ ${categories.length > 0 ? `
44
+ <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 sm:gap-8">
45
+ ${categories.map((c: StorefrontCategory) => {
46
+ const imageUrl = c.imageUrl || 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&auto=format&fit=crop&q=80';
47
+
48
+ return `
49
+ <a
50
+ href="${itemBaseHref}/${encodeURIComponent(c.slug)}"
51
+ class="group flex flex-col ${profile.cardRadiusClass} bg-[var(--sf-color-surface)] border border-[var(--sf-color-border)] shadow-sm hover:shadow-xl hover:-translate-y-1.5 transition-all duration-300 overflow-hidden"
52
+ >
53
+ <div class="aspect-[16/10] overflow-hidden bg-[var(--sf-color-bg)] relative">
54
+ <img
55
+ src="${escapeHtml(imageUrl)}"
56
+ alt="${escapeHtml(c.name)}"
57
+ class="w-full h-full object-cover object-center group-hover:scale-105 transition-transform duration-500 ease-out"
58
+ loading="lazy"
59
+ />
60
+ </div>
61
+ <div class="p-6 flex items-center justify-between">
62
+ <div>
63
+ <h3 class="text-lg font-bold text-[var(--sf-color-text)] group-hover:text-[var(--sf-color-primary)] transition-colors">
64
+ ${escapeHtml(c.name)}
65
+ </h3>
66
+ <span class="text-xs font-semibold text-[var(--sf-color-text-muted)] mt-1 block">
67
+ ${c.productCount || 0} Products
68
+ </span>
69
+ </div>
70
+ <span class="w-9 h-9 ${profile.buttonRadiusClass} bg-[var(--sf-color-bg)] border border-[var(--sf-color-border)] text-[var(--sf-color-text)] group-hover:bg-[var(--sf-color-primary)] group-hover:text-[var(--sf-color-primary-text)] group-hover:border-[var(--sf-color-primary)] transition-all flex items-center justify-center text-sm font-bold shadow-sm">
71
+ →
72
+ </span>
73
+ </div>
74
+ </a>
75
+ `;
76
+ }).join('')}
77
+ </div>
78
+ ` : `
79
+ <div class="text-center py-16 bg-[var(--sf-color-surface)] ${profile.cardRadiusClass} border border-[var(--sf-color-border)] shadow-sm">
80
+ <p class="text-[var(--sf-color-text-muted)]">No categories found at this time.</p>
81
+ </div>
82
+ `}
83
+
84
+ </div>
85
+ </section>
86
+ `;
87
+ }