QR코드 정사각형 강제

This commit is contained in:
dohyeons 2025-12-22 11:51:19 +09:00
parent c5cb4336e5
commit acc867e38d
2 changed files with 30 additions and 5 deletions

View File

@ -339,6 +339,20 @@ export function CanvasComponent({ component }: CanvasComponentProps) {
width: snapValueToGrid(boundedWidth),
});
}
} else if (component.type === "barcode" && component.barcodeType === "QR") {
// QR코드는 정사각형 유지: 더 큰 변화량 기준으로 동기화
const maxDelta = Math.abs(deltaX) > Math.abs(deltaY) ? deltaX : deltaY;
const newSize = Math.max(50, resizeStart.width + maxDelta);
const maxSize = Math.min(
canvasWidthPx - marginRightPx - component.x,
canvasHeightPx - marginBottomPx - component.y,
);
const boundedSize = Math.min(newSize, maxSize);
const snappedSize = snapValueToGrid(boundedSize);
updateComponent(component.id, {
width: snappedSize,
height: snappedSize,
});
} else {
// Grid Snap 적용
updateComponent(component.id, {

View File

@ -1649,11 +1649,22 @@ export function ReportDesignerRightPanel() {
<Label className="text-xs"> </Label>
<Select
value={selectedComponent.barcodeType || "CODE128"}
onValueChange={(value) =>
updateComponent(selectedComponent.id, {
barcodeType: value as "CODE128" | "CODE39" | "EAN13" | "EAN8" | "UPC" | "QR",
})
}
onValueChange={(value) => {
const newType = value as "CODE128" | "CODE39" | "EAN13" | "EAN8" | "UPC" | "QR";
// QR코드는 정사각형으로 크기 조정
if (newType === "QR") {
const size = Math.max(selectedComponent.width, selectedComponent.height);
updateComponent(selectedComponent.id, {
barcodeType: newType,
width: size,
height: size,
});
} else {
updateComponent(selectedComponent.id, {
barcodeType: newType,
});
}
}}
>
<SelectTrigger className="h-8">
<SelectValue />