fragment-headless-sdk 2.1.3 → 2.1.5

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.
@@ -33,29 +33,31 @@ export default function CountdownTimer({ content, }) {
33
33
  const blockClass = mergeSlotClasses("flex flex-col items-center", styling, "countdownBlock");
34
34
  const blockStyle = mergeSlotStyles(undefined, styling, "countdownBlock");
35
35
  const blockAttributes = mergeSlotAttributes(styling, "countdownBlock");
36
- const digitClass = mergeSlotClasses("w-5 h-6 rounded bg-black text-white text-base font-bold flex items-center justify-center", styling, "countdownDigit");
37
- const digitBgColor = resolveToken(styling, "counterBgColor", "#000000") || "#000000";
36
+ const digitClass = mergeSlotClasses("text-white text-xl font-bold flex items-center justify-center leading-none", styling, "countdownDigit");
38
37
  const digitTextColor = resolveToken(styling, "counterDigitColor", "#FFFFFF") || "#FFFFFF";
39
38
  const digitStyle = mergeSlotStyles({
40
- backgroundColor: digitBgColor,
41
39
  color: digitTextColor,
42
40
  }, styling, "countdownDigit");
43
41
  const digitAttributes = mergeSlotAttributes(styling, "countdownDigit");
44
- const labelClass = mergeSlotClasses("mt-0.5 text-[10px]", styling, "countdownLabel");
45
- const labelStyle = mergeSlotStyles(undefined, styling, "countdownLabel");
42
+ const labelClass = mergeSlotClasses("mt-0.5 text-[10px] leading-tight", styling, "countdownLabel");
43
+ const labelStyle = mergeSlotStyles({
44
+ color: digitTextColor,
45
+ }, styling, "countdownLabel");
46
46
  const labelAttributes = mergeSlotAttributes(styling, "countdownLabel");
47
47
  const separatorClass = mergeSlotClasses("text-xl font-semibold -mt-4", styling, "countdownSeparator");
48
- const separatorStyle = mergeSlotStyles(undefined, styling, "countdownSeparator");
48
+ const separatorStyle = mergeSlotStyles({
49
+ color: digitTextColor,
50
+ }, styling, "countdownSeparator");
49
51
  const separatorAttributes = mergeSlotAttributes(styling, "countdownSeparator");
50
52
  const renderBlock = (value, label) => (React.createElement("div", { className: blockClass, style: blockStyle, ...(blockAttributes ?? {}) },
51
- React.createElement("div", { className: "flex gap-1" }, value.split("").map((digit, i) => (React.createElement("span", { key: i, className: digitClass, style: digitStyle, ...(digitAttributes ?? {}) }, digit)))),
53
+ React.createElement("div", { className: "flex" }, value.split("").map((digit, i) => (React.createElement("span", { key: i, className: digitClass, style: digitStyle, ...(digitAttributes ?? {}) }, digit)))),
52
54
  React.createElement("span", { className: labelClass, style: labelStyle, ...(labelAttributes ?? {}) }, label)));
53
55
  return (React.createElement("div", { className: containerClass, style: containerStyle, ...(containerAttributes ?? {}) },
54
56
  renderBlock(timeLeft.days, "Days"),
55
57
  React.createElement("span", { className: separatorClass, style: separatorStyle, ...(separatorAttributes ?? {}) }, ":"),
56
58
  renderBlock(timeLeft.hours, "Hours"),
57
59
  React.createElement("span", { className: separatorClass, style: separatorStyle, ...(separatorAttributes ?? {}) }, ":"),
58
- renderBlock(timeLeft.minutes, "Minutes"),
60
+ renderBlock(timeLeft.minutes, "Mins"),
59
61
  React.createElement("span", { className: separatorClass, style: separatorStyle, ...(separatorAttributes ?? {}) }, ":"),
60
- renderBlock(timeLeft.seconds, "Seconds")));
62
+ renderBlock(timeLeft.seconds, "Secs")));
61
63
  }
@@ -1,3 +1,4 @@
1
+ import { XMarkIcon } from "@heroicons/react/24/outline";
1
2
  import React, { useEffect, useRef } from "react";
2
3
  import { AnnouncementType, ButtonType } from "../../constants";
3
4
  import { buildClickUrl, fireImpressionWhenVisible, getThemeClasses, mergeSlotAttributes, mergeSlotClasses, mergeSlotStyles, resolveToken, resolveTokenByCategory, } from "../../utils";
@@ -50,7 +51,7 @@ export default function Announcement({ content, type, handleClose, }) {
50
51
  const announcementTextClass = mergeSlotClasses("max-w-none text-base font-semibold", styling, "announcementText");
51
52
  const announcementTextStyle = mergeSlotStyles(undefined, styling, "announcementText");
52
53
  const announcementTextAttributes = mergeSlotAttributes(styling, "announcementText");
53
- const closeButtonClass = mergeSlotClasses("absolute right-4 top-1/2 -translate-y-1/2 text-3xl leading-none cursor-pointer", styling, "closeButton");
54
+ const closeButtonClass = mergeSlotClasses("absolute right-4 top-1/2 -translate-y-1/2 cursor-pointer", styling, "closeButton");
54
55
  const closeButtonColor = resolveTokenByCategory(styling, "colors", "closeButton") ||
55
56
  (resolveToken(styling, "closeButtonColor", textColor ?? "#000") ?? "#000");
56
57
  const closeButtonStyle = mergeSlotStyles({ color: closeButtonColor }, styling, "closeButton");
@@ -69,7 +70,8 @@ export default function Announcement({ content, type, handleClose, }) {
69
70
  React.createElement("div", { dangerouslySetInnerHTML: {
70
71
  __html: content.announcementHtml || "",
71
72
  } })),
72
- type === AnnouncementType.Countdown ? (React.createElement(CountdownTimer, { content: content })) : (content.buttonText &&
73
- content.buttonType !== ButtonType.None && (React.createElement(AnnouncementButton, { content: content, buttonHref: buttonHref, clickHref: clickTrackingHref }))))),
74
- React.createElement("div", { onClick: handleClose, className: closeButtonClass, style: closeButtonStyle, ...(closeButtonAttributes ?? {}) }, "\u00D7"))));
73
+ type === AnnouncementType.Countdown && (React.createElement(CountdownTimer, { content: content })),
74
+ content.buttonText && content.buttonType !== ButtonType.None && (React.createElement(AnnouncementButton, { content: content, buttonHref: buttonHref, clickHref: clickTrackingHref })))),
75
+ React.createElement("div", { onClick: handleClose, className: closeButtonClass, style: closeButtonStyle, ...(closeButtonAttributes ?? {}) },
76
+ React.createElement(XMarkIcon, { className: "w-5 h-5" })))));
75
77
  }
@@ -21,8 +21,10 @@ export interface IAnnouncement {
21
21
  name: string;
22
22
  status: AnnouncementStatus;
23
23
  content: IAnnouncementContent | null;
24
- created_at: string;
25
- updated_at: string;
24
+ active_start_date: string | null;
25
+ active_end_date: string | null;
26
+ created_at: string | null;
27
+ updated_at: string | null;
26
28
  views_count: number;
27
29
  clicks_count: number;
28
30
  }
@@ -22,11 +22,13 @@ export interface IHero {
22
22
  shop: string;
23
23
  name: string;
24
24
  type: HeroType;
25
- page: ShopPage["handle"];
25
+ page: ShopPage["handle"] | null;
26
26
  status: HeroStatus;
27
27
  content: IHeroContent | null;
28
- created_at: string;
29
- updated_at: string;
28
+ active_start_date: string | null;
29
+ active_end_date: string | null;
30
+ created_at: string | null;
31
+ updated_at: string | null;
30
32
  views_count: number;
31
33
  clicks_count: number;
32
34
  }
@@ -63,19 +63,6 @@ export interface IFragmentStyling {
63
63
  * Structured design tokens for consistent theming.
64
64
  */
65
65
  tokens?: IFragmentTokens;
66
- /**
67
- * Legacy flat token support for backward compatibility.
68
- * @deprecated Use structured tokens instead.
69
- */
70
- legacyTokens?: Record<string, string>;
71
- /**
72
- * Theme variant (light, dark, brand, etc.).
73
- */
74
- theme?: "light" | "dark" | "brand" | "minimal" | "bold" | string;
75
- /**
76
- * Component variant for different styles of the same component.
77
- */
78
- variant?: "default" | "outlined" | "ghost" | "solid" | "gradient" | string;
79
66
  /**
80
67
  * Global CSS variables to apply to the component root.
81
68
  */
@@ -260,10 +260,6 @@ export function resolveToken(styling, token, fallback) {
260
260
  }
261
261
  }
262
262
  }
263
- // Fall back to legacy tokens
264
- if (styling.legacyTokens && token in styling.legacyTokens) {
265
- return styling.legacyTokens[token];
266
- }
267
263
  return fallback;
268
264
  }
269
265
  export function resolveTokenByCategory(styling, category, token, fallback) {
@@ -278,16 +274,8 @@ export function resolveTokenByCategory(styling, category, token, fallback) {
278
274
  return fallback;
279
275
  }
280
276
  export function getThemeClasses(styling) {
281
- if (!styling)
282
- return "";
283
- const classes = [];
284
- if (styling.theme) {
285
- classes.push(`theme-${styling.theme}`);
286
- }
287
- if (styling.variant) {
288
- classes.push(`variant-${styling.variant}`);
289
- }
290
- return classes.join(" ");
277
+ // Theme and variant system has been removed
278
+ return "";
291
279
  }
292
280
  export function generateCSS(styling) {
293
281
  if (!styling)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fragment-headless-sdk",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,6 +18,7 @@
18
18
  "build": "tsc"
19
19
  },
20
20
  "dependencies": {
21
+ "@heroicons/react": "^2.2.0",
21
22
  "react": "^19.1.0"
22
23
  },
23
24
  "devDependencies": {
package/readme.md CHANGED
@@ -2,39 +2,11 @@
2
2
 
3
3
  The official SDK for integrating with Fragment-Shopify CMS. Provides React components, TypeScript types, and utilities for rendering published sections in headless Shopify storefronts.
4
4
 
5
- ## ✨ What's New in v2.1.3
5
+ ## ✨ What's New
6
6
 
7
- **Request Deduplication** - Intelligent request deduplication prevents identical concurrent API calls
8
- 🚀 **Enhanced Caching** - Improved caching strategy with 60-second revalidation for better performance
9
- 🔧 **Optimized Fetching** - Consistent parameter handling and smarter cache key generation
10
- 🛡️ **Anti-Spam Protection** - Built-in protection against redundant API requests
7
+ **v2.1.4** - Countdown timer enhancements and improved announcement layouts
11
8
 
12
- ### Previous Release (v2.1.2)
13
-
14
- 📚 **Enhanced Documentation** - Comprehensive documentation updates highlighting new click tracking features
15
- 📖 **Better Examples** - Improved usage examples and feature descriptions
16
- 🎯 **Feature Highlights** - Clear documentation of the enhanced click tracking system
17
-
18
- ### Previous Release (v2.1.1)
19
-
20
- 🎯 **Enhanced Click Tracking System** - Improved click tracking architecture with better user experience
21
- ⚡ **Direct Navigation** - Users go directly to destinations without redirect delays
22
- 🔗 **Separated Tracking** - Button destinations and click tracking are now handled separately
23
- 🛠️ **Better Performance** - Non-blocking click tracking that doesn't delay navigation
24
-
25
- ### Previous Release (v2.1.0)
26
-
27
- 🎨 **Enhanced Hero Styling System** - New hero resolvers utility with advanced typography, positioning, and layout controls
28
- 🔤 **Advanced Typography** - Built-in font family support with granular control over sizes and line heights
29
- 📐 **Flexible Layout Controls** - Content positioning (left/center/right), width management, and height configuration
30
- 🎯 **Developer Experience** - Enhanced TypeScript interfaces and utility functions for better development workflow
31
-
32
- ### Previous Major Release (v2.0.0)
33
-
34
- 🎨 **Revolutionary Styling System** - Complete overhaul with advanced theming, responsive design, and scalable architecture
35
- 🏗️ **Component-Specific Types** - Enhanced type safety with dedicated slot interfaces
36
- 🚀 **Performance Optimized** - Caching and optimizations for production-ready performance
37
- 🎯 **Future-Proof Architecture** - Built to scale with any number of components and styling requirements
9
+ > See [CHANGELOG.md](./docs/CHANGELOG.md) for full release history
38
10
 
39
11
  ---
40
12
 
@@ -59,7 +31,7 @@ Fragment-Shopify App (CMS) → API Endpoint → fragment-headless-sdk (Consumer)
59
31
  - ✅ **Data Fetching**: Built-in utilities to fetch sections from Fragment-Shopify API
60
32
  - ✅ **React Components**: Pre-built Hero and Announcement components with responsive design
61
33
  - ✅ **TypeScript Support**: Full type definitions for all components and data structures
62
- - ✅ **Multiple Announcement Types**: Standard, marquee, and countdown announcement variants
34
+ - ✅ **Multiple Announcement Types**: Standard, marquee, and countdown announcements
63
35
  - ✅ **Hero Sections**: Desktop/mobile responsive hero components with video support
64
36
  - ✅ **Advanced Click Tracking**: Separated tracking and navigation for optimal user experience
65
37
 
@@ -68,10 +40,9 @@ Fragment-Shopify App (CMS) → API Endpoint → fragment-headless-sdk (Consumer)
68
40
  - 🎨 **Structured Design Tokens**: Organized color, spacing, typography, and effect tokens
69
41
  - 📱 **Responsive Styling**: Breakpoint-specific overrides (sm, md, lg, xl, 2xl)
70
42
  - 🎭 **State-Based Styling**: Hover, active, focus, disabled, and loading states
71
- - 🎯 **Theme & Variant Support**: Built-in theme system with variant support
43
+ - 🎯 **Design Token System**: Structured tokens for consistent styling
72
44
  - 🔧 **Component-Specific Slots**: Type-safe styling for individual component parts
73
45
  - ⚡ **Performance Optimized**: Caching and memoization for optimal performance
74
- - 🔄 **Legacy Compatibility**: Seamless migration path from v1.x styling
75
46
  - 🎪 **CSS-in-JS Support**: Integration with styled-components, emotion, etc.
76
47
 
77
48
  ### Hero Resolvers System (v2.1+)
@@ -81,7 +52,6 @@ Fragment-Shopify App (CMS) → API Endpoint → fragment-headless-sdk (Consumer)
81
52
  - 🎨 **Smart Color Resolution**: Intelligent fallback handling for color tokens
82
53
  - 🛠️ **Utility Functions**: Helper functions for class joining, text rendering, and style resolution
83
54
  - 📝 **Type Safety**: Enhanced TypeScript interfaces for all styling options
84
- - 🔄 **Backward Compatible**: Works seamlessly with existing Hero implementations
85
55
 
86
56
  ### Request Deduplication & Performance System (v2.1.3+)
87
57
 
@@ -259,10 +229,6 @@ const heroContent = {
259
229
 
260
230
  // Advanced styling configuration
261
231
  styling: {
262
- // Theme and variant
263
- theme: "dark",
264
- variant: "gradient",
265
-
266
232
  // Structured design tokens
267
233
  tokens: {
268
234
  colors: {
@@ -317,357 +283,7 @@ const heroContent = {
317
283
  <Hero content={heroContent} />;
318
284
  ```
319
285
 
320
- ---
321
-
322
- ## 🎨 Advanced Styling System
323
-
324
- ### Overview
325
-
326
- The v2.0 styling system provides unprecedented control over component appearance while maintaining backward compatibility.
327
-
328
- ### Key Concepts
329
-
330
- #### 1. **Structured Design Tokens**
331
-
332
- Organize your design system with categorized tokens:
333
-
334
- ```typescript
335
- styling: {
336
- tokens: {
337
- colors: {
338
- primary: "#007bff",
339
- secondary: "#6c757d",
340
- background: "#ffffff",
341
- text: "#333333"
342
- },
343
- spacing: {
344
- xs: "0.25rem",
345
- sm: "0.5rem",
346
- md: "1rem",
347
- lg: "1.5rem",
348
- xl: "2rem"
349
- },
350
- typography: {
351
- heading: "2.5rem",
352
- body: "1rem",
353
- small: "0.875rem"
354
- },
355
- transitions: {
356
- fast: "150ms ease",
357
- normal: "300ms ease",
358
- slow: "500ms ease"
359
- },
360
- shadows: {
361
- sm: "0 1px 2px rgba(0,0,0,0.05)",
362
- md: "0 4px 6px rgba(0,0,0,0.1)",
363
- lg: "0 10px 15px rgba(0,0,0,0.1)"
364
- }
365
- }
366
- }
367
- ```
368
-
369
- #### 2. **Component Slots**
370
-
371
- Target specific parts of components with type-safe slot names:
372
-
373
- ```typescript
374
- // Announcement component slots
375
- slots: {
376
- root: { /* Root container */ },
377
- inner: { /* Inner wrapper */ },
378
- marqueeContainer: { /* Marquee wrapper */ },
379
- announcementText: { /* Text content */ },
380
- button: { /* Action button */ },
381
- closeButton: { /* Close button */ }
382
- }
383
-
384
- // Hero component slots
385
- slots: {
386
- root: { /* Root container */ },
387
- desktopContainer: { /* Desktop layout */ },
388
- mobileContainer: { /* Mobile layout */ },
389
- image: { /* Background image */ },
390
- title: { /* Hero title */ },
391
- description: { /* Hero description */ },
392
- button: { /* CTA button */ }
393
- }
394
- ```
395
-
396
- #### 3. **Responsive Design**
397
-
398
- Apply different styles at different breakpoints:
399
-
400
- ```typescript
401
- slots: {
402
- title: {
403
- className: "text-2xl font-bold",
404
- responsive: {
405
- sm: { className: "text-3xl" },
406
- md: { className: "text-4xl" },
407
- lg: { className: "text-5xl" },
408
- xl: { className: "text-6xl" }
409
- }
410
- }
411
- }
412
- ```
413
-
414
- #### 4. **State-Based Styling**
415
-
416
- Style components based on interaction states:
417
-
418
- ```typescript
419
- slots: {
420
- button: {
421
- className: "bg-blue-500 text-white px-6 py-3 rounded",
422
- states: {
423
- hover: {
424
- className: "bg-blue-600 shadow-lg",
425
- style: { transform: "translateY(-2px)" }
426
- },
427
- active: { className: "bg-blue-700" },
428
- disabled: {
429
- className: "bg-gray-300 cursor-not-allowed",
430
- attributes: { "aria-disabled": "true" }
431
- }
432
- }
433
- }
434
- }
435
- ```
436
-
437
- #### 5. **Theme and Variant System**
438
-
439
- Apply consistent theming across components:
440
-
441
- ```typescript
442
- styling: {
443
- theme: "dark", // "light" | "dark" | "brand" | custom
444
- variant: "outlined", // "default" | "outlined" | "ghost" | "solid" | custom
445
-
446
- // Automatic theme classes applied: "theme-dark variant-outlined"
447
- }
448
- ```
449
-
450
- ### Migration from v1.x
451
-
452
- The system maintains full backward compatibility:
453
-
454
- ```typescript
455
- // v1.x style (still works)
456
- content: {
457
- bgColor: "#ffffff",
458
- textColor: "#333333",
459
- buttonColor: "#007bff"
460
- }
461
-
462
- // v2.0+ enhanced style
463
- content: {
464
- styling: {
465
- // Legacy tokens (backward compatible)
466
- legacyTokens: {
467
- bgColor: "#ffffff",
468
- textColor: "#333333",
469
- buttonColor: "#007bff"
470
- },
471
-
472
- // New structured tokens (recommended)
473
- tokens: {
474
- colors: {
475
- background: "#ffffff",
476
- text: "#333333",
477
- button: "#007bff"
478
- }
479
- }
480
- }
481
- }
482
- ```
483
-
484
- ### CSS-in-JS Integration
485
-
486
- Support for styled-components, emotion, and other CSS-in-JS libraries:
487
-
488
- ```typescript
489
- slots: {
490
- button: {
491
- css: `
492
- background: linear-gradient(45deg, #007bff, #0056b3);
493
- border: none;
494
- border-radius: 8px;
495
- padding: 12px 24px;
496
-
497
- &:hover {
498
- background: linear-gradient(45deg, #0056b3, #004085);
499
- transform: translateY(-2px);
500
- }
501
- `;
502
- }
503
- }
504
- ```
505
-
506
- ---
507
-
508
- ## 🎨 Hero Resolvers System (v2.1+)
509
-
510
- The Hero Resolvers system provides advanced utilities for customizing Hero components with enhanced typography, layout, and styling controls.
511
-
512
- ### Typography Control
513
-
514
- ```typescript
515
- import { resolveHeroTypography, FontKey } from "fragment-headless-sdk";
516
-
517
- // Enhanced typography configuration
518
- const heroContent = {
519
- title: "Welcome to Our Store",
520
- description: "Discover amazing products",
521
- styling: {
522
- tokens: {
523
- typography: {
524
- // Title typography
525
- titleFont: "montserrat" as FontKey,
526
- titleFontSize: "text-6xl",
527
- titleLineHeight: "leading-tight",
528
-
529
- // Description typography
530
- descriptionFont: "inter" as FontKey,
531
- descriptionFontSize: "text-xl",
532
- descriptionLineHeight: "leading-relaxed",
533
- },
534
- },
535
- },
536
- };
537
-
538
- // Resolve typography settings
539
- const typography = resolveHeroTypography(heroContent);
540
- ```
541
-
542
- ### Layout & Positioning
543
-
544
- ```typescript
545
- import {
546
- resolvePosition,
547
- resolveContentWidthClass,
548
- resolveHeight,
549
- } from "fragment-headless-sdk";
550
-
551
- const heroContent = {
552
- title: "Centered Hero",
553
- styling: {
554
- tokens: {
555
- layout: {
556
- position: "center", // "left" | "center" | "right"
557
- contentWidth: "max-w-4xl", // Tailwind width classes
558
- height: "min-h-screen", // Custom height classes
559
- },
560
- },
561
- },
562
- };
563
-
564
- // Resolve layout settings
565
- const position = resolvePosition(heroContent); // "center"
566
- const contentWidth = resolveContentWidthClass(heroContent); // "max-w-4xl"
567
- const height = resolveHeight(heroContent); // "min-h-screen"
568
- ```
569
-
570
- ### Color Resolution
571
-
572
- ```typescript
573
- import { resolveHeroColors } from "fragment-headless-sdk";
574
-
575
- const heroContent = {
576
- title: "Styled Hero",
577
- styling: {
578
- tokens: {
579
- colors: {
580
- title: "#ffffff",
581
- text: "#f0f0f0",
582
- button: "#007bff",
583
- buttonText: "#ffffff",
584
- background: "#1a1a1a",
585
- },
586
- },
587
- },
588
- };
589
-
590
- // Resolve colors with intelligent fallbacks
591
- const colors = resolveHeroColors(heroContent);
592
- // Returns: { title: "#ffffff", text: "#f0f0f0", buttonBackground: "#007bff", buttonText: "#ffffff", background: "#1a1a1a" }
593
- ```
594
-
595
- ### Built-in Font Families
596
-
597
- The system includes support for popular web fonts:
598
-
599
- ```typescript
600
- type FontKey =
601
- | "roboto"
602
- | "open-sans"
603
- | "lato"
604
- | "montserrat"
605
- | "poppins"
606
- | "inter"
607
- | "nunito-sans"
608
- | "source-sans-pro";
609
- ```
610
-
611
- ### Utility Functions
612
-
613
- ```typescript
614
- import { joinClassNames, renderText } from "fragment-headless-sdk";
615
-
616
- // Safe class name joining
617
- const classes = joinClassNames("text-xl", "font-bold", null, "text-center");
618
- // Returns: "text-xl font-bold text-center"
619
-
620
- // Unified text rendering
621
- const titleElement = renderText({
622
- fontSize: "text-4xl",
623
- lineHeight: "leading-tight",
624
- text: "Hero Title",
625
- className: "font-bold",
626
- color: "#ffffff",
627
- font: "montserrat",
628
- });
629
- ```
630
-
631
- ### Complete Example
632
-
633
- ```typescript
634
- import { Hero } from "fragment-headless-sdk";
635
-
636
- const advancedHeroContent = {
637
- title: "Advanced Hero Section",
638
- description: "With enhanced typography and layout controls",
639
- buttonText: "Get Started",
640
- buttonLink: "/signup",
641
- imageUrl: "https://example.com/hero.jpg",
642
-
643
- styling: {
644
- tokens: {
645
- colors: {
646
- title: "#ffffff",
647
- text: "#e2e8f0",
648
- button: "#3b82f6",
649
- buttonText: "#ffffff",
650
- background: "#1e293b",
651
- },
652
- typography: {
653
- titleFont: "montserrat",
654
- titleFontSize: "text-5xl lg:text-7xl",
655
- titleLineHeight: "leading-tight",
656
- descriptionFont: "inter",
657
- descriptionFontSize: "text-lg lg:text-xl",
658
- descriptionLineHeight: "leading-relaxed",
659
- },
660
- layout: {
661
- position: "center",
662
- contentWidth: "max-w-4xl",
663
- height: "min-h-screen",
664
- },
665
- },
666
- },
667
- };
668
-
669
- <Hero content={advancedHeroContent} />;
670
- ```
286
+ > **Advanced Features:** For detailed styling options, see [STYLING.md](./docs/STYLING.md) | For hero customization, see [HERO-RESOLVERS.md](./docs/HERO-RESOLVERS.md)
671
287
 
672
288
  ---
673
289
 
@@ -818,88 +434,6 @@ interface IAnnouncementContent {
818
434
  - `closeButton` - Close button
819
435
  - `countdown` - Countdown container (countdown type)
820
436
 
821
- ---
822
-
823
- ## 🎯 Styling Examples
824
-
825
- ### Basic Theme Application
826
-
827
- ```typescript
828
- const styling = {
829
- theme: "dark",
830
- variant: "outlined",
831
- tokens: {
832
- colors: {
833
- background: "#1a1a1a",
834
- text: "#ffffff",
835
- button: "#007bff",
836
- },
837
- },
838
- };
839
- ```
840
-
841
- ### Responsive Hero Design
842
-
843
- ```typescript
844
- const heroStyling = {
845
- slots: {
846
- title: {
847
- className: "font-bold text-center",
848
- responsive: {
849
- sm: { className: "text-3xl" },
850
- md: { className: "text-4xl text-left" },
851
- lg: { className: "text-6xl" },
852
- },
853
- },
854
- button: {
855
- className: "px-6 py-3 rounded-lg",
856
- responsive: {
857
- md: { className: "px-8 py-4 text-lg" },
858
- },
859
- states: {
860
- hover: { className: "shadow-xl transform scale-105" },
861
- },
862
- },
863
- },
864
- };
865
- ```
866
-
867
- ### Advanced Announcement Styling
868
-
869
- ```typescript
870
- const announcementStyling = {
871
- theme: "brand",
872
- tokens: {
873
- colors: {
874
- background: "linear-gradient(90deg, #667eea 0%, #764ba2 100%)",
875
- text: "#ffffff",
876
- },
877
- transitions: {
878
- smooth: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
879
- },
880
- },
881
- slots: {
882
- root: {
883
- style: {
884
- background: "var(--colors-background)",
885
- transition: "var(--transitions-smooth)",
886
- },
887
- },
888
- announcementText: {
889
- className: "font-semibold tracking-wide",
890
- states: {
891
- hover: { className: "text-yellow-200" },
892
- },
893
- },
894
- closeButton: {
895
- className: "opacity-70 hover:opacity-100 transition-opacity",
896
- },
897
- },
898
- };
899
- ```
900
-
901
- ---
902
-
903
437
  ## 🔑 API Key Setup
904
438
 
905
439
  Before using the SDK, you need to generate an API key from your Fragment-Shopify app:
@@ -955,7 +489,7 @@ graph TD
955
489
  2. **Publishing**: Sections are published and available via API
956
490
  3. **Data Fetching**: Your app calls `fetchResource()` to get section data
957
491
  4. **Component Rendering**: Pass data to Hero/Announcement components
958
- 5. **Styling Application**: Advanced styling system applies themes, responsive design, and interactions
492
+ 5. **Styling Application**: Advanced styling system applies design tokens, responsive design, and interactions
959
493
  6. **UI Display**: Components render beautiful, responsive, styled sections
960
494
 
961
495
  ---
@@ -989,8 +523,8 @@ const sections = await fetchResource({...});
989
523
  fragment-headless-sdk/
990
524
  ├── src/
991
525
  │ ├── components/ # React components
992
- │ │ ├── Announcement/ # Announcement component variants
993
- │ │ └── Hero/ # Hero component variants
526
+ │ │ ├── Announcement/ # Announcement components
527
+ │ │ └── Hero/ # Hero components
994
528
  │ ├── constants/ # Enums and constants
995
529
  │ ├── types/ # TypeScript interfaces
996
530
  │ │ └── styling.ts # Advanced styling types
@@ -999,150 +533,16 @@ fragment-headless-sdk/
999
533
  └── dist/ # Compiled output
1000
534
  ```
1001
535
 
1002
- ---
1003
-
1004
- ## 🔄 Migration Guide
536
+ ## 📚 Documentation
1005
537
 
1006
- ### From v2.0 to v2.1
1007
-
1008
- **No Breaking Changes** - v2.1 is fully backward compatible!
1009
-
1010
- All existing Hero components continue to work exactly as before. The new Hero Resolvers system is completely opt-in.
1011
-
1012
- #### New Features Available (Optional)
1013
-
1014
- ```typescript
1015
- // v2.0 style (continues to work)
1016
- const heroContent = {
1017
- title: "My Hero",
1018
- styling: {
1019
- tokens: {
1020
- colors: {
1021
- title: "#ffffff",
1022
- button: "#007bff",
1023
- },
1024
- },
1025
- },
1026
- };
1027
-
1028
- // v2.1 enhanced style (new features)
1029
- const heroContent = {
1030
- title: "My Hero",
1031
- styling: {
1032
- tokens: {
1033
- colors: {
1034
- title: "#ffffff",
1035
- button: "#007bff",
1036
- },
1037
- // NEW: Typography controls
1038
- typography: {
1039
- titleFont: "montserrat",
1040
- titleFontSize: "text-6xl",
1041
- titleLineHeight: "leading-tight",
1042
- },
1043
- // NEW: Layout controls
1044
- layout: {
1045
- position: "center",
1046
- contentWidth: "max-w-4xl",
1047
- height: "min-h-screen",
1048
- },
1049
- },
1050
- },
1051
- };
1052
- ```
1053
-
1054
- ### From v1.x to v2.0
1055
-
1056
- **No Breaking Changes** - v2.0 is fully backward compatible!
1057
-
1058
- #### Option 1: Keep Using v1.x Style (No Changes Required)
1059
-
1060
- ```typescript
1061
- // This continues to work exactly as before
1062
- const content = {
1063
- title: "My Hero",
1064
- bgColor: "#ffffff",
1065
- textColor: "#333333",
1066
- };
1067
- ```
1068
-
1069
- #### Option 2: Gradual Migration
1070
-
1071
- ```typescript
1072
- // Start using new styling alongside legacy
1073
- const content = {
1074
- title: "My Hero",
1075
- styling: {
1076
- legacyTokens: {
1077
- bgColor: "#ffffff", // Keep existing tokens
1078
- textColor: "#333333",
1079
- },
1080
- tokens: {
1081
- colors: {
1082
- button: "#007bff", // Add new structured tokens
1083
- },
1084
- },
1085
- },
1086
- };
1087
- ```
1088
-
1089
- #### Option 3: Full v2.0 Adoption
1090
-
1091
- ```typescript
1092
- // Embrace the full power of v2.0
1093
- const content = {
1094
- title: "My Hero",
1095
- styling: {
1096
- theme: "dark",
1097
- variant: "gradient",
1098
- tokens: {
1099
- colors: {
1100
- background: "#1a1a1a",
1101
- text: "#ffffff",
1102
- button: "#007bff",
1103
- },
1104
- },
1105
- slots: {
1106
- title: {
1107
- className: "text-4xl font-bold",
1108
- responsive: {
1109
- md: { className: "text-6xl" },
1110
- },
1111
- },
1112
- },
1113
- },
1114
- };
1115
- ```
1116
-
1117
- ---
1118
-
1119
- ## 🤝 Contributing
1120
-
1121
- This package is designed to work specifically with the Fragment-Shopify app. When adding new section types:
1122
-
1123
- 1. Add the resource type to `ResourceType` enum
1124
- 2. Create corresponding TypeScript interfaces
1125
- 3. Build React components for rendering
1126
- 4. Add styling slot interfaces for type safety
1127
- 5. Update this documentation
538
+ - [CHANGELOG.md](./docs/CHANGELOG.md) - Release history and version notes
539
+ - [STYLING.md](./docs/STYLING.md) - Advanced styling system documentation
540
+ - [HERO-RESOLVERS.md](./docs/HERO-RESOLVERS.md) - Hero component customization guide
541
+ - [MIGRATION.md](./docs/MIGRATION.md) - Version migration guides
542
+ - [PUBLISHING.md](./docs/PUBLISHING.md) - NPM publishing guide
1128
543
 
1129
544
  ---
1130
545
 
1131
546
  ## 📝 License
1132
547
 
1133
548
  MIT License - See LICENSE file for details.
1134
-
1135
- ---
1136
-
1137
- ## 🎉 What's Next?
1138
-
1139
- The v2.1 Hero Resolvers system and v2.0 styling foundation provide unlimited customization and scalability. Future enhancements may include:
1140
-
1141
- - Visual styling editor integration
1142
- - Animation and transition presets
1143
- - Advanced layout system for all components
1144
- - Component composition utilities
1145
- - Design system generator
1146
- - Enhanced Announcement component resolvers
1147
-
1148
- **Ready to build beautiful, scalable headless experiences with advanced typography and layout controls!** 🚀
@@ -1,31 +0,0 @@
1
- @import url("https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&family=Roboto:wght@300;400;500;700&family=Open+Sans:wght@300;400;600;700&family=Lato:wght@300;400;700&family=Montserrat:wght@300;400;500;700&family=Inter:wght@300;400;500;700&family=Poppins:wght@300;400;600;700&family=Raleway:wght@300;400;500;700&family=Playfair+Display:wght@400;700&family=Merriweather:wght@300;400;700&family=Oswald:wght@300;400;500;700&display=swap");
2
-
3
- /* Custom animations for fragment-headless-sdk */
4
- @keyframes marquee {
5
- 0% {
6
- transform: translateX(0%);
7
- }
8
- 100% {
9
- transform: translateX(-100%);
10
- }
11
- }
12
-
13
- /* Utility classes for marquee animations */
14
- .animate-marquee {
15
- animation: marquee 25s linear infinite;
16
- }
17
-
18
- /* Make hero/announcement prose links inherit the surrounding text color (v2.1+) */
19
- .prose {
20
- --tw-prose-links: currentColor;
21
- --tw-prose-links-hover: currentColor;
22
- }
23
-
24
- .prose :where(a):not(:where([class~="not-prose"] *)) {
25
- color: currentColor;
26
- }
27
-
28
- .prose :where(a):not(:where([class~="not-prose"] *)):hover {
29
- color: currentColor;
30
- text-decoration: underline;
31
- }