From 25ce93207436523cecaa809906a62ed4737bf231 Mon Sep 17 00:00:00 2001 From: JM Kim <106949557+CSE-Shaco@users.noreply.github.com> Date: Sat, 20 Dec 2025 16:00:13 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix(guestbook):=20=EB=9E=9C=EB=8D=A4=20?= =?UTF-8?q?=EB=A0=8C=EB=8D=94=EB=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/homecoming/GuestbookWordCloud.jsx | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/src/components/event/homecoming/GuestbookWordCloud.jsx b/src/components/event/homecoming/GuestbookWordCloud.jsx index 4827b0d..0142c29 100644 --- a/src/components/event/homecoming/GuestbookWordCloud.jsx +++ b/src/components/event/homecoming/GuestbookWordCloud.jsx @@ -1,17 +1,8 @@ 'use client'; -const hashString = (value) => { - let hash = 0; - for (let i = 0; i < value.length; i += 1) { - hash = value.charCodeAt(i) + ((hash << 5) - hash); - } - return hash; -}; +import { useMemo } from "react"; -const mapToRange = (value, min, max) => { - const normalized = Math.abs(value % 1000) / 1000; - return min + normalized * (max - min); -}; +const mapToRange = (value, min, max) => min + value * (max - min); const defaultColors = { highlight: "text-cblue", @@ -20,28 +11,33 @@ const defaultColors = { }; export default function GuestbookWordCloud({ entries, isLoading, recentCount = 5, className = "", style = {}, colorScheme = defaultColors }) { - const words = (entries ?? []).map((entry, idx) => { - const key = entry.id ?? `${entry.wristbandSerial ?? "unknown"}-${idx}`; - const baseHash = hashString(`${key}-${entry.name}`); - const top = mapToRange(baseHash, 12, 88); - const left = mapToRange(baseHash * 3, 10, 90); - const fontSize = mapToRange(baseHash * 5, 1.2, 3.2); - const rotate = mapToRange(baseHash * 7, -10, 10); - const opacity = mapToRange(baseHash * 11, 0.45, 0.95); + const words = useMemo(() => { + if (!entries?.length) { + return []; + } + + return entries.map((entry, idx) => { + const key = entry.id ?? `${entry.wristbandSerial ?? "unknown"}-${idx}`; + const top = mapToRange(Math.random(), 12, 88); + const left = mapToRange(Math.random(), 10, 90); + const fontSize = mapToRange(Math.random(), 1.2, 3.2); + const rotate = mapToRange(Math.random(), -10, 10); + const opacity = mapToRange(Math.random(), 0.45, 0.95); - return { - key, - label: entry.name, - isRecent: idx >= Math.max(entries.length - recentCount, 0), - style: { - top: `${top}%`, - left: `${left}%`, - fontSize: `${fontSize}rem`, - opacity, - transform: `translate(-50%, -50%) rotate(${rotate}deg)`, - }, - }; - }); + return { + key, + label: entry.name, + isRecent: idx >= Math.max(entries.length - recentCount, 0), + style: { + top: `${top}%`, + left: `${left}%`, + fontSize: `${fontSize}rem`, + opacity, + transform: `translate(-50%, -50%) rotate(${rotate}deg)`, + }, + }; + }); + }, [entries, recentCount]); return (
From d6384b868030059a4caf44b578541e97eb5d2bdc Mon Sep 17 00:00:00 2001 From: JM Kim <106949557+CSE-Shaco@users.noreply.github.com> Date: Sat, 20 Dec 2025 16:03:45 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix(guestbook):=20=EB=9E=9C=EB=8D=A4=20?= =?UTF-8?q?=EB=A0=8C=EB=8D=94=EB=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/event/homecoming/GuestbookWordCloud.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/event/homecoming/GuestbookWordCloud.jsx b/src/components/event/homecoming/GuestbookWordCloud.jsx index 0142c29..cdaeec7 100644 --- a/src/components/event/homecoming/GuestbookWordCloud.jsx +++ b/src/components/event/homecoming/GuestbookWordCloud.jsx @@ -18,8 +18,10 @@ export default function GuestbookWordCloud({ entries, isLoading, recentCount = 5 return entries.map((entry, idx) => { const key = entry.id ?? `${entry.wristbandSerial ?? "unknown"}-${idx}`; - const top = mapToRange(Math.random(), 12, 88); - const left = mapToRange(Math.random(), 10, 90); + const goldenRatio = 0.61803398875; + const base = Math.random() + idx * goldenRatio; + const top = mapToRange(base % 1, 12, 88); + const left = mapToRange((base * goldenRatio) % 1, 10, 90); const fontSize = mapToRange(Math.random(), 1.2, 3.2); const rotate = mapToRange(Math.random(), -10, 10); const opacity = mapToRange(Math.random(), 0.45, 0.95);