Tansy UI: a themeable React component kit

Tansy UI is a React component kit by OpenKhalix, named after the tansy
flower ("golden buttons"). It has two surfaces:

- A landing page built entirely from the kit's own components, with
  five featured parts, a palette-switching playground form, and links
  into Storybook
- A Storybook workshop with Tansy branding, a Welcome page, palette
  toolbar and accessibility checks

Includes 15 components with colocated tokens and stories, seven brand
palettes, a palette-aware logo, a Docker/nginx image, a scripted
cPanel deploy, and a generator that keeps the landing page catalogue
in sync with Storybook.
This commit is contained in:
thekhalidsha committed 2026-09-28 17:09:57 +05:30
commit 9d406d6d2a
81 files changed
+14240

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import type { StorybookConfig } from '@storybook/react-vite'
const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(ts|tsx)'],
addons: ['@storybook/addon-docs', '@storybook/addon-a11y'],
framework: {
name: '@storybook/react-vite',
options: {},
},
// Serves the Tansy mark and favicon to the manager and the Welcome page.
staticDirs: ['../public'],
docs: {
defaultName: 'Documentation',
},
}
export default config
+8
View File
@@ -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" />
+9
View File
@@ -0,0 +1,9 @@
import { addons } from 'storybook/manager-api'
import { tansyTheme } from './tansyTheme'
addons.setConfig({
theme: tansyTheme,
sidebar: {
showRoots: true,
},
})
+11
View File
@@ -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>
+92
View File
@@ -0,0 +1,92 @@
import { useEffect, useRef, type ReactElement } from 'react'
import type { Decorator, Preview } from '@storybook/react-vite'
import '../src/index.css'
import { applyPalette } from '../src/theme/applyPalette'
import { palettes, DEFAULT_PALETTE, type PaletteName } from '../src/theme/palettes'
import { tansyTheme } from './tansyTheme'
/**
* Wraps every story in a themed surface.
*
* The palette globals are set on this wrapper rather than on
* `document.documentElement` so a story can opt into a *different* palette on
* its own subtree without fighting the global one, and so the docs page keeps
* its own chrome.
*
* Declared as a named component (not an inline arrow) so the rules-of-hooks lint
* recognises the hook calls below.
*/
function PaletteSurface({ palette, children }: { palette: PaletteName; children: ReactElement }) {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
if (ref.current) applyPalette(ref.current, palette)
}, [palette])
return (
<div
ref={ref}
data-palette={palette}
style={{
padding: '1.5rem',
minHeight: '100%',
color: 'var(--color-gray-900)',
}}
>
{children}
</div>
)
}
const withPalette: Decorator = (Story, context) => {
const palette = (context.globals.palette ?? DEFAULT_PALETTE) as PaletteName
return <PaletteSurface palette={palette}><Story /></PaletteSurface>
}
const preview: Preview = {
title: 'Tansy UI / Component Workshop',
decorators: [withPalette],
globalTypes: {
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: {
palette: DEFAULT_PALETTE,
},
parameters: {
docs: {
theme: tansyTheme,
},
options: {
storySort: {
order: ['Welcome', 'Actions', 'Forms', 'Data entry', 'Feedback', 'Display', 'Layout', 'Navigation', 'Overlays'],
},
},
backgrounds: {
default: 'showcase',
values: [
{ name: 'showcase', value: '#f3f4f6' },
{ name: 'surface', value: '#ffffff' },
{ name: 'dark', value: '#12151c' },
],
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
}
export default preview
+46
View File
@@ -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,
})