diff --git a/src/components/Home.tsx b/src/components/Home.tsx index 62c56e7..ab015c9 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -329,10 +329,6 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = }, [students, searchKeyword, sortType, matchStudentName]) const groupedStudents = useMemo(() => { - if (layoutType === "squareGrid") { - return [{ key: "all", students: sortedStudents }] - } - if (sortType === "score" || (sortType === "alphabet" && searchKeyword)) { return [{ key: "all", students: sortedStudents }] } @@ -349,6 +345,16 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = .map(([key, students]) => ({ key, students })) }, [sortedStudents, sortType, searchKeyword, layoutType]) + const firstStudentIdByGroup = useMemo(() => { + const result = new Map() + groupedStudents.forEach((group) => { + if (group.key === "all") return + const first = group.students[0] + if (first) result.set(group.key, first.id) + }) + return result + }, [groupedStudents]) + const groupedReasons = useMemo(() => { const groups: Record = {} reasons.forEach((r) => { @@ -869,6 +875,14 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = position: "relative", aspectRatio: "1 / 1", }} + ref={(el) => { + groupedStudents.forEach((group) => { + if (group.key === "all") return + if (firstStudentIdByGroup.get(group.key) === student.id) { + groupRefs.current[group.key] = el + } + }) + }} > = ({ canEdit, isPortraitMode = false }) = overflow: "visible", boxShadow: isQuickActionMode ? "0 8px 18px rgba(22, 119, 255, 0.18)" : undefined, }} - styles={{ body: { height: "100%", padding: "10px" } }} + styles={{ body: { height: "100%", padding: "8px" } }} > {rankBadge && (
= ({ canEdit, isPortraitMode = false }) = src={student.avatarUrl} alt={student.name} style={{ - width: "52px", - height: "52px", - borderRadius: "14px", + width: "42px", + height: "42px", + borderRadius: "12px", objectFit: "cover", flexShrink: 0, boxShadow: `0 4px 10px ${avatarColor}40`, @@ -926,16 +940,16 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = ) : (
1 ? "16px" : "20px", + fontSize: avatarText.length > 1 ? "14px" : "18px", flexShrink: 0, boxShadow: `0 4px 10px ${avatarColor}40`, }} @@ -943,19 +957,6 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = {avatarText}
)} -
- {student.name} -
{isQuickActionMode ? ( ) : ( - 0 ? "success" : student.score < 0 ? "error" : "default"} - style={{ fontWeight: "bold", marginInlineEnd: 0 }} +
- {student.score > 0 ? `+${student.score}` : student.score} - +
+ {student.name} +
+ 0 ? "success" : student.score < 0 ? "error" : "default"} + style={{ fontWeight: "bold", marginInlineEnd: 0 }} + > + {student.score > 0 ? `+${student.score}` : student.score} + +
)}
@@ -1001,8 +1026,8 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) =
{sortedStudents.map((student, idx) => renderStudentSquareCard(student, idx))} @@ -1253,7 +1278,6 @@ export const Home: React.FC = ({ canEdit, isPortraitMode = false }) = const shouldShowQuickNav = groupedStudents.length > 1 && - layoutType !== "squareGrid" && sortType !== "score" && !(sortType === "alphabet" && searchKeyword)