blocks-dusted 0.1.1 → 0.1.3

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 (56) hide show
  1. package/README.md +967 -3
  2. package/package.json +2 -2
  3. package/src/commands/add.js +143 -45
  4. package/src/commands/list.js +2 -2
  5. package/src/installers/checkRequirements.js +1 -0
  6. package/src/installers/copyTemplateFiles.js +23 -2
  7. package/src/installers/patchPayloadConfigCollections.js +92 -0
  8. package/src/installers/writeInstalledBlockReadme.js +17 -4
  9. package/src/registry/listTemplates.js +16 -7
  10. package/src/registry/loadTemplateManifest.js +20 -11
  11. package/src/registry/validateTemplateManifest.js +6 -5
  12. package/src/utils/paths.js +7 -0
  13. package/templates/blocks/DD-BookCall/Component.tsx +535 -573
  14. package/templates/blocks/DD-CardTemplate01/Component.tsx +45 -49
  15. package/templates/blocks/DD-Carousel-A/Component.tsx +249 -266
  16. package/templates/blocks/DD-Carousel-B/Component.tsx +403 -432
  17. package/templates/blocks/DD-ComparisonTable/Component.tsx +256 -272
  18. package/templates/blocks/DD-Contact/Component.tsx +434 -439
  19. package/templates/blocks/DD-Contact/config.ts +8 -3
  20. package/templates/blocks/DD-FeatCat/Component.tsx +302 -361
  21. package/templates/blocks/DD-FeatCat/config.ts +201 -204
  22. package/templates/blocks/DD-FeatStrip/Component.tsx +171 -201
  23. package/templates/blocks/DD-Hero/Component.tsx +297 -317
  24. package/templates/blocks/DD-HorizontalScroll/Component.tsx +244 -303
  25. package/templates/blocks/DD-MasonaryMedia/Component.tsx +202 -228
  26. package/templates/blocks/DD-MasonaryMedia/config.ts +13 -14
  27. package/templates/blocks/DD-Pricing/Component.tsx +372 -380
  28. package/templates/blocks/DD-Process/Component.tsx +149 -155
  29. package/templates/blocks/DD-Section/Component.tsx +266 -327
  30. package/templates/blocks/DD-Services/Component.tsx +176 -188
  31. package/templates/blocks/DD-ShowcaseGrid/Component.tsx +307 -317
  32. package/templates/blocks/DD-Slider-A/Component.tsx +237 -252
  33. package/templates/blocks/DD-StackCards/Component.tsx +137 -160
  34. package/templates/blocks/DD-Team/Component.tsx +247 -265
  35. package/templates/blocks/DD-TechStack/Component.tsx +57 -72
  36. package/templates/blocks/DD-Testimonials/Component.tsx +147 -147
  37. package/templates/blocks/DD-Testimonials/config.ts +66 -66
  38. package/templates/blocks/DD-Work/Component.tsx +315 -328
  39. package/templates/blocks/DD-Work-B/Component.tsx +294 -320
  40. package/templates/collections/Testimonials/README.md +11 -0
  41. package/templates/collections/Testimonials/Testimonials.ts +161 -0
  42. package/templates/collections/Testimonials/manifest.json +55 -0
  43. package/templates/components/HeaderDD02/MobileBottomNav/index.tsx +545 -0
  44. package/templates/components/HeaderDD02/README.md +45 -0
  45. package/templates/components/HeaderDD02/RowLabel.tsx +33 -0
  46. package/templates/components/HeaderDD02/config.ts +302 -0
  47. package/templates/components/HeaderDD02/index.tsx +517 -0
  48. package/templates/components/HeaderDD02/manifest.json +123 -0
  49. package/templates/components/RichText/README.md +13 -0
  50. package/templates/components/RichText/converter/componentConverter/blocks.tsx +43 -0
  51. package/templates/components/RichText/converter/componentConverter/types.ts +11 -0
  52. package/templates/components/RichText/converter/index.tsx +18 -0
  53. package/templates/components/RichText/converter/internalLinks.tsx +45 -0
  54. package/templates/components/RichText/converter/textConverter.tsx +27 -0
  55. package/templates/components/RichText/index.tsx +35 -0
  56. package/templates/components/RichText/manifest.json +80 -0
@@ -1,252 +1,237 @@
1
- "use client";
2
-
3
- import React, { useState, useCallback, useEffect } from "react";
4
- import Image from "next/image";
5
- import { ChevronLeft, ChevronRight } from "lucide-react";
6
- import { cn } from "@/utilities/ui";
7
- import useEmblaCarousel from "embla-carousel-react";
8
-
9
- type MediaObj = { url?: string | null; alt?: string | null };
10
-
11
- type Slide = {
12
- id?: string | null;
13
- title: string;
14
- category?: string | null;
15
- description?: string | null;
16
- image?: MediaObj | string | null;
17
- imageFallbackUrl?: string | null;
18
- };
19
-
20
- export type DDSliderAProps = {
21
- blockType: "DD-Slider-A";
22
- blockName?: string | null;
23
- eyebrow?: string | null;
24
- heading?: string | null;
25
- subtext?: string | null;
26
- slides?: Slide[] | null;
27
- sectionId?: string | null;
28
- customCSS?: string | null;
29
- };
30
-
31
- function isValidImageSrc(src?: string | null): src is string {
32
- return Boolean(src && src.startsWith("/api/media/file/"));
33
- }
34
-
35
- function getImageSrc(slide: Slide): string {
36
- const candidateSrc =
37
- slide.image &&
38
- typeof slide.image === "object" &&
39
- (slide.image as MediaObj).url
40
- ? (slide.image as MediaObj).url!
41
- : (slide.imageFallbackUrl ?? "");
42
-
43
- return isValidImageSrc(candidateSrc) ? candidateSrc : "";
44
- }
45
-
46
- export const DDSliderA: React.FC<DDSliderAProps> = ({
47
- eyebrow,
48
- heading,
49
- subtext,
50
- slides: slidesProp,
51
- sectionId,
52
- customCSS,
53
- }) => {
54
- const slides = slidesProp ?? [];
55
- const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true });
56
- const [activeIdx, setActiveIdx] = useState(0);
57
- const [loadedSlides, setLoadedSlides] = useState<Record<number, boolean>>({});
58
- const [loadedThumbs, setLoadedThumbs] = useState<Record<number, boolean>>({});
59
-
60
- const onSelect = useCallback(() => {
61
- if (!emblaApi) return;
62
- setActiveIdx(emblaApi.selectedScrollSnap());
63
- }, [emblaApi]);
64
-
65
- useEffect(() => {
66
- if (!emblaApi) return;
67
- onSelect();
68
- emblaApi.on("select", onSelect);
69
- emblaApi.on("reInit", onSelect);
70
- return () => {
71
- emblaApi.off("select", onSelect);
72
- emblaApi.off("reInit", onSelect);
73
- };
74
- }, [emblaApi, onSelect]);
75
-
76
- const scrollPrev = useCallback(() => emblaApi?.scrollPrev(), [emblaApi]);
77
- const scrollNext = useCallback(() => emblaApi?.scrollNext(), [emblaApi]);
78
- const scrollTo = useCallback(
79
- (i: number) => emblaApi?.scrollTo(i),
80
- [emblaApi],
81
- );
82
-
83
- if (!slides.length) return null;
84
-
85
- return (
86
- <section id={sectionId ?? undefined} className="py-20 overflow-hidden">
87
- {customCSS && <style dangerouslySetInnerHTML={{ __html: customCSS }} />}
88
- <div className="max-w-6xl lg:max-w-7xl mx-auto px-4 md:px-6">
89
- {/* Optional section header */}
90
- {(eyebrow || heading || subtext) && (
91
- <div className="mb-10 text-center">
92
- {eyebrow && (
93
- <p className="text-lime-500 text-xs font-bold uppercase tracking-widest mb-2">
94
- {eyebrow}
95
- </p>
96
- )}
97
- {heading && (
98
- <h2 className="text-4xl lg:text-5xl font-bold text-stone-900 dark:text-stone-50 leading-tight">
99
- {heading}
100
- </h2>
101
- )}
102
- {subtext && (
103
- <p className="text-stone-400 mt-3 text-base max-w-2xl mx-auto">
104
- {subtext}
105
- </p>
106
- )}
107
- </div>
108
- )}
109
-
110
- <div className="relative rounded-3xl overflow-hidden">
111
- {/* Embla viewport */}
112
- <div
113
- ref={emblaRef}
114
- className="overflow-hidden select-none cursor-grab active:cursor-grabbing h-[480px] lg:h-[560px]"
115
- >
116
- <div className="flex h-full">
117
- {slides.map((slide, i) => {
118
- const imgSrc = getImageSrc(slide);
119
- return (
120
- <div
121
- key={slide.id ?? i}
122
- className="flex-none w-full h-full relative"
123
- >
124
- {imgSrc ? (
125
- <>
126
- {!loadedSlides[i] && (
127
- <div className="absolute inset-0 bg-stone-900 animate-pulse" />
128
- )}
129
- <Image
130
- src={imgSrc}
131
- alt={slide.title}
132
- fill
133
- sizes="100vw"
134
- priority={i === 0}
135
- className="w-full h-full object-cover object-top"
136
- draggable={false}
137
- onLoad={() =>
138
- setLoadedSlides((prev) => ({ ...prev, [i]: true }))
139
- }
140
- />
141
- </>
142
- ) : (
143
- <div className="w-full h-full bg-gradient-to-br from-violet-950 to-indigo-950" />
144
- )}
145
-
146
- {/* Gradient overlay */}
147
- <div className="absolute inset-0 bg-gradient-to-r from-stone-950/80 via-stone-950/40 to-transparent pointer-events-none" />
148
-
149
- {/* Slide content */}
150
- <div className="absolute bottom-0 left-0 right-0 p-8 lg:p-12 pointer-events-none">
151
- <div className="max-w-lg">
152
- {slide.category && (
153
- <span className="inline-block bg-lime-500/50 border-lime-500 border text-stone-200 text-xs font-bold px-3 py-1 rounded-full mb-3 uppercase tracking-widest scale-90 origin-top-left">
154
- {slide.category}
155
- </span>
156
- )}
157
- <h3 className="text-stone-50 font-black text-3xl lg:text-4xl mb-3">
158
- {slide.title}
159
- </h3>
160
- {slide.description && (
161
- <p className="text-stone-50/70 text-base leading-relaxed">
162
- {slide.description}
163
- </p>
164
- )}
165
- </div>
166
- </div>
167
- </div>
168
- );
169
- })}
170
- </div>
171
- </div>
172
-
173
- {/* Navigation arrows */}
174
- <button
175
- onClick={scrollPrev}
176
- aria-label="Previous slide"
177
- className="absolute left-1 top-1/2 -translate-y-1/2 z-20 w-12 h-12 flex items-center justify-center rounded-full bg-stone-50/5 hover:bg-lime-500 text-stone-50 backdrop-blur-sm transition-all cursor-pointer"
178
- >
179
- <ChevronLeft className="w-5 h-5" />
180
- </button>
181
- <button
182
- onClick={scrollNext}
183
- aria-label="Next slide"
184
- className="absolute right-1 top-1/2 -translate-y-1/2 z-20 w-12 h-12 flex items-center justify-center rounded-full bg-stone-50/5 hover:bg-lime-500 text-stone-50 backdrop-blur-sm transition-all cursor-pointer"
185
- >
186
- <ChevronRight className="w-5 h-5" />
187
- </button>
188
-
189
- {/* Thumbnail strip */}
190
- <div className="absolute bottom-4 right-4 lg:right-8 z-20 flex gap-2">
191
- {slides.map((slide, i) => {
192
- const imgSrc = getImageSrc(slide);
193
- return (
194
- <button
195
- key={slide.id ?? i}
196
- onClick={() => scrollTo(i)}
197
- aria-label={`Go to slide: ${slide.title}`}
198
- className={cn(
199
- "relative w-16 h-12 rounded-lg overflow-hidden border-2 transition-all cursor-pointer",
200
- i === activeIdx
201
- ? "border-lime-500 scale-110"
202
- : "border-white/30 opacity-60 hover:opacity-100",
203
- )}
204
- >
205
- {imgSrc ? (
206
- <>
207
- {!loadedThumbs[i] && (
208
- <div className="absolute inset-0 bg-stone-800 animate-pulse" />
209
- )}
210
- <Image
211
- src={imgSrc}
212
- alt={slide.title}
213
- fill
214
- sizes="64px"
215
- className="w-full h-full object-cover object-top"
216
- draggable={false}
217
- onLoad={() =>
218
- setLoadedThumbs((prev) => ({ ...prev, [i]: true }))
219
- }
220
- />
221
- </>
222
- ) : (
223
- <div className="w-full h-full bg-stone-800" />
224
- )}
225
- </button>
226
- );
227
- })}
228
- </div>
229
- </div>
230
-
231
- {/* Dot indicators */}
232
- {slides.length > 1 && (
233
- <div className="flex justify-center gap-2 mt-6">
234
- {slides.map((_, i) => (
235
- <button
236
- key={i}
237
- onClick={() => scrollTo(i)}
238
- aria-label={`Go to slide ${i + 1}`}
239
- className={cn(
240
- "rounded-full transition-all duration-300 cursor-pointer",
241
- i === activeIdx
242
- ? "w-8 h-2.5 bg-lime-500"
243
- : "w-2.5 h-2.5 bg-stone-600 hover:bg-stone-400",
244
- )}
245
- />
246
- ))}
247
- </div>
248
- )}
249
- </div>
250
- </section>
251
- );
252
- };
1
+ 'use client'
2
+
3
+ import React, { useState, useCallback, useEffect } from 'react'
4
+ import Image from 'next/image'
5
+ import { ChevronLeft, ChevronRight } from 'lucide-react'
6
+ import { cn } from '@/utilities/ui'
7
+ import useEmblaCarousel from 'embla-carousel-react'
8
+
9
+ type MediaObj = { url?: string | null; alt?: string | null }
10
+
11
+ type Slide = {
12
+ id?: string | null
13
+ title: string
14
+ category?: string | null
15
+ description?: string | null
16
+ image?: MediaObj | string | null
17
+ imageFallbackUrl?: string | null
18
+ }
19
+
20
+ export type DDSliderAProps = {
21
+ blockType: 'DD-Slider-A'
22
+ blockName?: string | null
23
+ eyebrow?: string | null
24
+ heading?: string | null
25
+ subtext?: string | null
26
+ slides?: Slide[] | null
27
+ sectionId?: string | null
28
+ customCSS?: string | null
29
+ }
30
+
31
+ function isValidImageSrc(src?: string | null): src is string {
32
+ return Boolean(src && src.startsWith('/api/media/file/'))
33
+ }
34
+
35
+ function getImageSrc(slide: Slide): string {
36
+ const candidateSrc =
37
+ slide.image && typeof slide.image === 'object' && (slide.image as MediaObj).url
38
+ ? (slide.image as MediaObj).url!
39
+ : (slide.imageFallbackUrl ?? '')
40
+
41
+ return isValidImageSrc(candidateSrc) ? candidateSrc : ''
42
+ }
43
+
44
+ export const DDSliderA: React.FC<DDSliderAProps> = ({
45
+ eyebrow,
46
+ heading,
47
+ subtext,
48
+ slides: slidesProp,
49
+ sectionId,
50
+ customCSS,
51
+ }) => {
52
+ const slides = slidesProp ?? []
53
+ const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true })
54
+ const [activeIdx, setActiveIdx] = useState(0)
55
+ const [loadedSlides, setLoadedSlides] = useState<Record<number, boolean>>({})
56
+ const [loadedThumbs, setLoadedThumbs] = useState<Record<number, boolean>>({})
57
+
58
+ const onSelect = useCallback(() => {
59
+ if (!emblaApi) return
60
+ setActiveIdx(emblaApi.selectedScrollSnap())
61
+ }, [emblaApi])
62
+
63
+ useEffect(() => {
64
+ if (!emblaApi) return
65
+ onSelect()
66
+ emblaApi.on('select', onSelect)
67
+ emblaApi.on('reInit', onSelect)
68
+ return () => {
69
+ emblaApi.off('select', onSelect)
70
+ emblaApi.off('reInit', onSelect)
71
+ }
72
+ }, [emblaApi, onSelect])
73
+
74
+ const scrollPrev = useCallback(() => emblaApi?.scrollPrev(), [emblaApi])
75
+ const scrollNext = useCallback(() => emblaApi?.scrollNext(), [emblaApi])
76
+ const scrollTo = useCallback((i: number) => emblaApi?.scrollTo(i), [emblaApi])
77
+
78
+ if (!slides.length) return null
79
+
80
+ return (
81
+ <section id={sectionId ?? undefined} className="py-20 overflow-hidden">
82
+ {customCSS && <style dangerouslySetInnerHTML={{ __html: customCSS }} />}
83
+ <div className="max-w-6xl lg:max-w-7xl mx-auto px-4 md:px-6">
84
+ {/* Optional section header */}
85
+ #BlockName-DDSliderA
86
+ {(eyebrow || heading || subtext) && (
87
+ <div className="mb-10 text-center">
88
+ {eyebrow && (
89
+ <p className="text-lime-500 text-xs font-bold uppercase tracking-widest mb-2">
90
+ {eyebrow}
91
+ </p>
92
+ )}
93
+ {heading && (
94
+ <h2 className="text-4xl lg:text-5xl font-bold text-stone-900 dark:text-stone-50 leading-tight">
95
+ {heading}
96
+ </h2>
97
+ )}
98
+ {subtext && (
99
+ <p className="text-stone-400 mt-3 text-base max-w-2xl mx-auto">{subtext}</p>
100
+ )}
101
+ </div>
102
+ )}
103
+ <div className="relative rounded-3xl overflow-hidden">
104
+ {/* Embla viewport */}
105
+ <div
106
+ ref={emblaRef}
107
+ className="overflow-hidden select-none cursor-grab active:cursor-grabbing h-[480px] lg:h-[560px]"
108
+ >
109
+ <div className="flex h-full">
110
+ {slides.map((slide, i) => {
111
+ const imgSrc = getImageSrc(slide)
112
+ return (
113
+ <div key={slide.id ?? i} className="flex-none w-full h-full relative">
114
+ {imgSrc ? (
115
+ <>
116
+ {!loadedSlides[i] && (
117
+ <div className="absolute inset-0 bg-stone-900 animate-pulse" />
118
+ )}
119
+ <Image
120
+ src={imgSrc}
121
+ alt={slide.title}
122
+ fill
123
+ sizes="100vw"
124
+ priority={i === 0}
125
+ className="w-full h-full object-cover object-top"
126
+ draggable={false}
127
+ onLoad={() => setLoadedSlides((prev) => ({ ...prev, [i]: true }))}
128
+ />
129
+ </>
130
+ ) : (
131
+ <div className="w-full h-full bg-gradient-to-br from-violet-950 to-indigo-950" />
132
+ )}
133
+
134
+ {/* Gradient overlay */}
135
+ <div className="absolute inset-0 bg-gradient-to-r from-stone-950/80 via-stone-950/40 to-transparent pointer-events-none" />
136
+
137
+ {/* Slide content */}
138
+ <div className="absolute bottom-0 left-0 right-0 p-8 lg:p-12 pointer-events-none">
139
+ <div className="max-w-lg">
140
+ {slide.category && (
141
+ <span className="inline-block bg-lime-500/50 border-lime-500 border text-stone-200 text-xs font-bold px-3 py-1 rounded-full mb-3 uppercase tracking-widest scale-90 origin-top-left">
142
+ {slide.category}
143
+ </span>
144
+ )}
145
+ <h3 className="text-stone-50 font-black text-3xl lg:text-4xl mb-3">
146
+ {slide.title}
147
+ </h3>
148
+ {slide.description && (
149
+ <p className="text-stone-50/70 text-base leading-relaxed">
150
+ {slide.description}
151
+ </p>
152
+ )}
153
+ </div>
154
+ </div>
155
+ </div>
156
+ )
157
+ })}
158
+ </div>
159
+ </div>
160
+
161
+ {/* Navigation arrows */}
162
+ <button
163
+ onClick={scrollPrev}
164
+ aria-label="Previous slide"
165
+ className="absolute left-1 top-1/2 -translate-y-1/2 z-20 w-12 h-12 flex items-center justify-center rounded-full bg-stone-50/5 hover:bg-lime-500 text-stone-50 backdrop-blur-sm transition-all cursor-pointer"
166
+ >
167
+ <ChevronLeft className="w-5 h-5" />
168
+ </button>
169
+ <button
170
+ onClick={scrollNext}
171
+ aria-label="Next slide"
172
+ className="absolute right-1 top-1/2 -translate-y-1/2 z-20 w-12 h-12 flex items-center justify-center rounded-full bg-stone-50/5 hover:bg-lime-500 text-stone-50 backdrop-blur-sm transition-all cursor-pointer"
173
+ >
174
+ <ChevronRight className="w-5 h-5" />
175
+ </button>
176
+
177
+ {/* Thumbnail strip */}
178
+ <div className="absolute bottom-4 right-4 lg:right-8 z-20 flex gap-2">
179
+ {slides.map((slide, i) => {
180
+ const imgSrc = getImageSrc(slide)
181
+ return (
182
+ <button
183
+ key={slide.id ?? i}
184
+ onClick={() => scrollTo(i)}
185
+ aria-label={`Go to slide: ${slide.title}`}
186
+ className={cn(
187
+ 'relative w-16 h-12 rounded-lg overflow-hidden border-2 transition-all cursor-pointer',
188
+ i === activeIdx
189
+ ? 'border-lime-500 scale-110'
190
+ : 'border-white/30 opacity-60 hover:opacity-100',
191
+ )}
192
+ >
193
+ {imgSrc ? (
194
+ <>
195
+ {!loadedThumbs[i] && (
196
+ <div className="absolute inset-0 bg-stone-800 animate-pulse" />
197
+ )}
198
+ <Image
199
+ src={imgSrc}
200
+ alt={slide.title}
201
+ fill
202
+ sizes="64px"
203
+ className="w-full h-full object-cover object-top"
204
+ draggable={false}
205
+ onLoad={() => setLoadedThumbs((prev) => ({ ...prev, [i]: true }))}
206
+ />
207
+ </>
208
+ ) : (
209
+ <div className="w-full h-full bg-stone-800" />
210
+ )}
211
+ </button>
212
+ )
213
+ })}
214
+ </div>
215
+ </div>
216
+ {/* Dot indicators */}
217
+ {slides.length > 1 && (
218
+ <div className="flex justify-center gap-2 mt-6">
219
+ {slides.map((_, i) => (
220
+ <button
221
+ key={i}
222
+ onClick={() => scrollTo(i)}
223
+ aria-label={`Go to slide ${i + 1}`}
224
+ className={cn(
225
+ 'rounded-full transition-all duration-300 cursor-pointer',
226
+ i === activeIdx
227
+ ? 'w-8 h-2.5 bg-lime-500'
228
+ : 'w-2.5 h-2.5 bg-stone-600 hover:bg-stone-400',
229
+ )}
230
+ />
231
+ ))}
232
+ </div>
233
+ )}
234
+ </div>
235
+ </section>
236
+ )
237
+ }