c5200c7d45
## 变更内容 - 新增基于 shadcn open-code 模式的共享 UI canonical 组件、样式与导出。 - 新增 `/components` 共享组件展示页,并覆盖平台组件、Token、状态和移动端布局。 - 补齐平台展示页的筛选、排序、上传预览、标签、开关和异步状态交互。 - 修复排序导致预览主题变化、筛选弹窗误关闭和入口状态不更新的问题。 - 同步网站与客户端构建别名、依赖、路由测试和项目文档。 ## 验证 - `npm run test -- src/components/shared-components/SharedComponentsShowcasePage.test.tsx` - `npm run typecheck` - `npm run check:encoding` - `npm run build:raw` - `git diff --check` - pre-push 门禁通过 Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/202 Co-authored-by: kdletters <kdletters@qq.com> Co-committed-by: kdletters <kdletters@qq.com>
74 lines
1.5 KiB
TypeScript
74 lines
1.5 KiB
TypeScript
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
|
|
import { cn } from '../../lib/utils';
|
|
|
|
export type CardProps = HTMLAttributes<HTMLElement> & {
|
|
as?: 'section' | 'div' | 'article' | 'aside';
|
|
tone?: 'default' | 'soft' | 'contrast';
|
|
padding?: 'sm' | 'md' | 'lg' | 'none';
|
|
children?: ReactNode;
|
|
};
|
|
|
|
export function Card({
|
|
as: Component = 'div',
|
|
tone = 'default',
|
|
padding = 'md',
|
|
className,
|
|
...props
|
|
}: CardProps) {
|
|
return (
|
|
<Component
|
|
{...props}
|
|
data-slot="card"
|
|
className={cn(
|
|
'genarrative-ui-subpanel',
|
|
`genarrative-ui-subpanel--${tone}`,
|
|
`genarrative-ui-subpanel--padding-${padding}`,
|
|
className,
|
|
)}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function CardHeader({
|
|
className,
|
|
...props
|
|
}: HTMLAttributes<HTMLElement>) {
|
|
return (
|
|
<header
|
|
{...props}
|
|
data-slot="card-header"
|
|
className={cn('genarrative-ui-subpanel__header', className)}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function CardTitle({
|
|
className,
|
|
children,
|
|
...props
|
|
}: HTMLAttributes<HTMLHeadingElement> & { children?: ReactNode }) {
|
|
return (
|
|
<h2
|
|
{...props}
|
|
data-slot="card-title"
|
|
className={cn('genarrative-ui-subpanel__title', className)}
|
|
>
|
|
{children}
|
|
</h2>
|
|
);
|
|
}
|
|
|
|
export function CardActions({
|
|
className,
|
|
...props
|
|
}: HTMLAttributes<HTMLDivElement>) {
|
|
return (
|
|
<div
|
|
{...props}
|
|
data-slot="card-actions"
|
|
className={cn('genarrative-ui-subpanel__actions', className)}
|
|
/>
|
|
);
|
|
}
|