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
+100 -41
+100 -41
View File
@@ -9,6 +9,8 @@ const UPCOMING_GRID_MATCH_LIMIT = 3;
const UPCOMING_MATCH_LIST_LIMIT = UPCOMING_GRID_MATCH_LIMIT + 1; const UPCOMING_MATCH_LIST_LIMIT = UPCOMING_GRID_MATCH_LIMIT + 1;
const HISTORY_MATCH_PAGE_SIZE = 10; const HISTORY_MATCH_PAGE_SIZE = 10;
const EMPTY_SCHEDULE_TEXT = '예정된 매치가 없습니다.'; 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 }) { function SkeletonBlock({ className }: { className: string }) {
return ( return (
@@ -19,13 +21,46 @@ function SkeletonBlock({ className }: { className: string }) {
); );
} }
function HistoryRecordsSkeleton() { function SkeletonText({
const historySkeletons = Array.from({ length: 5 }); 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 ( return (
<>
<div className="hidden md:block border border-base-content/10 overflow-x-auto">
<table className="w-full table-fixed text-left">
<colgroup> <colgroup>
<col className="w-[156px]" /> <col className="w-[156px]" />
<col /> <col />
@@ -34,38 +69,78 @@ function HistoryRecordsSkeleton() {
<col className="w-[72px]" /> <col className="w-[72px]" />
<col className="w-[116px]" /> <col className="w-[116px]" />
</colgroup> </colgroup>
);
}
function HistoryTableHeader() {
return (
<thead> <thead>
<tr className="bg-base-200/60 border-b border-base-content/10"> <tr className="bg-base-200/60 border-b border-base-content/10 text-[11px] uppercase tracking-wider text-base-content/40">
{['날짜', '내전', '상태', '맵', '참가', '결과'].map((label) => ( <th className="py-2.5 px-4 font-semibold">날짜</th>
<th key={label} className="py-2.5 px-4"> <th className="py-2.5 px-4 font-semibold">내전</th>
<SkeletonBlock className="h-3 w-10" /> <th className="py-2.5 px-4 font-semibold">상태</th>
</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> </tr>
</thead> </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">
<HistoryTableColGroup />
<HistoryTableHeader />
<tbody> <tbody>
{historySkeletons.map((_, index) => ( {historySkeletons.map((_, index) => (
<tr <tr
key={index} 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"> <td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
<SkeletonBlock className="h-3 w-16" /> <SkeletonText
skeletonClassName="h-[1em] w-20"
>
2026년 6월 8일 월
</SkeletonText>
</td> </td>
<td className="py-2.5 px-4"> <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>
<td className="py-2.5 px-4"> <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>
<td className="py-2.5 px-4"> <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>
<td className="py-2.5 px-4"> <td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
<SkeletonBlock className="h-3 w-10" /> <SkeletonText
skeletonClassName="h-[1em] w-8"
>
10명
</SkeletonText>
</td> </td>
<td className="py-2.5 px-4"> <td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
<SkeletonBlock className="h-3 w-14" /> <SkeletonText
className="truncate"
skeletonClassName="h-[1em] w-14"
>
1팀 승리
</SkeletonText>
</td> </td>
</tr> </tr>
))} ))}
@@ -481,7 +556,7 @@ export default function HomePage() {
지난 내전 기록 지난 내전 기록
</h2> </h2>
{isHistoryPageLoading ? ( {isHistoryPageLoading ? (
<HistoryRecordsSkeleton /> <HistoryRecordsSkeleton rows={HISTORY_MATCH_PAGE_SIZE} />
) : hasHistoryError ? ( ) : hasHistoryError ? (
<div className="border border-base-content/10 px-4 py-8 text-center text-sm text-red-500"> <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"> <div className="hidden md:block border border-base-content/10 overflow-x-auto">
<table className="w-full table-fixed text-left"> <table className="w-full table-fixed text-left">
<colgroup> <HistoryTableColGroup />
<col className="w-[156px]" /> <HistoryTableHeader />
<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>
<tbody> <tbody>
{historyMatches.length > 0 ? ( {historyMatches.length > 0 ? (
historyMatches.map((match) => ( historyMatches.map((match) => (
<tr <tr
key={match.id} 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"> <td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
{match.date} {match.date}