@castui/cast-ui 4.8.0 → 4.10.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.
- package/README.md +78 -1
- package/dist/components/Accordion/Accordion.js +4 -3
- package/dist/components/Backdrop/Backdrop.js +7 -8
- package/dist/components/BottomSheet/BottomSheet.js +12 -14
- package/dist/components/Drawer/Drawer.js +12 -14
- package/dist/components/Progress/Progress.js +5 -4
- package/dist/components/Skeleton/Skeleton.js +11 -13
- package/dist/components/SpeedDial/SpeedDial.js +3 -5
- package/dist/components/Spinner/Spinner.js +6 -5
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useBreakpoint.d.ts +22 -0
- package/dist/hooks/useBreakpoint.js +45 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +23 -2
- package/dist/theme/ThemeContext.d.ts +12 -1
- package/dist/theme/ThemeContext.js +5 -2
- package/dist/theme/applyCastTheme.d.ts +32 -2
- package/dist/theme/applyCastTheme.js +72 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +3 -1
- package/dist/theme/useMotion.d.ts +32 -0
- package/dist/theme/useMotion.js +55 -0
- package/dist/tokens/breakpoints.d.ts +57 -0
- package/dist/tokens/breakpoints.js +92 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +17 -1
- package/dist/tokens/motion.d.ts +196 -0
- package/dist/tokens/motion.js +175 -0
- package/package.json +2 -1
- package/skills/cast-ui-component/SKILL.md +834 -0
- package/skills/cast-ui-docs-site/SKILL.md +114 -0
- package/skills/cast-ui-usage/SKILL.md +587 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cast-ui-docs-site
|
|
3
|
+
description: >-
|
|
4
|
+
How the Cast UI documentation site (site/, deployed to GitHub Pages at
|
|
5
|
+
connagh.github.io/cast-ui) is built and how to extend it. Use whenever
|
|
6
|
+
adding or editing a component's documentation page, registry entry, live
|
|
7
|
+
example, pattern, template, theme preset, motion demo, or docs guide;
|
|
8
|
+
wiring a new component into the site after building it; changing the site
|
|
9
|
+
shell, navigation, or the architecture graph; or debugging why the Pages
|
|
10
|
+
deploy or the SSR smoke test fails. The site renders every page with
|
|
11
|
+
@castui/cast-ui itself through react-native-web, so this also covers the
|
|
12
|
+
conventions that keep the site a credible showcase of the library.
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# The Cast UI docs site
|
|
16
|
+
|
|
17
|
+
The site lives in `site/` and deploys to GitHub Pages on every push to main
|
|
18
|
+
that touches `site/`, `src/`, or `design-tokens/` (`.github/workflows/pages.yml`).
|
|
19
|
+
It is a Vite + react-native-web single-page app. React Router drives real
|
|
20
|
+
URLs; `public/404.html` plus a restore script in `index.html` make deep links
|
|
21
|
+
work on Pages.
|
|
22
|
+
|
|
23
|
+
**The one big idea: the site consumes the library from source.**
|
|
24
|
+
`vite.config.ts` aliases `@castui/cast-ui` to `../src/index.ts`, so the site
|
|
25
|
+
always documents the code on the branch it was built from. There is no npm
|
|
26
|
+
version skew and no publish race. The install instructions shown to visitors
|
|
27
|
+
still say `npm install @castui/cast-ui`.
|
|
28
|
+
|
|
29
|
+
**The second big idea: the chrome is the demo.** The top bar, menus, footer,
|
|
30
|
+
tables, and code blocks are Cast UI components. The global theme controls
|
|
31
|
+
(colour mode, density, brand) restyle the whole site because everything sits
|
|
32
|
+
under one ThemeProvider (`src/theme/SiteTheme.tsx`). Before reaching for a
|
|
33
|
+
raw View with styles, check whether a library component can carry the job.
|
|
34
|
+
|
|
35
|
+
## Map
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
site/src/
|
|
39
|
+
App.tsx routes (lazy-loaded) + shell
|
|
40
|
+
theme/SiteTheme.tsx global colour mode / density / brand presets
|
|
41
|
+
shell/TopNav.tsx, Footer.tsx
|
|
42
|
+
ui/ Page, Section, LiveDemo, CodeSnippet,
|
|
43
|
+
PropsTable, snack.ts (Expo Snack hand-off),
|
|
44
|
+
scope.ts (everything live examples can use)
|
|
45
|
+
data/registry/ THE component registry (one file per category)
|
|
46
|
+
data/graph.json generated — do not edit by hand
|
|
47
|
+
pages/ Landing, docs/, components/, patterns/,
|
|
48
|
+
templates/, themes/, motion/, playground/,
|
|
49
|
+
architecture/
|
|
50
|
+
scripts/
|
|
51
|
+
build-graph.mjs design-tokens/*.json → data/graph.json (prebuild)
|
|
52
|
+
ssrSmoke.tsx renders every route + evaluates every example
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Adding a component's documentation (the common job)
|
|
56
|
+
|
|
57
|
+
1. Add a `ComponentDoc` entry to the right category file in
|
|
58
|
+
`site/src/data/registry/`. Copy a neighbour. Fields: slug (kebab-case),
|
|
59
|
+
name, category, summary (one line), description (when to reach for it),
|
|
60
|
+
importNames, props (real names, types, defaults — read the component's
|
|
61
|
+
Props type, do not guess), subProps for compound children, examples,
|
|
62
|
+
dos/donts, motionRole if it animates, related slugs.
|
|
63
|
+
2. Examples are strings of real code. Two shapes work: a bare JSX expression,
|
|
64
|
+
or statements defining `Demo` (auto-rendered). Everything exported from
|
|
65
|
+
the library plus React hooks, View, ScrollView, Animated, StyleSheet,
|
|
66
|
+
Platform is in scope (`ui/scope.ts`). Keep examples honest: they run live
|
|
67
|
+
on the page and get sent to Expo Snack verbatim.
|
|
68
|
+
3. Run the checks from `site/`:
|
|
69
|
+
`npx tsc --noEmit && npm run build && npm run smoke`.
|
|
70
|
+
The smoke renders all routes server-side and evaluates every example
|
|
71
|
+
through the same transpile path react-live uses. An example that names a
|
|
72
|
+
prop wrongly fails here, not in production.
|
|
73
|
+
|
|
74
|
+
The index page, detail page, search, related chips, and Snack links all
|
|
75
|
+
derive from the registry. No other file needs touching.
|
|
76
|
+
|
|
77
|
+
## Live examples and Snack
|
|
78
|
+
|
|
79
|
+
`ui/LiveDemo.tsx` renders preview + editable code (react-live). `ui/snack.ts`
|
|
80
|
+
wraps the same code in an App with ThemeProvider and the two fonts, and opens
|
|
81
|
+
snack.expo.dev with `@castui/cast-ui` as a dependency, so "Run on a device"
|
|
82
|
+
just works. If you add a wholly new global to examples, add it to
|
|
83
|
+
`ui/scope.ts` AND to the import template in `ui/snack.ts`.
|
|
84
|
+
|
|
85
|
+
## The graph
|
|
86
|
+
|
|
87
|
+
`scripts/build-graph.mjs` reads `design-tokens/*.tokens.json` and writes
|
|
88
|
+
`src/data/graph.json` (runs automatically as `prebuild`). Token changes flow
|
|
89
|
+
in on the next build. Ecosystem nodes and flow edges are declared in that
|
|
90
|
+
script; component→motion edges live in its `MOTION_USE` map — extend it when
|
|
91
|
+
a new component consumes a motion role.
|
|
92
|
+
|
|
93
|
+
## Conventions
|
|
94
|
+
|
|
95
|
+
- Copy is plain language: short sentences, no em dashes, no hype. Match the
|
|
96
|
+
voice of the existing pages.
|
|
97
|
+
- Every page starts with `Page` + `PageHeader` from `ui/Page.tsx`.
|
|
98
|
+
- Colours come from `useTheme()` (`scheme.*`, `colors.*`) — never hex, or
|
|
99
|
+
dark mode and brand presets break.
|
|
100
|
+
- Routes are lazy in `App.tsx`; a new top-level section needs its route,
|
|
101
|
+
a `NAV_ITEMS` entry in `shell/TopNav.tsx`, and a smoke-test route in
|
|
102
|
+
`scripts/ssrSmoke.tsx`.
|
|
103
|
+
- `Text` children are strings. Build labels with template literals, not JSX
|
|
104
|
+
fragments inside Text.
|
|
105
|
+
|
|
106
|
+
## When deploys fail
|
|
107
|
+
|
|
108
|
+
- Pages build = `npm ci && npm run build && npm run smoke` in `site/` on
|
|
109
|
+
Node 20. Reproduce locally the same way.
|
|
110
|
+
- The smoke failing on an example names the slug and example title. Fix the
|
|
111
|
+
example (or the registry props that misled it), not the smoke.
|
|
112
|
+
- Blank page on Pages but fine locally: check `base: '/cast-ui/'` in
|
|
113
|
+
vite.config.ts survived, and that new asset URLs go through
|
|
114
|
+
`import.meta.env.BASE_URL`.
|