44 lines
1005 B
TypeScript
44 lines
1005 B
TypeScript
import * as React from "react";
|
|
import { Slot } from "@radix-ui/react-slot";
|
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
const containerVariants = cva("mx-auto w-full px-4 sm:px-6 lg:px-8", {
|
|
variants: {
|
|
size: {
|
|
default: "max-w-layout",
|
|
narrow: "max-w-narrow",
|
|
wide: "max-w-wide",
|
|
admin: "max-w-admin",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
size: "default",
|
|
},
|
|
});
|
|
|
|
export interface ContainerProps
|
|
extends React.HTMLAttributes<HTMLDivElement>,
|
|
VariantProps<typeof containerVariants> {
|
|
asChild?: boolean;
|
|
}
|
|
|
|
const Container = React.forwardRef<HTMLDivElement, ContainerProps>(
|
|
({ className, size, asChild = false, ...props }, ref) => {
|
|
const Comp = asChild ? Slot : "div";
|
|
|
|
return (
|
|
<Comp
|
|
ref={ref}
|
|
className={cn(containerVariants({ size }), className)}
|
|
{...props}
|
|
/>
|
|
);
|
|
},
|
|
);
|
|
|
|
Container.displayName = "Container";
|
|
|
|
export { Container, containerVariants };
|