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,123 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite'
|
||||
import { Button } from './Button'
|
||||
import { Skeleton, SkeletonGroup, SkeletonText } from './Skeleton'
|
||||
import { SKELETON_VARIANTS } from './skeleton.tokens'
|
||||
|
||||
const meta = {
|
||||
title: 'Feedback/Skeleton',
|
||||
component: Skeleton,
|
||||
tags: ['autodocs'],
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component:
|
||||
'Placeholder shapes shown while content loads, so the layout does not jump. `Skeleton` draws one block (`rectangle`, `circle` for avatars, `text` for a line); `SkeletonText` draws a paragraph. The shapes are `aria-hidden`; wrap a loading region in `SkeletonGroup`, which sets `aria-busy` and gives screen readers one "Loading" message. The pulse stops under reduced motion.',
|
||||
},
|
||||
},
|
||||
},
|
||||
argTypes: {
|
||||
variant: { control: 'inline-radio', options: SKELETON_VARIANTS, table: { defaultValue: { summary: 'rectangle' } } },
|
||||
width: { control: 'text' },
|
||||
height: { control: 'text' },
|
||||
},
|
||||
args: { variant: 'rectangle', width: '16rem', height: '1rem' },
|
||||
} satisfies Meta<typeof Skeleton>
|
||||
|
||||
export default meta
|
||||
type Story = StoryObj<typeof meta>
|
||||
|
||||
export const Playground: Story = {}
|
||||
|
||||
export const Shapes: Story = {
|
||||
render: () => (
|
||||
<div className="flex flex-wrap items-center gap-6">
|
||||
<Skeleton variant="circle" />
|
||||
<Skeleton variant="circle" width={56} height={56} />
|
||||
<Skeleton width={160} height={96} className="rounded-xl" />
|
||||
<div className="grid w-48 gap-2">
|
||||
<Skeleton variant="text" />
|
||||
<Skeleton variant="text" width="70%" />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Text: Story = {
|
||||
render: () => (
|
||||
<div className="max-w-md">
|
||||
<SkeletonText lines={4} />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
function CardSkeleton() {
|
||||
return (
|
||||
<div className="rounded-xl border border-border bg-surface p-5">
|
||||
<div className="flex items-center gap-3">
|
||||
<Skeleton variant="circle" />
|
||||
<div className="grid flex-1 gap-2">
|
||||
<Skeleton variant="text" width="45%" />
|
||||
<Skeleton variant="text" width="30%" className="h-2.5" />
|
||||
</div>
|
||||
</div>
|
||||
<Skeleton height={140} className="mt-5 rounded-lg" />
|
||||
<SkeletonText lines={3} className="mt-5" />
|
||||
<div className="mt-5 flex gap-2">
|
||||
<Skeleton width={88} height={32} className="rounded-md" />
|
||||
<Skeleton width={72} height={32} className="rounded-md" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const CardLoading: Story = {
|
||||
parameters: { docs: { description: { story: 'A card placeholder inside a `SkeletonGroup` that marks the region busy.' } } },
|
||||
render: () => (
|
||||
<SkeletonGroup label="Loading posts" className="grid max-w-3xl gap-4 sm:grid-cols-2">
|
||||
<CardSkeleton />
|
||||
<CardSkeleton />
|
||||
</SkeletonGroup>
|
||||
),
|
||||
}
|
||||
|
||||
export const LoadingThenContent: Story = {
|
||||
render: function Render() {
|
||||
const [loading, setLoading] = useState(true)
|
||||
useEffect(() => {
|
||||
if (!loading) return
|
||||
const id = setTimeout(() => setLoading(false), 2000)
|
||||
return () => clearTimeout(id)
|
||||
}, [loading])
|
||||
return (
|
||||
<div className="grid max-w-sm gap-3">
|
||||
<SkeletonGroup loading={loading} label="Loading profile" className="rounded-xl border border-border bg-surface p-5">
|
||||
{loading ? (
|
||||
<div className="flex items-center gap-3">
|
||||
<Skeleton variant="circle" />
|
||||
<div className="grid flex-1 gap-2">
|
||||
<Skeleton variant="text" width="50%" />
|
||||
<Skeleton variant="text" width="70%" />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="flex size-10 items-center justify-center rounded-full bg-primary-100 text-sm font-semibold text-primary-700 dark:bg-primary-500/20 dark:text-primary-200">
|
||||
JD
|
||||
</span>
|
||||
<div>
|
||||
<p className="text-sm font-semibold text-fg">Jane Doe</p>
|
||||
<p className="text-sm text-fg-muted">name@example.com</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</SkeletonGroup>
|
||||
<div>
|
||||
<Button size="sm" variant="outline" color="neutral" onClick={() => setLoading(true)} disabled={loading}>
|
||||
Reload
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user