Package Tansy UI as @openkhalix/tansy-ui in a monorepo (v0.4.0)
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.
This commit is contained in:
1 parent
23e67006d3
commit
9255b255a6
214 files changed
+1521
-389
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { useEffect, type ReactNode } from 'react'
|
||||
import { applyPalette, type PaletteName } from '@openkhalix/tansy-ui'
|
||||
|
||||
/**
|
||||
* Applies the toolbar's palette and light/dark mode to <html>.
|
||||
*
|
||||
* It has to be the root element, not a wrapper: Base UI renders popups (menus,
|
||||
* selects, dialogs, toasts) into a portal on document.body, and they must pick
|
||||
* up the same tokens as the story.
|
||||
*/
|
||||
export function ThemeSurface({
|
||||
palette,
|
||||
mode,
|
||||
padded,
|
||||
children,
|
||||
}: {
|
||||
palette: PaletteName
|
||||
mode: 'light' | 'dark'
|
||||
padded: boolean
|
||||
children: ReactNode
|
||||
}) {
|
||||
useEffect(() => {
|
||||
const root = document.documentElement
|
||||
applyPalette(root, palette)
|
||||
root.classList.toggle('dark', mode === 'dark')
|
||||
root.dataset.palette = palette
|
||||
document.body.style.background = 'var(--color-background)'
|
||||
document.body.style.color = 'var(--color-fg)'
|
||||
}, [palette, mode])
|
||||
|
||||
return <div style={{ padding: padded ? '1.5rem' : 0, minHeight: '100%' }}>{children}</div>
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { StorybookConfig } from '@storybook/react-vite'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
|
||||
const config: StorybookConfig = {
|
||||
stories: ['../src/**/*.mdx', '../../../packages/ui/src/**/*.stories.@(ts|tsx)'],
|
||||
addons: [
|
||||
{
|
||||
name: '@storybook/addon-docs',
|
||||
// GitHub-flavoured Markdown, so tables in the Introduction pages render.
|
||||
options: { mdxPluginOptions: { mdxCompileOptions: { remarkPlugins: [remarkGfm] } } },
|
||||
},
|
||||
'@storybook/addon-a11y',
|
||||
],
|
||||
framework: {
|
||||
name: '@storybook/react-vite',
|
||||
options: {},
|
||||
},
|
||||
// Serves the Tansy mark and favicon to the manager and the Welcome page.
|
||||
staticDirs: ['../../../packages/brand/public'],
|
||||
docs: {
|
||||
defaultName: 'Documentation',
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
@@ -0,0 +1,8 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Schibsted+Grotesk:wght@700;800&display=swap"
|
||||
/>
|
||||
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
||||
<meta name="theme-color" content="#f3f4f6" />
|
||||
@@ -0,0 +1,9 @@
|
||||
import { addons } from 'storybook/manager-api'
|
||||
import { tansyTheme } from './tansyTheme'
|
||||
|
||||
addons.setConfig({
|
||||
theme: tansyTheme,
|
||||
sidebar: {
|
||||
showRoots: true,
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Schibsted+Grotesk:wght@700;800&display=swap"
|
||||
/>
|
||||
<style>
|
||||
/* Tailwind's preflight strips list markers; restore them on docs pages. */
|
||||
.sbdocs ol { list-style: decimal; padding-left: 1.5rem; }
|
||||
.sbdocs h2 { font-family: "Schibsted Grotesk", sans-serif; font-weight: 800; letter-spacing: -0.02em; }
|
||||
</style>
|
||||
@@ -0,0 +1,90 @@
|
||||
import type { Decorator, Preview } from '@storybook/react-vite'
|
||||
import '../src/styles.css'
|
||||
import { palettes, DEFAULT_PALETTE, type PaletteName } from '@openkhalix/tansy-ui'
|
||||
import { tansyTheme } from './tansyTheme'
|
||||
import { ThemeSurface } from './ThemeSurface'
|
||||
|
||||
const withTheme: Decorator = (Story, context) => {
|
||||
const palette = (context.globals.palette ?? DEFAULT_PALETTE) as PaletteName
|
||||
const mode = context.globals.mode === 'dark' ? 'dark' : 'light'
|
||||
const padded = context.parameters.layout !== 'fullscreen'
|
||||
return (
|
||||
<ThemeSurface palette={palette} mode={mode} padded={padded}>
|
||||
<Story />
|
||||
</ThemeSurface>
|
||||
)
|
||||
}
|
||||
|
||||
const preview: Preview = {
|
||||
title: 'Tansy UI / Component Workshop',
|
||||
decorators: [withTheme],
|
||||
globalTypes: {
|
||||
mode: {
|
||||
description: 'Light or dark mode for every component and popup.',
|
||||
toolbar: {
|
||||
title: 'Mode',
|
||||
icon: 'contrast',
|
||||
items: [
|
||||
{ value: 'light', title: 'Light', icon: 'sun' },
|
||||
{ value: 'dark', title: 'Dark', icon: 'moon' },
|
||||
],
|
||||
dynamicTitle: true,
|
||||
},
|
||||
},
|
||||
palette: {
|
||||
description: 'Brand palette applied to every element in the canvas.',
|
||||
toolbar: {
|
||||
title: 'Palette',
|
||||
icon: 'paintbrush',
|
||||
items: Object.values(palettes).map((p) => ({
|
||||
value: p.name,
|
||||
title: `${p.label} — ${p.note}`,
|
||||
})),
|
||||
dynamicTitle: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
initialGlobals: {
|
||||
mode: 'light',
|
||||
palette: DEFAULT_PALETTE,
|
||||
},
|
||||
parameters: {
|
||||
backgrounds: { disable: true },
|
||||
a11y: {
|
||||
// Page-level rules can't apply to an isolated component: a story has no
|
||||
// <main>, no <h1> and no landmarks of its own. Everything else runs.
|
||||
config: {
|
||||
rules: [
|
||||
{ id: 'landmark-one-main', enabled: false },
|
||||
{ id: 'page-has-heading-one', enabled: false },
|
||||
{ id: 'region', enabled: false },
|
||||
],
|
||||
},
|
||||
},
|
||||
docs: {
|
||||
theme: tansyTheme,
|
||||
},
|
||||
options: {
|
||||
storySort: {
|
||||
order: [
|
||||
'Introduction',
|
||||
['Welcome', 'Getting started', 'Theming', 'Accessibility', 'Changelog', 'Roadmap'],
|
||||
'Actions',
|
||||
'Forms',
|
||||
'Feedback',
|
||||
'Display',
|
||||
'Layout',
|
||||
'Navigation',
|
||||
'Overlays',
|
||||
],
|
||||
},
|
||||
},
|
||||
controls: {
|
||||
matchers: {
|
||||
date: /Date$/i,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default preview
|
||||
@@ -0,0 +1,46 @@
|
||||
import { create } from 'storybook/theming'
|
||||
|
||||
/**
|
||||
* Tansy UI branding for the Storybook manager and docs pages.
|
||||
*
|
||||
* `brandTitle` is HTML: the mark comes from `public/` (served via `staticDirs`)
|
||||
* and is referenced relatively so it resolves both at `/` in dev and under
|
||||
* `/docs/` in production.
|
||||
*/
|
||||
export const tansyTheme = create({
|
||||
base: 'light',
|
||||
|
||||
brandTitle: `<span style="display:inline-flex;align-items:center;gap:8px;white-space:nowrap">
|
||||
<img src="./tansy-mark.svg" width="28" height="28" alt="" />
|
||||
<span style="font-family:'Schibsted Grotesk',sans-serif;font-weight:800;font-size:19px;letter-spacing:-0.03em;color:#12151c">Tansy <span style="font-weight:700;color:#6b7384">UI</span></span>
|
||||
<span style="font-size:11px;color:#6b7384;padding-left:8px;border-left:1px solid #c5cad4">by OpenKhalix</span>
|
||||
</span>`,
|
||||
brandUrl: '/',
|
||||
brandTarget: '_self',
|
||||
|
||||
colorPrimary: '#305ddd',
|
||||
colorSecondary: '#305ddd',
|
||||
|
||||
appBg: '#f3f4f6',
|
||||
appContentBg: '#ffffff',
|
||||
appPreviewBg: '#ffffff',
|
||||
appBorderColor: '#dde1e8',
|
||||
appBorderRadius: 8,
|
||||
|
||||
fontBase: '"Instrument Sans", "Helvetica Neue", Arial, sans-serif',
|
||||
fontCode: '"JetBrains Mono", "SFMono-Regular", Consolas, monospace',
|
||||
|
||||
textColor: '#12151c',
|
||||
textInverseColor: '#ffffff',
|
||||
textMutedColor: '#6b7384',
|
||||
|
||||
barBg: '#ffffff',
|
||||
barTextColor: '#4a5162',
|
||||
barSelectedColor: '#305ddd',
|
||||
barHoverColor: '#305ddd',
|
||||
|
||||
inputBg: '#ffffff',
|
||||
inputBorder: '#c5cad4',
|
||||
inputTextColor: '#12151c',
|
||||
inputBorderRadius: 6,
|
||||
})
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@tansy/docs",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "storybook dev -p 6006",
|
||||
"build": "storybook build -o storybook-static"
|
||||
},
|
||||
"dependencies": {
|
||||
"@openkhalix/tansy-ui": "*",
|
||||
"@tansy/brand": "*",
|
||||
"lucide-react": "^1.48.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/addon-a11y": "^10.6.0",
|
||||
"@storybook/addon-docs": "^10.6.0",
|
||||
"@storybook/react-vite": "^10.6.0",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.7",
|
||||
"@vitejs/plugin-react": "^6.1.1",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"storybook": "^10.6.0",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"typescript": "~6.0.2",
|
||||
"vite": "^8.3.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Meta } from '@storybook/addon-docs/blocks'
|
||||
import { DocHero } from './DocBlocks'
|
||||
|
||||
<Meta title="Introduction/Accessibility" />
|
||||
|
||||
<DocHero title="Accessibility">
|
||||
What every Tansy UI component guarantees, how that's checked, and what to verify by hand when you compose them.
|
||||
</DocHero>
|
||||
|
||||
## What every component guarantees
|
||||
|
||||
| Area | Guarantee |
|
||||
|---|---|
|
||||
| Behaviour | Interactive parts are built on [Base UI](https://base-ui.com), which implements the WAI-ARIA patterns: focus traps and focus return for dialogs, roving focus and type-ahead for menus and lists, and arrow keys for tabs, radios and sliders. |
|
||||
| Keyboard focus | Every interactive element shows a visible focus ring (`focus-visible`), including the hidden inputs behind Checkbox, Radio and Switch. |
|
||||
| Labels | Form fields sit in `Field`, which links the label, description and error to the control with `aria-labelledby`, `aria-describedby` and `aria-invalid`. Icon-only buttons require an `aria-label`. |
|
||||
| Popups | Escape closes dialogs, menus, popovers, selects and tooltips, and focus returns to the trigger. Tooltips open on keyboard focus as well as hover. |
|
||||
| Announcements | Alerts use `role="alert"` only for danger and warning; other colours use `role="status"`. Toasts announce through one polite live region. Spinners and progress bars carry an accessible name and value. |
|
||||
| Colour | Text meets WCAG AA contrast (4.5:1) in light and dark mode, in every palette. Status is never shown by colour alone: errors have text, and badges and alerts have icons or labels. |
|
||||
| Motion | Animations respect `prefers-reduced-motion`. |
|
||||
|
||||
## How it's checked
|
||||
|
||||
1. **Unit tests.** Every component has Vitest and Testing Library tests for roles, names, keyboard interaction and label wiring, plus an axe scan (`npm test`).
|
||||
2. **Every story in a real browser.** `scripts/check-stories.mjs` loads each story in Chrome, in light and dark mode, and fails on runtime errors or any axe violation, colour contrast included.
|
||||
3. **The Accessibility panel.** Below the canvas, axe re-checks the story you're looking at, including after you change controls.
|
||||
|
||||
## What to check by hand
|
||||
|
||||
Automated checks cover markup, names and contrast. When you compose components into a screen, also check:
|
||||
|
||||
1. **Tab** reaches every interactive part in visual order, and focus is always visible.
|
||||
2. **Enter** and **Space** activate buttons, switches and checkboxes; **arrow keys** move within radio groups, menus, tabs and lists.
|
||||
3. **Escape** closes anything that opened, and focus returns to what opened it.
|
||||
4. A screen reader reads each field's label, help text and error when the field is focused.
|
||||
5. Headings follow a logical order (`Card` and `Accordion` take a `headingLevel` prop).
|
||||
6. The screen still works at 200% zoom and at phone width.
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Meta, Markdown } from '@storybook/addon-docs/blocks'
|
||||
import { DocHero } from './DocBlocks'
|
||||
import changelog from '../../../packages/ui/CHANGELOG.md?raw'
|
||||
|
||||
<Meta title="Introduction/Changelog" />
|
||||
|
||||
<DocHero title="Changelog">
|
||||
Every release of Tansy UI, rendered from CHANGELOG.md in the repository.
|
||||
</DocHero>
|
||||
|
||||
<Markdown>{changelog.replace(/^# Changelog\s*/, '')}</Markdown>
|
||||
@@ -0,0 +1,76 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { VERSION } from '@openkhalix/tansy-ui'
|
||||
import { TansyMark } from '@tansy/brand'
|
||||
|
||||
/*
|
||||
* Building blocks for the Storybook Introduction pages. They sit inside
|
||||
* `sb-unstyled` so Storybook's docs typography does not restyle them, and use
|
||||
* inline styles so they read the same in every palette.
|
||||
*/
|
||||
|
||||
const ink = '#12151c'
|
||||
const muted = '#6b7384'
|
||||
const line = '#dde1e8'
|
||||
const display = '"Schibsted Grotesk", "Instrument Sans", sans-serif'
|
||||
const mono = '"JetBrains Mono", ui-monospace, monospace'
|
||||
|
||||
/** Page header: mark, title, one-line summary and the kit version. */
|
||||
export function DocHero({ title, children }: { title: string; children: ReactNode }) {
|
||||
return (
|
||||
<div className="sb-unstyled" style={{ display: 'flex', gap: 18, alignItems: 'flex-start', margin: '4px 0 32px' }}>
|
||||
<TansyMark size={52} style={{ flexShrink: 0, marginTop: 4 }} />
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<span style={{ fontFamily: mono, fontSize: 12, letterSpacing: '0.06em', textTransform: 'uppercase', color: muted }}>
|
||||
Tansy UI · v{VERSION}
|
||||
</span>
|
||||
<h1 style={{ margin: 0, fontFamily: display, fontWeight: 800, fontSize: 38, lineHeight: 1.05, letterSpacing: '-0.035em', color: ink }}>
|
||||
{title}
|
||||
</h1>
|
||||
<p style={{ margin: 0, maxWidth: 620, fontSize: 16, lineHeight: 1.6, color: '#4a5162' }}>{children}</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export type DocCard = {
|
||||
title: string
|
||||
body: string
|
||||
/** A Storybook path such as `/docs/introduction-theming--documentation`. */
|
||||
path: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Links that navigate the whole Storybook, not just the preview frame.
|
||||
* `./?path=` resolves next to iframe.html, so it works at `/` in dev and
|
||||
* under `/docs/` in production.
|
||||
*/
|
||||
export function DocCards({ items }: { items: DocCard[] }) {
|
||||
return (
|
||||
<div
|
||||
className="sb-unstyled"
|
||||
style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(230px, 1fr))', gap: 12, margin: '16px 0 32px' }}
|
||||
>
|
||||
{items.map((item) => (
|
||||
<a
|
||||
key={item.path}
|
||||
href={`./?path=${item.path}`}
|
||||
target="_top"
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 6,
|
||||
padding: '16px 18px',
|
||||
border: `1px solid ${line}`,
|
||||
borderRadius: 10,
|
||||
background: '#fff',
|
||||
color: ink,
|
||||
textDecoration: 'none',
|
||||
}}
|
||||
>
|
||||
<strong style={{ fontFamily: display, fontSize: 16, fontWeight: 700 }}>{item.title} →</strong>
|
||||
<span style={{ fontSize: 14, lineHeight: 1.5, color: muted }}>{item.body}</span>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { Meta, Source } from '@storybook/addon-docs/blocks'
|
||||
import { DocHero } from './DocBlocks'
|
||||
|
||||
<Meta title="Introduction/Getting started" />
|
||||
|
||||
<DocHero title="Getting started">
|
||||
Install one package, add one line of CSS, and every component is ready to use in any React 19 app, with or without Tailwind.
|
||||
</DocHero>
|
||||
|
||||
## Requirements
|
||||
|
||||
| Dependency | Version | Why |
|
||||
|---|---|---|
|
||||
| React and React DOM | 19 | Peer dependency. Components take `ref` as a normal prop |
|
||||
| Tailwind CSS | 4, optional | With Tailwind, your build generates the utilities; without it, use the prebuilt `styles.css` |
|
||||
| `@base-ui/react` | 1.8+ | Accessible behaviour: focus management, keyboard navigation, popups. Installed with the package |
|
||||
| `lucide-react` | 1.x | The icons components draw themselves (chevrons, close, status icons). Installed with the package |
|
||||
| `clsx` + `tailwind-merge` | 2 and 3 | `cn()` merges class names so your `className` always wins |
|
||||
|
||||
## 1. Install
|
||||
|
||||
<Source language="bash" code={`npm install @openkhalix/tansy-ui`} />
|
||||
|
||||
## 2. Add the styles
|
||||
|
||||
**With Tailwind CSS v4** (recommended). Import the tokens after Tailwind, and let Tailwind scan the package for the classes it uses:
|
||||
|
||||
<Source
|
||||
language="css"
|
||||
code={`@import "tailwindcss";
|
||||
@import "@openkhalix/tansy-ui/tokens.css";
|
||||
@source "../node_modules/@openkhalix/tansy-ui/dist";`}
|
||||
/>
|
||||
|
||||
**Without Tailwind.** Import the prebuilt stylesheet once. It includes the tokens, the utilities the components use, and a modern CSS reset the components rely on:
|
||||
|
||||
<Source language="ts" code={`import '@openkhalix/tansy-ui/styles.css'`} />
|
||||
|
||||
## 3. Render components
|
||||
|
||||
<Source
|
||||
language="tsx"
|
||||
code={`import { Mail } from 'lucide-react'
|
||||
import { Button, FeaturedInput, Select, Switch } from '@openkhalix/tansy-ui'
|
||||
|
||||
export function InviteForm() {
|
||||
return (
|
||||
<form className="grid max-w-sm gap-5">
|
||||
<FeaturedInput label="Work email" type="email" startIcon={<Mail />} required />
|
||||
<Select
|
||||
label="Team"
|
||||
options={[
|
||||
{ value: 'design', label: 'Design' },
|
||||
{ value: 'engineering', label: 'Engineering' },
|
||||
]}
|
||||
/>
|
||||
<Switch label="Send a welcome email" defaultChecked />
|
||||
<Button type="submit">Send invite</Button>
|
||||
</form>
|
||||
)
|
||||
}`}
|
||||
/>
|
||||
|
||||
Every form component takes the same field props, `label`, `description`, `error` and `required`, and links them to the control for screen readers. Values work controlled (`value` and `onValueChange`) or uncontrolled (`defaultValue`).
|
||||
|
||||
## Next.js
|
||||
|
||||
Components are marked `"use client"`, so you can import them straight into Server Components. Helpers like `cn` and `applyPalette` stay server-safe.
|
||||
|
||||
## 4. Dark mode
|
||||
|
||||
Add the `dark` class to `<html>`. The surface, border and text tokens switch, and every component and popup follows:
|
||||
|
||||
<Source language="tsx" code={`document.documentElement.classList.toggle('dark', prefersDark)`} />
|
||||
|
||||
## 5. Pick a palette (optional)
|
||||
|
||||
Classic Blue is the default. Apply another palette to any element; everything inside it re-themes, including popups when you apply it to `<html>`:
|
||||
|
||||
<Source
|
||||
language="tsx"
|
||||
code={`import { applyPalette } from '@openkhalix/tansy-ui'
|
||||
|
||||
applyPalette(document.documentElement, 'emerald')`}
|
||||
/>
|
||||
|
||||
## Fonts
|
||||
|
||||
The Tansy brand uses Schibsted Grotesk for headings, Instrument Sans for text and JetBrains Mono for code, all from Google Fonts. Components inherit your app's font, so these are optional.
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Meta, Markdown } from '@storybook/addon-docs/blocks'
|
||||
import { DocHero } from './DocBlocks'
|
||||
import roadmap from '../../../docs/ROADMAP.md?raw'
|
||||
|
||||
<Meta title="Introduction/Roadmap" />
|
||||
|
||||
<DocHero title="Roadmap">
|
||||
How Tansy UI compares with MUI and shadcn/ui, and the plan to get it ready to publish. Rendered from docs/ROADMAP.md.
|
||||
</DocHero>
|
||||
|
||||
<Markdown>{roadmap.replace(/^# Roadmap\s*/, '')}</Markdown>
|
||||
@@ -0,0 +1,66 @@
|
||||
import { Meta, ColorPalette, ColorItem, Source } from '@storybook/addon-docs/blocks'
|
||||
import { DocHero } from './DocBlocks'
|
||||
import { palettes } from '@openkhalix/tansy-ui'
|
||||
|
||||
<Meta title="Introduction/Theming" />
|
||||
|
||||
export const STEPS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900]
|
||||
export const ramp = (r) => Object.fromEntries(STEPS.map((s) => [s, r[s]]))
|
||||
|
||||
<DocHero title="Theming">
|
||||
Components never use hex codes. They read colour from four 50–900 ramps and a set of semantic colours, so swapping the
|
||||
palette re-themes every part without touching component code.
|
||||
</DocHero>
|
||||
|
||||
## How it works
|
||||
|
||||
1. `src/index.css` registers every colour in Tailwind's `@theme`, so utilities like `bg-primary-500` exist at build time. These are the Classic Blue defaults.
|
||||
2. `applyPalette(element, name)` writes a palette's values as `--color-*` custom properties on an element. Everything inside that element picks them up.
|
||||
3. Because the values are scoped to an element, one page can show several palettes at once. Storybook's **Palette** toolbar and the landing page playground both work this way.
|
||||
|
||||
<Source
|
||||
language="tsx"
|
||||
code={`import { applyPalette } from '@openkhalix/tansy-ui'
|
||||
|
||||
// Whole app
|
||||
applyPalette(document.documentElement, 'violet')
|
||||
|
||||
// One subtree, e.g. a preview panel
|
||||
applyPalette(previewRef.current, 'teal')`}
|
||||
/>
|
||||
|
||||
## Token names
|
||||
|
||||
| Layer | Utilities | Used for |
|
||||
|---|---|---|
|
||||
| Surfaces | `bg-background`, `bg-surface`, `bg-surface-muted`, `bg-surface-sunken` | Page, cards, inputs and popups, hover fills |
|
||||
| Borders | `border-border`, `border-border-strong` | Dividers and control outlines |
|
||||
| Text | `text-fg`, `text-fg-muted`, `text-fg-subtle` | Body text, secondary text, placeholders |
|
||||
| Brand | `primary-50` … `primary-900`, `secondary-*` | Actions, focus rings, selection. Set by the palette |
|
||||
| Status | `success-*`, `warning-*`, `danger-*`, `info-*` (50 … 900) | The same in every palette, so danger is always red |
|
||||
|
||||
Components use only these tokens, never raw Tailwind colours or hex codes, which is why a palette or mode change reaches all of them.
|
||||
|
||||
## Dark mode
|
||||
|
||||
Add the `dark` class to `<html>`. The surface, border and text tokens switch to their dark values, and components adjust brand and status colours with `dark:` variants where contrast needs it. Every story is checked for contrast in both modes. Use the **Mode** toolbar button to switch this workshop.
|
||||
|
||||
<Source language="tsx" code={`document.documentElement.classList.toggle('dark', true)`} />
|
||||
|
||||
## Palettes
|
||||
|
||||
Each palette's primary ramp. The 500 step is the one bare `bg-primary` resolves to.
|
||||
|
||||
<ColorPalette>
|
||||
{Object.values(palettes).map((p) => (
|
||||
<ColorItem key={p.name} title={p.label} subtitle={p.note} colors={ramp(p.primary)} />
|
||||
))}
|
||||
</ColorPalette>
|
||||
|
||||
## Status colours
|
||||
|
||||
The same in every palette. Bare names such as `bg-success` resolve to these values; the full 50–900 scales are in `src/styles/tokens.css`.
|
||||
|
||||
<ColorPalette>
|
||||
<ColorItem title="Status" subtitle="Shared by every palette" colors={palettes.classicBlue.semantic} />
|
||||
</ColorPalette>
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Meta } from '@storybook/addon-docs/blocks'
|
||||
import { DocHero, DocCards } from './DocBlocks'
|
||||
import { documentation, totalStories } from '@tansy/brand'
|
||||
|
||||
<Meta title="Introduction/Welcome" />
|
||||
|
||||
<DocHero title="Welcome to Tansy UI">
|
||||
A themeable React component kit by OpenKhalix. Every part is owned source code with its variants, states and tokens
|
||||
documented here, one story per state.
|
||||
</DocHero>
|
||||
|
||||
Tansy UI is named after the tansy flower, also called golden buttons: many small round heads that read as one bloom. The kit works the same way. It currently has **{documentation.length} components** and **{totalStories} stories**, built on Base UI with React 19, TypeScript and Tailwind CSS v4.
|
||||
|
||||
## Start here
|
||||
|
||||
<DocCards
|
||||
items={[
|
||||
{ title: 'Getting started', body: 'Add Tansy UI to a Vite and Tailwind v4 project and render your first component.', path: '/docs/introduction-getting-started--documentation' },
|
||||
{ title: 'Theming', body: 'The seven palettes, their 50–900 ramps, and how applyPalette() re-themes a subtree.', path: '/docs/introduction-theming--documentation' },
|
||||
{ title: 'Accessibility', body: 'What each component guarantees today, and how the a11y panel checks every story.', path: '/docs/introduction-accessibility--documentation' },
|
||||
{ title: 'Changelog', body: 'Every release, following Semantic Versioning.', path: '/docs/introduction-changelog--documentation' },
|
||||
{ title: 'Roadmap', body: 'How Tansy UI compares with MUI and shadcn/ui, and what ships next.', path: '/docs/introduction-roadmap--documentation' },
|
||||
{ title: 'Components', body: 'Browse every component, starting with Button.', path: '/docs/actions-button--documentation' },
|
||||
]}
|
||||
/>
|
||||
|
||||
## How to read this workshop
|
||||
|
||||
- **Documentation** pages list every prop, with controls you can change live.
|
||||
- **Stories** show one state each: defaults, errors, disabled and loading states all get their own.
|
||||
- **Mode** in the toolbar switches every component, popup included, between light and dark.
|
||||
- **Palette** in the toolbar re-themes every component from the brand ramps.
|
||||
- **Accessibility** runs axe checks against the open story in the panel below the canvas.
|
||||
|
||||
## Adding a component
|
||||
|
||||
1. Put the component in `src/components/` and keep its style maps in a sibling `*.tokens.ts`.
|
||||
2. Add a colocated `ComponentName.stories.tsx` with a story for every meaningful state.
|
||||
3. Read colours from the palette ramps (`bg-primary-500`), never from hex codes.
|
||||
4. Run `npm run build-storybook`, then `python3 scripts/gen_catalogue.py --patch` to update the landing page catalogue.
|
||||
@@ -0,0 +1,6 @@
|
||||
@import "tailwindcss";
|
||||
@import "../../../packages/ui/src/styles/tokens.css";
|
||||
|
||||
/* Components and their stories live in the package. */
|
||||
@source "../../../packages/ui/src";
|
||||
@source not "../../../packages/ui/src/**/*.test.tsx";
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"customConditions": ["source"],
|
||||
"types": ["vite/client"],
|
||||
"jsx": "react-jsx",
|
||||
"skipLibCheck": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"allowImportingTsExtensions": true,
|
||||
"noEmit": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"include": ["src", ".storybook"]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import { defaultClientConditions, defineConfig } from 'vite'
|
||||
|
||||
/** Storybook's Vite config: stories render the package from source. */
|
||||
const ui = JSON.parse(readFileSync(new URL('../../packages/ui/package.json', import.meta.url), 'utf8')) as { version: string }
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
resolve: { conditions: ['source', ...defaultClientConditions] },
|
||||
define: { __TANSY_VERSION__: JSON.stringify(ui.version) },
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#f3f4f6" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Schibsted+Grotesk:wght@700;800&display=swap"
|
||||
/>
|
||||
<meta
|
||||
name="description"
|
||||
content="Tansy UI is a themeable React component kit by OpenKhalix, with every state documented in Storybook."
|
||||
/>
|
||||
<title>Tansy UI · React component kit</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "@tansy/site",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -p tsconfig.json --noEmit && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@openkhalix/tansy-ui": "*",
|
||||
"@tansy/brand": "*",
|
||||
"lucide-react": "^1.48.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.7",
|
||||
"@vitejs/plugin-react": "^6.1.1",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"typescript": "~6.0.2",
|
||||
"vite": "^8.3.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,565 @@
|
||||
import { useEffect, useState, type FormEvent, type ReactNode } from 'react'
|
||||
import { ArrowRight, Mail, UserRound } from 'lucide-react'
|
||||
import {
|
||||
Alert,
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Checkbox,
|
||||
FeaturedInput,
|
||||
FeaturedSelect,
|
||||
LinkButton,
|
||||
Radio,
|
||||
Switch,
|
||||
Tooltip,
|
||||
applyPalette,
|
||||
palettes,
|
||||
DEFAULT_PALETTE,
|
||||
VERSION,
|
||||
type PaletteName,
|
||||
} from '@openkhalix/tansy-ui'
|
||||
import { TansyMark, documentation, featured, totalStories, type FeaturedName } from '@tansy/brand'
|
||||
|
||||
const STORYBOOK = '/docs/'
|
||||
|
||||
const RAMP_STEPS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900] as const
|
||||
|
||||
const DEPARTMENTS = [
|
||||
{ value: 'engineering', label: 'Engineering' },
|
||||
{ value: 'finance', label: 'Finance' },
|
||||
{ value: 'people', label: 'People operations' },
|
||||
{ value: 'sales', label: 'Sales' },
|
||||
{ value: 'support', label: 'Customer support' },
|
||||
]
|
||||
|
||||
const PAY_CYCLES = [
|
||||
{ value: 'monthly', label: 'Monthly' },
|
||||
{ value: 'semi-monthly', label: 'Twice a month' },
|
||||
{ value: 'weekly', label: 'Weekly' },
|
||||
]
|
||||
|
||||
/** Storybook pages the landing page links into. */
|
||||
const DOCS = {
|
||||
gettingStarted: `${STORYBOOK}?path=/docs/introduction-getting-started--documentation`,
|
||||
theming: `${STORYBOOK}?path=/docs/introduction-theming--documentation`,
|
||||
accessibility: `${STORYBOOK}?path=/docs/introduction-accessibility--documentation`,
|
||||
changelog: `${STORYBOOK}?path=/docs/introduction-changelog--documentation`,
|
||||
roadmap: `${STORYBOOK}?path=/docs/introduction-roadmap--documentation`,
|
||||
}
|
||||
|
||||
const USAGE = `import {
|
||||
Button,
|
||||
Switch,
|
||||
} from '@openkhalix/tansy-ui'
|
||||
|
||||
<Switch label="Welcome email" />
|
||||
<Button>Send invite</Button>`
|
||||
|
||||
const STATES = ['Default', 'Error', 'Disabled', 'Loading', 'Required', 'Controlled']
|
||||
|
||||
/** Mirrors docs/ROADMAP.md; update both together. */
|
||||
const roadmap = [
|
||||
{
|
||||
stage: 'Shipped',
|
||||
title: `v${VERSION}`,
|
||||
color: 'success',
|
||||
items: [
|
||||
`${documentation.length} accessible components on Base UI`,
|
||||
'Dark mode, seven palettes, one consistent API',
|
||||
'Tests and a real-browser check for every story',
|
||||
],
|
||||
},
|
||||
{
|
||||
stage: 'Next',
|
||||
title: 'Data and dates',
|
||||
color: 'warning',
|
||||
items: ['Date Picker and Date Range Picker', 'Data Table with sorting and filtering', 'Command palette'],
|
||||
},
|
||||
{
|
||||
stage: 'Planned',
|
||||
title: 'v1',
|
||||
color: 'neutral',
|
||||
items: ['Publish to npm', 'A shadcn-compatible registry', 'Palette builder with contrast checks'],
|
||||
},
|
||||
] as const
|
||||
|
||||
/** A small live instance of each featured part, sized to sit in a list row. */
|
||||
const previews: Record<FeaturedName, ReactNode> = {
|
||||
Button: <Button size="sm">Save</Button>,
|
||||
Switch: <Switch size="sm" aria-label="Example switch" defaultChecked />,
|
||||
Checkbox: <Checkbox aria-label="Example checkbox" defaultChecked />,
|
||||
Badge: (
|
||||
<span className="preview-badges">
|
||||
<Badge color="success" dot>
|
||||
Paid
|
||||
</Badge>
|
||||
<Badge color="warning" dot>
|
||||
Pending
|
||||
</Badge>
|
||||
</span>
|
||||
),
|
||||
Tooltip: (
|
||||
<Tooltip content="Explains a control without adding clutter." side="left">
|
||||
<Button size="sm" variant="outline" color="neutral">
|
||||
Hover me
|
||||
</Button>
|
||||
</Tooltip>
|
||||
),
|
||||
}
|
||||
|
||||
/** Highlights the few token kinds USAGE contains, without a syntax library. */
|
||||
function highlight(code: string) {
|
||||
return code.split(/('[^']*'|"[^"]*"|\bimport\b|\bfrom\b|<\/?[A-Z]\w*|\/>|>)/g).map((part, index) => {
|
||||
if (!part) return null
|
||||
let kind = ''
|
||||
if (part === 'import' || part === 'from') kind = 'tok-key'
|
||||
else if (/^['"]/.test(part)) kind = 'tok-str'
|
||||
else if (/^<\/?[A-Z]|^\/?>$/.test(part)) kind = 'tok-tag'
|
||||
return kind ? <span className={kind} key={index}>{part}</span> : part
|
||||
})
|
||||
}
|
||||
|
||||
function CodeSample() {
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
async function copy() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(USAGE)
|
||||
setCopied(true)
|
||||
window.setTimeout(() => setCopied(false), 1600)
|
||||
} catch {
|
||||
setCopied(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="code-sample">
|
||||
<div className="code-sample-bar">
|
||||
<span>InviteForm.tsx</span>
|
||||
<Button size="sm" variant="ghost" onClick={copy} className="code-copy">
|
||||
{copied ? 'Copied' : 'Copy'}
|
||||
</Button>
|
||||
</div>
|
||||
<pre>
|
||||
<code>{highlight(USAGE)}</code>
|
||||
</pre>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
type FormErrors = Partial<Record<'name' | 'email' | 'department' | 'confirmed', string>>
|
||||
|
||||
function EmployeeForm() {
|
||||
const [name, setName] = useState('Jane Doe')
|
||||
const [email, setEmail] = useState('jane.doe@')
|
||||
const [department, setDepartment] = useState('engineering')
|
||||
const [cycle, setCycle] = useState('monthly')
|
||||
const [welcome, setWelcome] = useState(true)
|
||||
const [confirmed, setConfirmed] = useState(false)
|
||||
const [errors, setErrors] = useState<FormErrors>({})
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [added, setAdded] = useState<string | null>(null)
|
||||
|
||||
function validate(): FormErrors {
|
||||
const next: FormErrors = {}
|
||||
if (!name.trim()) next.name = "Enter the employee's full name."
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) next.email = 'Enter a full work email, like [email protected].'
|
||||
if (!department) next.department = 'Choose a department.'
|
||||
if (!confirmed) next.confirmed = 'Confirm the details before adding the employee.'
|
||||
return next
|
||||
}
|
||||
|
||||
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault()
|
||||
const next = validate()
|
||||
setErrors(next)
|
||||
if (Object.keys(next).length > 0) return
|
||||
|
||||
setSaving(true)
|
||||
setAdded(null)
|
||||
window.setTimeout(() => {
|
||||
const dept = DEPARTMENTS.find((d) => d.value === department)?.label ?? department
|
||||
const pay = PAY_CYCLES.find((c) => c.value === cycle)?.label.toLowerCase() ?? cycle
|
||||
setAdded(`${name.trim()} joins ${dept}, paid ${pay}.${welcome ? ' A welcome email is on its way.' : ''}`)
|
||||
setSaving(false)
|
||||
}, 900)
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
setName('')
|
||||
setEmail('')
|
||||
setDepartment('')
|
||||
setCycle('monthly')
|
||||
setWelcome(true)
|
||||
setConfirmed(false)
|
||||
setErrors({})
|
||||
setAdded(null)
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card variant="elevated" padding="none" className="employee-card">
|
||||
<Card.Header className="employee-card-header">
|
||||
<Card.Title>Add an employee</Card.Title>
|
||||
<p>They appear in the next payroll run.</p>
|
||||
</Card.Header>
|
||||
<Card.Body className="employee-card-body">
|
||||
{added && (
|
||||
<Alert key={added} color="success" title="Employee added" dismissible onOpenChange={(open) => !open && setAdded(null)}>
|
||||
{added}
|
||||
</Alert>
|
||||
)}
|
||||
<div className="form-row">
|
||||
<FeaturedInput
|
||||
name="employee-name"
|
||||
label="Full name"
|
||||
startIcon={<UserRound />}
|
||||
value={name}
|
||||
onValueChange={setName}
|
||||
error={errors.name}
|
||||
required
|
||||
/>
|
||||
<FeaturedInput
|
||||
name="employee-email"
|
||||
label="Work email"
|
||||
type="email"
|
||||
startIcon={<Mail />}
|
||||
value={email}
|
||||
onValueChange={setEmail}
|
||||
error={errors.email}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<FeaturedSelect
|
||||
name="department"
|
||||
label="Department"
|
||||
options={DEPARTMENTS}
|
||||
value={department || null}
|
||||
onValueChange={(value) => setDepartment(value ?? '')}
|
||||
clearable
|
||||
error={errors.department}
|
||||
required
|
||||
/>
|
||||
<Radio
|
||||
name="pay-cycle"
|
||||
label="Pay cycle"
|
||||
options={PAY_CYCLES}
|
||||
value={cycle}
|
||||
onValueChange={setCycle}
|
||||
orientation="horizontal"
|
||||
description="How often this employee appears in a payroll run."
|
||||
/>
|
||||
<Switch
|
||||
name="welcome-email"
|
||||
label="Send a welcome email"
|
||||
description="Includes the sign-in link and the first-day checklist."
|
||||
checked={welcome}
|
||||
onCheckedChange={setWelcome}
|
||||
/>
|
||||
<Checkbox
|
||||
name="confirmed"
|
||||
label="I checked these details against the signed offer letter"
|
||||
checked={confirmed}
|
||||
onCheckedChange={setConfirmed}
|
||||
error={errors.confirmed}
|
||||
/>
|
||||
</Card.Body>
|
||||
<Card.Footer className="employee-card-footer">
|
||||
<Button variant="ghost" onClick={handleReset} disabled={saving}>
|
||||
Clear form
|
||||
</Button>
|
||||
<Button type="submit" loading={saving} loadingText="Adding…">
|
||||
Add employee
|
||||
</Button>
|
||||
</Card.Footer>
|
||||
</Card>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [palette, setPalette] = useState<PaletteName>(DEFAULT_PALETTE)
|
||||
const active = palettes[palette]
|
||||
|
||||
// On <html>, not the shell: select lists and tooltips portal to <body> and
|
||||
// must wear the same palette.
|
||||
useEffect(() => {
|
||||
applyPalette(document.documentElement, palette)
|
||||
}, [palette])
|
||||
|
||||
return (
|
||||
<div className="site-shell" data-palette={palette}>
|
||||
<header className="site-header">
|
||||
<div className="container header-inner">
|
||||
<a className="brand" href="#top" aria-label="Tansy UI home">
|
||||
<TansyMark size={30} />
|
||||
<span className="brand-name">
|
||||
Tansy<span className="brand-ui">UI</span>
|
||||
</span>
|
||||
<span className="brand-by">by OpenKhalix</span>
|
||||
</a>
|
||||
<a className="version-pill" href={DOCS.changelog} aria-label={`Version ${VERSION}, see the changelog`}>
|
||||
v{VERSION}
|
||||
</a>
|
||||
<nav className="header-nav" aria-label="Primary">
|
||||
<a href={DOCS.gettingStarted}>Docs</a>
|
||||
<a href={STORYBOOK}>Components</a>
|
||||
<a href="#playground">Theming</a>
|
||||
<a href="#roadmap">Roadmap</a>
|
||||
</nav>
|
||||
<LinkButton href={STORYBOOK} size="sm" variant="outline" className="header-cta">
|
||||
Storybook
|
||||
</LinkButton>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="top">
|
||||
<section className="hero container" id="components">
|
||||
<div className="hero-copy">
|
||||
<p className="eyebrow">
|
||||
<span>React component kit</span>
|
||||
<span className="eyebrow-dim">v{VERSION} · {documentation.length} parts · {totalStories} stories</span>
|
||||
</p>
|
||||
<h1>
|
||||
Small parts,
|
||||
<br />
|
||||
<em>one bloom.</em>
|
||||
</h1>
|
||||
<p className="lede">
|
||||
Tansy UI is a React component kit named after the tansy flower, also called golden buttons. Every part
|
||||
ships with its states, its tokens and a Storybook page, so screens come together from parts that
|
||||
already work.
|
||||
</p>
|
||||
<div className="hero-actions">
|
||||
<LinkButton href={STORYBOOK} size="lg" endIcon={<ArrowRight aria-hidden="true" />}>
|
||||
Browse all components
|
||||
</LinkButton>
|
||||
<LinkButton href="#playground" size="lg" variant="outline">
|
||||
Try the playground
|
||||
</LinkButton>
|
||||
</div>
|
||||
<p className="stack">React 19 · TypeScript · Tailwind v4 · Storybook 10</p>
|
||||
</div>
|
||||
|
||||
<Card variant="elevated" padding="none" className="featured-card" aria-labelledby="featured-title">
|
||||
<Card.Header
|
||||
className="featured-header"
|
||||
action={
|
||||
<Badge color="primary">
|
||||
{featured.length} of {documentation.length}
|
||||
</Badge>
|
||||
}
|
||||
>
|
||||
<h2 id="featured-title">Featured parts</h2>
|
||||
</Card.Header>
|
||||
<Card.Body className="featured-body">
|
||||
<ul className="featured-list">
|
||||
{featured.map((item) => (
|
||||
<li className="featured-row" key={item.name}>
|
||||
<div className="featured-text">
|
||||
<a href={item.href}>{item.name}</a>
|
||||
<span>
|
||||
{item.group} · {item.detail}
|
||||
</span>
|
||||
</div>
|
||||
<div className="featured-preview">{previews[item.name]}</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Card.Body>
|
||||
<Card.Footer className="featured-footer">
|
||||
<LinkButton
|
||||
href={STORYBOOK}
|
||||
variant="soft"
|
||||
color="neutral"
|
||||
fullWidth
|
||||
endIcon={<ArrowRight aria-hidden="true" />}
|
||||
>
|
||||
See all {documentation.length} components
|
||||
</LinkButton>
|
||||
</Card.Footer>
|
||||
</Card>
|
||||
</section>
|
||||
|
||||
<section className="container why" aria-labelledby="why-title">
|
||||
<div className="section-head">
|
||||
<p className="kicker">Why Tansy</p>
|
||||
<h2 id="why-title">Built to be owned, themed and trusted.</h2>
|
||||
</div>
|
||||
<div className="why-grid">
|
||||
<article className="why-card">
|
||||
<div className="why-visual why-visual-code">
|
||||
<CodeSample />
|
||||
</div>
|
||||
<h3>Source you own</h3>
|
||||
<p>
|
||||
Components live in your repository, like shadcn/ui. Read them, change them, and keep the variants your
|
||||
product needs.
|
||||
</p>
|
||||
<a href={DOCS.gettingStarted}>Getting started →</a>
|
||||
</article>
|
||||
<article className="why-card">
|
||||
<div className="why-visual">
|
||||
<div className="why-swatches" role="group" aria-label="Try a palette">
|
||||
{Object.values(palettes).map((p) => (
|
||||
<button
|
||||
key={p.name}
|
||||
type="button"
|
||||
aria-label={p.label}
|
||||
aria-pressed={p.name === palette}
|
||||
title={p.label}
|
||||
style={{ background: p.primary[500] }}
|
||||
onClick={() => setPalette(p.name)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="why-buttons">
|
||||
<Button size="sm">Primary</Button>
|
||||
<Button size="sm" variant="outline">Outline</Button>
|
||||
</div>
|
||||
</div>
|
||||
<h3>Palettes scoped anywhere</h3>
|
||||
<p>
|
||||
Seven palettes, each a full 50–900 ramp. Apply one to the whole app or to a single panel, at runtime,
|
||||
without a rebuild.
|
||||
</p>
|
||||
<a href={DOCS.theming}>Theming →</a>
|
||||
</article>
|
||||
<article className="why-card">
|
||||
<div className="why-visual">
|
||||
<div className="why-states">
|
||||
{STATES.map((state) => (
|
||||
<Badge key={state} color={state === 'Error' ? 'danger' : 'neutral'}>
|
||||
{state}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
<p className="why-stat">
|
||||
<strong>{totalStories}</strong> stories across <strong>{documentation.length}</strong> components
|
||||
</p>
|
||||
</div>
|
||||
<h3>Every state documented</h3>
|
||||
<p>
|
||||
Each state gets its own Storybook story with axe accessibility checks, so reviews cover more than the
|
||||
default look.
|
||||
</p>
|
||||
<a href={DOCS.accessibility}>Accessibility →</a>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="playground" id="playground" aria-labelledby="playground-title">
|
||||
<div className="container playground-grid">
|
||||
<div className="playground-intro">
|
||||
<p className="kicker">Playground</p>
|
||||
<h2 id="playground-title">A working form, built only from Tansy parts.</h2>
|
||||
<p>
|
||||
Pick a palette and every part on this page re-themes from the same tokens. Storybook's Palette toolbar
|
||||
does the same thing.
|
||||
</p>
|
||||
|
||||
<fieldset className="palette-picker">
|
||||
<legend>Palette</legend>
|
||||
<div className="palette-options">
|
||||
{Object.values(palettes).map((p) => (
|
||||
<button
|
||||
key={p.name}
|
||||
type="button"
|
||||
aria-pressed={p.name === palette}
|
||||
onClick={() => setPalette(p.name)}
|
||||
>
|
||||
<span className="swatch" style={{ background: p.primary[500] }} aria-hidden="true" />
|
||||
{p.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p className="palette-note">{active.note}</p>
|
||||
</fieldset>
|
||||
|
||||
<div className="ramp" aria-label={`${active.label} primary ramp`}>
|
||||
{RAMP_STEPS.map((step) => (
|
||||
<div className="ramp-step" key={step}>
|
||||
<span className="ramp-chip" style={{ background: active.primary[step] }} />
|
||||
<span className="ramp-label">{step}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<p className="ramp-caption">
|
||||
<code>primary-500</code> = <code>{active.primary[500].toLowerCase()}</code>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<EmployeeForm />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="container roadmap" id="roadmap" aria-labelledby="roadmap-title">
|
||||
<div className="section-head section-head-row">
|
||||
<div>
|
||||
<p className="kicker">Roadmap</p>
|
||||
<h2 id="roadmap-title">From a kit to a package.</h2>
|
||||
</div>
|
||||
<LinkButton href={DOCS.roadmap} variant="outline" color="neutral" endIcon={<ArrowRight aria-hidden="true" />}>
|
||||
Read the full roadmap
|
||||
</LinkButton>
|
||||
</div>
|
||||
<ol className="roadmap-grid">
|
||||
{roadmap.map((step) => (
|
||||
<li className="roadmap-step" key={step.stage}>
|
||||
<Badge color={step.color} dot>
|
||||
{step.stage}
|
||||
</Badge>
|
||||
<h3>{step.title}</h3>
|
||||
<ul>
|
||||
{step.items.map((item) => (
|
||||
<li key={item}>{item}</li>
|
||||
))}
|
||||
</ul>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer className="site-footer">
|
||||
<div className="container footer-grid">
|
||||
<div className="footer-brand">
|
||||
<div className="footer-logo">
|
||||
<TansyMark size={26} />
|
||||
<strong>
|
||||
Tansy<span className="brand-ui">UI</span>
|
||||
</strong>
|
||||
</div>
|
||||
<p>A themeable React component kit by OpenKhalix.</p>
|
||||
<p className="footer-version">
|
||||
v{VERSION} · <a href={DOCS.changelog}>Changelog</a>
|
||||
</p>
|
||||
</div>
|
||||
<nav className="footer-col" aria-label="Documentation">
|
||||
<h2>Docs</h2>
|
||||
<a href={DOCS.gettingStarted}>Getting started</a>
|
||||
<a href={DOCS.theming}>Theming</a>
|
||||
<a href={DOCS.accessibility}>Accessibility</a>
|
||||
</nav>
|
||||
<nav className="footer-col" aria-label="Components">
|
||||
<h2>Components</h2>
|
||||
{featured.slice(0, 3).map((item) => (
|
||||
<a href={item.href} key={item.name}>
|
||||
{item.name}
|
||||
</a>
|
||||
))}
|
||||
<a href={STORYBOOK}>All {documentation.length} components</a>
|
||||
</nav>
|
||||
<nav className="footer-col" aria-label="Project">
|
||||
<h2>Project</h2>
|
||||
<a href={DOCS.roadmap}>Roadmap</a>
|
||||
<a href={DOCS.changelog}>Changelog</a>
|
||||
<a href="#playground">Playground</a>
|
||||
</nav>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -0,0 +1,904 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@import "../../../packages/ui/src/styles/tokens.css";
|
||||
|
||||
/* The landing page renders package components: generate their utilities. */
|
||||
@source "../../../packages/ui/src";
|
||||
@source not "../../../packages/ui/src/**/*.stories.tsx";
|
||||
@source not "../../../packages/ui/src/**/*.test.tsx";
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
Tansy UI landing page.
|
||||
|
||||
Page neutrals are cool greys biased toward the blue default. The
|
||||
accent is never a literal: it reads the live palette ramp, so the
|
||||
picker in the playground re-themes the page chrome with the parts.
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
:root {
|
||||
--canvas: #f3f4f6;
|
||||
--surface: #ffffff;
|
||||
--surface-sunk: #eceef2;
|
||||
--ink: #12151c;
|
||||
--ink-soft: #4a5162;
|
||||
--ink-muted: #6b7384;
|
||||
--line: #dde1e8;
|
||||
--line-strong: #c5cad4;
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
background: var(--canvas);
|
||||
scroll-behavior: smooth;
|
||||
scroll-padding-top: 5rem;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: var(--canvas);
|
||||
color: var(--ink);
|
||||
font-family: var(--font-sans);
|
||||
font-size: 1rem;
|
||||
line-height: 1.6;
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--color-primary-500);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
::selection {
|
||||
color: #ffffff;
|
||||
background: var(--color-primary-500);
|
||||
}
|
||||
}
|
||||
|
||||
/* Aliases are declared on the shell, where applyPalette writes the ramp, so
|
||||
they resolve against the live palette instead of the :root defaults. */
|
||||
.site-shell {
|
||||
--accent: var(--color-primary-500);
|
||||
--accent-strong: var(--color-primary-700);
|
||||
--accent-soft: var(--color-primary-50);
|
||||
--accent-line: var(--color-primary-200);
|
||||
min-height: 100vh;
|
||||
overflow-x: clip;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: min(100%, 72rem);
|
||||
margin-inline: auto;
|
||||
padding-inline: 1.25rem;
|
||||
}
|
||||
|
||||
.kicker,
|
||||
.eyebrow {
|
||||
margin: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
/* Element defaults stay in the base layer so component utilities (text-*, font-*) win. */
|
||||
@layer base {
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
color: var(--ink);
|
||||
text-wrap: balance;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Header ---------- */
|
||||
|
||||
.site-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: color-mix(in srgb, var(--canvas) 88%, transparent);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.header-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
min-height: 4rem;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.3rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.brand-ui {
|
||||
margin-left: 0.22em;
|
||||
font-weight: 700;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.brand-by {
|
||||
white-space: nowrap;
|
||||
padding-left: 0.6rem;
|
||||
border-left: 1px solid var(--line-strong);
|
||||
font-size: 0.8125rem;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.version-pill {
|
||||
padding: 0.15rem 0.55rem;
|
||||
border: 1px solid var(--line-strong);
|
||||
border-radius: 999px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.75rem;
|
||||
color: var(--ink-soft);
|
||||
font-variant-numeric: tabular-nums;
|
||||
transition: border-color 150ms, color 150ms;
|
||||
}
|
||||
|
||||
.version-pill:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.header-nav {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
margin-left: auto;
|
||||
margin-right: 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.header-nav a:hover {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* ---------- Hero ---------- */
|
||||
|
||||
.hero {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
|
||||
align-items: center;
|
||||
gap: 4rem;
|
||||
padding-block: 4.5rem 5rem;
|
||||
}
|
||||
|
||||
.hero-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem 0.9rem;
|
||||
}
|
||||
|
||||
.eyebrow-dim {
|
||||
color: var(--ink-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.hero-copy h1 {
|
||||
font-size: clamp(2.75rem, 6vw, 4.6rem);
|
||||
font-weight: 800;
|
||||
line-height: 0.98;
|
||||
letter-spacing: -0.045em;
|
||||
}
|
||||
|
||||
.hero-copy h1 em {
|
||||
font-style: normal;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.lede {
|
||||
max-width: 34rem;
|
||||
margin: 0;
|
||||
font-size: 1.125rem;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.hero-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.stack {
|
||||
margin: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.75rem;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
/* The featured card is a Tansy Card; these classes tune its slots. */
|
||||
.featured-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.featured-header h2 {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.featured-body {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.featured-list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.featured-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
min-height: 4.25rem;
|
||||
padding: 0.75rem 1.25rem;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.featured-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.featured-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.featured-text a {
|
||||
width: fit-content;
|
||||
font-family: var(--font-display);
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.featured-text a:hover {
|
||||
color: var(--accent);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
|
||||
.featured-text span {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.featured-preview {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.preview-badges {
|
||||
display: inline-flex;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.featured-footer {
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
/* ---------- Playground ---------- */
|
||||
|
||||
.playground {
|
||||
padding-block: 5rem;
|
||||
border-block: 1px solid var(--line);
|
||||
background: var(--surface-sunk);
|
||||
}
|
||||
|
||||
.playground-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
|
||||
align-items: start;
|
||||
gap: 4rem;
|
||||
}
|
||||
|
||||
.playground-intro {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.playground-intro h2 {
|
||||
font-size: clamp(1.75rem, 3.2vw, 2.4rem);
|
||||
font-weight: 800;
|
||||
line-height: 1.08;
|
||||
letter-spacing: -0.035em;
|
||||
}
|
||||
|
||||
.playground-intro > p:not(.kicker) {
|
||||
max-width: 30rem;
|
||||
margin: 0;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.palette-picker {
|
||||
margin: 0.5rem 0 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.palette-picker legend {
|
||||
margin-bottom: 0.6rem;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.palette-options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.palette-options button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
min-height: 2.25rem;
|
||||
padding: 0 0.8rem 0 0.55rem;
|
||||
border: 1px solid var(--line-strong);
|
||||
border-radius: 999px;
|
||||
background: var(--surface);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
color: var(--ink-soft);
|
||||
cursor: pointer;
|
||||
transition: border-color 150ms, color 150ms;
|
||||
}
|
||||
|
||||
.palette-options button:hover {
|
||||
border-color: var(--ink-muted);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.palette-options button[aria-pressed="true"] {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 1px var(--accent);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.swatch {
|
||||
width: 0.85rem;
|
||||
height: 0.85rem;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.palette-note {
|
||||
min-height: 1.5em;
|
||||
margin: 0.6rem 0 0;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.ramp {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(10, minmax(0, 1fr));
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.ramp-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.ramp-chip {
|
||||
height: 2.5rem;
|
||||
border-radius: 0.3rem;
|
||||
box-shadow: inset 0 0 0 1px rgb(18 21 28 / 0.06);
|
||||
transition: background-color 250ms;
|
||||
}
|
||||
|
||||
.ramp-label {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.6875rem;
|
||||
text-align: center;
|
||||
color: var(--ink-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.ramp-caption {
|
||||
margin: -0.5rem 0 0;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.ramp-caption code {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* The form is a Tansy Card; these classes lay out its slots. */
|
||||
.employee-card-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
padding: 1.25rem 1.5rem;
|
||||
}
|
||||
|
||||
.employee-card-header p {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 400;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.employee-card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.35rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.employee-card-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 1.5rem;
|
||||
}
|
||||
|
||||
/* ---------- Shared section heading ---------- */
|
||||
|
||||
.section-head {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.section-head h2 {
|
||||
max-width: 32rem;
|
||||
font-size: clamp(1.75rem, 3.2vw, 2.4rem);
|
||||
font-weight: 800;
|
||||
line-height: 1.08;
|
||||
letter-spacing: -0.035em;
|
||||
}
|
||||
|
||||
.section-head-row {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.section-head-row > div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
/* ---------- Why Tansy ---------- */
|
||||
|
||||
.why,
|
||||
.roadmap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2.5rem;
|
||||
padding-block: 5rem;
|
||||
}
|
||||
|
||||
/* The hero above already ends with generous padding. */
|
||||
.why {
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.why-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.why-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6rem;
|
||||
padding: 1.25rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 1rem;
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.why-card h3 {
|
||||
margin-top: 0.6rem;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.015em;
|
||||
}
|
||||
|
||||
.why-card > p {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
font-size: 0.9375rem;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.why-card > a {
|
||||
width: fit-content;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.why-card > a:hover {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
|
||||
.why-visual {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 1rem;
|
||||
min-height: 10.5rem;
|
||||
padding: 1.1rem;
|
||||
border-radius: 0.75rem;
|
||||
background: var(--surface-sunk);
|
||||
}
|
||||
|
||||
.why-visual-code {
|
||||
padding: 0;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.why-swatches {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.why-swatches button {
|
||||
width: 1.75rem;
|
||||
height: 1.75rem;
|
||||
border: 2px solid var(--surface);
|
||||
border-radius: 999px;
|
||||
box-shadow: 0 0 0 1px var(--line-strong);
|
||||
cursor: pointer;
|
||||
transition: transform 150ms;
|
||||
}
|
||||
|
||||
.why-swatches button:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.why-swatches button[aria-pressed="true"] {
|
||||
box-shadow: 0 0 0 2px var(--ink);
|
||||
}
|
||||
|
||||
.why-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.why-states {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.why-stat {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--ink-soft);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.why-stat strong {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* Code sample: a dark panel so it reads as code in any palette. */
|
||||
.code-sample {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 10.5rem;
|
||||
overflow: hidden;
|
||||
border-radius: 0.75rem;
|
||||
background: #151923;
|
||||
color: #d7dce5;
|
||||
}
|
||||
|
||||
.code-sample-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.35rem 0.4rem 0.35rem 0.9rem;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.08);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.6875rem;
|
||||
color: #8a93a6;
|
||||
}
|
||||
|
||||
.code-copy {
|
||||
min-height: 1.75rem;
|
||||
color: #c3cad6;
|
||||
}
|
||||
|
||||
.code-copy:hover {
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.code-sample pre {
|
||||
margin: 0;
|
||||
padding: 0.85rem 0.9rem 1rem;
|
||||
overflow-x: auto;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.tok-key {
|
||||
color: #c792ea;
|
||||
}
|
||||
|
||||
.tok-str {
|
||||
color: #a5d6a7;
|
||||
}
|
||||
|
||||
.tok-tag {
|
||||
color: #82aaff;
|
||||
}
|
||||
|
||||
/* ---------- Roadmap ---------- */
|
||||
|
||||
.roadmap {
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.roadmap-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 1.25rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.roadmap-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
padding-top: 1.25rem;
|
||||
border-top: 2px solid var(--ink);
|
||||
}
|
||||
|
||||
.roadmap-step h3 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.roadmap-step ul {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
margin: 0;
|
||||
padding-left: 1.1rem;
|
||||
list-style: disc;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
/* ---------- Footer ---------- */
|
||||
|
||||
.site-footer {
|
||||
border-top: 1px solid var(--line);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.footer-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
|
||||
gap: 2rem;
|
||||
padding-block: 3rem;
|
||||
font-size: 0.875rem;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.footer-brand {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.footer-brand p {
|
||||
max-width: 18rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.footer-logo {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.125rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.footer-version {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.75rem;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.footer-version a {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.footer-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.footer-col h2 {
|
||||
margin-bottom: 0.25rem;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.footer-col a:hover {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* ---------- Responsive ---------- */
|
||||
|
||||
/* Tablets: the nav needs the room the tagline was using. */
|
||||
@media (max-width: 900px) {
|
||||
.brand-by {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Three narrow "Why" cards: keep the longest code line inside its card. */
|
||||
@media (min-width: 961px) and (max-width: 1199px) {
|
||||
.code-sample pre {
|
||||
font-size: 0.6875rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.hero,
|
||||
.playground-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 3rem;
|
||||
}
|
||||
|
||||
.hero {
|
||||
padding-block: 3rem 4rem;
|
||||
}
|
||||
|
||||
.why-grid,
|
||||
.roadmap-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.footer-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.footer-brand {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.container {
|
||||
padding-inline: 1rem;
|
||||
}
|
||||
|
||||
.header-inner {
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.header-nav,
|
||||
.brand-by,
|
||||
.version-pill {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.header-cta {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.playground,
|
||||
.why,
|
||||
.roadmap {
|
||||
padding-block: 3.5rem;
|
||||
}
|
||||
|
||||
.footer-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.employee-card-body,
|
||||
.employee-card-header,
|
||||
.employee-card-footer {
|
||||
padding-inline: 1.1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
html {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
transition-duration: 0.01ms !important;
|
||||
animation-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import App from './App'
|
||||
import './index.css'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"customConditions": ["source"],
|
||||
"types": ["vite/client"],
|
||||
"jsx": "react-jsx",
|
||||
"skipLibCheck": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"allowImportingTsExtensions": true,
|
||||
"noEmit": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import { defaultClientConditions, defineConfig } from 'vite'
|
||||
|
||||
const ui = JSON.parse(readFileSync(new URL('../../packages/ui/package.json', import.meta.url), 'utf8')) as { version: string }
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
// Resolve @openkhalix/tansy-ui to its source (the "source" export condition),
|
||||
// so edits to components hot-reload without rebuilding the package.
|
||||
resolve: { conditions: ['source', ...defaultClientConditions] },
|
||||
define: { __TANSY_VERSION__: JSON.stringify(ui.version) },
|
||||
publicDir: '../../packages/brand/public',
|
||||
})
|
||||
Reference in new issue
Block a user