feat(lps-admin): 관리자 페이지 디자인 개선 및 컴포넌트 통일

- 공용 프리미티브(ui.tsx): PageHeader·Segmented·Button·SearchForm·Legend·
  ScrollBox·ScrollTable·Modal + Card(fill/compact) 옵션
- 차트 공용 설정(lib/chart.ts): 축·그리드·툴팁 스타일 단일화
- 뷰포트 채우기 레이아웃 + content 영역 스크롤(Layout), 버튼 커서 복구
- 표: 헤더 밴드·행 좌우 패딩·고정/채움/auto 높이·sticky 헤더, 배지 줄바꿈 방지
- 작업 큐: 풀폭 표 + 행별 상세/JSON 모달(복사)
- 상품·가격: 가로 배치, Y축 0 기준, 시점 클릭→몰별 비교, 커스텀 툴팁·
  그라데이션 area, 몰별 컴팩트 표(소스 뱃지)
- 크롤 상태: 도넛 중앙 총계·라운드 세그먼트, 막대 그라데이션, 툴팁 통일
- 테스트 검색: 결과 통일(모달·표·소스 뱃지), 진행상태 좌측 이동, 초기화 전
  재검색 차단, 퍼널 가독성(감소량), 배송(로켓배송) 표기, 한 화면 컴팩트
- 사이드바: API 상태 상단 뱃지, 테스트 메뉴 배경색으로 구분

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Opus 4.8 committed 2026-07-16 08:48:43 +09:00
1 parent e6005b4f94
commit d111610555
11 files changed
+860 -525

No files matched your search

+14 -21
View File
@@ -4,15 +4,14 @@ import { useQuery } from "@tanstack/react-query";
import { NavLink, Outlet } from "react-router";
import { healthz } from "../api/client";
// action: 실제 비용이 드는 실행 페이지(모니터링과 성격이 다름) — 앰버(warn) 마커로 구분.
// group: 이 항목 앞에 구분선(모니터링 ↔ 실행/설정 경계).
// action: 실제 비용이 드는 실행 페이지(모니터링과 성격이 다름) — 다른 메뉴와 배경색(앰버)만 다르게.
const MENU = [
{ to: "/", label: "대시보드", end: true },
{ to: "/jobs", label: "작업 큐" },
{ to: "/products", label: "상품·가격" },
{ to: "/crawl", label: "크롤 상태" },
{ to: "/costs", label: "비용" },
{ to: "/test", label: "테스트 검색", action: true, group: true },
{ to: "/test", label: "테스트 검색", action: true },
{ to: "/settings", label: "설정" },
];
@@ -20,55 +19,49 @@ export default function Layout() {
const health = useQuery({ queryKey: ["healthz"], queryFn: healthz, refetchInterval: 10_000 });
const up = health.data === true;
return (
<div className="mx-auto flex min-h-screen w-full max-w-[1280px] flex-col md:flex-row">
<div className="mx-auto flex h-dvh w-full max-w-[1280px] flex-col overflow-hidden md:flex-row">
{/* 모바일(<md): 상단 바 + 가로 스크롤 네비(터치 44px). md 이상: 좌측 고정 사이드바. */}
<aside className="w-full min-w-0 shrink-0 border-b border-line-200 px-3 py-3 md:w-[196px] md:border-b-0 md:border-r md:py-5">
<div className="flex items-center justify-between md:block">
<div className="flex items-center gap-2.5 px-2 md:mb-6">
<div className="flex items-center gap-2.5 px-2 md:mb-3">
<span className="grid h-8 w-8 place-items-center rounded-lg bg-gradient-to-br from-primary-600 to-primary-400 text-[14px] font-extrabold text-white">L</span>
<div>
<div className="text-[14px] font-bold leading-tight">LPS 관리자</div>
<div className="text-[11px] font-medium text-ink-400">인터넷 최저가 검색</div>
</div>
</div>
<div className="flex items-center gap-2 px-2 text-[12px] font-semibold text-ink-500 md:hidden">
<span className={`h-2 w-2 rounded-full ${up ? "bg-ok-600" : "bg-dead-600"}`} aria-hidden />
{up ? "연결됨" : "연결 안 됨"}
{/* API 헬스 — 상단 배지(모바일: 우측, 데스크톱: 제목 아래) */}
<div className="shrink-0 px-2 md:mb-5">
<span className={`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11px] font-semibold ${up ? "bg-ok-50 text-ok-600" : "bg-dead-50 text-dead-600"}`}>
<span className={`h-1.5 w-1.5 rounded-full ${up ? "bg-ok-600" : "bg-dead-600"}`} aria-hidden />
{up ? "API 연결됨" : "API 연결 안 됨"}
</span>
</div>
</div>
<nav aria-label="주 메뉴" className="mt-2 md:mt-0">
<ul className="flex items-center gap-1 overflow-x-auto md:flex-col md:items-stretch md:gap-0 md:space-y-0.5">
{MENU.map((m) => (
<li key={m.to} className="flex shrink-0 items-center">
{/* 모니터링 ↔ 실행/설정 경계: 모바일=세로 구분선, 데스크톱=가로 구분선 */}
{m.group && <span className="mx-1 h-5 w-px bg-line-200 md:my-1 md:h-px md:w-full" aria-hidden />}
<NavLink
to={m.to}
end={m.end}
className={({ isActive }) =>
`flex min-h-[44px] w-full items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-[13px] font-semibold transition-colors md:min-h-0 md:py-2 ${
`flex min-h-[44px] w-full items-center whitespace-nowrap rounded-lg px-3 text-[13px] font-semibold transition-colors md:min-h-0 md:py-2 ${
m.action
? isActive ? "bg-warn-50 text-warn-700" : "text-warn-700 hover:bg-warn-50"
? isActive ? "bg-warn-600/20 text-warn-700" : "bg-warn-600/10 text-ink-700 hover:bg-warn-600/20"
: isActive ? "bg-primary-50 text-primary-700" : "text-ink-700 hover:bg-surface-2"
}`
}
>
{m.action && <span className="h-1.5 w-1.5 shrink-0 rounded-full bg-warn-600" aria-hidden />}
{m.label}
</NavLink>
</li>
))}
</ul>
</nav>
<div className="mt-8 hidden items-center gap-2 px-3 text-[12px] font-semibold text-ink-500 md:flex">
<span
className={`h-2 w-2 rounded-full ${up ? "bg-ok-600" : "bg-dead-600"}`}
aria-hidden
/>
{up ? "API 연결됨" : "API 연결 안 됨"}
</div>
</aside>
<main className="min-w-0 flex-1 px-4 py-4 md:px-6 md:py-5">
{/* content 영역만 스크롤 — 페이지가 h-full 로 채우면 스크롤 없음, 넘치면 여기서 스크롤. */}
<main className="flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto px-4 py-4 md:px-6 md:py-5">
<Outlet />
</main>
</div>
+154 -8
View File
@@ -1,20 +1,24 @@
/** 공용 UI 조각 — 카드·스탯 타일·상태 배지·빈/오류 표시. 웹 표준 시맨틱 마크업 유지. */
/** 공용 UI 조각 — 카드·스탯 타일·상태 배지·빈/오류 표시 + 페이지 공통 컨트롤
* (헤더·세그먼트 탭·버튼·검색폼·범례·고정높이 표/스크롤). 웹 표준 시맨틱 마크업 유지. */
import type { ReactNode } from "react";
import { useEffect } from "react";
import type { ButtonHTMLAttributes, ReactNode } from "react";
import type { JobStatusName } from "../api/types";
export function Card({ title, hint, children, className = "" }: {
title?: ReactNode; hint?: ReactNode; children: ReactNode; className?: string;
// fill: 카드가 부모 높이를 채우고 본문이 남는 높이를 flex 로 차지(그래프·표가 높이 채우기용).
// compact: 패딩을 줄여 밀도 높은 레이아웃(한 화면에 많이 담기).
export function Card({ title, hint, children, className = "", fill = false, compact = false }: {
title?: ReactNode; hint?: ReactNode; children: ReactNode; className?: string; fill?: boolean; compact?: boolean;
}) {
return (
<section className={`rounded-xl border border-line-200 bg-surface shadow-[0_1px_2px_rgba(16,24,40,.04)] ${className}`}>
<section className={`rounded-xl border border-line-200 bg-surface shadow-[0_1px_2px_rgba(16,24,40,.04)] ${fill ? "flex min-h-0 flex-col" : ""} ${className}`}>
{title !== undefined && (
<header className="flex items-center gap-2 border-b border-line-100 px-4 py-2.5">
<header className={`flex shrink-0 items-center gap-2 border-b border-line-100 ${compact ? "px-3 py-2" : "px-4 py-2.5"}`}>
<h2 className="text-[13px] font-bold tracking-tight">{title}</h2>
{hint && <span className="ml-auto text-[11px] text-ink-400">{hint}</span>}
{hint && <div className="ml-auto text-[11px] text-ink-400">{hint}</div>}
</header>
)}
<div className="p-4">{children}</div>
<div className={`${compact ? "p-3" : "p-4"} ${fill ? "flex min-h-0 flex-1 flex-col" : ""}`}>{children}</div>
</section>
);
}
@@ -71,3 +75,145 @@ export function ErrorNote({ error }: { error: unknown }) {
export function Loading() {
return <p className="py-8 text-center text-[13px] text-ink-400" aria-busy="true">불러오는 중…</p>;
}
// ── 페이지 헤더 — h1 + 우측 컨트롤 슬롯(기간 탭 등). 모든 페이지 제목을 이걸로 통일. ──
export function PageHeader({ title, children }: { title: ReactNode; children?: ReactNode }) {
return (
<div className="flex items-center gap-3">
<h1 className="text-[17px] font-bold tracking-tight">{title}</h1>
{children && <div className="ml-auto flex items-center gap-2">{children}</div>}
</div>
);
}
// ── 세그먼트 탭 — 상태/기간/상위N 필터 공용(기존 4곳의 동일 마크업 통일). ──
export function Segmented<T extends string | number>({ options, value, onChange, ariaLabel, size = "md" }: {
options: readonly { v: T; label: ReactNode }[];
value: T; onChange: (v: T) => void; ariaLabel: string; size?: "sm" | "md";
}) {
const cell = size === "sm" ? "px-2 py-0.5 text-[11px]" : "px-3 py-1.5 text-[12px]";
return (
<div role="tablist" aria-label={ariaLabel} className="flex rounded-lg border border-line-200 bg-surface p-0.5">
{options.map((o) => (
<button key={String(o.v)} role="tab" aria-selected={value === o.v} onClick={() => onChange(o.v)}
className={`rounded-md font-semibold ${cell} ${value === o.v ? "bg-primary-50 text-primary-700" : "text-ink-500 hover:text-ink-700"}`}>
{o.label}
</button>
))}
</div>
);
}
// ── 버튼 — primary(실행 CTA)·outline(보조). 크기 sm/md/lg. 반복되던 파랑 버튼 통일. ──
export function Button({ variant = "primary", size = "md", className = "", ...props }: {
variant?: "primary" | "outline"; size?: "sm" | "md" | "lg";
} & ButtonHTMLAttributes<HTMLButtonElement>) {
const sizes = { sm: "px-2.5 py-1 text-[12px]", md: "px-3 py-1.5 text-[13px]", lg: "px-4 py-2 text-[13px]" };
const variants = {
primary: "bg-primary-600 text-white hover:bg-primary-700",
outline: "border border-line-200 text-ink-700 hover:bg-line-200 hover:text-ink-900",
};
return <button className={`cursor-pointer rounded-lg font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${sizes[size]} ${variants[variant]} ${className}`} {...props} />;
}
// ── 검색 폼 — input + 검색 버튼(Jobs·Products 동일 폼 통일). ──
export function SearchForm({ value, onChange, onSubmit, placeholder, className = "", inputClassName = "w-64" }: {
value: string; onChange: (v: string) => void; onSubmit: () => void;
placeholder: string; className?: string; inputClassName?: string;
}) {
return (
<form className={`flex gap-1.5 ${className}`} onSubmit={(e) => { e.preventDefault(); onSubmit(); }}>
<input value={value} onChange={(e) => onChange(e.target.value)} placeholder={placeholder} aria-label={placeholder}
className={`rounded-lg border border-line-200 bg-surface px-3 py-1.5 text-[13px] outline-none focus:border-primary-600 ${inputClassName}`} />
<Button type="submit">검색</Button>
</form>
);
}
// ── 범례 — 색 dot + 라벨(차트 아래, Dashboard·Costs·Products 통일). ──
export function Legend({ items, note }: {
items: readonly { label: ReactNode; color: string }[]; note?: ReactNode;
}) {
return (
<p className="mt-1 flex flex-wrap gap-4 text-[11px] font-semibold text-ink-500">
{items.map((it, i) => (
<span key={i}>
<span className="mr-1 inline-block h-2 w-2 rounded-full" style={{ background: it.color }} aria-hidden />
{it.label}
</span>
))}
{note && <span className="ml-auto font-medium text-ink-400">{note}</span>}
</p>
);
}
// ── 스크롤 컨테이너 — height 숫자면 고정 높이, "fill" 이면 부모의 남는 높이를 채움. ──
export function ScrollBox({ height = 420, className = "", children }: {
height?: number | "fill"; className?: string; children: ReactNode;
}) {
const fill = height === "fill";
return (
<div className={`overflow-y-auto ${fill ? "min-h-0 flex-1" : ""} ${className}`}
style={fill ? undefined : { height }}>{children}</div>
);
}
// ── 모달 — 배경 딤 + Esc/바깥클릭 닫기. actions 로 헤더 우측 버튼(복사 등) 배치. ──
export function Modal({ title, onClose, actions, children }: {
title: ReactNode; onClose: () => void; actions?: ReactNode; children: ReactNode;
}) {
useEffect(() => {
const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); };
document.addEventListener("keydown", onKey);
return () => document.removeEventListener("keydown", onKey);
}, [onClose]);
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
<div className="absolute inset-0 bg-ink-900/30" onClick={onClose} aria-hidden />
<div role="dialog" aria-modal="true"
className="relative flex max-h-[85vh] w-full max-w-2xl flex-col rounded-xl border border-line-200 bg-surface shadow-[0_10px_40px_rgba(16,24,40,.18)]">
<header className="flex shrink-0 items-center gap-2 border-b border-line-100 px-4 py-3">
<h2 className="text-[14px] font-bold tracking-tight">{title}</h2>
<div className="ml-auto flex items-center gap-2">
{actions}
<button onClick={onClose} aria-label="닫기"
className="grid h-7 w-7 place-items-center rounded-md text-ink-400 hover:bg-surface-2 hover:text-ink-700">✕</button>
</div>
</header>
<div className="min-h-0 flex-1 overflow-auto p-4">{children}</div>
</div>
</div>
);
}
// ── 표 — thead sticky. height 숫자=고정 높이, "fill"=남는 높이 채움, "auto"=내용 높이.
// fixed=table-fixed(좁은 폭에서 열 넘침·줄바꿈 방지), 열별 width 지정 가능. ──
export function ScrollTable({ height = 420, dense = false, fixed = false, columns, children }: {
height?: number | "fill" | "auto"; dense?: boolean; fixed?: boolean;
columns: readonly { key: string; label: ReactNode; align?: "right"; width?: string }[];
children: ReactNode;
}) {
const pad = dense ? "pb-1.5 pr-2 pt-1.5" : "pb-2 pr-3 pt-2";
const fill = height === "fill";
const auto = height === "auto";
// 행 좌우 여백: 첫/마지막 셀에 padding(헤더·본문 공통). 헤더는 bg-surface-2 밴드로 카드 제목바와 구분.
const edge = dense ? "[&_th:first-child]:pl-3 [&_td:first-child]:pl-3 [&_th:last-child]:pr-3 [&_td:last-child]:pr-3"
: "[&_th:first-child]:pl-4 [&_td:first-child]:pl-4 [&_th:last-child]:pr-4 [&_td:last-child]:pr-4";
return (
<div className={`overflow-auto ${fill ? "min-h-0 flex-1" : ""}`} style={fill || auto ? undefined : { height }}>
<table className={`w-full text-left ${fixed ? "table-fixed" : ""} ${dense ? "text-[12px]" : "text-[13px]"} ${edge}`}>
<thead>
<tr>
{columns.map((c) => (
<th key={c.key} style={c.width ? { width: c.width } : undefined}
className={`sticky top-0 z-10 whitespace-nowrap border-b border-line-200 bg-surface-2 text-[11px] font-semibold text-ink-500 ${pad} ${c.align === "right" ? "text-right" : ""}`}>
{c.label}
</th>
))}
</tr>
</thead>
<tbody>{children}</tbody>
</table>
</div>
);
}