Skip to content

Commit 0ffe005

Browse files
authored
Merge pull request #243 from boostcampwm-2024/feature-position-refactor-fe
[Feature-position-refactor-fe] ๋…ธ๋“œ ์žฌ์ •๋ ฌ ๋กœ์ง ์ˆ˜์ • & ๋…ธ๋“œ ์ƒ์„ฑ ์œ„์น˜ ๋กœ์ง ์ˆ˜์ • & ๋…ธ๋“œ ์ƒ‰์ƒ ๋ณ€๊ฒฝ
2 parents 7a09af0 + a6f6a8a commit 0ffe005

File tree

10 files changed

+67
-44
lines changed

10 files changed

+67
-44
lines changed

โ€Žclient/src/components/Dashboard/MindMapInfoItem.tsxโ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export default function MindMapInfoItem({ data, index }: MindMapInfoItemProps) {
5555
</span>
5656
))}
5757
</div>
58-
<div className="flex min-w-24 items-center justify-center gap-2">
58+
<div className="flex w-44 items-center gap-2 pl-4">
5959
<FaUserCircle className="h-6 w-6" />
60-
<div>{data.ownerName}</div>
60+
<div className="w-32 overflow-hidden text-ellipsis whitespace-nowrap">{data.ownerName}</div>
6161
</div>
62-
<div className="flex min-w-40 justify-between">
62+
<div className="flex min-w-40 justify-between pl-4">
6363
<div>{extractDate(new Date(data.createDate))}</div>
6464
{ownerCheck ? (
6565
<Button

โ€Žclient/src/components/Dashboard/UserDashBoard.tsxโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export default function UserDashBoard() {
3535
<header className="flex items-center justify-between px-3 py-2 font-bold">
3636
<div className="min-w-72 pl-2">์ œ๋ชฉ</div>
3737
<div className="min-w-60 pl-8">ํ‚ค์›Œ๋“œ</div>
38-
<div className="min-w-24 pl-4">์†Œ์œ ์ž</div>
39-
<div className="min-w-40 pl-1">์ƒ์„ฑ ์ผ์ž</div>
38+
<div className="w-44 pl-4">์†Œ์œ ์ž</div>
39+
<div className="min-w-40 pl-4">์ƒ์„ฑ ์ผ์ž</div>
4040
</header>
4141
<div className="no-scrollbar h-[calc(100%-40px)] overflow-y-scroll border-b-[1px] border-t-[1px] border-grayscale-500">
4242
{filteredData.map((info, i) => (

โ€Žclient/src/components/MindMapCanvas/ToolMenu.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function ToolMenu({ dimensions, zoomIn, zoomOut, dragmode, setDra
4646
}
4747

4848
return (
49-
<div className="absolute bottom-2 left-1/2 flex -translate-x-2/4 -translate-y-2/4 items-center justify-center rounded-full border bg-white px-6 py-2 shadow-md">
49+
<div className="absolute bottom-2 left-1/2 z-20 flex -translate-x-2/4 -translate-y-2/4 items-center justify-center rounded-full border bg-white px-6 py-2 shadow-md">
5050
<div className="flex items-center gap-3">
5151
<Button
5252
className={`group flex h-8 w-8 items-center justify-center rounded-md p-1 hover:bg-blue-300 ${dragmode ? "bg-blue-400" : ""}`}

โ€Žclient/src/components/MindMapHeader/index.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default function MindMapHeader() {
5353
onChange={(e) => updateTitle(e.target.value)}
5454
onBlur={handleInputBlur}
5555
onKeyDown={handleInputKeyDown}
56-
maxLength={32}
56+
maxLength={16}
5757
autoFocus
5858
/>
5959
) : (

โ€Žclient/src/components/Minutes/Tiptap/index.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function Tiptap() {
2727
Indent,
2828
Placeholder.configure({
2929
emptyEditorClass: "is-editor-empty",
30-
placeholder: "ํšŒ์˜๋ก์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”...",
30+
placeholder: "ํšŒ์˜๋ก์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”",
3131
}),
3232
TextAlign.configure({
3333
types: ["heading", "paragraph"],

โ€Žclient/src/components/common/Toast/ToastContainer.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function ToastContainer({ toasts, setToasts }) {
55
setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));
66
};
77
return (
8-
<div className="no-scrollbar absolute right-3 top-3 max-h-[calc(100%-50px)] overflow-y-scroll">
8+
<div className="no-scrollbar absolute right-3 top-3 z-20 max-h-[calc(100%-50px)] overflow-y-scroll">
99
{toasts.toReversed().map((toast) => (
1010
<Toast key={toast.id} message={toast.message} status={toast.status} onClose={() => removeToast(toast.id)} />
1111
))}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const colors = ["#0053B5", "#64B5F6", "#6B95BC", "#E6F4F1", "#FCFCD4"];
1+
export const colors = ["#0053B5", "#64B5F6", "#6B95BC", "#A2D2FF", "#1d70a2"];

โ€Žclient/src/konva_mindmap/events/addNode.tsโ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ export function addNode(
6363
return;
6464
}
6565

66-
if (!selectedNode.nodeId || data[selectedNode.nodeId].depth === NODE_DEPTH_LIMIT) return;
66+
if (!selectedNode.nodeId || data[selectedNode.nodeId].depth === NODE_DEPTH_LIMIT) {
67+
useConnectionStore.getState().propagateError("์ตœ๋Œ€ ๊นŠ์ด 5๊นŒ์ง€๋งŒ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์–ด์š”", "error");
68+
return;
69+
}
6770

6871
const newNodeId = parseInt(Object.keys(data)[Object.keys(data).length - 1]) + 1;
6972
// ์†Œ์ผ“์œผ๋กœ ์„œ๋ฒ„์— ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•  ๋•Œ๋„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ๋ณ€์ˆ˜๋กœ ๋”ฐ๋กœ ๋นผ์„œ ๊ด€๋ฆฌ
7073
const newNode = {
7174
id: newNodeId,
7275
keyword: "์ œ๋ชฉ์—†์Œ",
7376
depth: data[selectedNode.nodeId].depth + 1,
74-
location: getNewNodePosition(data[selectedNode.nodeId].children, data, data[selectedNode.nodeId]),
77+
location: getNewNodePosition(data, selectedNode.nodeId),
7578
children: [],
7679
};
7780

โ€Žclient/src/konva_mindmap/utils/getNewNodePosition.tsโ€Ž

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
import { Node, NodeData } from "@/types/Node";
1+
import { NodeData } from "@/types/Node";
22
import { findRootNodeKey } from "./findRootNodeKey";
33
import { calculateVector } from "./vector";
4+
import { NODE_RADIUS } from "./nodeAttrs";
45

5-
export function getNewNodePosition(children: number[], data: NodeData, parentNode: Node) {
6+
const lineLength = [360, 360, 360, 270];
7+
const angle = [104, 105, 103, 104];
8+
const distance = [240, 200, 160, 120];
9+
10+
export function getNewNodePosition(data: NodeData, nodeId: number) {
611
const rootKey = findRootNodeKey(data);
12+
const node = data[nodeId];
13+
const children = node.children;
14+
const depth = node.depth;
715

816
if (!children.length) {
9-
if (parentNode.id === rootKey)
17+
if (node.id === rootKey)
1018
return {
11-
x: parentNode.location.x + 300,
12-
y: parentNode.location.y,
19+
x: node.location.x + NODE_RADIUS(depth) * 7,
20+
y: node.location.y,
1321
};
14-
const { x, y } = calculateVector(data[rootKey].location, parentNode.location, -80, 240);
15-
return parentNode ? { x: parentNode.location.x + x, y: parentNode.location.y + y } : { x: 0, y: 0 };
22+
const { x, y } = calculateVector(data[rootKey].location, node.location, -60, lineLength[depth - 1]);
23+
return node ? { x: node.location.x + x, y: node.location.y + y } : { x: 0, y: 0 };
1624
}
1725
const lastChildren = data[children[children.length - 1]];
18-
const uv = calculateVector(parentNode.location, lastChildren.location, 110, 240);
26+
const uv = calculateVector(node.location, lastChildren.location, angle[depth - 1], distance[depth - 1]);
1927
return {
2028
x: lastChildren.location.x + uv.x,
2129
y: lastChildren.location.y + uv.y,

โ€Žclient/src/konva_mindmap/utils/initializeNodePosition.tsโ€Ž

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,44 @@ export default function initializeNodePosition(data: NodeData) {
5252
const depth = node.depth;
5353
const radius = NODE_RADIUS(depth);
5454

55-
if (depth === 2) {
56-
const angle = (360 / length) * index;
57-
const radianAngle = (Math.PI / 180) * angle;
58-
xPos += radius * Math.cos(radianAngle) * 8;
59-
yPos += radius * Math.sin(radianAngle) * 8;
60-
} else if (depth === 3) {
61-
const divideAngle = 180 / (length + 1);
62-
const adjustedAngle = divideAngle * (index + 1) - 90;
63-
const { x, y } = calculateVector(rootLocation, { x: xPos, y: yPos }, adjustedAngle, 360);
64-
xPos += x;
65-
yPos += y;
66-
} else if (depth === 4) {
67-
const divideAngle = 180 / (length + 3);
68-
const adjustedAngle = divideAngle * (index + 2) - 90;
69-
const { x, y } = calculateVector(rootLocation, { x: xPos, y: yPos }, adjustedAngle, 360);
70-
xPos += x;
71-
yPos += y;
72-
} else if (depth === 5) {
73-
const ancestor = findAncestor(data, nodeId, 2);
74-
const divideAngle = 180 / (length + 1);
75-
const adjustedAngle = divideAngle * (index + 1) - 90;
76-
const calculatedDistance = Math.sqrt((2 * radius * radius) / (1 - Math.cos((Math.PI / 180) * divideAngle))) * 1.8;
77-
const maxDistance = Math.max(calculatedDistance, 200);
78-
const { x, y } = calculateVector(ancestor.location, { x: xPos, y: yPos }, adjustedAngle, maxDistance);
55+
const applyVectorAdjustment = (origin: { x: number; y: number }, angle: number, distance: number) => {
56+
const { x, y } = calculateVector(origin, { x: xPos, y: yPos }, angle, distance);
7957
xPos += x;
8058
yPos += y;
59+
};
60+
61+
switch (depth) {
62+
case 2: {
63+
const angle = (360 / length) * index;
64+
const radianAngle = (Math.PI / 180) * angle;
65+
xPos += radius * Math.cos(radianAngle) * 8;
66+
yPos += radius * Math.sin(radianAngle) * 8;
67+
break;
68+
}
69+
case 3: {
70+
const divideAngle = 180 / (length + 1);
71+
const adjustedAngle = divideAngle * (index + 1) - 90;
72+
applyVectorAdjustment(rootLocation, adjustedAngle, 360);
73+
break;
74+
}
75+
case 4: {
76+
const divideAngle = 180 / (length + 3);
77+
const adjustedAngle = divideAngle * (index + 2) - 90;
78+
applyVectorAdjustment(rootLocation, adjustedAngle, 360);
79+
break;
80+
}
81+
case 5: {
82+
const ancestor = findAncestor(data, nodeId, 2);
83+
const divideAngle = 180 / (length + 1);
84+
const adjustedAngle = divideAngle * (index + 1) - 90;
85+
const calculatedDistance =
86+
Math.sqrt((2 * radius * radius) / (1 - Math.cos((Math.PI / 180) * divideAngle))) * 1.8;
87+
const maxDistance = Math.max(calculatedDistance, 200);
88+
applyVectorAdjustment(ancestor.location, adjustedAngle, maxDistance);
89+
break;
90+
}
91+
default:
92+
break;
8193
}
8294
node.location.x = xPos;
8395
node.location.y = yPos;

0 commit comments

Comments
ย (0)