Working on this site
This site is an Astro Starlight project in the docs folder
of the library repository. It has its own package.json and is not part of the published
package.
Run it locally
Section titled “Run it locally”The site renders the real components from the library build in ../dist, so build the library
first.
nvm usepnpm install && pnpm buildcd docs && pnpm installpnpm devThe site is at http://localhost:4321. After changing library code, run pnpm build in the
repository root again; the site picks up the new dist.
pnpm build in docs writes the static site to docs/dist, and pnpm preview serves it.
How it is put together
Section titled “How it is put together”Directorydocs
- astro.config.mjs sidebar, stylesheets, React
Directoryscripts
- gen-props.mjs reads prop types from ../src into src/generated/props.json
Directorysrc
Directorycontent
Directorydocs/ the pages (MDX)
- …
Directoryexamples/ one file per live example
- …
Directorycomponents
- Example.astro preview frame plus the example’s source
- PropsTable.astro props of one component
- IconGrid.tsx the searchable icon grid
Directorylib
- tokens.ts reads ../tokens/*.json for the Foundations pages
Directorystyles
- layers.css cascade layer order (must stay first)
- docs.css preview frame and token tables
- The library is linked, not installed.
docs/package.jsonhas"@beyul/sulmu-ui": "link:..", so imports resolve through the package’s ownexportsto../dist, exactly as they do in an app. React is linked to the copy in the rootnode_modulesso that the library and the site share one React. - Examples are real files.
<Example src="button/variants">shows the filesrc/examples/button/variants.tsxas the code and renders the component passed as its child. The code on the page is the code that runs. - Props tables are generated from the hand-written interfaces in
../src/componentsbyscripts/gen-props.mjs, which runs beforedevandbuild. - Foundations pages read
../tokens/*.jsondirectly. - Dark mode needs no mapping. Starlight sets
data-themeon<html>, which is the attribute the library uses. - Styles are kept apart. Previews are wrapped in Starlight’s
not-contentclass, which switches off its prose styles inside them.layers.cssdeclares Starlight’s cascade layer before the library’s, so Starlight’s reset cannot override a component.
Add an example to a page
Section titled “Add an example to a page”-
Create
docs/src/examples/<component>/<name>.tsxwith a default export:import { Button } from '@beyul/sulmu-ui'export default function Example() {return <Button variant="secondary">Edit</Button>} -
Import it in the page and wrap it in
Example:import Example from '~/components/Example.astro'import ButtonVariants from '~/examples/button/variants'<Example src="button/variants"><ButtonVariants client:load /></Example>Add
client:loadwhen the example needs JavaScript in the browser (state, popups, event handlers). Leave it out for static examples; they are rendered to HTML at build time.
Example also takes canvas (the lavender page background), flush (no padding),
minHeight (room for a popup) and minWidth (for page-wide components; the preview scrolls).
Deploy on Vercel
Section titled “Deploy on Vercel”The repository has a vercel.json at its root, and a second one in docs, that tell Vercel how to build the site:
install the library and the docs, build the library, build the docs, and serve docs/dist.
No secrets are needed, because the build installs nothing from the private registry.
Connecting it is done once, in the Vercel dashboard:
-
Go to Add New… > Project and import the
beyul/sulmu-uirepository. If it is not listed, choose Adjust GitHub App Permissions and give Vercel access to it. -
Set Root Directory to
docs, or leave it empty. Both work:docs/vercel.jsonis used in the first case and the rootvercel.jsonin the second. Withdocs, keep Include files outside the root directory in the Build Step switched on (the default). -
Leave Framework Preset as Other. The build, install and output settings come from
vercel.json; do not override them. -
Add no environment variables.
-
Press Deploy.
-
After the first deployment, open Settings > Build and Deployment (called General in older dashboards) and set Node.js Version to 24.x, then redeploy.
Every push to main then deploys to production, and every pull request gets a preview URL.