@foundrykit/blocks 1.0.24 → 1.1.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.
@@ -1,4 +1,4 @@
1
- import { ComponentConfig } from '@foundrykit/types';
1
+ import type { ComponentConfig } from '@foundrykit/types';
2
2
 
3
3
  export const interactiveRegionsMapConfig: ComponentConfig = {
4
4
  name: 'Interactive Regions Map',
@@ -17,9 +17,9 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
17
17
  code: `<InteractiveRegionsMap
18
18
  title="Our Global Presence"
19
19
  regions={[
20
- { countries: ["france", "germany", "spain"], name: "Europe" },
21
- { countries: ["iraq", "iran"], name: "Middle East" },
22
- { countries: ["madagascar", "south-africa", "kenya"], name: "Africa" }
20
+ { countries: ["FR", "DE", "ES"], name: "Europe" },
21
+ { countries: ["IQ", "IR"], name: "Middle East" },
22
+ { countries: ["MG", "ZA", "KE"], name: "Africa" }
23
23
  ]}
24
24
  />`,
25
25
  preview: {
@@ -28,10 +28,10 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
28
28
  props: {
29
29
  title: 'Our Global Presence',
30
30
  regions: [
31
- { countries: ['france', 'germany', 'spain'], name: 'Europe' },
32
- { countries: ['iraq', 'iran'], name: 'Middle East' },
31
+ { countries: ['FR', 'DE', 'ES'], name: 'Europe' },
32
+ { countries: ['IQ', 'IR'], name: 'Middle East' },
33
33
  {
34
- countries: ['madagascar', 'south-africa', 'kenya'],
34
+ countries: ['MG', 'ZA', 'KE'],
35
35
  name: 'Africa',
36
36
  },
37
37
  ],
@@ -45,9 +45,9 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
45
45
  title="Explore Our Hotel Destinations"
46
46
  content="Discover luxury accommodations across multiple continents. Click on any region to learn more about our properties in that area."
47
47
  regions={[
48
- { countries: ["united-states", "canada"], name: "North America", color: "#3b82f6" },
49
- { countries: ["france", "germany", "spain"], name: "Europe", color: "#10b981" },
50
- { countries: ["iraq", "iran"], name: "Middle East", color: "#f59e0b" }
48
+ { countries: ["US", "CA"], name: "North America", color: "#3b82f6" },
49
+ { countries: ["FR", "DE", "ES"], name: "Europe", color: "#10b981" },
50
+ { countries: ["IQ", "IR"], name: "Middle East", color: "#f59e0b" }
51
51
  ]}
52
52
  />`,
53
53
  preview: {
@@ -59,17 +59,17 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
59
59
  'Discover luxury accommodations across multiple continents. Click on any region to learn more about our properties in that area.',
60
60
  regions: [
61
61
  {
62
- countries: ['united-states', 'canada'],
62
+ countries: ['US', 'CA'],
63
63
  name: 'North America',
64
64
  color: '#3b82f6',
65
65
  },
66
66
  {
67
- countries: ['france', 'germany', 'spain'],
67
+ countries: ['FR', 'DE', 'ES'],
68
68
  name: 'Europe',
69
69
  color: '#10b981',
70
70
  },
71
71
  {
72
- countries: ['iraq', 'iran'],
72
+ countries: ['IQ', 'IR'],
73
73
  name: 'Middle East',
74
74
  color: '#f59e0b',
75
75
  },
@@ -83,10 +83,10 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
83
83
  code: `<InteractiveRegionsMap
84
84
  title="Regional Divisions"
85
85
  regions={[
86
- { countries: ["france", "germany", "spain"], name: "Western Europe", color: "#8b5cf6" },
87
- { countries: ["iraq", "iran", "saudi-arabia"], name: "Middle East", color: "#ef4444" },
88
- { countries: ["south-africa", "kenya", "madagascar"], name: "Africa", color: "#f97316" },
89
- { countries: ["united-states", "canada"], name: "North America", color: "#06b6d4" }
86
+ { countries: ["FR", "DE", "ES"], name: "Western Europe", color: "#8b5cf6" },
87
+ { countries: ["IQ", "IR", "SA"], name: "Middle East", color: "#ef4444" },
88
+ { countries: ["ZA", "KE", "MG"], name: "Africa", color: "#f97316" },
89
+ { countries: ["US", "CA"], name: "North America", color: "#06b6d4" }
90
90
  ]}
91
91
  />`,
92
92
  preview: {
@@ -96,22 +96,22 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
96
96
  title: 'Regional Divisions',
97
97
  regions: [
98
98
  {
99
- countries: ['france', 'germany', 'spain'],
99
+ countries: ['FR', 'DE', 'ES'],
100
100
  name: 'Western Europe',
101
101
  color: '#8b5cf6',
102
102
  },
103
103
  {
104
- countries: ['iraq', 'iran', 'saudi-arabia'],
104
+ countries: ['IQ', 'IR', 'SA'],
105
105
  name: 'Middle East',
106
106
  color: '#ef4444',
107
107
  },
108
108
  {
109
- countries: ['south-africa', 'kenya', 'madagascar'],
109
+ countries: ['ZA', 'KE', 'MG'],
110
110
  name: 'Africa',
111
111
  color: '#f97316',
112
112
  },
113
113
  {
114
- countries: ['united-states', 'canada'],
114
+ countries: ['US', 'CA'],
115
115
  name: 'North America',
116
116
  color: '#06b6d4',
117
117
  },
@@ -126,10 +126,10 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
126
126
  title="Hotel Locations by Region"
127
127
  content="Click on any region to view available properties"
128
128
  regions={[
129
- { countries: ["france", "spain"], name: "Southern Europe", color: "#3b82f6", href: "/hotels/southern-europe" },
130
- { countries: ["germany"], name: "Central Europe", color: "#10b981", href: "/hotels/central-europe" },
131
- { countries: ["iraq", "iran"], name: "Middle East", color: "#f59e0b", href: "/hotels/middle-east" },
132
- { countries: ["south-africa", "kenya"], name: "Africa", color: "#ef4444", href: "/hotels/africa" }
129
+ { countries: ["FR", "ES"], name: "Southern Europe", color: "#3b82f6", href: "/hotels/southern-europe" },
130
+ { countries: ["DE"], name: "Central Europe", color: "#10b981", href: "/hotels/central-europe" },
131
+ { countries: ["IQ", "IR"], name: "Middle East", color: "#f59e0b", href: "/hotels/middle-east" },
132
+ { countries: ["ZA", "KE"], name: "Africa", color: "#ef4444", href: "/hotels/africa" }
133
133
  ]}
134
134
  />`,
135
135
  preview: {
@@ -140,25 +140,25 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
140
140
  content: 'Click on any region to view available properties',
141
141
  regions: [
142
142
  {
143
- countries: ['france', 'spain'],
143
+ countries: ['FR', 'ES'],
144
144
  name: 'Southern Europe',
145
145
  color: '#3b82f6',
146
146
  href: '/hotels/southern-europe',
147
147
  },
148
148
  {
149
- countries: ['germany'],
149
+ countries: ['DE'],
150
150
  name: 'Central Europe',
151
151
  color: '#10b981',
152
152
  href: '/hotels/central-europe',
153
153
  },
154
154
  {
155
- countries: ['iraq', 'iran'],
155
+ countries: ['IQ', 'IR'],
156
156
  name: 'Middle East',
157
157
  color: '#f59e0b',
158
158
  href: '/hotels/middle-east',
159
159
  },
160
160
  {
161
- countries: ['south-africa', 'kenya'],
161
+ countries: ['ZA', 'KE'],
162
162
  name: 'Africa',
163
163
  color: '#ef4444',
164
164
  href: '/hotels/africa',
@@ -174,14 +174,14 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
174
174
  title="Global Hotel Network"
175
175
  content="Our extensive portfolio spans continents with premium properties in key destinations"
176
176
  regions={[
177
- { countries: ["united-states", "canada"], name: "North America", color: "#3b82f6" },
178
- { countries: ["brazil", "argentina", "mexico"], name: "Latin America", color: "#10b981" },
179
- { countries: ["france", "germany", "spain", "italy", "united-kingdom"], name: "Europe", color: "#8b5cf6" },
180
- { countries: ["iraq", "iran", "saudi-arabia"], name: "Middle East", color: "#f59e0b" },
181
- { countries: ["south-africa", "kenya", "madagascar", "egypt"], name: "Africa", color: "#ef4444" },
182
- { countries: ["china", "japan", "india"], name: "Asia", color: "#06b6d4" },
183
- { countries: ["australia"], name: "Oceania", color: "#f97316" },
184
- { countries: ["russia"], name: "Eastern Europe", color: "#84cc16" }
177
+ { countries: ["US", "CA"], name: "North America", color: "#3b82f6" },
178
+ { countries: ["BR", "AR", "MX"], name: "Latin America", color: "#10b981" },
179
+ { countries: ["FR", "DE", "ES", "IT", "GB"], name: "Europe", color: "#8b5cf6" },
180
+ { countries: ["IQ", "IR", "SA"], name: "Middle East", color: "#f59e0b" },
181
+ { countries: ["ZA", "KE", "MG", "EG"], name: "Africa", color: "#ef4444" },
182
+ { countries: ["CN", "JP", "IN"], name: "Asia", color: "#06b6d4" },
183
+ { countries: ["AU"], name: "Oceania", color: "#f97316" },
184
+ { countries: ["RU"], name: "Eastern Europe", color: "#84cc16" }
185
185
  ]}
186
186
  />`,
187
187
  preview: {
@@ -193,43 +193,60 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
193
193
  'Our extensive portfolio spans continents with premium properties in key destinations',
194
194
  regions: [
195
195
  {
196
- countries: ['united-states', 'canada'],
196
+ countries: ['US', 'CA'],
197
197
  name: 'North America',
198
198
  color: '#3b82f6',
199
199
  },
200
200
  {
201
- countries: ['brazil', 'argentina', 'mexico'],
201
+ countries: ['BR', 'AR', 'MX'],
202
202
  name: 'Latin America',
203
203
  color: '#10b981',
204
204
  },
205
205
  {
206
- countries: [
207
- 'france',
208
- 'germany',
209
- 'spain',
210
- 'italy',
211
- 'united-kingdom',
212
- ],
206
+ countries: ['FR', 'DE', 'ES', 'IT', 'GB'],
213
207
  name: 'Europe',
214
208
  color: '#8b5cf6',
215
209
  },
216
210
  {
217
- countries: ['iraq', 'iran', 'saudi-arabia'],
211
+ countries: ['IQ', 'IR', 'SA'],
218
212
  name: 'Middle East',
219
213
  color: '#f59e0b',
220
214
  },
221
215
  {
222
- countries: ['south-africa', 'kenya', 'madagascar', 'egypt'],
216
+ countries: ['ZA', 'KE', 'MG', 'EG'],
223
217
  name: 'Africa',
224
218
  color: '#ef4444',
225
219
  },
226
220
  {
227
- countries: ['china', 'japan', 'india'],
221
+ countries: ['CN', 'JP', 'IN'],
228
222
  name: 'Asia',
229
223
  color: '#06b6d4',
230
224
  },
231
- { countries: ['australia'], name: 'Oceania', color: '#f97316' },
232
- { countries: ['russia'], name: 'Eastern Europe', color: '#84cc16' },
225
+ { countries: ['AU'], name: 'Oceania', color: '#f97316' },
226
+ { countries: ['RU'], name: 'Eastern Europe', color: '#84cc16' },
227
+ ],
228
+ },
229
+ },
230
+ },
231
+ {
232
+ name: 'Zoomed In',
233
+ description:
234
+ 'Map configured to initially zoom into a specific area (e.g., Europe)',
235
+ code: `<InteractiveRegionsMap
236
+ title="European Hotels"
237
+ initialView={{ x: -1600, y: -450, scale: 4.5 }}
238
+ regions={[
239
+ { countries: ["FR", "DE", "ES", "IT", "GB"], name: "Europe" }
240
+ ]}
241
+ />`,
242
+ preview: {
243
+ type: 'component',
244
+ component: 'InteractiveRegionsMap',
245
+ props: {
246
+ title: 'European Hotels',
247
+ initialView: { x: 100, y: 100, scale: 4.5 },
248
+ regions: [
249
+ { countries: ['FR', 'DE', 'ES', 'IT', 'GB'], name: 'Europe' },
233
250
  ],
234
251
  },
235
252
  },
@@ -240,8 +257,8 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
240
257
  code: `<InteractiveRegionsMap
241
258
  title="Primary Markets"
242
259
  regions={[
243
- { countries: ["united-states"], name: "United States" },
244
- { countries: ["france", "germany"], name: "Europe" }
260
+ { countries: ["US"], name: "United States" },
261
+ { countries: ["FR", "DE"], name: "Europe" }
245
262
  ]}
246
263
  />`,
247
264
  preview: {
@@ -250,13 +267,217 @@ export const interactiveRegionsMapConfig: ComponentConfig = {
250
267
  props: {
251
268
  title: 'Primary Markets',
252
269
  regions: [
253
- { countries: ['united-states'], name: 'United States' },
254
- { countries: ['france', 'germany'], name: 'Europe' },
270
+ { countries: ['US'], name: 'United States' },
271
+ { countries: ['FR', 'DE'], name: 'Europe' },
272
+ ],
273
+ },
274
+ },
275
+ },
276
+ {
277
+ name: 'Custom Styled',
278
+ description:
279
+ 'Demonstrates mapStyles and classNames props for full visual customisation',
280
+ code: `<InteractiveRegionsMap
281
+ title="Our Regions"
282
+ mapStyles={{
283
+ mapBackground: '#1e293b',
284
+ countryDefaultFill: '#334155',
285
+ countryStroke: '#0f172a',
286
+ regionDefaultColor: '#6366f1',
287
+ }}
288
+ classNames={{
289
+ title: 'mb-2 text-3xl font-bold text-white',
290
+ content: 'max-w-2xl text-lg text-slate-400',
291
+ mapContainer: 'relative aspect-video w-full touch-none overflow-hidden rounded-xl shadow-2xl',
292
+ resetButton: 'rounded-md bg-slate-700 px-3 py-1.5 text-sm font-medium text-slate-200 hover:bg-slate-600',
293
+ tooltip: 'pointer-events-none fixed z-50 rounded-md bg-slate-700 px-3 py-2 text-sm font-medium text-white shadow-md',
294
+ legendItem: 'flex items-center gap-2 rounded-lg border border-slate-700 bg-slate-800 px-3 py-2 transition-all duration-200',
295
+ legendItemActive: 'flex items-center gap-2 rounded-lg border border-indigo-500 bg-slate-700 px-3 py-2 shadow-md transition-all duration-200',
296
+ }}
297
+ regions={[
298
+ { countries: ["US", "CA"], name: "North America", color: "#6366f1" },
299
+ { countries: ["FR", "DE", "GB"], name: "Europe", color: "#10b981" },
300
+ ]}
301
+ />`,
302
+ preview: {
303
+ type: 'component',
304
+ component: 'InteractiveRegionsMap',
305
+ props: {
306
+ title: 'Our Regions',
307
+ mapStyles: {
308
+ mapBackground: '#1e293b',
309
+ countryDefaultFill: '#334155',
310
+ countryStroke: '#0f172a',
311
+ regionDefaultColor: '#6366f1',
312
+ },
313
+ classNames: {
314
+ title: 'mb-2 text-3xl font-bold text-white',
315
+ content: 'max-w-2xl text-lg text-slate-400',
316
+ mapContainer:
317
+ 'relative aspect-video w-full touch-none overflow-hidden rounded-xl shadow-2xl',
318
+ resetButton:
319
+ 'rounded-md bg-slate-700 px-3 py-1.5 text-sm font-medium text-slate-200 hover:bg-slate-600',
320
+ tooltip:
321
+ 'pointer-events-none fixed z-50 rounded-md bg-slate-700 px-3 py-2 text-sm font-medium text-white shadow-md',
322
+ legendItem:
323
+ 'flex items-center gap-2 rounded-lg border border-slate-700 bg-slate-800 px-3 py-2 transition-all duration-200',
324
+ legendItemActive:
325
+ 'flex items-center gap-2 rounded-lg border border-indigo-500 bg-slate-700 px-3 py-2 shadow-md transition-all duration-200',
326
+ },
327
+ regions: [
328
+ {
329
+ countries: ['US', 'CA'],
330
+ name: 'North America',
331
+ color: '#6366f1',
332
+ },
333
+ { countries: ['FR', 'DE', 'GB'], name: 'Europe', color: '#10b981' },
334
+ ],
335
+ },
336
+ },
337
+ },
338
+ {
339
+ name: 'Compound Primitives',
340
+ description:
341
+ 'Uses the compound component API to compose Legend, Tooltip, ZoomControls and ResetButton as explicit children',
342
+ code: `<InteractiveRegionsMap
343
+ title="Global Presence"
344
+ regions={[
345
+ { countries: ["US", "CA"], name: "North America", color: "#3b82f6" },
346
+ { countries: ["FR", "DE", "ES", "IT", "GB"], name: "Europe", color: "#10b981" },
347
+ { countries: ["CN", "JP", "IN"], name: "Asia", color: "#f59e0b" },
348
+ ]}
349
+ >
350
+ {/*
351
+ ZoomControls renders as an absolute overlay inside the map canvas.
352
+ Use the position prop to place it: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
353
+ */}
354
+ <InteractiveRegionsMap.ZoomControls position="bottom-right" />
355
+
356
+ {/* Tooltip uses fixed positioning so can be placed anywhere inside the provider */}
357
+ <InteractiveRegionsMap.Tooltip />
358
+
359
+ <InteractiveRegionsMap.Legend />
360
+ </InteractiveRegionsMap>`,
361
+ preview: {
362
+ type: 'component',
363
+ component: 'InteractiveRegionsMap',
364
+ props: {
365
+ title: 'Global Presence',
366
+ regions: [
367
+ {
368
+ countries: ['US', 'CA'],
369
+ name: 'North America',
370
+ color: '#3b82f6',
371
+ },
372
+ {
373
+ countries: ['FR', 'DE', 'ES', 'IT', 'GB'],
374
+ name: 'Europe',
375
+ color: '#10b981',
376
+ },
377
+ { countries: ['CN', 'JP', 'IN'], name: 'Asia', color: '#f59e0b' },
255
378
  ],
256
379
  },
257
380
  },
258
381
  },
382
+ {
383
+ name: 'Journey / Trip Planner',
384
+ description:
385
+ 'Visual route planner with animated waypoints, transport icons, callout labels and step navigation',
386
+ code: `// Waypoint coordinates use SVG viewBox space (0–1010 x, 0–666 y).
387
+ // Use the developer tools SVG inspector to find coordinates for any location.
388
+
389
+ const WAYPOINTS = [
390
+ {
391
+ id: 'london',
392
+ label: 'London',
393
+ description: 'Trip begins',
394
+ x: 468,
395
+ y: 195,
396
+ transport: 'flight',
397
+ duration: 'Start',
398
+ },
399
+ {
400
+ id: 'dubai',
401
+ label: 'Dubai',
402
+ description: 'Stopover',
403
+ x: 610,
404
+ y: 330,
405
+ transport: 'flight',
406
+ duration: '7h flight',
407
+ },
408
+ {
409
+ id: 'singapore',
410
+ label: 'Singapore',
411
+ description: 'Cultural hub',
412
+ x: 750,
413
+ y: 415,
414
+ transport: 'flight',
415
+ duration: '7h flight',
416
+ },
417
+ {
418
+ id: 'sydney',
419
+ label: 'Sydney',
420
+ description: 'Final destination',
421
+ x: 870,
422
+ y: 510,
423
+ transport: 'flight',
424
+ duration: '8h flight',
425
+ },
426
+ ];
427
+
428
+ export function TripPlanner() {
429
+ const [step, setStep] = useState(0);
430
+
431
+ return (
432
+ <InteractiveRegionsMap
433
+ title="Around the World"
434
+ content="Follow the journey from London to Sydney"
435
+ regions={[]}
436
+ mapStyles={{ mapBackground: '#bfdbfe' }}
437
+ >
438
+ <InteractiveRegionsMap.ZoomControls position="bottom-right" />
439
+ <InteractiveRegionsMap.Tooltip />
440
+
441
+ {/*
442
+ Journey renders the SVG overlay and provides JourneyContext.
443
+ Place it as a child of InteractiveRegionsMap so it sits
444
+ inside the map canvas div.
445
+ */}
446
+ <InteractiveRegionsMap.Journey
447
+ waypoints={WAYPOINTS}
448
+ activeIndex={step}
449
+ onStepChange={(i) => setStep(i)}
450
+ pathColor="#3b82f6"
451
+ autoFocus
452
+ autoFocusScale={2.5}
453
+ animationDuration={900}
454
+ >
455
+ {/* Callout bubble above the active waypoint */}
456
+ <InteractiveRegionsMap.JourneyCallout />
457
+ </InteractiveRegionsMap.Journey>
458
+
459
+ {/* JourneyControls and JourneyStepList also consume JourneyContext */}
460
+ {/* so they must be inside <Journey>, not siblings of it */}
461
+ <InteractiveRegionsMap.JourneyControls />
462
+ <InteractiveRegionsMap.JourneyStepList />
463
+ </InteractiveRegionsMap>
464
+ );
465
+ }`,
466
+ preview: {
467
+ type: 'component',
468
+ component: 'InteractiveRegionsMap',
469
+ props: {
470
+ title: 'Around the World',
471
+ content: 'Follow the journey from London to Sydney',
472
+ regions: [],
473
+ mapStyles: { mapBackground: '#bfdbfe' },
474
+ },
475
+ },
476
+ },
259
477
  ],
260
478
  dependencies: ['card', 'badge', 'utils'],
261
- files: ['components/interactive-regions-map/index.tsx'],
479
+ files: [
480
+ 'components/interactive-regions-map/index.tsx',
481
+ 'components/interactive-regions-map/world-map-data.ts',
482
+ ],
262
483
  };
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  export { HeroMinimal } from './components/hero-minimal/index.js';
3
3
  export { Pricing } from './components/pricing/index.js';
4
4
  export { Testimonials } from './components/testimonials/index.js';
5
- export { InteractiveRegionsMap } from './components/interactive-regions-map/index.js';
5
+ export { InteractiveRegionsMap } from '@foundrykit/maps';
6
6
 
7
7
  // Export utilities from utils package
8
8
  export { cn } from '@foundrykit/utils';