feat: 모바일 대응 + 삭제 모드 UI 개선
- 모바일: 헤더에 + 등록 버튼, 삭제는 아이콘 버튼 - 삭제 모드: 탭 아래 바에 전체선택/삭제/취소 배치 - 체크박스 CSS transition 애니메이션 - 100dvh 적용 (모바일 브라우저 대응) - 최소 너비 320px 설정 - 운송장 번호 공백/하이픈 자동 제거 - 날짜에 요일 표시 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9d2055fa7c
commit
92b223eea1
2 changed files with 110 additions and 68 deletions
|
|
@ -1,23 +1,32 @@
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Plus } from "lucide-react";
|
||||||
import MainPage from "@/pages/MainPage";
|
import MainPage from "@/pages/MainPage";
|
||||||
import Toast from "@/components/Toast";
|
import Toast from "@/components/Toast";
|
||||||
import useToastStore from "@/stores/useToastStore";
|
import useToastStore from "@/stores/useToastStore";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const toastMessage = useToastStore((s) => s.message);
|
const toastMessage = useToastStore((s) => s.message);
|
||||||
|
const [showForm, setShowForm] = useState(false);
|
||||||
|
|
||||||
return (
|
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">
|
<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">
|
<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">
|
<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-xl lg:text-2xl font-bold text-primary">Traeon</span>
|
||||||
<span className="text-sm lg:text-base text-gray-400">택배 배송조회</span>
|
<span className="text-sm lg:text-base text-gray-400">택배 배송조회</span>
|
||||||
</a>
|
</a>
|
||||||
|
<button
|
||||||
|
onClick={() => setShowForm(!showForm)}
|
||||||
|
className="ml-auto lg:hidden text-primary hover:text-primary-dark p-1.5"
|
||||||
|
>
|
||||||
|
<Plus size={22} />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main className="flex-1 min-h-0 overflow-hidden">
|
<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">
|
<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>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<Toast message={toastMessage} />
|
<Toast message={toastMessage} />
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ import { Loader2, Package, Trash2 } from "lucide-react";
|
||||||
|
|
||||||
const PAGE_LIMIT = 20;
|
const PAGE_LIMIT = 20;
|
||||||
|
|
||||||
function MainPage() {
|
function MainPage({ showForm, setShowForm }) {
|
||||||
const [showForm, setShowForm] = useState(false);
|
|
||||||
const [selectedId, setSelectedId] = useState(null);
|
const [selectedId, setSelectedId] = useState(null);
|
||||||
const [deleteMode, setDeleteMode] = useState(false);
|
const [deleteMode, setDeleteMode] = useState(false);
|
||||||
const [checkedIds, setCheckedIds] = useState(new Set());
|
const [checkedIds, setCheckedIds] = useState(new Set());
|
||||||
|
|
@ -122,56 +121,91 @@ function MainPage() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full min-h-0">
|
<div className="flex flex-col h-full min-h-0">
|
||||||
<div className="flex-shrink-0 flex items-center justify-between mb-4">
|
<div className="flex-shrink-0 mb-4 space-y-3">
|
||||||
<FilterTabs
|
<div className="flex items-center justify-between">
|
||||||
filter={filter}
|
<FilterTabs
|
||||||
onFilterChange={handleFilterChange}
|
filter={filter}
|
||||||
activeCount={activeCount}
|
onFilterChange={handleFilterChange}
|
||||||
deliveredCount={deliveredCount}
|
activeCount={activeCount}
|
||||||
totalCount={allCount}
|
deliveredCount={deliveredCount}
|
||||||
/>
|
totalCount={allCount}
|
||||||
<div className="flex items-center gap-2">
|
/>
|
||||||
{deleteMode ? (
|
<div className="flex items-center gap-2 shrink-0">
|
||||||
<>
|
{!deleteMode && parcels.length > 0 && (
|
||||||
<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 && (
|
|
||||||
<button
|
<button
|
||||||
onClick={() => setDeleteMode(true)}
|
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>
|
||||||
)}
|
<button
|
||||||
|
onClick={() => setDeleteMode(true)}
|
||||||
|
className="lg:hidden p-2 text-gray-400 hover:text-red-500 transition-colors"
|
||||||
|
>
|
||||||
|
<Trash2 size={18} />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{!deleteMode && (
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowForm(!showForm)}
|
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 ? "취소" : "+ 등록"}
|
{showForm ? "취소" : "+ 등록"}
|
||||||
</button>
|
</button>
|
||||||
</>
|
)}
|
||||||
)}
|
</div>
|
||||||
</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>
|
</div>
|
||||||
|
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
|
|
@ -222,31 +256,30 @@ function MainPage() {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{deleteMode && (
|
<div
|
||||||
<motion.div
|
onClick={(e) => {
|
||||||
initial={{ opacity: 0, width: 0 }}
|
if (!deleteMode) return;
|
||||||
animate={{ opacity: 1, width: "auto" }}
|
e.stopPropagation();
|
||||||
className="shrink-0"
|
toggleCheck(parcel.id);
|
||||||
>
|
}}
|
||||||
<div
|
className={`w-5 h-5 rounded-md border-2 flex items-center justify-center shrink-0 transition-all duration-300 ${
|
||||||
onClick={(e) => {
|
deleteMode
|
||||||
e.stopPropagation();
|
? "opacity-100 scale-100 mr-0"
|
||||||
toggleCheck(parcel.id);
|
: "opacity-0 scale-0 w-0 -mr-2"
|
||||||
}}
|
} ${
|
||||||
className={`w-5 h-5 rounded-md border-2 flex items-center justify-center cursor-pointer transition-all ${
|
deleteMode && checkedIds.has(parcel.id)
|
||||||
checkedIds.has(parcel.id)
|
? "bg-primary border-primary cursor-pointer"
|
||||||
? "bg-primary border-primary"
|
: deleteMode
|
||||||
: "border-gray-300 hover:border-primary/50"
|
? "border-gray-300 hover:border-primary/50 cursor-pointer"
|
||||||
}`}
|
: "border-transparent"
|
||||||
>
|
}`}
|
||||||
{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">
|
{checkedIds.has(parcel.id) && deleteMode && (
|
||||||
<path d="M2 6l3 3 5-5" />
|
<svg viewBox="0 0 12 12" className="w-3 h-3 text-white" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||||
</svg>
|
<path d="M2 6l3 3 5-5" />
|
||||||
)}
|
</svg>
|
||||||
</div>
|
)}
|
||||||
</motion.div>
|
</div>
|
||||||
)}
|
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<ParcelCard
|
<ParcelCard
|
||||||
parcel={parcel}
|
parcel={parcel}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue