ghostcn 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/commands/create.js +10 -3
  2. package/dist/commands/diff.js +47 -5
  3. package/dist/commands/init.js +17 -8
  4. package/dist/commands/list.js +22 -4
  5. package/dist/registry/components/accordion.json +66 -0
  6. package/dist/registry/components/account-card.json +57 -0
  7. package/dist/registry/components/announcement-bar.json +79 -0
  8. package/dist/registry/components/archive-header.json +1 -1
  9. package/dist/registry/components/author-card.json +2 -2
  10. package/dist/registry/components/author-list.json +1 -1
  11. package/dist/registry/components/author-stack.json +63 -0
  12. package/dist/registry/components/avatar.json +62 -0
  13. package/dist/registry/components/back-to-top.json +72 -0
  14. package/dist/registry/components/breadcrumbs.json +59 -0
  15. package/dist/registry/components/button.json +1 -1
  16. package/dist/registry/components/callout.json +56 -0
  17. package/dist/registry/components/checkbox.json +82 -0
  18. package/dist/registry/components/code-copy.json +52 -0
  19. package/dist/registry/components/comments-section.json +56 -0
  20. package/dist/registry/components/dialog.json +83 -0
  21. package/dist/registry/components/dropdown.json +85 -0
  22. package/dist/registry/components/empty-state.json +65 -0
  23. package/dist/registry/components/error-card.json +74 -0
  24. package/dist/registry/components/faq-section.json +83 -0
  25. package/dist/registry/components/featured-posts.json +2 -2
  26. package/dist/registry/components/hero.json +89 -0
  27. package/dist/registry/components/image-lightbox.json +44 -0
  28. package/dist/registry/components/input.json +8 -2
  29. package/dist/registry/components/magazine-grid.json +62 -0
  30. package/dist/registry/components/member-cta.json +1 -1
  31. package/dist/registry/components/mobile-dock.json +69 -0
  32. package/dist/registry/components/newsletter-form.json +12 -3
  33. package/dist/registry/components/pagination.json +2 -2
  34. package/dist/registry/components/post-card.json +2 -2
  35. package/dist/registry/components/post-grid.json +2 -2
  36. package/dist/registry/components/post-header.json +2 -2
  37. package/dist/registry/components/post-list.json +62 -0
  38. package/dist/registry/components/pricing-table.json +24 -4
  39. package/dist/registry/components/pull-quote.json +70 -0
  40. package/dist/registry/components/radio-group.json +94 -0
  41. package/dist/registry/components/reader-controls.json +60 -0
  42. package/dist/registry/components/reading-meta.json +49 -0
  43. package/dist/registry/components/reading-progress.json +73 -0
  44. package/dist/registry/components/related-posts.json +7 -1
  45. package/dist/registry/components/search-trigger.json +68 -0
  46. package/dist/registry/components/select.json +94 -0
  47. package/dist/registry/components/separator.json +46 -0
  48. package/dist/registry/components/series-nav.json +62 -0
  49. package/dist/registry/components/share-buttons.json +76 -0
  50. package/dist/registry/components/site-footer.json +2 -2
  51. package/dist/registry/components/site-header.json +1 -1
  52. package/dist/registry/components/skeleton.json +48 -0
  53. package/dist/registry/components/skip-link.json +53 -0
  54. package/dist/registry/components/social-links.json +74 -0
  55. package/dist/registry/components/stat-strip.json +85 -0
  56. package/dist/registry/components/sticky-subscribe.json +82 -0
  57. package/dist/registry/components/subscribe-bar.json +61 -0
  58. package/dist/registry/components/switch.json +76 -0
  59. package/dist/registry/components/table-of-contents.json +12 -2
  60. package/dist/registry/components/tabs.json +81 -0
  61. package/dist/registry/components/tag-bar.json +63 -0
  62. package/dist/registry/components/tag-grid.json +1 -1
  63. package/dist/registry/components/tag-list.json +1 -1
  64. package/dist/registry/components/textarea.json +95 -0
  65. package/dist/registry/components/theme-toggle.json +65 -0
  66. package/dist/registry/components/tier-comparison.json +55 -0
  67. package/dist/registry/components/timeline.json +85 -0
  68. package/dist/registry/components/tooltip.json +65 -0
  69. package/dist/registry/components/visibility-badge.json +71 -0
  70. package/dist/registry/index.json +478 -4
  71. package/dist/templates/playground/index.html +2 -2
  72. package/dist/templates/playground/playground.css +8 -1
  73. package/dist/templates/playground/playground.js +39 -5
  74. package/dist/templates/playground/preview.css +1 -0
  75. package/dist/templates/theme-tools.mjs +62 -24
  76. package/dist/utils/component-diff.d.ts +1 -1
  77. package/dist/utils/component-diff.js +46 -17
  78. package/dist/utils/component-files.js +3 -2
  79. package/dist/utils/component-history.js +1 -1
  80. package/dist/utils/playground-server.js +40 -12
  81. package/dist/utils/preview-renderer.d.ts +77 -0
  82. package/dist/utils/preview-renderer.js +68 -8
  83. package/dist/utils/registry.js +15 -5
  84. package/dist/utils/theme-files.js +14 -7
  85. package/dist/utils/theme-project.js +6 -4
  86. package/dist/utils/theme-scaffold.js +22 -7
  87. package/dist/utils/theme.js +39 -32
  88. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "name": "newsletter-form",
4
4
  "description": "A native Ghost members subscription form with state handling.",
5
- "category": "components:ui",
5
+ "category": "components:members",
6
6
  "ghost_version": ">=5.0.0",
7
7
  "files": [
8
8
  "newsletter-form.hbs",
@@ -11,12 +11,13 @@
11
11
  },
12
12
  {
13
13
  "name": "pricing-table",
14
- "description": "Membership tiers and pricing plans with native Ghost Portal checkout triggers.",
15
- "category": "components:ui",
14
+ "description": "Live Ghost tiers, prices, currencies, benefits, and progressive monthly/yearly toggle with Portal checkout.",
15
+ "category": "components:members",
16
16
  "ghost_version": ">=5.0.0",
17
17
  "files": [
18
18
  "pricing-table.hbs",
19
- "pricing-table.css"
19
+ "pricing-table.css",
20
+ "pricing-table.js"
20
21
  ]
21
22
  },
22
23
  {
@@ -190,6 +191,26 @@
190
191
  "alert.css"
191
192
  ]
192
193
  },
194
+ {
195
+ "name": "avatar",
196
+ "description": "A reusable author or user avatar with image and initials fallback.",
197
+ "category": "components:ui",
198
+ "ghost_version": ">=5.0.0",
199
+ "files": [
200
+ "avatar.hbs",
201
+ "avatar.css"
202
+ ]
203
+ },
204
+ {
205
+ "name": "accordion",
206
+ "description": "Zero-JS collapsible disclosure built on native details and summary elements.",
207
+ "category": "components:ui",
208
+ "ghost_version": ">=5.0.0",
209
+ "files": [
210
+ "accordion.hbs",
211
+ "accordion.css"
212
+ ]
213
+ },
193
214
  {
194
215
  "name": "post-grid",
195
216
  "description": "A responsive grid using post-card; pass posts from a loop, archive or get query.",
@@ -229,5 +250,458 @@
229
250
  "archive-header.hbs",
230
251
  "archive-header.css"
231
252
  ]
253
+ },
254
+ {
255
+ "name": "theme-toggle",
256
+ "description": "Light, dark, and system theme switcher syncing .dark-mode and .auto-color with localStorage persistence.",
257
+ "category": "components:layout",
258
+ "ghost_version": ">=5.0.0",
259
+ "files": [
260
+ "theme-toggle.hbs",
261
+ "theme-toggle.css",
262
+ "theme-toggle.js"
263
+ ]
264
+ },
265
+ {
266
+ "name": "announcement-bar",
267
+ "description": "Dismissible top publication announcement bar with optional link and session persistence.",
268
+ "category": "components:layout",
269
+ "ghost_version": ">=5.0.0",
270
+ "files": [
271
+ "announcement-bar.hbs",
272
+ "announcement-bar.css",
273
+ "announcement-bar.js"
274
+ ]
275
+ },
276
+ {
277
+ "name": "reading-progress",
278
+ "description": "Thin scroll-linked reading progress bar tracking article scroll depth.",
279
+ "category": "components:content",
280
+ "ghost_version": ">=5.0.0",
281
+ "files": [
282
+ "reading-progress.hbs",
283
+ "reading-progress.css",
284
+ "reading-progress.js"
285
+ ]
286
+ },
287
+ {
288
+ "name": "share-buttons",
289
+ "description": "Accessible article share links (Copy link, Bluesky, X, LinkedIn, Email, and native Web Share).",
290
+ "category": "components:content",
291
+ "ghost_version": ">=5.0.0",
292
+ "files": [
293
+ "share-buttons.hbs",
294
+ "share-buttons.css",
295
+ "share-buttons.js"
296
+ ]
297
+ },
298
+ {
299
+ "name": "breadcrumbs",
300
+ "description": "Accessible breadcrumb navigation with Schema.org BreadcrumbList microdata for posts, tags, and authors.",
301
+ "category": "components:content",
302
+ "ghost_version": ">=5.0.0",
303
+ "files": [
304
+ "breadcrumbs.hbs",
305
+ "breadcrumbs.css"
306
+ ]
307
+ },
308
+ {
309
+ "name": "visibility-badge",
310
+ "description": "Ghost-native access indicator pill for members-only, paid-only, tier-restricted, or public posts.",
311
+ "category": "components:members",
312
+ "ghost_version": ">=5.0.0",
313
+ "files": [
314
+ "visibility-badge.hbs",
315
+ "visibility-badge.css"
316
+ ]
317
+ },
318
+ {
319
+ "name": "callout",
320
+ "description": "Editorial callout box with semantic note, tip, warning, and danger accents.",
321
+ "category": "components:ui",
322
+ "ghost_version": ">=5.0.0",
323
+ "files": [
324
+ "callout.hbs",
325
+ "callout.css"
326
+ ]
327
+ },
328
+ {
329
+ "name": "tabs",
330
+ "description": "Accessible tabbed panel switcher with underline, pills, and boxed variants plus arrow-key navigation.",
331
+ "category": "components:ui",
332
+ "ghost_version": ">=5.0.0",
333
+ "files": [
334
+ "tabs.hbs",
335
+ "tabs.css",
336
+ "tabs.js"
337
+ ]
338
+ },
339
+ {
340
+ "name": "dialog",
341
+ "description": "Accessible native HTML dialog modal with backdrop click, Escape key close, and customizable content.",
342
+ "category": "components:ui",
343
+ "ghost_version": ">=5.0.0",
344
+ "files": [
345
+ "dialog.hbs",
346
+ "dialog.css",
347
+ "dialog.js"
348
+ ]
349
+ },
350
+ {
351
+ "name": "dropdown",
352
+ "description": "Accessible popover menu built on native details/summary with Escape and outside-click dismissal.",
353
+ "category": "components:ui",
354
+ "ghost_version": ">=5.0.0",
355
+ "files": [
356
+ "dropdown.hbs",
357
+ "dropdown.css",
358
+ "dropdown.js"
359
+ ]
360
+ },
361
+ {
362
+ "name": "separator",
363
+ "description": "Editorial horizontal divider with solid, dashed, and labeled variants.",
364
+ "category": "components:ui",
365
+ "ghost_version": ">=5.0.0",
366
+ "files": [
367
+ "separator.hbs",
368
+ "separator.css"
369
+ ]
370
+ },
371
+ {
372
+ "name": "empty-state",
373
+ "description": "Reusable empty state block with icon, title, message, and optional call-to-action button.",
374
+ "category": "components:ui",
375
+ "ghost_version": ">=5.0.0",
376
+ "files": [
377
+ "empty-state.hbs",
378
+ "empty-state.css"
379
+ ]
380
+ },
381
+ {
382
+ "name": "textarea",
383
+ "description": "Accessible labeled multiline textarea with optional hint, invalid, and disabled states.",
384
+ "category": "components:ui",
385
+ "ghost_version": ">=5.0.0",
386
+ "files": [
387
+ "textarea.hbs",
388
+ "textarea.css"
389
+ ]
390
+ },
391
+ {
392
+ "name": "select",
393
+ "description": "Accessible labeled native select dropdown with custom chevron icon and filled variant.",
394
+ "category": "components:ui",
395
+ "ghost_version": ">=5.0.0",
396
+ "files": [
397
+ "select.hbs",
398
+ "select.css"
399
+ ]
400
+ },
401
+ {
402
+ "name": "checkbox",
403
+ "description": "Accessible native checkbox with inline and card variants, optional description, and crisp tick mark.",
404
+ "category": "components:ui",
405
+ "ghost_version": ">=5.0.0",
406
+ "files": [
407
+ "checkbox.hbs",
408
+ "checkbox.css"
409
+ ]
410
+ },
411
+ {
412
+ "name": "hero",
413
+ "description": "Publication homepage hero with centered, split, editorial, and cover variants plus optional inline signup.",
414
+ "category": "components:content",
415
+ "ghost_version": ">=5.0.0",
416
+ "files": [
417
+ "hero.hbs",
418
+ "hero.css"
419
+ ]
420
+ },
421
+ {
422
+ "name": "post-list",
423
+ "description": "Compact editorial post list for newsletter archives, feeds, and sidebars.",
424
+ "category": "components:content",
425
+ "ghost_version": ">=5.0.0",
426
+ "files": [
427
+ "post-list.hbs",
428
+ "post-list.css"
429
+ ]
430
+ },
431
+ {
432
+ "name": "author-stack",
433
+ "description": "Overlapping multi-author avatar stack with linked names and optional date/reading time.",
434
+ "category": "components:content",
435
+ "ghost_version": ">=5.0.0",
436
+ "files": [
437
+ "author-stack.hbs",
438
+ "author-stack.css"
439
+ ]
440
+ },
441
+ {
442
+ "name": "code-copy",
443
+ "description": "Progressive-enhancement copy button and language header automatically added to Ghost post code blocks.",
444
+ "category": "components:content",
445
+ "ghost_version": ">=5.0.0",
446
+ "files": [
447
+ "code-copy.hbs",
448
+ "code-copy.css",
449
+ "code-copy.js"
450
+ ]
451
+ },
452
+ {
453
+ "name": "image-lightbox",
454
+ "description": "Zero-dependency zoom lightbox for Ghost Koenig image and gallery cards with keyboard navigation.",
455
+ "category": "components:content",
456
+ "ghost_version": ">=5.0.0",
457
+ "files": [
458
+ "image-lightbox.hbs",
459
+ "image-lightbox.css",
460
+ "image-lightbox.js"
461
+ ]
462
+ },
463
+ {
464
+ "name": "back-to-top",
465
+ "description": "Scroll-to-top button that reveals after scrolling past the hero and respects prefers-reduced-motion.",
466
+ "category": "components:content",
467
+ "ghost_version": ">=5.0.0",
468
+ "files": [
469
+ "back-to-top.hbs",
470
+ "back-to-top.css",
471
+ "back-to-top.js"
472
+ ]
473
+ },
474
+ {
475
+ "name": "reading-meta",
476
+ "description": "Reusable post metadata row with author, date, reading time, and optional tag or comment count.",
477
+ "category": "components:content",
478
+ "ghost_version": ">=5.0.0",
479
+ "files": [
480
+ "reading-meta.hbs",
481
+ "reading-meta.css"
482
+ ]
483
+ },
484
+ {
485
+ "name": "subscribe-bar",
486
+ "description": "Compact single-row native Ghost members subscribe bar for headers, footers, and hero sections.",
487
+ "category": "components:members",
488
+ "ghost_version": ">=5.0.0",
489
+ "files": [
490
+ "subscribe-bar.hbs",
491
+ "subscribe-bar.css"
492
+ ]
493
+ },
494
+ {
495
+ "name": "search-trigger",
496
+ "description": "Keyboard-hinted search trigger wired directly to Ghost native Sodo Search (data-ghost-search).",
497
+ "category": "components:layout",
498
+ "ghost_version": ">=5.0.0",
499
+ "files": [
500
+ "search-trigger.hbs",
501
+ "search-trigger.css",
502
+ "search-trigger.js"
503
+ ]
504
+ },
505
+ {
506
+ "name": "tier-comparison",
507
+ "description": "Responsive Ghost membership tier comparison matrix displaying live monthly/yearly prices, benefits, and Portal CTAs.",
508
+ "category": "components:members",
509
+ "ghost_version": ">=5.0.0",
510
+ "files": [
511
+ "tier-comparison.hbs",
512
+ "tier-comparison.css"
513
+ ]
514
+ },
515
+ {
516
+ "name": "social-links",
517
+ "description": "Accessible social channel icon bar reading Ghost site accounts with optional Bluesky, GitHub, LinkedIn, YouTube, Instagram, email, and RSS.",
518
+ "category": "components:layout",
519
+ "ghost_version": ">=5.0.0",
520
+ "files": [
521
+ "social-links.hbs",
522
+ "social-links.css"
523
+ ]
524
+ },
525
+ {
526
+ "name": "tag-bar",
527
+ "description": "Horizontal snap-scrolling topic bar populated from public Ghost tags for quick category browsing.",
528
+ "category": "components:content",
529
+ "ghost_version": ">=5.0.0",
530
+ "files": [
531
+ "tag-bar.hbs",
532
+ "tag-bar.css"
533
+ ]
534
+ },
535
+ {
536
+ "name": "series-nav",
537
+ "description": "Numbered multi-part series box grouping chronological Ghost posts under a shared tag and highlighting the active installment.",
538
+ "category": "components:content",
539
+ "ghost_version": ">=5.0.0",
540
+ "files": [
541
+ "series-nav.hbs",
542
+ "series-nav.css"
543
+ ]
544
+ },
545
+ {
546
+ "name": "magazine-grid",
547
+ "description": "Editorial newsroom grid pairing a large featured lead story with a stacked right-hand dispatch rail.",
548
+ "category": "components:content",
549
+ "ghost_version": ">=5.0.0",
550
+ "files": [
551
+ "magazine-grid.hbs",
552
+ "magazine-grid.css"
553
+ ]
554
+ },
555
+ {
556
+ "name": "comments-section",
557
+ "description": "Styled surface container wrapping Ghost native comments with heading and live comment count badge.",
558
+ "category": "components:content",
559
+ "ghost_version": ">=5.0.0",
560
+ "files": [
561
+ "comments-section.hbs",
562
+ "comments-section.css"
563
+ ]
564
+ },
565
+ {
566
+ "name": "reader-controls",
567
+ "description": "Compact reading comfort toolbar letting readers adjust article font size and serif/sans typeface with localStorage persistence.",
568
+ "category": "components:content",
569
+ "ghost_version": ">=5.0.0",
570
+ "files": [
571
+ "reader-controls.hbs",
572
+ "reader-controls.css",
573
+ "reader-controls.js"
574
+ ]
575
+ },
576
+ {
577
+ "name": "pull-quote",
578
+ "description": "Editorial pull quote and reader testimonial block with accent rule, optional avatar, and centered/card variants.",
579
+ "category": "components:content",
580
+ "ghost_version": ">=5.0.0",
581
+ "files": [
582
+ "pull-quote.hbs",
583
+ "pull-quote.css"
584
+ ]
585
+ },
586
+ {
587
+ "name": "account-card",
588
+ "description": "Signed-in Ghost member profile panel with tier badge, Portal management links, sign-out action, and visitor sign-in fallback.",
589
+ "category": "components:members",
590
+ "ghost_version": ">=5.0.0",
591
+ "files": [
592
+ "account-card.hbs",
593
+ "account-card.css"
594
+ ]
595
+ },
596
+ {
597
+ "name": "sticky-subscribe",
598
+ "description": "Scroll-triggered, session-dismissible native Ghost subscribe prompt that hides automatically for signed-in members.",
599
+ "category": "components:members",
600
+ "ghost_version": ">=5.0.0",
601
+ "files": [
602
+ "sticky-subscribe.hbs",
603
+ "sticky-subscribe.css",
604
+ "sticky-subscribe.js"
605
+ ]
606
+ },
607
+ {
608
+ "name": "faq-section",
609
+ "description": "Zero-JS membership FAQ block with native details disclosures and Schema.org FAQPage microdata.",
610
+ "category": "components:members",
611
+ "ghost_version": ">=5.0.0",
612
+ "files": [
613
+ "faq-section.hbs",
614
+ "faq-section.css"
615
+ ]
616
+ },
617
+ {
618
+ "name": "stat-strip",
619
+ "description": "Editorial social-proof and publication metrics strip for About and Subscribe landing pages.",
620
+ "category": "components:members",
621
+ "ghost_version": ">=5.0.0",
622
+ "files": [
623
+ "stat-strip.hbs",
624
+ "stat-strip.css"
625
+ ]
626
+ },
627
+ {
628
+ "name": "switch",
629
+ "description": "Accessible zero-JS native toggle switch (role=\"switch\") with default and selectable card styles.",
630
+ "category": "components:ui",
631
+ "ghost_version": ">=5.0.0",
632
+ "files": [
633
+ "switch.hbs",
634
+ "switch.css"
635
+ ]
636
+ },
637
+ {
638
+ "name": "radio-group",
639
+ "description": "Accessible native radio button group with default and selectable card styles.",
640
+ "category": "components:ui",
641
+ "ghost_version": ">=5.0.0",
642
+ "files": [
643
+ "radio-group.hbs",
644
+ "radio-group.css"
645
+ ]
646
+ },
647
+ {
648
+ "name": "tooltip",
649
+ "description": "Pure CSS hover and keyboard-focus tooltip for metadata hints, icons, and badges.",
650
+ "category": "components:ui",
651
+ "ghost_version": ">=5.0.0",
652
+ "files": [
653
+ "tooltip.hbs",
654
+ "tooltip.css"
655
+ ]
656
+ },
657
+ {
658
+ "name": "timeline",
659
+ "description": "Vertical editorial timeline for publication changelogs, company milestones, and author biographies.",
660
+ "category": "components:ui",
661
+ "ghost_version": ">=5.0.0",
662
+ "files": [
663
+ "timeline.hbs",
664
+ "timeline.css"
665
+ ]
666
+ },
667
+ {
668
+ "name": "skeleton",
669
+ "description": "Accessible shimmer loading placeholder presets (card, post, avatar, text) with reduced-motion support.",
670
+ "category": "components:ui",
671
+ "ghost_version": ">=5.0.0",
672
+ "files": [
673
+ "skeleton.hbs",
674
+ "skeleton.css"
675
+ ]
676
+ },
677
+ {
678
+ "name": "error-card",
679
+ "description": "Drop-in 404/500 error page block for Ghost error.hbs with status code, native search trigger, and home CTA.",
680
+ "category": "components:layout",
681
+ "ghost_version": ">=5.0.0",
682
+ "files": [
683
+ "error-card.hbs",
684
+ "error-card.css"
685
+ ]
686
+ },
687
+ {
688
+ "name": "skip-link",
689
+ "description": "WCAG keyboard-accessible \"Skip to content\" link hidden visually until focused via Tab.",
690
+ "category": "components:layout",
691
+ "ghost_version": ">=5.0.0",
692
+ "files": [
693
+ "skip-link.hbs",
694
+ "skip-link.css"
695
+ ]
696
+ },
697
+ {
698
+ "name": "mobile-dock",
699
+ "description": "Thumb-friendly mobile bottom navigation bar with Home, Ghost Search, Member Portal, and Top actions.",
700
+ "category": "components:layout",
701
+ "ghost_version": ">=5.0.0",
702
+ "files": [
703
+ "mobile-dock.hbs",
704
+ "mobile-dock.css"
705
+ ]
232
706
  }
233
707
  ]
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
2
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Ghostcn playground</title><link rel="stylesheet" href="/playground.css"><script defer src="/playground.js"></script></head>
3
3
  <body><header><p class="eyebrow">LOCAL COMPONENT PLAYGROUND</p><h1>Build it your way.</h1><p>Installed theme files. Synthetic content. No emails, payments or Ghost settings changes.</p></header>
4
- <main><aside aria-label="Preview controls"><label>Component<select id="component"></select></label><p id="description"></p><label>Theme<select id="scheme"><option value="light">Light</option><option value="dark">Dark</option><option value="auto">Auto</option></select></label><label>Member state<select id="state"><option value="visitor">Visitor</option><option value="free">Free member</option><option value="paid">Paid member</option><option value="disabled">Membership disabled</option><option value="invite">Invite only</option><option value="restricted">Self-signup restricted</option></select></label><div id="parameters"></div><button id="reload" type="button">Reload preview</button><p id="status" role="status"></p></aside>
5
- <section aria-label="Component preview"><iframe id="preview" title="Installed component preview" sandbox="allow-scripts"></iframe><h2>Use in your template</h2><pre><code id="usage"></code></pre><p>Classes only preview if your CSS defines them. For Tailwind, put utilities in a scanned .hbs file and keep <code>npm run dev</code> running. Verify real data, editor cards and member behavior in Ghost.</p><p>Preview changes are temporary. Copy the usage into your theme to keep them.</p></section></main></body></html>
4
+ <main><aside aria-label="Preview controls"><label>Component<select id="component"></select></label><p id="description"></p><label>Theme<select id="scheme"><option value="light">Light</option><option value="dark">Dark</option><option value="auto">Auto</option></select></label><label>Viewport<select id="viewport"><option value="full">Full width</option><option value="desktop">Desktop (1024px)</option><option value="tablet">Tablet (768px)</option><option value="mobile">Mobile (375px)</option></select></label><label>Member state<select id="state"><option value="visitor">Visitor</option><option value="free">Free member</option><option value="paid">Paid member</option><option value="free-only">Free-only site</option><option value="disabled">Membership disabled</option><option value="invite">Invite only</option><option value="restricted">Self-signup restricted</option></select></label><label>Post access<select id="access"><option value="true">Public / accessible</option><option value="false">Protected (paywall)</option></select></label><div id="parameters"></div><button id="reload" type="button">Reload preview</button><p id="status" role="status"></p></aside>
5
+ <section aria-label="Component preview"><div id="frame-stage" data-viewport="full"><iframe id="preview" title="Installed component preview" sandbox="allow-scripts"></iframe></div><div class="usage-header"><h2>Use in your template</h2><button id="copy-usage" type="button" class="copy-button">Copy snippet</button></div><pre><code id="usage"></code></pre><p>Classes only preview if your CSS defines them. For Tailwind, put utilities in a scanned .hbs file and keep <code>npm run dev</code> running. Verify real data, editor cards and member behavior in Ghost.</p><p>Preview changes are temporary. Copy the usage into your theme to keep them.</p></section></main></body></html>
@@ -13,6 +13,13 @@ input, select, button { font: inherit; width: 100%; min-width: 0; padding: 10px;
13
13
  button { cursor: pointer; }
14
14
  input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid #bca1f8; outline-offset: 3px; }
15
15
  label small, #description { color: #a0bdcf; }
16
- iframe { width: 100%; height: 650px; border: 1px solid #516475; border-radius: 8px; background: #fff; }
16
+ #frame-stage { display: flex; justify-content: center; }
17
+ #frame-stage[data-viewport="desktop"] iframe { max-width: 1024px; }
18
+ #frame-stage[data-viewport="tablet"] iframe { max-width: 768px; }
19
+ #frame-stage[data-viewport="mobile"] iframe { max-width: 375px; }
20
+ .usage-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
21
+ .usage-header h2 { margin: 0; }
22
+ .copy-button { width: auto; padding: 6px 14px; font-size: 13px; }
23
+ iframe { width: 100%; height: 650px; border: 1px solid #516475; border-radius: 8px; background: #fff; transition: max-width 200ms ease; }
17
24
  pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #1d2731; padding: 20px; border-radius: 8px; }
18
25
  @media(max-width:760px) { main { grid-template-columns: 1fr; } aside { border-right: 0; border-bottom: 1px solid #34414e; } header, aside, section { padding: 20px; } }
@@ -1,21 +1,39 @@
1
1
  const component = document.querySelector('#component');
2
2
  const parameters = document.querySelector('#parameters');
3
3
  const status = document.querySelector('#status');
4
+ const viewport = document.querySelector('#viewport');
5
+ const frameStage = document.querySelector('#frame-stage');
6
+ const copyUsage = document.querySelector('#copy-usage');
4
7
  const controls = new Map();
5
- let catalog = [], revision, busy = false;
8
+ const booleanParams = new Set(['disabled', 'required', 'invalid', 'urgent', 'decorative', 'open', 'hideDismiss', 'showPublic', 'checked', 'showSubscribe', 'showImage', 'hideMeta', 'showLabel', 'alwaysVisible', 'hideShortcut', 'hideRss', 'hideAll', 'showCounts', 'hideSearch']);
9
+ let catalog = [], revision, busy = false, debounceTimer;
6
10
  const current = () => catalog.find(item => item.name === component.value);
7
11
  function render() {
8
12
  const item = current();
9
13
  if (!item) return;
10
- const query = new URLSearchParams({ scheme: document.querySelector('#scheme').value, state: document.querySelector('#state').value });
14
+ const query = new URLSearchParams({
15
+ scheme: document.querySelector('#scheme').value,
16
+ state: document.querySelector('#state').value,
17
+ access: document.querySelector('#access')?.value || 'true'
18
+ });
11
19
  const args = [];
12
20
  for (const [name, input] of controls) {
13
21
  query.set(name, input.value);
14
- if (input.value) args.push(`${name}=${['disabled','required','invalid','urgent'].includes(name) ? input.value : JSON.stringify(input.value)}`);
22
+ if (booleanParams.has(name)) {
23
+ if (input.value === 'true') args.push(`${name}=true`);
24
+ } else if (input.value) {
25
+ args.push(`${name}=${JSON.stringify(input.value)}`);
26
+ }
15
27
  }
16
28
  document.querySelector('#preview').src = `/preview/${item.name}?${query}`;
17
29
  const context = item.name === 'author-card' ? ' primary_author' : item.name === 'pagination' ? ' pagination' : '';
18
- document.querySelector('#usage').textContent = `{{> "${item.partial}"${context}${args.map(arg => `\n ${arg}`).join('')}\n}}`;
30
+ document.querySelector('#usage').textContent = args.length
31
+ ? `{{> "${item.partial}"${context}${args.map(arg => `\n ${arg}`).join('')}\n}}`
32
+ : `{{> "${item.partial}"${context}}}`;
33
+ }
34
+ function scheduleRender() {
35
+ clearTimeout(debounceTimer);
36
+ debounceTimer = setTimeout(render, 180);
19
37
  }
20
38
  function selectComponent() {
21
39
  controls.clear(); parameters.replaceChildren();
@@ -24,7 +42,7 @@ function selectComponent() {
24
42
  document.querySelector('#description').textContent = item.description;
25
43
  const definitions = { ...item.parameters, ...Object.fromEntries(Object.keys(item.styleSlots).map(key => [key, { description: key === 'class' ? 'Root classes for this instance.' : `Classes for ${item.styleSlots[key].join(', ')}.` }])) };
26
44
  for (const [name, definition] of Object.entries(definitions)) {
27
- const boolean = ['disabled','required','invalid','urgent'].includes(name);
45
+ const boolean = booleanParams.has(name);
28
46
  const label = document.createElement('label'); label.append(document.createTextNode(name));
29
47
  const input = document.createElement(definition.options || boolean ? 'select' : 'input');
30
48
  input.name = name;
@@ -33,6 +51,7 @@ function selectComponent() {
33
51
  const help = document.createElement('small'); help.textContent = definition.description;
34
52
  label.append(input, help); parameters.append(label); controls.set(name, input);
35
53
  input.addEventListener('change', render);
54
+ if (input.tagName === 'INPUT') input.addEventListener('input', scheduleRender);
36
55
  }
37
56
  status.textContent = 'Read-only preview. Your files have not been changed.';
38
57
  render();
@@ -50,6 +69,21 @@ async function loadCatalog() {
50
69
  component.addEventListener('change', selectComponent);
51
70
  document.querySelector('#scheme').addEventListener('change', render);
52
71
  document.querySelector('#state').addEventListener('change', render);
72
+ document.querySelector('#access')?.addEventListener('change', render);
73
+ viewport?.addEventListener('change', () => {
74
+ if (frameStage) frameStage.dataset.viewport = viewport.value;
75
+ });
76
+ copyUsage?.addEventListener('click', async () => {
77
+ const snippet = document.querySelector('#usage')?.textContent || '';
78
+ if (!snippet) return;
79
+ try {
80
+ await navigator.clipboard.writeText(snippet);
81
+ copyUsage.textContent = 'Copied';
82
+ setTimeout(() => { copyUsage.textContent = 'Copy snippet'; }, 1500);
83
+ } catch {
84
+ status.textContent = 'Copy manually from the template snippet below.';
85
+ }
86
+ });
53
87
  document.querySelector('#reload').addEventListener('click', render);
54
88
  loadCatalog().catch(error => { status.textContent = error.message; });
55
89
  setInterval(async () => {
@@ -1,4 +1,5 @@
1
1
  /* Only the preview shell, never component defaults. */
2
+ :root { --ghost-accent-color: #385bc6; }
2
3
  body { margin: 0; background: var(--background); color: var(--foreground); font: 16px/1.5 ui-sans-serif,system-ui,sans-serif; }
3
4
  .playground-preview { padding: 24px; overflow-wrap: anywhere; }
4
5
  #preview-feedback { font-size: 14px; color: var(--muted-foreground); margin-top: 16px; }