Restructure the repo into npm workspaces so the component kit publishes as its own package, like MUI and shadcn/ui: - packages/ui: @openkhalix/tansy-ui (published), with components, stories, tests, tokens and the library build - packages/brand: private logo and catalogue data shared by both apps - apps/site: the landing page - apps/docs: Storybook The package: - MIT licence (copyright OpenKhalix) - per-component ES modules and type declarations - "use client" on component modules so they import into Next.js Server Components; helpers stay server-safe - tokens.css for Tailwind v4 apps, and a prebuilt styles.css for apps without Tailwind - lucide-react 1.x, whose types compile against current React 19 types The apps resolve the package through a "source" export condition, so they hot-reload component edits, while outside users get dist/. scripts/test-package.mjs packs the package and installs the tarball into Vite + Tailwind (strict types), plain React and Next.js apps; each must build and render correctly. Gitea workflows run CI on push and publish to npm when a vX.Y.Z tag matching the package version is pushed.
108 lines
4.5 KiB
Markdown
108 lines
4.5 KiB
Markdown
<p align="center">
|
|
<img src="packages/brand/public/tansy-mark.svg" width="88" height="88" alt="Tansy UI logo" />
|
|
</p>
|
|
|
|
<h1 align="center">Tansy UI</h1>
|
|
|
|
<p align="center">
|
|
A themeable, accessible React component kit by OpenKhalix.<br />
|
|
<a href="https://ui.openkhalix.com">Website</a> ·
|
|
<a href="https://ui.openkhalix.com/docs/">Storybook</a> ·
|
|
<a href="packages/ui/README.md">Package README</a> ·
|
|
<a href="packages/ui/CHANGELOG.md">Changelog</a>
|
|
</p>
|
|
|
|
---
|
|
|
|
Tansy UI is named after the tansy flower, also called *golden buttons*: many small, round heads that read
|
|
as one bloom. It is published to npm as **`@openkhalix/tansy-ui`**:
|
|
|
|
```bash
|
|
npm install @openkhalix/tansy-ui
|
|
```
|
|
|
|
See the [package README](packages/ui/README.md) for setup and usage.
|
|
|
|
## Repository layout
|
|
|
|
This is an npm workspaces monorepo, laid out the way MUI and shadcn/ui lay out theirs:
|
|
|
|
| Path | Package | Published | What it is |
|
|
|---|---|---|---|
|
|
| [`packages/ui`](packages/ui) | `@openkhalix/tansy-ui` | yes | The components, their stories and tests, tokens, and the library build |
|
|
| [`packages/brand`](packages/brand) | `@tansy/brand` | no | The Tansy mark and the component catalogue, shared by both apps |
|
|
| [`apps/site`](apps/site) | `@tansy/site` | no | The landing page at ui.openkhalix.com |
|
|
| [`apps/docs`](apps/docs) | `@tansy/docs` | no | Storybook at ui.openkhalix.com/docs |
|
|
| [`docs`](docs) | | | [Conventions](docs/CONVENTIONS.md) and [roadmap](docs/ROADMAP.md) |
|
|
| [`scripts`](scripts) | | | Deploy, story checks, package install tests, catalogue generator |
|
|
|
|
The apps depend on the package through its real `exports`. In this repo they resolve its `source` export
|
|
condition, so editing a component hot-reloads the landing page and Storybook without a rebuild. Outside
|
|
users get the built files in `dist/`.
|
|
|
|
## Develop
|
|
|
|
```bash
|
|
npm install
|
|
npm run dev # landing page at http://localhost:5173
|
|
npm run storybook # Storybook at http://localhost:6006
|
|
npm run lint
|
|
npm run typecheck
|
|
npm test # unit, keyboard and axe tests for every component
|
|
npm run build # package, then landing page, then Storybook
|
|
```
|
|
|
|
### Checks before a release
|
|
|
|
```bash
|
|
npm run build:docs
|
|
node scripts/check-stories.mjs --mode light # every story in Chrome: errors and axe
|
|
node scripts/check-stories.mjs --mode dark
|
|
node scripts/check-stories.mjs --width 320 # nothing may scroll sideways on phones
|
|
npm run test:package # packs the package and installs it into Vite + Tailwind,
|
|
# plain React and Next.js apps; each must build and render
|
|
```
|
|
|
|
Adding a component: follow [`docs/CONVENTIONS.md`](docs/CONVENTIONS.md), export it from
|
|
`packages/ui/src/index.ts`, then run `python3 scripts/gen_catalogue.py --patch` after `npm run build:docs`
|
|
to refresh the landing page catalogue.
|
|
|
|
## Release
|
|
|
|
1. Move the **Unreleased** notes in [`packages/ui/CHANGELOG.md`](packages/ui/CHANGELOG.md) under the new
|
|
version and set `version` in `packages/ui/package.json`.
|
|
2. Run the checks above.
|
|
3. Commit, tag and push: `git tag -a v0.4.0 -m "Tansy UI v0.4.0" && git push origin main --follow-tags`.
|
|
4. The **Release** workflow (`.gitea/workflows/release.yml`) checks that the tag matches the package
|
|
version, re-runs the checks and publishes to npm. It needs an `NPM_TOKEN` repository secret for an
|
|
account in the `openkhalix` npm organisation.
|
|
|
|
To publish by hand instead: `npm login`, then `npm publish -w @openkhalix/tansy-ui` (the package's
|
|
`prepublishOnly` runs the type-check, tests and build first).
|
|
|
|
## Deploy the website
|
|
|
|
The landing page is served at `/` and Storybook at `/docs/`.
|
|
|
|
- **cPanel:** `python3 scripts/deploy.py` builds a committed tree, uploads it and removes files left over
|
|
from earlier builds. See [`scripts/README.md`](scripts/README.md).
|
|
- **Container:** the `Dockerfile` runs the checks, builds both apps and serves them from nginx with a
|
|
`/healthz` endpoint:
|
|
|
|
```bash
|
|
docker build -t tansy-ui .
|
|
docker run --rm -p 8041:80 tansy-ui
|
|
```
|
|
|
|
## Brand
|
|
|
|
The mark is a tansy flowerhead: six buttons in the palette's primary colour around a gold centre button.
|
|
`packages/brand/src/TansyMark.tsx` re-themes with the active palette; `packages/brand/public/` holds the
|
|
fixed-colour SVG and the favicon. Typefaces: Schibsted Grotesk, Instrument Sans and JetBrains Mono.
|
|
|
|
## Licence
|
|
|
|
[MIT](LICENSE) © OpenKhalix. Free to use, fork and ship in commercial products; keep the copyright
|
|
notice in copies of the code. A visible credit ("UI by Tansy UI") is appreciated but not required.
|
|
Contributions are welcome.
|