Package Tansy UI as @openkhalix/tansy-ui in a monorepo (v0.4.0)
CI / check (push) Successful in 3m9s
Release / publish (push) Failing after 1m22s

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:
thekhalidsha committed 2026-09-29 09:24:03 +05:30
1 parent 23e67006d3
commit 9255b255a6
214 files changed
+1521 -389

No files matched your search

+285
View File
@@ -0,0 +1,285 @@
import type { Meta, StoryObj } from '@storybook/react-vite'
import { ArrowRight, ArrowUpRight, BookOpen, MapPin, MoreHorizontal, TrendingUp, Users } from 'lucide-react'
import { fn } from 'storybook/test'
import { Avatar, AvatarGroup } from './Avatar'
import { Badge } from './Badge'
import { Button, IconButton } from './Button'
import { Card } from './Card'
import { CARD_LAYOUTS, CARD_PADDINGS, CARD_VARIANTS } from './card.tokens'
import { PORTRAITS, landscape } from './display.fixtures'
const meta = {
title: 'Layout/Card',
component: Card,
subcomponents: {
'Card.Header': Card.Header,
'Card.Title': Card.Title,
'Card.Description': Card.Description,
'Card.Body': Card.Body,
'Card.Footer': Card.Footer,
'Card.Media': Card.Media,
},
tags: ['autodocs'],
parameters: {
docs: {
description: {
component:
'A surface that groups related content. Compose `Card.Media`, `Card.Header` (with `Card.Title`, `Card.Description` and an optional `action`), `Card.Body` and `Card.Footer`; the card spaces them by `padding`. `layout="horizontal"` puts the media beside the text. Pass `href` (or `render={<button />}`) to make the whole card a link or button with a hover lift and focus ring. `headingLevel` fits the title into the page outline.',
},
},
},
argTypes: {
variant: { control: 'inline-radio', options: CARD_VARIANTS, table: { defaultValue: { summary: 'outline' } } },
padding: { control: 'inline-radio', options: CARD_PADDINGS, table: { defaultValue: { summary: 'md' } } },
layout: { control: 'inline-radio', options: CARD_LAYOUTS, table: { defaultValue: { summary: 'vertical' } } },
interactive: { control: 'boolean' },
href: { control: 'text' },
headingLevel: { control: 'inline-radio', options: [2, 3, 4, 5, 6], table: { defaultValue: { summary: '3' } } },
render: { control: false },
children: { control: false },
},
args: {
variant: 'outline',
padding: 'md',
layout: 'vertical',
headingLevel: 3,
},
} satisfies Meta<typeof Card>
export default meta
type Story = StoryObj<typeof meta>
const title = (s: string) => s[0].toUpperCase() + s.slice(1)
export const Playground: Story = {
render: (args) => (
<Card {...args} className="max-w-sm">
<Card.Header>
<Card.Title>Quarterly review</Card.Title>
<Card.Description>Acme Corporation · Due 14 October</Card.Description>
</Card.Header>
<Card.Body>
Collect the self-assessments from your team and schedule a 30-minute conversation with each person before the
end of the month.
</Card.Body>
<Card.Footer>
<Button size="sm" onClick={fn()}>
Start review
</Button>
<Button size="sm" variant="ghost" color="neutral" onClick={fn()}>
Later
</Button>
</Card.Footer>
</Card>
),
}
export const Variants: Story = {
render: (args) => (
<div className="grid max-w-4xl gap-5 sm:grid-cols-3">
{CARD_VARIANTS.map((variant) => (
<Card key={variant} {...args} variant={variant}>
<Card.Header>
<Card.Title>{title(variant)}</Card.Title>
<Card.Description>
{variant === 'outline'
? 'A bordered surface for most content.'
: variant === 'elevated'
? 'A soft shadow lifts it off the page.'
: 'A quiet fill for secondary content.'}
</Card.Description>
</Card.Header>
<Card.Body>Cards group related content and actions about a single subject.</Card.Body>
</Card>
))}
</div>
),
}
export const Padding: Story = {
render: (args) => (
<div className="grid max-w-5xl items-start gap-5 sm:grid-cols-4">
{CARD_PADDINGS.map((padding) => (
<Card key={padding} {...args} padding={padding}>
<Card.Header>
<Card.Title>padding=&quot;{padding}&quot;</Card.Title>
</Card.Header>
<Card.Body>Spacing shared by every section.</Card.Body>
</Card>
))}
</div>
),
}
export const ProfileCard: Story = {
render: (args) => (
<Card {...args} className="max-w-sm">
<Card.Header
action={<IconButton size="sm" aria-label="More actions for Jane Doe" icon={<MoreHorizontal />} onClick={fn()} />}
>
<div className="flex items-center gap-3">
<Avatar name="Jane Doe" src={PORTRAITS.jane} size="lg" status="online" />
<div className="min-w-0">
<Card.Title>Jane Doe</Card.Title>
<Card.Description>Senior Product Engineer</Card.Description>
</div>
</div>
</Card.Header>
<Card.Body className="grid gap-3">
<div className="flex flex-wrap gap-1.5">
<Badge color="primary">Engineering</Badge>
<Badge color="neutral">Full-time</Badge>
<Badge color="success" dot>
Available
</Badge>
</div>
<p className="flex items-center gap-1.5 text-sm text-fg-muted">
<MapPin aria-hidden="true" className="size-4" /> Lisbon, Portugal · jane.doe@example.com
</p>
</Card.Body>
<Card.Footer divider>
<Button size="sm" variant="outline" color="neutral" className="flex-1" onClick={fn()}>
Message
</Button>
<Button size="sm" className="flex-1" onClick={fn()}>
View profile
</Button>
</Card.Footer>
</Card>
),
}
export const StatCards: Story = {
parameters: { docs: { description: { story: 'Compact stat cards in a dashboard row.' } } },
render: (args) => (
<div className="grid max-w-4xl gap-4 sm:grid-cols-3">
{[
{ label: 'Active employees', value: '1,284', delta: '+4.2%', note: 'vs last month', color: 'success' as const, icon: Users },
{ label: 'Open positions', value: '37', delta: '+6', note: 'across 9 teams', color: 'info' as const, icon: TrendingUp },
{ label: 'Attrition (12 mo)', value: '8.1%', delta: '+0.6 pts', note: 'above target', color: 'warning' as const, icon: ArrowUpRight },
].map((s) => (
<Card key={s.label} {...args} variant="elevated" padding="sm">
<Card.Header
action={
<span className="flex size-8 items-center justify-center rounded-lg bg-surface-sunken text-fg-muted">
<s.icon aria-hidden="true" className="size-4" />
</span>
}
>
<Card.Description className="font-medium">{s.label}</Card.Description>
<p className="text-2xl font-semibold tracking-tight text-fg tabular-nums">{s.value}</p>
</Card.Header>
<Card.Body className="flex items-center gap-2 text-xs">
<Badge size="sm" color={s.color}>
{s.delta}
</Badge>
<span>{s.note}</span>
</Card.Body>
</Card>
))}
</div>
),
}
export const HorizontalMedia: Story = {
args: { layout: 'horizontal' },
render: (args) => (
<Card {...args} className="max-w-2xl">
<Card.Media>
<img src={landscape('#bfd2fd', '#305ddd')} alt="Illustration of blue hills under a pale sky" />
</Card.Media>
<Card.Header>
<Badge size="sm" color="primary" className="self-start">
Offsite
</Badge>
<Card.Title>Team offsite in the Sintra hills</Card.Title>
<Card.Description>12–14 November · 24 attending</Card.Description>
</Card.Header>
<Card.Body>
Three days of planning, workshops and long walks. Travel and accommodation are booked; bring layers, the
evenings get cold.
</Card.Body>
<Card.Footer className="justify-between">
<AvatarGroup size="sm" max={3} aria-label="Attendees">
<Avatar name="Jane Doe" src={PORTRAITS.jane} />
<Avatar name="John Smith" src={PORTRAITS.john} />
<Avatar name="Maya Chen" src={PORTRAITS.maya} />
<Avatar name="Carlos Mendez" />
<Avatar name="Aiko Tanaka" />
</AvatarGroup>
<Button size="sm" variant="soft" endIcon={<ArrowRight aria-hidden="true" />} onClick={fn()}>
Details
</Button>
</Card.Footer>
</Card>
),
}
export const VerticalMedia: Story = {
render: (args) => (
<div className="grid max-w-3xl gap-5 sm:grid-cols-2">
{[
{ t: 'Designing for dark mode', d: 'Five rules for surfaces, borders and text that hold up at night.', sky: '#fde68a', hills: '#d97706', tag: 'Guide' },
{ t: 'Accessible data tables', d: 'Captions, header scopes and sort state that screen readers announce.', sky: '#a7f3d0', hills: '#047857', tag: 'Article' },
].map((p) => (
<Card key={p.t} {...args}>
<Card.Media className="aspect-[16/9]">
<img src={landscape(p.sky, p.hills)} alt="" />
</Card.Media>
<Card.Header>
<Card.Title>{p.t}</Card.Title>
<Card.Description>{p.d}</Card.Description>
</Card.Header>
<Card.Footer>
<Badge size="sm" variant="outline">
{p.tag}
</Badge>
<span className="text-xs text-fg-muted">6 min read</span>
</Card.Footer>
</Card>
))}
</div>
),
}
export const InteractiveLink: Story = {
parameters: {
docs: {
description: {
story:
'With `href` the whole card is one link: it lifts on hover and shows a focus ring. Keep other interactive elements out of a link card. `render={<button type="button" />}` makes a button card.',
},
},
},
render: (args) => (
<div className="grid max-w-3xl gap-4 sm:grid-cols-3">
<Card {...args} href="#getting-started">
<Card.Header>
<span className="mb-2 flex size-9 items-center justify-center rounded-lg bg-primary-50 text-primary-700 dark:bg-primary-500/15 dark:text-primary-300">
<BookOpen aria-hidden="true" className="size-5" />
</span>
<Card.Title>Getting started</Card.Title>
<Card.Description>Install the kit and render your first component.</Card.Description>
</Card.Header>
</Card>
<Card {...args} variant="elevated" href="#theming">
<Card.Header>
<span className="mb-2 flex size-9 items-center justify-center rounded-lg bg-info-50 text-info-700 dark:bg-info-500/15 dark:text-info-300">
<TrendingUp aria-hidden="true" className="size-5" />
</span>
<Card.Title>Theming</Card.Title>
<Card.Description>Swap palettes and switch to dark mode.</Card.Description>
</Card.Header>
</Card>
<Card {...args} variant="filled" render={<button type="button" onClick={fn()} />}>
<Card.Header>
<span className="mb-2 flex size-9 items-center justify-center rounded-lg bg-success-50 text-success-700 dark:bg-success-500/15 dark:text-success-300">
<Users aria-hidden="true" className="size-5" />
</span>
<Card.Title>Invite your team</Card.Title>
<Card.Description>A button card that opens a dialog.</Card.Description>
</Card.Header>
</Card>
</div>
),
}