fix: use forwardRef for Story

This commit is contained in:
p-sw 2024-06-01 07:48:57 +09:00
parent 38975b7d15
commit 70f8f43209

View File

@ -6,23 +6,25 @@ const layoutClasses = {
centered: "flex items-center justify-center", centered: "flex items-center justify-center",
}; };
export function Story({ const Story = React.forwardRef<
layout = "default", HTMLDivElement,
children, {
className,
}: {
layout?: keyof typeof layoutClasses; layout?: keyof typeof layoutClasses;
children: React.ReactNode; children: React.ReactNode;
className?: string; className?: string;
}) { }
>(({ layout = "default", children, className }, ref) => {
return ( return (
<div <div
className={twMerge( className={twMerge(
`bg-white dark:bg-black border border-neutral-300 dark:border-neutral-700 rounded-lg w-full p-4 min-h-48 h-auto mt-8 ${layoutClasses[layout]}`, `bg-white dark:bg-black border border-neutral-300 dark:border-neutral-700 rounded-lg w-full p-4 min-h-48 h-auto mt-8 ${layoutClasses[layout]}`,
className className
)} )}
ref={ref}
> >
{children} {children}
</div> </div>
); );
} });
export { Story };