Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

2.4 KB
Raw Blame
import * as React from "react";

import { cn } from "../../utils";
import { rowLinkContainerClassName } from "../RowLink";

function Card({ className, linked, ...props }: React.ComponentProps<"div"> & { linked?: boolean }) {
  return (
    <div
      data-slot="card"
      className={cn(
        "flex h-fit flex-col gap-5 rounded-card border border-border bg-card p-5 text-foreground shadow-xs",
        linked && rowLinkContainerClassName,
        className
      )}
      {...props}
    />
  );
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-header"
      className={cn(
        "@container/card-header grid auto-rows-min items-center gap-2",
        "border-border [.border-b]:pb-4",
        "has-data-[slot=card-action]:@xs:grid-cols-[1fr_auto]",
        "has-data-[slot=icon-button]:grid-cols-[1fr_auto]",
        className
      )}
      {...props}
    />
  );
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-title"
      className={cn(
        "flex flex-wrap items-center gap-1.5 font-alliance text-lg leading-none font-normal",
        className
      )}
      {...props}
    />
  );
}

function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div data-slot="card-description" className={cn("text-sm text-accent", className)} {...props} />
  );
}

function CardAction({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-action"
      className={cn(
        "justify-self-start",
        "@xs:col-start-2 @xs:row-span-2 @xs:row-start-1 @xs:self-start @xs:justify-self-end",
        "has-data-[slot=icon-button]:col-start-2 has-data-[slot=icon-button]:row-span-2 has-data-[slot=icon-button]:row-start-1 has-data-[slot=icon-button]:self-start has-data-[slot=icon-button]:justify-self-end",
        className
      )}
      {...props}
    />
  );
}

function CardContent({ className, ...props }: React.ComponentProps<"div">) {
  return <div data-slot="card-content" className={cn("", className)} {...props} />;
}

function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-footer"
      className={cn("flex items-center border-border", className)}
      {...props}
    />
  );
}

export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };