79 lines
2.2 KiB
TypeScript
79 lines
2.2 KiB
TypeScript
"use client";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
import { ColumnComponent as ColumnComponentType } from "@/types/screen";
|
|
|
|
interface ColumnComponentProps {
|
|
component: ColumnComponentType;
|
|
children?: React.ReactNode;
|
|
className?: string;
|
|
onClick?: () => void;
|
|
isSelected?: boolean;
|
|
onMouseDown?: (e: React.MouseEvent) => void;
|
|
isMoving?: boolean;
|
|
}
|
|
|
|
export default function ColumnComponent({
|
|
component,
|
|
children,
|
|
className,
|
|
onClick,
|
|
isSelected,
|
|
onMouseDown,
|
|
isMoving,
|
|
}: ColumnComponentProps) {
|
|
// 스타일 객체 생성
|
|
const style: React.CSSProperties = {
|
|
gridColumn: `span ${component.size.width}`,
|
|
minHeight: `${component.size.height}px`,
|
|
...(component.style && {
|
|
width: component.style.width,
|
|
height: component.style.height,
|
|
margin: component.style.margin,
|
|
padding: component.style.padding,
|
|
backgroundColor: component.style.backgroundColor,
|
|
border: component.style.border,
|
|
borderRadius: component.style.borderRadius,
|
|
boxShadow: component.style.boxShadow,
|
|
display: component.style.display || "flex",
|
|
flexDirection: component.style.flexDirection || "column",
|
|
justifyContent: component.style.justifyContent,
|
|
alignItems: component.style.alignItems,
|
|
gap: component.style.gap,
|
|
color: component.style.color,
|
|
fontSize: component.style.fontSize,
|
|
fontWeight: component.style.fontWeight,
|
|
textAlign: component.style.textAlign,
|
|
position: component.style.position,
|
|
zIndex: component.style.zIndex,
|
|
opacity: component.style.opacity,
|
|
overflow: component.style.overflow,
|
|
cursor: component.style.cursor,
|
|
transition: component.style.transition,
|
|
transform: component.style.transform,
|
|
}),
|
|
...(isMoving && {
|
|
zIndex: 50,
|
|
opacity: 0.8,
|
|
transform: "scale(1.02)",
|
|
}),
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"flex-1 rounded border border-gray-200 p-2",
|
|
isSelected && "border-primary bg-accent",
|
|
isMoving && "cursor-move",
|
|
className,
|
|
)}
|
|
style={style}
|
|
onClick={onClick}
|
|
onMouseDown={onMouseDown}
|
|
>
|
|
<div className="mb-2 text-xs text-gray-500">열</div>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|