@contentrain/astro-kit 0.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.
Files changed (63) hide show
  1. package/README.md +89 -0
  2. package/catalog.json +1780 -0
  3. package/components/_shared/Button.astro +37 -0
  4. package/components/_shared/KitImage.astro +21 -0
  5. package/components/_shared/Section.astro +43 -0
  6. package/components/_shared/types.ts +26 -0
  7. package/components/breadcrumb/Breadcrumb.astro +56 -0
  8. package/components/breadcrumb/fixtures.json +5 -0
  9. package/components/breadcrumb/meta.json +27 -0
  10. package/components/card-grid/CardGrid.astro +82 -0
  11. package/components/card-grid/fixtures.json +6 -0
  12. package/components/card-grid/meta.json +123 -0
  13. package/components/contact-form/ContactForm.astro +79 -0
  14. package/components/contact-form/fixtures.json +18 -0
  15. package/components/contact-form/meta.json +28 -0
  16. package/components/cta/Cta.astro +64 -0
  17. package/components/cta/fixtures.json +6 -0
  18. package/components/cta/meta.json +28 -0
  19. package/components/faq/Faq.astro +79 -0
  20. package/components/faq/fixtures.json +36 -0
  21. package/components/faq/meta.json +30 -0
  22. package/components/footer/Footer.astro +87 -0
  23. package/components/footer/fixtures.json +5 -0
  24. package/components/footer/meta.json +31 -0
  25. package/components/gallery/Gallery.astro +88 -0
  26. package/components/gallery/fixtures.json +191 -0
  27. package/components/gallery/meta.json +30 -0
  28. package/components/header/Header.astro +62 -0
  29. package/components/header/fixtures.json +125 -0
  30. package/components/header/meta.json +34 -0
  31. package/components/hero/Hero.astro +84 -0
  32. package/components/hero/fixtures.json +95 -0
  33. package/components/hero/meta.json +127 -0
  34. package/components/nav/Nav.astro +102 -0
  35. package/components/nav/fixtures.json +80 -0
  36. package/components/nav/meta.json +30 -0
  37. package/components/pagination/Pagination.astro +69 -0
  38. package/components/pagination/fixtures.json +6 -0
  39. package/components/pagination/meta.json +31 -0
  40. package/components/post-card/PostCard.astro +67 -0
  41. package/components/post-card/fixtures.json +54 -0
  42. package/components/post-card/meta.json +32 -0
  43. package/components/prose/Prose.astro +30 -0
  44. package/components/prose/fixtures.json +4 -0
  45. package/components/prose/meta.json +69 -0
  46. package/components/slider/Slider.astro +136 -0
  47. package/components/slider/fixtures.json +5 -0
  48. package/components/slider/meta.json +32 -0
  49. package/components/tabs/Tabs.astro +101 -0
  50. package/components/tabs/fixtures.json +37 -0
  51. package/components/tabs/meta.json +28 -0
  52. package/components/testimonial/Testimonial.astro +70 -0
  53. package/components/testimonial/fixtures.json +26 -0
  54. package/components/testimonial/meta.json +97 -0
  55. package/dist/index.d.mts +150 -0
  56. package/dist/index.d.mts.map +1 -0
  57. package/dist/index.mjs +199 -0
  58. package/dist/index.mjs.map +1 -0
  59. package/mapping/classic.json +261 -0
  60. package/mapping/divi.json +295 -0
  61. package/mapping/elementor.json +322 -0
  62. package/mapping/gutenberg.json +395 -0
  63. package/package.json +63 -0
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @contentrain/astro-kit
2
+
3
+ Copy-in Astro components for Contentrain sites, the shadcn model: a site
4
+ receives the component source and owns it from then on. Nothing here is a
5
+ runtime dependency of the site. The package ships the components, a
6
+ machine-readable catalog, builder mapping tables and a small API to copy
7
+ components into a project.
8
+
9
+ The components are made for [`templates/astro-starter`](../../templates/astro-starter).
10
+ They read its design tokens and pass its gates: `astro check` with the
11
+ `strictest` preset, knip, a single stylesheet and zero JavaScript by default.
12
+
13
+ ## Components
14
+
15
+ | id | What it is | JavaScript |
16
+ |---|---|---|
17
+ | `header` | Brand, navigation, optional call to action | none |
18
+ | `nav` | Inline menu with submenus; popover drawer or `<details>` on phones | none |
19
+ | `footer` | Brand, link columns or a link row, social links, copyright | none |
20
+ | `hero` | Page opener: heading, text, actions, image | none |
21
+ | `card-grid` | Grid of cards (features, services, team) | none |
22
+ | `post-card` | One post in a list | none |
23
+ | `cta` | Call-to-action band | none |
24
+ | `faq` | Questions as `<details>`, optional FAQPage JSON-LD | none |
25
+ | `tabs` | Tabbed panels; readable as headed sections without JavaScript | Zag.js |
26
+ | `testimonial` | Quotes with author and role | none |
27
+ | `gallery` | Image grid with a popover lightbox | none |
28
+ | `slider` | Carousel on a scroll-snap row | Embla |
29
+ | `contact-form` | Contentrain Studio form in a section | Studio runtime |
30
+ | `pagination` | WordPress-style `/page/N/` links | none |
31
+ | `breadcrumb` | Ancestors, then the current page, optional JSON-LD | none |
32
+
33
+ Each component lives in `components/<id>/`:
34
+
35
+ - `<Name>.astro`: the component. Variants use `tailwind-variants`, props are typed, and every optional prop also accepts `undefined`.
36
+ - `meta.json`: its catalog entry. Props are Contentrain `FieldDef`s with a description; the entry also lists variants, slots, JavaScript, npm dependencies, `sources` (the builder elements it replaces) and accessibility notes.
37
+ - `fixtures.json`: the visual-regression cases. Every variant option is covered.
38
+
39
+ `components/_shared/` holds `Section`, `Button`, `KitImage` and the value types
40
+ (`ImageInput`, `LinkInput`, `ActionInput`, `NavItem`).
41
+
42
+ ## Tokens
43
+
44
+ Components use colour roles and widths, never raw values. A site defines them
45
+ in `@theme` (the starter already does): `--color-surface`,
46
+ `--color-surface-muted`, `--color-ink`, `--color-ink-muted`, `--color-line`,
47
+ `--color-accent`, `--color-accent-ink`, `--font-sans`, `--container-prose`,
48
+ `--container-page`, `--container-wide` and `--radius-card`. The same list is in
49
+ `catalog.json` under `tokens`.
50
+
51
+ ## API
52
+
53
+ ```ts
54
+ import { copyComponents, KIT_COMPONENTS_DIR, loadCatalog, loadMapping, planCopy, rulesFor } from '@contentrain/astro-kit'
55
+
56
+ const catalog = await loadCatalog()
57
+ const plan = planCopy(catalog, ['header', 'card-grid']) // adds nav, the shared files, and the npm packages needed
58
+ await copyComponents(plan, KIT_COMPONENTS_DIR, '/path/to/site') // → src/components/kit/<id>/…
59
+ // install plan.dependencies in the site
60
+
61
+ const gutenberg = await loadMapping('gutenberg')
62
+ rulesFor(gutenberg, 'core/cover') // → the rule that turns a cover block into a hero, with its prop sources
63
+ ```
64
+
65
+ `validateCatalog`, `componentsForSource`, `validateMapping` and
66
+ `unmappedSources` check the catalog and the mapping tables against each other.
67
+
68
+ ## Mapping tables
69
+
70
+ `mapping/<builder>.json` (`gutenberg`, `elementor`, `divi`, `classic`) map
71
+ builder elements to components, with a source for each prop from a small closed
72
+ set of expressions (see `src/mapping.ts`). They are versioned, and an element
73
+ no rule covers stays rich text (`fallback: "prose"`). When one rule matches an
74
+ element, the outermost match owns its subtree.
75
+
76
+ ## Development
77
+
78
+ ```bash
79
+ pnpm --filter @contentrain/astro-kit catalog # regenerate catalog.json from meta.json files
80
+ pnpm --filter @contentrain/astro-kit test # catalog, mapping and starter-copy checks
81
+ node packages/astro-kit/scripts/visual.mjs --local-sdk [--only <id>] [--update]
82
+ ```
83
+
84
+ `visual.mjs` copies the starter and installs every component into it. It
85
+ renders each fixture at `/kit/<id>/`, type-checking the fixtures against the
86
+ component props, then runs `astro check` and a build. Last, it compares
87
+ screenshots at 390, 768 and 1280 px with `visual/<platform>/`. The starter
88
+ carries some kit components in `src/components/kit/`, and a test keeps those
89
+ copies identical to the source here.