feat: 모바일 대응 + 삭제 모드 UI 개선

- 모바일: 헤더에 + 등록 버튼, 삭제는 아이콘 버튼
- 삭제 모드: 탭 아래 바에 전체선택/삭제/취소 배치
- 체크박스 CSS transition 애니메이션
- 100dvh 적용 (모바일 브라우저 대응)
- 최소 너비 320px 설정
- 운송장 번호 공백/하이픈 자동 제거
- 날짜에 요일 표시

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
caadiq 2026-03-24 20:55:23 +09:00
parent 9d2055fa7c
commit 92b223eea1
2 changed files with 110 additions and 68 deletions

View file

@ -1,23 +1,32 @@
import { useState } from "react";
import { Plus } from "lucide-react";
import MainPage from "@/pages/MainPage";
import Toast from "@/components/Toast";
import useToastStore from "@/stores/useToastStore";
function App() {
const toastMessage = useToastStore((s) => s.message);
const [showForm, setShowForm] = useState(false);
return (
<div className="h-screen overflow-hidden flex flex-col bg-secondary">
<div className="h-[100dvh] min-w-[320px] overflow-hidden flex flex-col bg-secondary">
<header className="flex-shrink-0 bg-white border-b border-gray-200 z-10">
<div className="max-w-2xl lg:max-w-4xl mx-auto px-4 py-3 lg:py-4 flex items-center gap-2">
<a href="/" className="flex items-center gap-2 no-underline">
<span className="text-xl lg:text-2xl font-bold text-primary">Traeon</span>
<span className="text-sm lg:text-base text-gray-400">택배 배송조회</span>
</a>
<button
onClick={() => setShowForm(!showForm)}
className="ml-auto lg:hidden text-primary hover:text-primary-dark p-1.5"
>
<Plus size={22} />
</button>
</div>
</header>
<main className="flex-1 min-h-0 overflow-hidden">
<div className="h-full max-w-2xl lg:max-w-4xl mx-auto px-4 py-6 lg:py-8 flex flex-col">
<MainPage />
<MainPage showForm={showForm} setShowForm={setShowForm} />
</div>
</main>
<Toast message={toastMessage} />

View file

@ -13,8 +13,7 @@ import { Loader2, Package, Trash2 } from "lucide-react";
const PAGE_LIMIT = 20;
function MainPage() {
const [showForm, setShowForm] = useState(false);
function MainPage({ showForm, setShowForm }) {
const [selectedId, setSelectedId] = useState(null);
const [deleteMode, setDeleteMode] = useState(false);
const [checkedIds, setCheckedIds] = useState(new Set());
@ -122,56 +121,91 @@ function MainPage() {
return (
<div className="flex flex-col h-full min-h-0">
<div className="flex-shrink-0 flex items-center justify-between mb-4">
<FilterTabs
filter={filter}
onFilterChange={handleFilterChange}
activeCount={activeCount}
deliveredCount={deliveredCount}
totalCount={allCount}
/>
<div className="flex items-center gap-2">
{deleteMode ? (
<>
<button
onClick={toggleAll}
className="px-3 lg:px-4 py-2 lg:py-2.5 text-sm lg:text-base text-gray-500 hover:text-gray-700 transition-colors"
>
{checkedIds.size === parcels.length ? "선택해제" : "전체선택"}
</button>
<button
onClick={() => checkedIds.size > 0 && setShowDeleteConfirm(true)}
disabled={checkedIds.size === 0}
className="px-4 lg:px-5 py-2 lg:py-2.5 bg-red-500 text-white rounded-lg text-sm lg:text-base font-medium hover:bg-red-600 transition-colors disabled:opacity-40"
>
삭제 ({checkedIds.size})
</button>
<button
onClick={exitDeleteMode}
className="px-3 lg:px-4 py-2 lg:py-2.5 text-sm lg:text-base text-gray-500 hover:text-gray-700 transition-colors"
>
취소
</button>
</>
) : (
<>
{parcels.length > 0 && (
<div className="flex-shrink-0 mb-4 space-y-3">
<div className="flex items-center justify-between">
<FilterTabs
filter={filter}
onFilterChange={handleFilterChange}
activeCount={activeCount}
deliveredCount={deliveredCount}
totalCount={allCount}
/>
<div className="flex items-center gap-2 shrink-0">
{!deleteMode && parcels.length > 0 && (
<>
<button
onClick={() => setDeleteMode(true)}
className="px-4 lg:px-5 py-[7px] lg:py-[9px] border border-red-300 text-red-500 rounded-lg text-sm lg:text-base font-medium hover:bg-red-50 transition-colors"
className="hidden lg:block px-5 py-[9px] border border-red-300 text-red-500 rounded-lg text-base font-medium hover:bg-red-50 transition-colors"
>
삭제
</button>
)}
<button
onClick={() => setDeleteMode(true)}
className="lg:hidden p-2 text-gray-400 hover:text-red-500 transition-colors"
>
<Trash2 size={18} />
</button>
</>
)}
{!deleteMode && (
<button
onClick={() => setShowForm(!showForm)}
className="px-4 lg:px-5 py-2 lg:py-2.5 bg-primary text-white rounded-lg text-sm lg:text-base font-medium hover:bg-primary-dark transition-colors"
className="hidden lg:block px-5 py-2.5 bg-primary text-white rounded-lg text-base font-medium hover:bg-primary-dark transition-colors"
>
{showForm ? "취소" : "+ 등록"}
</button>
</>
)}
)}
</div>
</div>
<AnimatePresence>
{deleteMode && (
<motion.div
initial={{ opacity: 0, height: 0 }}
animate={{ opacity: 1, height: "auto" }}
exit={{ opacity: 0, height: 0 }}
transition={{ duration: 0.2 }}
className="overflow-hidden"
>
<div className="flex items-center justify-between bg-red-50 rounded-lg px-3 lg:px-4 py-2.5 lg:py-3">
<button
onClick={toggleAll}
className="flex items-center gap-2 text-xs lg:text-sm text-gray-600"
>
<div
className={`w-4 h-4 lg:w-[18px] lg:h-[18px] rounded border-2 flex items-center justify-center transition-all ${
checkedIds.size === parcels.length && parcels.length > 0
? "bg-red-500 border-red-500"
: "border-gray-300"
}`}
>
{checkedIds.size === parcels.length && parcels.length > 0 && (
<svg viewBox="0 0 12 12" className="w-2.5 h-2.5 text-white" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M2 6l3 3 5-5" />
</svg>
)}
</div>
전체선택 ({checkedIds.size}/{parcels.length})
</button>
<div className="flex items-center gap-2">
<button
onClick={exitDeleteMode}
className="px-3 lg:px-4 py-1.5 text-xs lg:text-sm text-gray-500 hover:text-gray-700 rounded-lg transition-colors"
>
취소
</button>
<button
onClick={() => checkedIds.size > 0 && setShowDeleteConfirm(true)}
disabled={checkedIds.size === 0}
className="px-3.5 lg:px-4 py-2 lg:py-2 bg-red-500 text-white rounded-lg text-xs lg:text-sm font-medium hover:bg-red-600 transition-colors disabled:opacity-40"
>
삭제 ({checkedIds.size})
</button>
</div>
</div>
</motion.div>
)}
</AnimatePresence>
</div>
<AnimatePresence>
@ -222,31 +256,30 @@ function MainPage() {
}}
>
<div className="flex items-center gap-2">
{deleteMode && (
<motion.div
initial={{ opacity: 0, width: 0 }}
animate={{ opacity: 1, width: "auto" }}
className="shrink-0"
>
<div
onClick={(e) => {
e.stopPropagation();
toggleCheck(parcel.id);
}}
className={`w-5 h-5 rounded-md border-2 flex items-center justify-center cursor-pointer transition-all ${
checkedIds.has(parcel.id)
? "bg-primary border-primary"
: "border-gray-300 hover:border-primary/50"
}`}
>
{checkedIds.has(parcel.id) && (
<svg viewBox="0 0 12 12" className="w-3 h-3 text-white" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M2 6l3 3 5-5" />
</svg>
)}
</div>
</motion.div>
)}
<div
onClick={(e) => {
if (!deleteMode) return;
e.stopPropagation();
toggleCheck(parcel.id);
}}
className={`w-5 h-5 rounded-md border-2 flex items-center justify-center shrink-0 transition-all duration-300 ${
deleteMode
? "opacity-100 scale-100 mr-0"
: "opacity-0 scale-0 w-0 -mr-2"
} ${
deleteMode && checkedIds.has(parcel.id)
? "bg-primary border-primary cursor-pointer"
: deleteMode
? "border-gray-300 hover:border-primary/50 cursor-pointer"
: "border-transparent"
}`}
>
{checkedIds.has(parcel.id) && deleteMode && (
<svg viewBox="0 0 12 12" className="w-3 h-3 text-white" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M2 6l3 3 5-5" />
</svg>
)}
</div>
<div className="flex-1 min-w-0">
<ParcelCard
parcel={parcel}