mirror of
https://github.com/cosscom/coss.git
synced 2026-09-14 20:06:50 +08:00
9302c06311
* update biome config + resolve issues * improve the ui:sync command to run organizeImports on packages * reformat * build registry * exclude base-ui stuff * fix useExportsLast * further improvements * silence errors * exclude examples app * update biome + reformat * format all the other files * include examples app * improve copyable-field * remove unwanted comment * remove a few unneeded biome comments * avoid nested ternary * refactored some shared components * upgrade base ui to 1.2.0 * fix
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import type { RegistryItem } from "shadcn/registry";
|
|
import { cn } from "@/registry/default/lib/utils";
|
|
|
|
export default function ComponentCard({
|
|
isSearchPage = false,
|
|
children,
|
|
component,
|
|
className,
|
|
}: {
|
|
isSearchPage?: boolean;
|
|
children: React.ReactNode;
|
|
component: RegistryItem;
|
|
className?: string;
|
|
}) {
|
|
const getColSpanClasses = (includeStart = false) => {
|
|
const baseClasses =
|
|
component.meta?.colSpan === 2
|
|
? "col-span-12 sm:col-span-6 lg:col-span-6"
|
|
: component.meta?.colSpan === 3
|
|
? "col-span-12 sm:col-span-12 lg:col-span-12"
|
|
: "col-span-12 sm:col-span-6 lg:col-span-4";
|
|
|
|
const startClasses =
|
|
includeStart && component.meta?.colSpan !== 3
|
|
? component.meta?.colSpan === 2
|
|
? "sm:col-start-4 lg:col-start-4"
|
|
: "sm:col-start-4 lg:col-start-5"
|
|
: "";
|
|
|
|
return cn(baseClasses, startClasses);
|
|
};
|
|
|
|
const styleClasses =
|
|
component.meta?.style === 1
|
|
? "flex justify-center items-center"
|
|
: component.meta?.style === 2
|
|
? "text-center"
|
|
: "";
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"group/item relative border border-zinc-200 has-[[data-comp-loading=true]]:border-none dark:border-zinc-900",
|
|
isSearchPage
|
|
? "col-span-12 grid grid-cols-12"
|
|
: cn(getColSpanClasses(), styleClasses),
|
|
className,
|
|
)}
|
|
data-slot={component.name}
|
|
>
|
|
{isSearchPage ? (
|
|
<div className={cn(getColSpanClasses(true), styleClasses)}>
|
|
{children}
|
|
</div>
|
|
) : (
|
|
children
|
|
)}
|
|
</div>
|
|
);
|
|
}
|