@caartzee/theme-sdk 0.0.0-stage → 1.0.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/README.md +34 -2
- package/dist/bin/caartzee-theme.js +7449 -0
- package/dist/lib/index.js +9838 -0
- package/dist/types/src/auth/credentials-store.d.ts +18 -0
- package/dist/types/src/auth/index.d.ts +2 -0
- package/dist/types/src/auth/oauth-client.d.ts +39 -0
- package/dist/types/src/blocks/block-contract.d.ts +242 -0
- package/dist/types/src/candy/compatibility-matrix.d.ts +10 -0
- package/dist/types/src/candy/context-builder.d.ts +31 -0
- package/dist/types/src/candy/engine.d.ts +69 -0
- package/dist/types/src/candy/filters.d.ts +32 -0
- package/dist/types/src/candy/ide-support.d.ts +20 -0
- package/dist/types/src/candy/index.d.ts +9 -0
- package/dist/types/src/candy/schema-parser.d.ts +13 -0
- package/dist/types/src/candy/security.d.ts +54 -0
- package/dist/types/src/candy/tags.d.ts +11 -0
- package/dist/types/src/candy/types.d.ts +185 -0
- package/dist/types/src/cli/caartzee-cli.d.ts +9 -0
- package/dist/types/src/cli/index.d.ts +1 -0
- package/dist/types/src/cli/sdk-client.d.ts +12 -0
- package/dist/types/src/contracts/category-selection.d.ts +15 -0
- package/dist/types/src/contracts/commerce.d.ts +282 -0
- package/dist/types/src/contracts/footer-builder.d.ts +125 -0
- package/dist/types/src/contracts/hooks.d.ts +37 -0
- package/dist/types/src/contracts/manifest.d.ts +3127 -0
- package/dist/types/src/contracts/navigation.d.ts +39 -0
- package/dist/types/src/contracts/order-tracking.d.ts +40 -0
- package/dist/types/src/contracts/page.d.ts +262 -0
- package/dist/types/src/contracts/storefront-content.d.ts +60 -0
- package/dist/types/src/contracts/style-document.d.ts +2 -0
- package/dist/types/src/contracts/styles.d.ts +2002 -0
- package/dist/types/src/contracts/theme.d.ts +35 -0
- package/dist/types/src/dev-server/catalog-preview.d.ts +25 -0
- package/dist/types/src/dev-server/dev-server.d.ts +22 -0
- package/dist/types/src/dev-server/index.d.ts +1 -0
- package/dist/types/src/dev-server/theme-preview.d.ts +4 -0
- package/dist/types/src/index.d.ts +27 -0
- package/dist/types/src/mock/index.d.ts +10 -0
- package/dist/types/src/mock/mock-categories.d.ts +2 -0
- package/dist/types/src/mock/mock-commerce.d.ts +55 -0
- package/dist/types/src/mock/mock-customer.d.ts +47 -0
- package/dist/types/src/mock/mock-hooks.d.ts +2 -0
- package/dist/types/src/mock/mock-products.d.ts +3 -0
- package/dist/types/src/rendering/commerce-pages.d.ts +16 -0
- package/dist/types/src/rendering/raw-html.d.ts +12 -0
- package/dist/types/src/rendering/section-wrapper.d.ts +30 -0
- package/dist/types/src/scaffold/candy-starter-assets.d.ts +2 -0
- package/dist/types/src/scaffold/commerce-generator.d.ts +3 -0
- package/dist/types/src/scaffold/index.d.ts +2 -0
- package/dist/types/src/scaffold/template-generator.d.ts +21 -0
- package/dist/types/src/sections/section-contract.d.ts +350 -0
- package/dist/types/src/settings/global-settings.d.ts +25 -0
- package/dist/types/src/templates/json-template.d.ts +991 -0
- package/dist/types/src/validation/package-validator.d.ts +53 -0
- package/dist/types/src/validation/rich-text.d.ts +24 -0
- package/package.json +28 -3
- package/templates/commerce/README.md +165 -0
- package/templates/commerce/assets/theme.css +1 -0
- package/templates/commerce/manifest.json +1 -0
- package/templates/commerce/src/blocks/index.ts +184 -0
- package/templates/commerce/src/config/settings-defaults.ts +25 -0
- package/templates/commerce/src/config/settings-schema.ts +102 -0
- package/templates/commerce/src/index.ts +90 -0
- package/templates/commerce/src/layouts/default.ts +275 -0
- package/templates/commerce/src/manifest.ts +976 -0
- package/templates/commerce/src/pages/account/components.ts +369 -0
- package/templates/commerce/src/pages/account/tabs.ts +792 -0
- package/templates/commerce/src/pages/account.ts +55 -0
- package/templates/commerce/src/pages/campaign.ts +423 -0
- package/templates/commerce/src/pages/cart.ts +261 -0
- package/templates/commerce/src/pages/category-detail.ts +124 -0
- package/templates/commerce/src/pages/category-list.ts +87 -0
- package/templates/commerce/src/pages/checkout.ts +712 -0
- package/templates/commerce/src/pages/commerce.ts +45 -0
- package/templates/commerce/src/pages/home.ts +160 -0
- package/templates/commerce/src/pages/index.ts +99 -0
- package/templates/commerce/src/pages/login.ts +204 -0
- package/templates/commerce/src/pages/order-success.ts +80 -0
- package/templates/commerce/src/pages/product-detail.ts +489 -0
- package/templates/commerce/src/pages/product-list.ts +125 -0
- package/templates/commerce/src/pages/search.ts +88 -0
- package/templates/commerce/src/pages/signup.ts +253 -0
- package/templates/commerce/src/pages/status.ts +7 -0
- package/templates/commerce/src/pages/theme-layout.ts +491 -0
- package/templates/commerce/src/pages/track-order.ts +196 -0
- package/templates/commerce/src/pages/wishlist.ts +83 -0
- package/templates/commerce/src/sections/about-story.ts +117 -0
- package/templates/commerce/src/sections/announcement-bar.ts +101 -0
- package/templates/commerce/src/sections/banner-grid.ts +319 -0
- package/templates/commerce/src/sections/campaign-banners.ts +158 -0
- package/templates/commerce/src/sections/category-slider.ts +144 -0
- package/templates/commerce/src/sections/content-builder.ts +123 -0
- package/templates/commerce/src/sections/content-controls.ts +45 -0
- package/templates/commerce/src/sections/custom-form.ts +59 -0
- package/templates/commerce/src/sections/faq-accordion.ts +123 -0
- package/templates/commerce/src/sections/footer.ts +728 -0
- package/templates/commerce/src/sections/header.ts +439 -0
- package/templates/commerce/src/sections/hero-slider.ts +492 -0
- package/templates/commerce/src/sections/hero.ts +137 -0
- package/templates/commerce/src/sections/index.ts +102 -0
- package/templates/commerce/src/sections/mobile-slider.ts +102 -0
- package/templates/commerce/src/sections/newsletter.ts +43 -0
- package/templates/commerce/src/sections/product-grid.ts +191 -0
- package/templates/commerce/src/sections/raw-html.ts +1 -0
- package/templates/commerce/src/sections/rich-text.ts +26 -0
- package/templates/commerce/src/sections/services-features.ts +211 -0
- package/templates/commerce/src/sections/testimonials.ts +194 -0
- package/templates/commerce/src/snippets/product-card.ts +178 -0
- package/templates/commerce/src/snippets/product-price.ts +46 -0
- package/templates/commerce/src/snippets/responsive-image.ts +29 -0
- package/templates/commerce/src/styles.ts +477 -0
- package/templates/commerce/src/templates/404.json +26 -0
- package/templates/commerce/src/templates/account.json +17 -0
- package/templates/commerce/src/templates/cart.json +17 -0
- package/templates/commerce/src/templates/category.json +16 -0
- package/templates/commerce/src/templates/checkout.json +15 -0
- package/templates/commerce/src/templates/collection.json +16 -0
- package/templates/commerce/src/templates/index.json +180 -0
- package/templates/commerce/src/templates/login.json +17 -0
- package/templates/commerce/src/templates/order-success.json +17 -0
- package/templates/commerce/src/templates/page.json +17 -0
- package/templates/commerce/src/templates/product.json +17 -0
- package/templates/commerce/src/templates/search.json +18 -0
- package/templates/commerce/src/templates/signup.json +17 -0
- package/templates/commerce/src/templates/track-order.json +17 -0
- package/templates/commerce/src/templates/wishlist.json +17 -0
- package/templates/commerce/src/templates.ts +510 -0
- package/templates/commerce/src/tokens.ts +22 -0
- package/templates/vscode-candy/README.md +22 -0
- package/templates/vscode-candy/extension.js +338 -0
- package/templates/vscode-candy/icons/candy-dark.svg +23 -0
- package/templates/vscode-candy/icons/candy-light.svg +23 -0
- package/templates/vscode-candy/icons/candy-logo.png +0 -0
- package/templates/vscode-candy/icons/candy-sweet-dark.svg +23 -0
- package/templates/vscode-candy/icons/candy-sweet-light.svg +23 -0
- package/templates/vscode-candy/language-configuration.json +47 -0
- package/templates/vscode-candy/package.json +103 -0
- package/templates/vscode-candy/schemas/candy-config.schema.json +56 -0
- package/templates/vscode-candy/schemas/candy-settings.schema.json +70 -0
- package/templates/vscode-candy/snippets/candy.code-snippets +179 -0
- package/templates/vscode-candy/syntaxes/candy.tmLanguage.json +296 -0
- package/templates/vscode-candy/vim/ftdetect/candy.vim +5 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { contentBuilderSections, renderContentBuilder } from './content-builder';
|
|
2
|
+
import type { ThemeSectionRenderer } from '@caartzee/theme-sdk';
|
|
3
|
+
import { renderStarterHeader } from './header';
|
|
4
|
+
import { renderStarterHero } from './hero';
|
|
5
|
+
import { renderStarterProductGrid } from './product-grid';
|
|
6
|
+
import { renderStarterFooter, renderFooterBuilder } from './footer';
|
|
7
|
+
import { renderStarterCategorySlider } from './category-slider';
|
|
8
|
+
import { renderStarterBannerGrid } from './banner-grid';
|
|
9
|
+
import { renderStarterRichText } from './rich-text';
|
|
10
|
+
import { renderStarterNewsletter } from './newsletter';
|
|
11
|
+
import { renderStarterHeroSlider } from './hero-slider';
|
|
12
|
+
import { renderRawHtml, sanitizeRawHtml } from './raw-html';
|
|
13
|
+
|
|
14
|
+
import { renderAnnouncementBar } from './announcement-bar';
|
|
15
|
+
import { renderServicesFeatures } from './services-features';
|
|
16
|
+
import { renderTestimonials } from './testimonials';
|
|
17
|
+
import { renderFaqAccordion } from './faq-accordion';
|
|
18
|
+
import { renderAboutStory } from './about-story';
|
|
19
|
+
import { renderCustomForm } from './custom-form';
|
|
20
|
+
import { renderMobileSlider } from './mobile-slider';
|
|
21
|
+
import { renderCampaignBanners, renderCampaignBannersSection } from './campaign-banners';
|
|
22
|
+
|
|
23
|
+
export const starterSections: Record<string, ThemeSectionRenderer> = {
|
|
24
|
+
...Object.fromEntries(contentBuilderSections.map(section => [section.type, renderContentBuilder])),
|
|
25
|
+
// Starter native sections
|
|
26
|
+
'starter-header': renderStarterHeader,
|
|
27
|
+
'starter-hero': renderStarterHero,
|
|
28
|
+
'starter-hero-slider': renderStarterHeroSlider,
|
|
29
|
+
'starter-featured-grid': renderStarterProductGrid,
|
|
30
|
+
'starter-promo-banner': renderStarterBannerGrid,
|
|
31
|
+
'starter-footer': renderStarterFooter,
|
|
32
|
+
|
|
33
|
+
// Canonical cross-theme standard sections & plugins
|
|
34
|
+
hero: renderStarterHero,
|
|
35
|
+
'header-nav': renderStarterHeader,
|
|
36
|
+
'header_nav': renderStarterHeader,
|
|
37
|
+
'announcement-bar': renderAnnouncementBar,
|
|
38
|
+
'announcement_bar': renderAnnouncementBar,
|
|
39
|
+
'hero-slider': renderStarterHeroSlider,
|
|
40
|
+
'hero_slider': renderStarterHeroSlider,
|
|
41
|
+
'plugin:hero-slider:hero-slider': renderStarterHeroSlider,
|
|
42
|
+
'featured-products': renderStarterProductGrid,
|
|
43
|
+
'featured_products': renderStarterProductGrid,
|
|
44
|
+
'product-carousel': renderStarterProductGrid,
|
|
45
|
+
'category-slider': renderStarterCategorySlider,
|
|
46
|
+
'category_slider': renderStarterCategorySlider,
|
|
47
|
+
'category-grid': renderStarterCategorySlider,
|
|
48
|
+
'category_grid': renderStarterCategorySlider,
|
|
49
|
+
'banner-grid': renderStarterBannerGrid,
|
|
50
|
+
'banner_grid': renderStarterBannerGrid,
|
|
51
|
+
'campaign-banners': renderCampaignBanners,
|
|
52
|
+
'campaign_banners': renderCampaignBanners,
|
|
53
|
+
'campaign-banner': renderCampaignBanners,
|
|
54
|
+
'campaigns': renderCampaignBanners,
|
|
55
|
+
'services-features': renderServicesFeatures,
|
|
56
|
+
'services_features': renderServicesFeatures,
|
|
57
|
+
'trust-badges': renderServicesFeatures,
|
|
58
|
+
'trust_badges': renderServicesFeatures,
|
|
59
|
+
'testimonials': renderTestimonials,
|
|
60
|
+
'faq-accordion': renderFaqAccordion,
|
|
61
|
+
'faq_accordion': renderFaqAccordion,
|
|
62
|
+
'about-story': renderAboutStory,
|
|
63
|
+
'about_story': renderAboutStory,
|
|
64
|
+
'policy-content': renderAboutStory,
|
|
65
|
+
'policy_content': renderAboutStory,
|
|
66
|
+
'rich-text': renderStarterRichText,
|
|
67
|
+
'rich_text': renderStarterRichText,
|
|
68
|
+
'raw-html': renderRawHtml,
|
|
69
|
+
'raw_html': renderRawHtml,
|
|
70
|
+
'newsletter-subscribe': renderStarterNewsletter,
|
|
71
|
+
'newsletter_subscribe': renderStarterNewsletter,
|
|
72
|
+
'custom-form': renderCustomForm,
|
|
73
|
+
'custom_form': renderCustomForm,
|
|
74
|
+
'footer-builder': renderFooterBuilder,
|
|
75
|
+
'footer_builder': renderFooterBuilder,
|
|
76
|
+
'footer-links': renderStarterFooter,
|
|
77
|
+
'footer_links': renderStarterFooter,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
renderFooterBuilder,
|
|
82
|
+
renderCustomForm,
|
|
83
|
+
renderStarterHeader,
|
|
84
|
+
renderStarterHero,
|
|
85
|
+
renderStarterHeroSlider,
|
|
86
|
+
renderStarterProductGrid,
|
|
87
|
+
renderStarterFooter,
|
|
88
|
+
renderStarterCategorySlider,
|
|
89
|
+
renderStarterBannerGrid,
|
|
90
|
+
renderStarterRichText,
|
|
91
|
+
renderStarterNewsletter,
|
|
92
|
+
renderRawHtml,
|
|
93
|
+
sanitizeRawHtml,
|
|
94
|
+
renderAnnouncementBar,
|
|
95
|
+
renderServicesFeatures,
|
|
96
|
+
renderTestimonials,
|
|
97
|
+
renderFaqAccordion,
|
|
98
|
+
renderAboutStory,
|
|
99
|
+
renderMobileSlider,
|
|
100
|
+
renderCampaignBanners,
|
|
101
|
+
renderCampaignBannersSection,
|
|
102
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { StorefrontMobileSlider } from '@caartzee/theme-sdk';
|
|
2
|
+
|
|
3
|
+
function escapeHtml(str: string | null | undefined): string {
|
|
4
|
+
if (!str) return '';
|
|
5
|
+
return String(str)
|
|
6
|
+
.replace(/&/g, '&')
|
|
7
|
+
.replace(/</g, '<')
|
|
8
|
+
.replace(/>/g, '>')
|
|
9
|
+
.replace(/"/g, '"')
|
|
10
|
+
.replace(/'/g, ''');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Renders the Mobile Slider section for mobile/tablet viewports (block md:hidden).
|
|
15
|
+
*
|
|
16
|
+
* Features:
|
|
17
|
+
* - Responsive touch-swipe horizontal scroll snap with aspect-[16/9]
|
|
18
|
+
* - LCP optimization: loading="eager" and fetchpriority="high" on initial slide
|
|
19
|
+
* - High contrast title, description and CTA button overlays
|
|
20
|
+
* - Interactive pagination dots with active slide indicator
|
|
21
|
+
* - Graceful fallback on empty/missing slides (renders nothing)
|
|
22
|
+
*/
|
|
23
|
+
export function renderMobileSlider(sliders: StorefrontMobileSlider[] | undefined | null): string {
|
|
24
|
+
if (!sliders || !Array.isArray(sliders) || sliders.length === 0) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const validSliders = sliders.filter((s) => s && (s.image || s.imageUrl));
|
|
29
|
+
if (validSliders.length === 0) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const slidesHtml = validSliders
|
|
34
|
+
.map((slide, idx) => {
|
|
35
|
+
const img = slide.image || slide.imageUrl || '';
|
|
36
|
+
const title = slide.title || '';
|
|
37
|
+
const description = slide.description || '';
|
|
38
|
+
const btnUrl = slide.button_url || slide.buttonUrl || '';
|
|
39
|
+
const btnText = slide.button_text || slide.buttonText || 'Shop Now';
|
|
40
|
+
const isFirst = idx === 0;
|
|
41
|
+
|
|
42
|
+
return `
|
|
43
|
+
<div
|
|
44
|
+
class="snap-start shrink-0 w-full relative aspect-[16/9] overflow-hidden js-mobile-slide"
|
|
45
|
+
data-slide-index="${idx}"
|
|
46
|
+
>
|
|
47
|
+
<img
|
|
48
|
+
src="${escapeHtml(img)}"
|
|
49
|
+
alt="${escapeHtml(title || 'Mobile Promotion')}"
|
|
50
|
+
class="w-full h-full object-cover select-none"
|
|
51
|
+
${isFirst ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"'}
|
|
52
|
+
/>
|
|
53
|
+
${(title || description || btnUrl) ? `
|
|
54
|
+
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent flex flex-col justify-end p-4 text-white">
|
|
55
|
+
${title ? `<h3 class="text-base font-bold leading-snug line-clamp-2 drop-shadow-sm">${escapeHtml(title)}</h3>` : ''}
|
|
56
|
+
${description ? `<p class="text-xs text-white/90 mt-1 line-clamp-2 leading-relaxed drop-shadow-sm">${escapeHtml(description)}</p>` : ''}
|
|
57
|
+
${btnUrl ? `
|
|
58
|
+
<div class="mt-2.5">
|
|
59
|
+
<a
|
|
60
|
+
href="${escapeHtml(btnUrl)}"
|
|
61
|
+
class="inline-flex items-center justify-center px-3.5 py-1.5 bg-white text-slate-900 text-xs font-semibold rounded-md shadow-sm active:scale-95 transition-transform"
|
|
62
|
+
>
|
|
63
|
+
${escapeHtml(btnText)}
|
|
64
|
+
</a>
|
|
65
|
+
</div>
|
|
66
|
+
` : ''}
|
|
67
|
+
</div>
|
|
68
|
+
` : ''}
|
|
69
|
+
</div>`;
|
|
70
|
+
})
|
|
71
|
+
.join('\n');
|
|
72
|
+
|
|
73
|
+
const dotsHtml = validSliders.length > 1 ? `
|
|
74
|
+
<div class="absolute bottom-2.5 inset-x-0 flex justify-center items-center gap-1.5 pointer-events-none js-mobile-slider-dots">
|
|
75
|
+
${validSliders.map((_, i) => `
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
class="h-1.5 rounded-full pointer-events-auto transition-all duration-200 ${i === 0 ? 'bg-white w-4' : 'bg-white/50 w-1.5'}"
|
|
79
|
+
data-slide-target="${i}"
|
|
80
|
+
aria-label="Go to slide ${i + 1}"
|
|
81
|
+
></button>
|
|
82
|
+
`).join('')}
|
|
83
|
+
</div>
|
|
84
|
+
` : '';
|
|
85
|
+
|
|
86
|
+
return `
|
|
87
|
+
<section
|
|
88
|
+
class="block md:hidden w-full relative overflow-hidden bg-neutral-900 sf-mobile-slider js-mobile-slider-container"
|
|
89
|
+
aria-label="Promotions"
|
|
90
|
+
data-mobile-slider="true"
|
|
91
|
+
>
|
|
92
|
+
<div
|
|
93
|
+
class="flex overflow-x-auto snap-x snap-mandatory scrollbar-none js-mobile-slider-track"
|
|
94
|
+
style="scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch;"
|
|
95
|
+
>
|
|
96
|
+
${slidesHtml}
|
|
97
|
+
</div>
|
|
98
|
+
${dotsHtml}
|
|
99
|
+
</section>
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SectionRenderContext } from '@caartzee/theme-sdk';
|
|
2
|
+
|
|
3
|
+
function escapeHtml(str: string): string {
|
|
4
|
+
return str
|
|
5
|
+
.replace(/&/g, '&')
|
|
6
|
+
.replace(/</g, '<')
|
|
7
|
+
.replace(/>/g, '>')
|
|
8
|
+
.replace(/"/g, '"')
|
|
9
|
+
.replace(/'/g, ''');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function renderStarterNewsletter(ctx: SectionRenderContext): string {
|
|
13
|
+
const settings = ctx.section.settings || {};
|
|
14
|
+
const heading = typeof settings.heading === 'string' ? settings.heading : 'Join the Community';
|
|
15
|
+
const subheading = typeof settings.subheading === 'string' ? settings.subheading : 'Get 10% off spare parts, upgrade guides, and priority access to limited edition drops.';
|
|
16
|
+
const buttonLabel = typeof settings.buttonLabel === 'string' ? settings.buttonLabel : 'Subscribe';
|
|
17
|
+
|
|
18
|
+
return `
|
|
19
|
+
<section class="sf-section sf-starter-newsletter py-16 lg:py-20 bg-gradient-to-tr from-indigo-900 via-indigo-950 to-slate-950 text-white relative overflow-hidden" id="${escapeHtml(ctx.section.id)}" data-section-id="${escapeHtml(ctx.section.id)}" data-section-type="${escapeHtml(ctx.section.type)}" data-region="body">
|
|
20
|
+
<div class="pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-indigo-500/20 via-transparent to-transparent"></div>
|
|
21
|
+
<div class="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 text-center relative z-10">
|
|
22
|
+
<span class="inline-block px-3 py-1 rounded-full text-xs font-bold tracking-wider uppercase bg-white/10 backdrop-blur-md mb-4 text-indigo-300">VIP Access</span>
|
|
23
|
+
<h2 class="text-3xl sm:text-4xl font-black font-heading tracking-tight mb-4">${escapeHtml(heading)}</h2>
|
|
24
|
+
<p class="text-base sm:text-lg text-slate-300 max-w-xl mx-auto mb-8">${escapeHtml(subheading)}</p>
|
|
25
|
+
|
|
26
|
+
<form class="flex flex-col sm:flex-row gap-3 max-w-md mx-auto" onsubmit="event.preventDefault(); showToast && showToast('Thanks for subscribing!', 'success');">
|
|
27
|
+
<input
|
|
28
|
+
type="email"
|
|
29
|
+
placeholder="Enter your email address"
|
|
30
|
+
required
|
|
31
|
+
class="flex-1 px-4 py-3 rounded-xl bg-white/10 border border-white/20 text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-indigo-400 text-sm"
|
|
32
|
+
/>
|
|
33
|
+
<button
|
|
34
|
+
type="submit"
|
|
35
|
+
class="px-6 py-3 rounded-xl bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-sm shadow-lg shadow-indigo-600/30 transition-all active:scale-95"
|
|
36
|
+
>
|
|
37
|
+
${escapeHtml(buttonLabel)}
|
|
38
|
+
</button>
|
|
39
|
+
</form>
|
|
40
|
+
</div>
|
|
41
|
+
</section>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { SectionRenderContext, StorefrontProduct } from '@caartzee/theme-sdk';
|
|
2
|
+
import { renderStarterProductCard } from '../snippets/product-card';
|
|
3
|
+
|
|
4
|
+
function escapeHtml(str: string): string {
|
|
5
|
+
return str
|
|
6
|
+
.replace(/&/g, '&')
|
|
7
|
+
.replace(/</g, '<')
|
|
8
|
+
.replace(/>/g, '>')
|
|
9
|
+
.replace(/"/g, '"')
|
|
10
|
+
.replace(/'/g, ''');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Starter Featured Product Grid Section - Warm Luxury 5-Column Edition
|
|
15
|
+
*
|
|
16
|
+
* Features:
|
|
17
|
+
* - Flame eyebrow icon + serif section title + View All link
|
|
18
|
+
* - 5-column responsive product grid on desktop
|
|
19
|
+
* - White rounded product cards with floating wishlist button, price + star rating, and full-width sand Add to Cart button
|
|
20
|
+
*/
|
|
21
|
+
export function renderStarterProductGrid(ctx: SectionRenderContext): string {
|
|
22
|
+
const settings = ctx.section.settings || {};
|
|
23
|
+
const title = typeof settings.title === 'string' ? settings.title : 'Trending This Week';
|
|
24
|
+
const subtitle = typeof settings.subtitle === 'string' ? settings.subtitle : '';
|
|
25
|
+
const viewAllText = typeof settings.viewAllText === 'string' ? settings.viewAllText : 'View All';
|
|
26
|
+
const viewAllUrl = typeof settings.viewAllUrl === 'string' ? settings.viewAllUrl : '/products';
|
|
27
|
+
const limit = typeof settings.limit === 'number' ? settings.limit : (typeof settings.productLimit === 'number' ? settings.productLimit : 5);
|
|
28
|
+
const cols = Number(settings.columns) || (limit === 4 ? 4 : 5);
|
|
29
|
+
const colGridClasses: Record<number, string> = {
|
|
30
|
+
1: 'grid-cols-1',
|
|
31
|
+
2: 'grid-cols-1 sm:grid-cols-2',
|
|
32
|
+
3: 'grid-cols-2 md:grid-cols-3',
|
|
33
|
+
4: 'grid-cols-2 sm:grid-cols-2 lg:grid-cols-4',
|
|
34
|
+
5: 'grid-cols-2 sm:grid-cols-3 lg:grid-cols-5',
|
|
35
|
+
6: 'grid-cols-2 sm:grid-cols-3 lg:grid-cols-6',
|
|
36
|
+
};
|
|
37
|
+
const gridClass = colGridClasses[cols] || colGridClasses[5];
|
|
38
|
+
|
|
39
|
+
const currencySymbol =
|
|
40
|
+
(typeof (ctx.pageContext as any)?.currencyInfo?.symbol === 'string' && (ctx.pageContext as any).currencyInfo.symbol) ||
|
|
41
|
+
(typeof ctx.globalSettings?.currencySymbol === 'string' && ctx.globalSettings.currencySymbol) ||
|
|
42
|
+
'₹';
|
|
43
|
+
|
|
44
|
+
const defaultJoybeeProducts: StorefrontProduct[] = [
|
|
45
|
+
{
|
|
46
|
+
id: 101,
|
|
47
|
+
name: 'Araf t shirt',
|
|
48
|
+
title: 'Araf t shirt',
|
|
49
|
+
slug: 'araf-t-shirt',
|
|
50
|
+
price: 599.0,
|
|
51
|
+
salePrice: null,
|
|
52
|
+
formattedPrice: `${currencySymbol}599.00`,
|
|
53
|
+
priceFormatted: `${currencySymbol}599.00`,
|
|
54
|
+
hasDiscount: false,
|
|
55
|
+
onSale: false,
|
|
56
|
+
inStock: true,
|
|
57
|
+
stockCount: 24,
|
|
58
|
+
isCartable: true,
|
|
59
|
+
avgRating: 4.8,
|
|
60
|
+
reviewCount: 124,
|
|
61
|
+
imageUrl: 'https://images.unsplash.com/photo-1576566588028-4147f3842f27?w=700&auto=format&fit=crop&q=85',
|
|
62
|
+
galleryImages: ['https://images.unsplash.com/photo-1576566588028-4147f3842f27?w=700&auto=format&fit=crop&q=85'],
|
|
63
|
+
categoryName: 'Action Figures & Collectibles',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 102,
|
|
67
|
+
name: 'Kids Kitchen Pretend Play Set',
|
|
68
|
+
title: 'Kids Kitchen Pretend Play Set',
|
|
69
|
+
slug: 'kids-kitchen-pretend-play-set',
|
|
70
|
+
price: 1899.0,
|
|
71
|
+
salePrice: null,
|
|
72
|
+
formattedPrice: `${currencySymbol}1899.00`,
|
|
73
|
+
priceFormatted: `${currencySymbol}1899.00`,
|
|
74
|
+
hasDiscount: false,
|
|
75
|
+
onSale: false,
|
|
76
|
+
inStock: true,
|
|
77
|
+
stockCount: 12,
|
|
78
|
+
isCartable: true,
|
|
79
|
+
avgRating: 4.7,
|
|
80
|
+
reviewCount: 98,
|
|
81
|
+
imageUrl: 'https://images.unsplash.com/photo-1566576912321-d58ddd7a6088?w=700&auto=format&fit=crop&q=85',
|
|
82
|
+
galleryImages: ['https://images.unsplash.com/photo-1566576912321-d58ddd7a6088?w=700&auto=format&fit=crop&q=85'],
|
|
83
|
+
categoryName: 'Educational & STEM Toys',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 103,
|
|
87
|
+
name: 'Off-Road Monster RC Truck',
|
|
88
|
+
title: 'Off-Road Monster RC Truck',
|
|
89
|
+
slug: 'off-road-monster-rc-truck',
|
|
90
|
+
price: 1000.0,
|
|
91
|
+
salePrice: null,
|
|
92
|
+
formattedPrice: `${currencySymbol}1000.00`,
|
|
93
|
+
priceFormatted: `${currencySymbol}1000.00`,
|
|
94
|
+
hasDiscount: false,
|
|
95
|
+
onSale: false,
|
|
96
|
+
inStock: true,
|
|
97
|
+
stockCount: 18,
|
|
98
|
+
isCartable: true,
|
|
99
|
+
avgRating: 4.8,
|
|
100
|
+
reviewCount: 256,
|
|
101
|
+
imageUrl: 'https://images.unsplash.com/photo-1594787318286-3d835c1d207f?w=700&auto=format&fit=crop&q=85',
|
|
102
|
+
galleryImages: ['https://images.unsplash.com/photo-1594787318286-3d835c1d207f?w=700&auto=format&fit=crop&q=85'],
|
|
103
|
+
categoryName: 'Action Figures & Collectibles',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 104,
|
|
107
|
+
name: 'Princess Vanity Dressing Table Set',
|
|
108
|
+
title: 'Princess Vanity Dressing Table Set',
|
|
109
|
+
slug: 'princess-vanity-dressing-table-set',
|
|
110
|
+
price: 1499.0,
|
|
111
|
+
salePrice: null,
|
|
112
|
+
formattedPrice: `${currencySymbol}1499.00`,
|
|
113
|
+
priceFormatted: `${currencySymbol}1499.00`,
|
|
114
|
+
hasDiscount: false,
|
|
115
|
+
onSale: false,
|
|
116
|
+
inStock: true,
|
|
117
|
+
stockCount: 8,
|
|
118
|
+
isCartable: true,
|
|
119
|
+
avgRating: 4.6,
|
|
120
|
+
reviewCount: 139,
|
|
121
|
+
imageUrl: 'https://images.unsplash.com/photo-1515488042361-ee00e0ddd4e4?w=700&auto=format&fit=crop&q=85',
|
|
122
|
+
galleryImages: ['https://images.unsplash.com/photo-1515488042361-ee00e0ddd4e4?w=700&auto=format&fit=crop&q=85'],
|
|
123
|
+
categoryName: 'Arts, Crafts & DIY Kits',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: 105,
|
|
127
|
+
name: 'Carr Classic Tee',
|
|
128
|
+
title: 'Carr Classic Tee',
|
|
129
|
+
slug: 'carr-classic-tee',
|
|
130
|
+
price: 140.0,
|
|
131
|
+
salePrice: null,
|
|
132
|
+
formattedPrice: `${currencySymbol}140.00`,
|
|
133
|
+
priceFormatted: `${currencySymbol}140.00`,
|
|
134
|
+
hasDiscount: false,
|
|
135
|
+
onSale: false,
|
|
136
|
+
inStock: true,
|
|
137
|
+
stockCount: 30,
|
|
138
|
+
isCartable: true,
|
|
139
|
+
avgRating: 4.5,
|
|
140
|
+
reviewCount: 67,
|
|
141
|
+
imageUrl: 'https://images.unsplash.com/photo-1583743814966-8936f5b7be1a?w=700&auto=format&fit=crop&q=85',
|
|
142
|
+
galleryImages: ['https://images.unsplash.com/photo-1583743814966-8936f5b7be1a?w=700&auto=format&fit=crop&q=85'],
|
|
143
|
+
categoryName: 'Arts, Crafts & DIY Kits',
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
const rawProducts = ctx.catalog?.featuredProducts?.length
|
|
148
|
+
? ctx.catalog.featuredProducts
|
|
149
|
+
: (ctx.catalog?.products?.length ? ctx.catalog.products : defaultJoybeeProducts);
|
|
150
|
+
|
|
151
|
+
const displayProducts = rawProducts.slice(0, limit);
|
|
152
|
+
|
|
153
|
+
return `
|
|
154
|
+
<section class="sf-section sf-starter-products py-10 sm:py-14 bg-[#fbf7f2] select-none" id="${escapeHtml(ctx.section.id)}" data-section-id="${escapeHtml(ctx.section.id)}" data-section-type="${escapeHtml(ctx.section.type)}" data-region="body">
|
|
155
|
+
<div class="max-w-[1360px] mx-auto px-4 sm:px-6 lg:px-8">
|
|
156
|
+
|
|
157
|
+
<!-- Header Row with Flame Icon, Serif Title and View All -->
|
|
158
|
+
<div class="flex items-end justify-between mb-7 sm:mb-8">
|
|
159
|
+
<div>
|
|
160
|
+
<div class="flex items-center gap-2.5">
|
|
161
|
+
<span class="inline-flex items-center justify-center w-6 h-6 rounded-full bg-orange-100 text-orange-600 shrink-0" aria-hidden="true">
|
|
162
|
+
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="currentColor">
|
|
163
|
+
<path d="M12.5 2c.3 3.2-1.8 5.2-3.2 7.1-1.3 1.7-2 3.3-1.6 5.2.3 1.7 1.6 3.2 3.3 3.6-1-.8-1.5-2-1.2-3.2.3-1.4 1.4-2.5 2.4-3.7 1.1 1.6 2.5 2.8 2.5 4.8 0 1.4-.6 2.4-1.5 3.1 2.7-.4 4.8-2.7 4.8-5.7 0-3.3-2.3-5.9-3.9-8-.6-.8-1.1-1.8-1.6-3.2z"/>
|
|
164
|
+
</svg>
|
|
165
|
+
</span>
|
|
166
|
+
<h2 class="text-2xl sm:text-3xl font-bold tracking-tight text-[#1c1613] font-heading">
|
|
167
|
+
${escapeHtml(title)}
|
|
168
|
+
</h2>
|
|
169
|
+
</div>
|
|
170
|
+
${subtitle ? `
|
|
171
|
+
<p class="text-xs sm:text-sm text-[#73655b] mt-1">
|
|
172
|
+
${escapeHtml(subtitle)}
|
|
173
|
+
</p>
|
|
174
|
+
` : ''}
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<a href="${escapeHtml(viewAllUrl)}" class="group/link inline-flex items-center gap-1.5 text-xs sm:text-sm font-semibold text-[#1c1613] hover:text-[#7e192b] transition-colors pb-0.5 whitespace-nowrap">
|
|
178
|
+
<span>${escapeHtml(viewAllText)}</span>
|
|
179
|
+
<span class="inline-block transition-transform duration-200 group-hover/link:translate-x-1">→</span>
|
|
180
|
+
</a>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<!-- Product Cards Grid -->
|
|
184
|
+
<div class="sf-product-grid grid ${gridClass} gap-4 sm:gap-5" data-element="container" data-cols="${cols}">
|
|
185
|
+
${displayProducts.map((p: StorefrontProduct) => renderStarterProductCard(p, { currencySymbol })).join('')}
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
</div>
|
|
189
|
+
</section>
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderRawHtml, sanitizeRawHtml } from '@caartzee/theme-sdk';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SectionRenderContext } from '@caartzee/theme-sdk';
|
|
2
|
+
|
|
3
|
+
function escapeHtml(str: string): string {
|
|
4
|
+
return str
|
|
5
|
+
.replace(/&/g, '&')
|
|
6
|
+
.replace(/</g, '<')
|
|
7
|
+
.replace(/>/g, '>')
|
|
8
|
+
.replace(/"/g, '"')
|
|
9
|
+
.replace(/'/g, ''');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function renderStarterRichText(ctx: SectionRenderContext): string {
|
|
13
|
+
const settings = ctx.section.settings || {};
|
|
14
|
+
const heading = typeof settings.heading === 'string' ? settings.heading : (typeof settings.title === 'string' ? settings.title : 'Built for Extreme Performance');
|
|
15
|
+
const body = typeof settings.body === 'string' ? settings.body : (typeof settings.content === 'string' ? settings.content : '');
|
|
16
|
+
const alignment = settings.alignment === 'left' ? 'text-left' : (settings.alignment === 'right' ? 'text-right' : 'text-center');
|
|
17
|
+
|
|
18
|
+
return `
|
|
19
|
+
<section class="sf-section sf-starter-richtext py-16 lg:py-24 bg-slate-50/50 dark:bg-slate-900/30 border-b border-slate-200/80 dark:border-slate-800/80" id="${escapeHtml(ctx.section.id)}" data-section-id="${escapeHtml(ctx.section.id)}" data-section-type="${escapeHtml(ctx.section.type)}" data-region="body">
|
|
20
|
+
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 ${alignment}">
|
|
21
|
+
${heading ? `<h2 class="text-3xl sm:text-4xl font-black font-heading tracking-tight text-slate-900 dark:text-white mb-6">${escapeHtml(heading)}</h2>` : ''}
|
|
22
|
+
${body ? `<div class="text-base sm:text-lg text-slate-600 dark:text-slate-300 leading-relaxed font-normal">${escapeHtml(body)}</div>` : ''}
|
|
23
|
+
</div>
|
|
24
|
+
</section>
|
|
25
|
+
`;
|
|
26
|
+
}
|