fix(web): keep history table shell during loading

This commit is contained in:
dahyeon committed 2026-06-08 22:48:16 -07:00
1 parent 170e42098a
commit d10e2ab011
1 file changed
+108 -49
+108 -49
View File
@@ -9,6 +9,8 @@ const UPCOMING_GRID_MATCH_LIMIT = 3;
const UPCOMING_MATCH_LIST_LIMIT = UPCOMING_GRID_MATCH_LIMIT + 1;
const HISTORY_MATCH_PAGE_SIZE = 10;
const EMPTY_SCHEDULE_TEXT = '예정된 매치가 없습니다.';
const HISTORY_TABLE_ROW_CLASS =
'h-10 border-b border-base-content/5 last:border-b-0';
function SkeletonBlock({ className }: { className: string }) {
return (
@@ -19,53 +21,126 @@ function SkeletonBlock({ className }: { className: string }) {
);
}
function HistoryRecordsSkeleton() {
const historySkeletons = Array.from({ length: 5 });
function SkeletonText({
children,
className = '',
skeletonClassName,
}: {
children: string;
className?: string;
skeletonClassName: string;
}) {
return (
<span className={`relative block ${className}`}>
<span className="invisible">{children}</span>
<span
aria-hidden="true"
className={`absolute left-0 top-1/2 -translate-y-1/2 animate-pulse bg-base-content/10 ${skeletonClassName}`}
/>
</span>
);
}
function SkeletonBadge({
children,
className,
}: {
children: string;
className: string;
}) {
return (
<span className={`relative ${className}`}>
<span className="invisible">{children}</span>
<span
aria-hidden="true"
className="absolute inset-0 animate-pulse bg-base-content/10"
/>
</span>
);
}
function HistoryTableColGroup() {
return (
<colgroup>
<col className="w-[156px]" />
<col />
<col className="w-[88px]" />
<col className="w-[132px]" />
<col className="w-[72px]" />
<col className="w-[116px]" />
</colgroup>
);
}
function HistoryTableHeader() {
return (
<thead>
<tr className="bg-base-200/60 border-b border-base-content/10 text-[11px] uppercase tracking-wider text-base-content/40">
<th className="py-2.5 px-4 font-semibold">날짜</th>
<th className="py-2.5 px-4 font-semibold">내전</th>
<th className="py-2.5 px-4 font-semibold">상태</th>
<th className="py-2.5 px-4 font-semibold">맵</th>
<th className="py-2.5 px-4 font-semibold">참가</th>
<th className="py-2.5 px-4 font-semibold">결과</th>
</tr>
</thead>
);
}
function HistoryRecordsSkeleton({ rows = 5 }: { rows?: number }) {
const historySkeletons = Array.from({ length: rows });
return (
<>
<div className="hidden md:block border border-base-content/10 overflow-x-auto">
<table className="w-full table-fixed text-left">
<colgroup>
<col className="w-[156px]" />
<col />
<col className="w-[88px]" />
<col className="w-[132px]" />
<col className="w-[72px]" />
<col className="w-[116px]" />
</colgroup>
<thead>
<tr className="bg-base-200/60 border-b border-base-content/10">
{['날짜', '내전', '상태', '맵', '참가', '결과'].map((label) => (
<th key={label} className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-10" />
</th>
))}
</tr>
</thead>
<HistoryTableColGroup />
<HistoryTableHeader />
<tbody>
{historySkeletons.map((_, index) => (
<tr
key={index}
className="border-b border-base-content/5 last:border-b-0"
className={HISTORY_TABLE_ROW_CLASS}
>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-16" />
<td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
<SkeletonText
skeletonClassName="h-[1em] w-20"
>
2026년 6월 8일 월
</SkeletonText>
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-4 w-36" />
<SkeletonText
className="truncate text-sm font-medium"
skeletonClassName="h-[1em] w-36 max-w-full"
>
정기 내전
</SkeletonText>
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-5 w-12" />
<SkeletonBadge className="inline-flex items-center whitespace-nowrap text-[11px] font-semibold px-1.5 py-0.5 border border-transparent">
팀빌딩
</SkeletonBadge>
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-5 w-16" />
<SkeletonBadge className="inline-flex items-center whitespace-nowrap text-[11px] px-1.5 py-0.5 border border-transparent">
소환사의 협곡
</SkeletonBadge>
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-10" />
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
<SkeletonText
skeletonClassName="h-[1em] w-8"
>
10명
</SkeletonText>
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-14" />
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
<SkeletonText
className="truncate"
skeletonClassName="h-[1em] w-14"
>
1팀 승리
</SkeletonText>
</td>
</tr>
))}
@@ -481,7 +556,7 @@ export default function HomePage() {
지난 내전 기록
</h2>
{isHistoryPageLoading ? (
<HistoryRecordsSkeleton />
<HistoryRecordsSkeleton rows={HISTORY_MATCH_PAGE_SIZE} />
) : hasHistoryError ? (
<div className="border border-base-content/10 px-4 py-8 text-center text-sm text-red-500">
지난 내전 기록을 불러오지 못했습니다.
@@ -491,30 +566,14 @@ export default function HomePage() {
{/* 데스크톱: 테이블 */}
<div className="hidden md:block border border-base-content/10 overflow-x-auto">
<table className="w-full table-fixed text-left">
<colgroup>
<col className="w-[156px]" />
<col />
<col className="w-[88px]" />
<col className="w-[132px]" />
<col className="w-[72px]" />
<col className="w-[116px]" />
</colgroup>
<thead>
<tr className="bg-base-200/60 border-b border-base-content/10 text-[11px] uppercase tracking-wider text-base-content/40">
<th className="py-2.5 px-4 font-semibold">날짜</th>
<th className="py-2.5 px-4 font-semibold">내전</th>
<th className="py-2.5 px-4 font-semibold">상태</th>
<th className="py-2.5 px-4 font-semibold">맵</th>
<th className="py-2.5 px-4 font-semibold">참가</th>
<th className="py-2.5 px-4 font-semibold">결과</th>
</tr>
</thead>
<HistoryTableColGroup />
<HistoryTableHeader />
<tbody>
{historyMatches.length > 0 ? (
historyMatches.map((match) => (
<tr
key={match.id}
className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02] transition-colors"
className={`${HISTORY_TABLE_ROW_CLASS} hover:bg-base-content/[0.02] transition-colors`}
>
<td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
{match.date}