Versioning: - package.json is the single source of the version (0.2.0); the build injects it into the landing page and Storybook via src/version.ts - Add CHANGELOG.md and a release section in the README Deploy: - Refuse to deploy uncommitted work unless --allow-dirty is passed - Stamp each deploy with version.json and verify the live stamp - Serve HTML and JSON with Cache-Control: no-cache and cache only the content-hashed assets/ folders long-term - Return 404 for missing assets instead of index.html, which blanked the Storybook canvas for browsers holding a stale page - Always restore the hardened .htaccess, even when a step fails - Make the post-deploy PHP-off check real, build Storybook before checking for its index, and stop logging the session token
155 lines
6.1 KiB
Markdown
155 lines
6.1 KiB
Markdown
<p align="center">
|
||
<img src="public/tansy-mark.svg" width="88" height="88" alt="Tansy UI logo" />
|
||
</p>
|
||
|
||
<h1 align="center">Tansy UI</h1>
|
||
|
||
<p align="center">
|
||
A themeable React component kit, with every state documented in Storybook.<br />
|
||
By OpenKhalix.
|
||
</p>
|
||
|
||
---
|
||
|
||
Tansy UI is named after the tansy flower, also called *golden buttons*: many small, round heads that together read as one bloom. The kit works the same way. It is a set of small, owned parts (buttons, fields, selects, feedback and overlays) that combine into a consistent interface.
|
||
|
||
Every part ships with:
|
||
|
||
- **Named variants.** A short list of deliberate choices, such as `variant="outline"`, instead of one-off styling.
|
||
- **Its states.** Error, disabled, loading and required are part of the component, and each has its own story.
|
||
- **Tokens, not hex codes.** Colours come from a 50–900 palette ramp, so switching the palette re-themes every part without a code change.
|
||
|
||
> **Status:** pre-release (v0.2.0). Tansy UI is not published to npm yet. It is developed in this repository, with a landing page and a Storybook workshop as its showcase.
|
||
|
||
## Components
|
||
|
||
| Group | Components |
|
||
|---|---|
|
||
| Actions | `Button`, `LinkButton` |
|
||
| Forms | `Input`, `FeaturedInput`, `Select`, `Checkbox`, `Radio`, `Switch`, `TextArea` |
|
||
| Data entry | `TextField` |
|
||
| Feedback | `Alert`, `Spinner` |
|
||
| Display | `Badge` |
|
||
| Layout | `Card` (with `Card.Header`, `Card.Title`, `Card.Body`, `Card.Footer`) |
|
||
| Navigation | `Accordion` |
|
||
| Overlays | `Tooltip` |
|
||
|
||
Each component lives in `src/components/` with its style maps in a sibling `*.tokens.ts` and its stories in `*.stories.tsx`.
|
||
|
||
## Usage
|
||
|
||
```tsx
|
||
import { useState } from 'react'
|
||
import { Button } from './components/Button'
|
||
import { FeaturedInput } from './components/FeaturedInput'
|
||
import { Switch } from './components/Switch'
|
||
|
||
export function InviteForm() {
|
||
const [email, setEmail] = useState('')
|
||
|
||
return (
|
||
<form>
|
||
<FeaturedInput
|
||
label="Work email"
|
||
type="email"
|
||
value={email}
|
||
onChange={(e) => setEmail(e.target.value)}
|
||
required
|
||
/>
|
||
<Switch label="Send a welcome email" defaultChecked />
|
||
<Button type="submit">Send invite</Button>
|
||
</form>
|
||
)
|
||
}
|
||
```
|
||
|
||
## Theming
|
||
|
||
Tansy UI ships seven palettes: Classic Blue (default), Emerald, Violet, Amber, Crimson, Slate and Teal. Each defines full `primary`, `secondary`, `gray` and `zink` ramps plus semantic colours in `src/theme/palettes.ts`.
|
||
|
||
`applyPalette(element, name)` writes a palette as CSS custom properties on any element. Tailwind v4 reads those properties, so a palette applies to one subtree and several palettes can appear on the same page:
|
||
|
||
```ts
|
||
import { applyPalette } from './theme/applyPalette'
|
||
|
||
applyPalette(document.getElementById('settings')!, 'emerald')
|
||
```
|
||
|
||
Storybook's **Palette** toolbar and the landing page playground both use this function.
|
||
|
||
## Development
|
||
|
||
```bash
|
||
npm install
|
||
npm run dev # landing page at http://localhost:5173
|
||
npm run storybook # component workshop at http://localhost:6006
|
||
npm run lint
|
||
npm run build # landing page -> dist/
|
||
npm run build-storybook # workshop -> storybook-static/
|
||
```
|
||
|
||
### Adding a component
|
||
|
||
1. Add it under `src/components/`, with style maps in a sibling `*.tokens.ts`.
|
||
2. Add a colocated `ComponentName.stories.tsx` that covers every meaningful state.
|
||
3. Read colours from the palette ramps (`bg-primary-500`) so the palette switcher reaches it.
|
||
4. Run `npm run build-storybook && python3 scripts/gen_catalogue.py --patch` to refresh the landing page catalogue.
|
||
|
||
## Versioning
|
||
|
||
Tansy UI follows [Semantic Versioning](https://semver.org). While the version is `0.x`, a minor release may include breaking changes.
|
||
|
||
- `package.json` holds the version. The build injects it into the landing page and Storybook through `src/version.ts`, so it is never typed by hand.
|
||
- Every release gets an entry in [`CHANGELOG.md`](CHANGELOG.md) and an annotated git tag such as `v0.2.0`.
|
||
- Every deploy publishes `/version.json`, which records the version and commit that are live.
|
||
|
||
To cut a release:
|
||
|
||
```bash
|
||
# 1. Move the [Unreleased] notes in CHANGELOG.md under the new version, then:
|
||
npm version minor -m "Release v%s" # or patch / major; bumps package.json, commits and tags
|
||
git push origin main --follow-tags
|
||
python3 scripts/deploy.py # builds that commit and deploys it
|
||
```
|
||
|
||
## Project structure
|
||
|
||
```text
|
||
src/
|
||
├── brand/TansyMark.tsx # Palette-aware logo
|
||
├── components/ # Components, their tokens and their stories
|
||
├── data/catalogue.ts # Landing page catalogue (regenerated by scripts/gen_catalogue.py)
|
||
├── theme/ # Palettes and applyPalette()
|
||
├── version.ts # VERSION, injected from package.json
|
||
├── Welcome.mdx # Storybook welcome page
|
||
├── App.tsx # Landing page, built only from Tansy components
|
||
└── index.css # Tailwind entry, palette tokens, landing styles
|
||
.storybook/ # Storybook config, Tansy theme, fonts
|
||
public/ # tansy-mark.svg and favicon.svg
|
||
scripts/ # Deploy and catalogue scripts
|
||
```
|
||
|
||
## Brand
|
||
|
||
The mark is a tansy flowerhead: six buttons in the palette's primary colour around a gold centre button.
|
||
|
||
- `src/brand/TansyMark.tsx` re-themes with the active palette. The gold centre stays fixed.
|
||
- `public/tansy-mark.svg` is the fixed Classic Blue version, used by Storybook.
|
||
- `public/favicon.svg` is the mark on a dark tile, so it stays visible in both light and dark browser tabs.
|
||
|
||
Typefaces: Schibsted Grotesk for headings, Instrument Sans for text and JetBrains Mono for code.
|
||
|
||
## Deployment
|
||
|
||
The build serves the landing page at `/` and Storybook at `/docs/`.
|
||
|
||
**Container.** The `Dockerfile` lints and builds both surfaces, then serves them from nginx with a `/healthz` endpoint:
|
||
|
||
```bash
|
||
docker build -t tansy-ui .
|
||
docker run --rm -p 8041:80 tansy-ui
|
||
curl http://127.0.0.1:8041/healthz
|
||
```
|
||
|
||
**cPanel.** `python3 scripts/deploy.py` builds, packages and uploads to a cPanel host, then removes files left over from earlier builds. See [`scripts/README.md`](scripts/README.md) for setup.
|