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,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
|
||||
Reference in new issue
Block a user