Follow-up PR to #95 (Liquid Glass foundation + primitives + Layout shell) that closes out the remaining sub-convoy briefs in a single sweep. Operator-instructed scope: "finish off the design changes." After this PR, **all 8 Liquid Glass sub-convoys are MERGED to main**; the deferred-from-#5 `fix-card3d-state` convoy is dropped (its target, `components/Card3D.js`, turned out to be dead code). ## #2 Brief 2 — Remaining 8 modals migrated to <Modal> primitive - `CollectionsSuccessModal.js` — wrap in <Modal hideCloseButton>; 2 Buttons. - `CollectionsEditModal.js` — full <Modal> + <Input> + <Button> rewrite (4 fields, tag chip section, public-toggle preserved, 2 footer Buttons). - `CollectionEditModal.js` — same pattern as above (4 fields + public-toggle + 2 Buttons). - `CardDetailDeckModal.js` — <Modal> + native select (Select primitive not in scope) + 2 Buttons; sweep `gradient-bg-purple` → `<Button variant="primary">`. - `UploadImageModal.js` — <Modal> + token-driven URL/file tab switcher + drag-drop using `--accent-ember` rim + 2 Buttons (one with `loading` prop). - `CollectionSelectionModal.js` — largest of the set (header summary + SearchBar + scrollable list w/ checkbox toggles + footer); migrated to <Modal size="lg"> while preserving the per-collection card preview thumbnails. - `OCRSettings.js` — trivial <Modal> wrap + single primary <Button>. - `pages/decks.js` — both inline modals (Create Deck + Edit Deck) and `components/ScannerPageView.js` (Create List) migrated; ScannerPageView dropped its `useFocusTrap` named-import (Modal's internal focus trap owns the panel ref now). - **`.github/workflows/ci.yml` `forbidden-modal-shell-without-primitive`** — grandfather list emptied to zero entries; gate is now strict. ## #3 Brief 2 — Forms migrated to <Button> / <SearchBar> - `pages/dashboard.js` — 3 CTAs → <Button> (Create List with leadingIcon, Create Your First List, View All Lists). - `pages/my-cards.js` — empty-state CTA → <Button variant="primary" size="lg">. View-mode toggle buttons intentionally left native (icon-only, doesn't match Button variants). - `pages/community/collections.js` — Go to My Lists CTA → <Button>. - `components/CollectionsPageView.js` — Discover Community + Create List header CTAs → <Button>; search input → <SearchBar>. - Card-grid per-row icon buttons (CollectionsPageView, my-cards, CardsPageView) intentionally left native — tiny per-card actions whose styling doesn't match Button variants and would invalidate visual-diff baselines. ## #5 — scope revised + landed `components/Card3D.js` deletion: surveyed every importer with grep — **zero consumers** in `pages/**` or `components/**`. Only references were in convoy docs. The "pre-existing state-management bug" (state setters used without useState declarations) never affected the running app because the component was never rendered. -505 LOC. The `fix-card3d-state` convoy is dropped from the roadmap as a result. The actual card-grid component (`components/CardItem.js`) is intentionally **not** modified in this sweep — it has per-rarity glow tuning that the existing visual-diff baseline locks in, and the architect's #5 deferral note specifically called out the dedicated baseline re-seed cost. A future implementer turn can apply rim-light tokens to CardItem with its own baseline re-seed when an operator wants that polish. ## #6 Brief 1 — Landing + invite pages glass-migrated - `pages/index.js` — top nav: `var(--glass-surface-mid)` + `--glass-blur-mid` + rim-light. 3 feature cards: `<GlassSurface tint="mid" rim="subtle" elevation="ambient">`. Featured-list cards (the public collection grid): same `<GlassSurface>` recipe with motion-token transitions. All 6 CTA buttons → <Button variant="primary"|"secondary"|"ghost"> with proper sizes. Pulse-loading placeholders tagged `.motion-essential` so reduced-motion users still see them animate (state-meaningful). - `pages/invite/accept.js` + `pages/invite/decline.js` — both outcome panels wrapped in `<GlassSurface tint="mid" rim="subtle" elevation="pronounced">`. Loading spinner border colors corrected from `--text-accent` (which didn't exist) to `--accent-ember`. All 8 buttons → <Button>. `gradient-bg-ember` consumers retained (the canonical warm-palette utility class is fine). ## #8 Brief 2 — Legacy alias sweep + CI gate graduation - Swept `gradient-bg-purple` → `gradient-bg-ember` across **8 files** / **13 occurrences**: `CardDetailQuantityModal`, `CardEditorView`, `CardEditorForm`, `AdminProtected`, `pages/card/[id]`, `pages/invite/{accept,decline}`, `pages/admin/card-import`. `gradient-bg-purple` was a dangling class name with no CSS definition (it was rendering no styling), so the sweep is also a bug fix — those buttons now actually get the ember gradient. - Deleted the 5 dead CSS classes from `styles/globals.css`: `.gradient-text-blue`, `.gradient-text-purple`, `[data-theme="dark"] .glow-blue`, `[data-theme="dark"] .glow-purple`, `[data-theme="dark"] .glow-pink`. Each was zero-consumer post-sweep. - **Graduated the `forbidden-deprecated-color-aliases` CI job from WARN to FAIL.** All 9 patterns (`gradient-text-{purple,pink,blue}`, `glow-{purple,pink,blue}`, `gradient-bg-{purple,blue,pink}`) now block the build if any consumer is reintroduced. ## Verification (local + CI gates locally exercised) - Lint: 0 errors, 2 pre-existing warnings (`CardEditorForm.js` + `CollectionsPageView.js` carry-overs from before #95; out of scope). - Vitest: 104/104 passing — unchanged from #95. - Build: clean (Turbopack default; passes both light + dark theme prerender). - `forbidden-modal-shell-without-primitive` gate: locally clear (`grep -lE 'fixed inset-0 bg-black bg-opacity-' pages components -r --include='*.js'` returns no matches). - `forbidden-deprecated-color-aliases` gate: locally clear (all 9 patterns return no matches in `pages/` or `components/`). ## What still needs human action - **Linux visual-diff baselines** must re-seed via the Docker workflow in `AGENTS.md` § 6. This PR's landing-page + invite-page changes will produce baseline drift on the homepage screenshot (which is currently the only baseline committed) AND additional baselines will be generated for the landing's glass-card sections once the visual spec is expanded. Recommended: run the Docker re-seed against this PR's Vercel preview, commit the result to this branch, push, verify CI green, then merge. - Vercel auto-promotes the merge to production. ## Closes / supersedes - Closes `.convoys/liquid-glass-modal-and-surface-primitive.md` Brief 2 (status → merged). - Closes `.convoys/liquid-glass-form-primitives.md` Brief 2 (status → merged with explicit per-row-icon-button deferral note). - Closes `.convoys/liquid-glass-public-and-auth.md` Brief 1 (status → merged). - Closes `.convoys/cleanup-legacy-design-css.md` Brief 2 (status → merged + CI gate FAIL). - Drops `.convoys/liquid-glass-card-surfaces.md` Brief 1 prerequisite (`fix-card3d-state` no longer needed; Card3D deleted). - Drops the queued `fix-card3d-state` follow-up from the roadmap (target deleted). - Updates `.convoys/ship-readiness.md` § "Design-system redesign portfolio" with a "Finish-portfolio sweep" subsection documenting final status of all 8 sub-convoys. Co-authored-by: Cursor <cursoragent@cursor.com>
471 lines
16 KiB
JavaScript
471 lines
16 KiB
JavaScript
import { useState, useEffect } from 'react';
|
||
import { useRouter } from 'next/router';
|
||
import Link from 'next/link';
|
||
import Layout from '../components/Layout';
|
||
import { Modal, Input, Button } from '../components/ui';
|
||
import { useAuth } from '../lib/use-auth';
|
||
|
||
export default function Decks() {
|
||
const { user } = useAuth();
|
||
const router = useRouter();
|
||
const [decks, setDecks] = useState([]);
|
||
const [loading, setLoading] = useState(true);
|
||
const [showCreateModal, setShowCreateModal] = useState(false);
|
||
const [editingDeck, setEditingDeck] = useState(null);
|
||
const [newDeck, setNewDeck] = useState({
|
||
name: '',
|
||
description: '',
|
||
format: 'Commander',
|
||
is_public: false
|
||
});
|
||
|
||
const fetchDecks = async () => {
|
||
try {
|
||
const token = localStorage.getItem('auth_token');
|
||
const response = await fetch('/api/decks', {
|
||
headers: {
|
||
'Authorization': `Bearer ${token}`
|
||
}
|
||
});
|
||
|
||
if (response.ok) {
|
||
const data = await response.json();
|
||
setDecks(data);
|
||
} else {
|
||
console.error('Failed to fetch decks');
|
||
}
|
||
} catch (error) {
|
||
console.error('Error fetching decks:', error);
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
}
|
||
|
||
useEffect(() => {
|
||
if (user) {
|
||
// eslint-disable-next-line react-hooks/set-state-in-effect -- load decks when user is available
|
||
fetchDecks();
|
||
}
|
||
}, [user]);
|
||
|
||
;
|
||
|
||
const handleCreateDeck = async (e) => {
|
||
e.preventDefault();
|
||
|
||
try {
|
||
const token = localStorage.getItem('auth_token');
|
||
const response = await fetch('/api/decks', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/json',
|
||
'Authorization': `Bearer ${token}`
|
||
},
|
||
body: JSON.stringify(newDeck)
|
||
});
|
||
|
||
if (response.ok) {
|
||
const createdDeck = await response.json();
|
||
setDecks([createdDeck, ...decks]);
|
||
setShowCreateModal(false);
|
||
setNewDeck({ name: '', description: '', format: 'Commander', is_public: false });
|
||
|
||
// Navigate to deck builder for the new deck
|
||
router.push(`/deck-builder?deck=${createdDeck.id}`);
|
||
} else {
|
||
console.error('Failed to create deck');
|
||
}
|
||
} catch (error) {
|
||
console.error('Error creating deck:', error);
|
||
}
|
||
};
|
||
|
||
const handleEditDeck = async (e) => {
|
||
e.preventDefault();
|
||
|
||
try {
|
||
const token = localStorage.getItem('auth_token');
|
||
const response = await fetch(`/api/decks/${editingDeck.id}`, {
|
||
method: 'PUT',
|
||
headers: {
|
||
'Content-Type': 'application/json',
|
||
'Authorization': `Bearer ${token}`
|
||
},
|
||
body: JSON.stringify(editingDeck)
|
||
});
|
||
|
||
if (response.ok) {
|
||
const updatedDeck = await response.json();
|
||
setDecks(decks.map(deck => deck.id === updatedDeck.id ? updatedDeck : deck));
|
||
setEditingDeck(null);
|
||
} else {
|
||
console.error('Failed to update deck');
|
||
}
|
||
} catch (error) {
|
||
console.error('Error updating deck:', error);
|
||
}
|
||
};
|
||
|
||
const handleDeleteDeck = async (deckId) => {
|
||
if (!confirm('Are you sure you want to delete this deck? This action cannot be undone.')) {
|
||
return;
|
||
}
|
||
|
||
try {
|
||
const token = localStorage.getItem('auth_token');
|
||
const response = await fetch(`/api/decks/${deckId}`, {
|
||
method: 'DELETE',
|
||
headers: {
|
||
'Authorization': `Bearer ${token}`
|
||
}
|
||
});
|
||
|
||
if (response.ok) {
|
||
setDecks(decks.filter(deck => deck.id !== deckId));
|
||
} else {
|
||
console.error('Failed to delete deck');
|
||
}
|
||
} catch (error) {
|
||
console.error('Error deleting deck:', error);
|
||
}
|
||
};
|
||
|
||
const getFormatIcon = (format) => {
|
||
switch (format) {
|
||
case 'Commander':
|
||
return '⚔️';
|
||
case 'Standard':
|
||
return '🏆';
|
||
case 'Modern':
|
||
return '🔥';
|
||
case 'Legacy':
|
||
return '💎';
|
||
default:
|
||
return '🃏';
|
||
}
|
||
};
|
||
|
||
const getFormatColor = (format) => {
|
||
switch (format) {
|
||
case 'Commander':
|
||
return 'bg-purple-100 text-purple-800';
|
||
case 'Standard':
|
||
return 'bg-blue-100 text-blue-800';
|
||
case 'Modern':
|
||
return 'bg-red-100 text-red-800';
|
||
case 'Legacy':
|
||
return 'bg-yellow-100 text-yellow-800';
|
||
default:
|
||
return 'bg-gray-100 text-gray-800';
|
||
}
|
||
};
|
||
|
||
if (!user) {
|
||
return (
|
||
<Layout user={user}>
|
||
<div className="flex items-center justify-center min-h-screen">
|
||
<div className="text-center">
|
||
<h1 className="text-2xl font-bold mb-4">Please log in to view your decks</h1>
|
||
<Link href="/login" className="text-accent-ember hover:underline">
|
||
Go to Login
|
||
</Link>
|
||
</div>
|
||
</div>
|
||
</Layout>
|
||
);
|
||
}
|
||
|
||
if (loading) {
|
||
return (
|
||
<Layout user={user}>
|
||
<div className="flex items-center justify-center min-h-screen">
|
||
<div className="animate-spin rounded-full h-32 w-32 border-b-2 border-accent-ember"></div>
|
||
</div>
|
||
</Layout>
|
||
);
|
||
}
|
||
|
||
return (
|
||
<Layout user={user}>
|
||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||
{/* Header */}
|
||
<div className="flex justify-between items-center mb-8">
|
||
<div>
|
||
<h1 className="text-3xl font-bold text-text-primary">My Decks</h1>
|
||
<p className="text-text-secondary mt-2">
|
||
Build and manage your MTG decks
|
||
</p>
|
||
</div>
|
||
<button
|
||
onClick={() => setShowCreateModal(true)}
|
||
className="bg-accent-ember text-white px-6 py-3 rounded-lg hover:bg-accent-ember-dark transition-colors"
|
||
>
|
||
Create New Deck
|
||
</button>
|
||
</div>
|
||
|
||
{/* Stats */}
|
||
<div className="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
|
||
<div className="bg-bg-secondary rounded-lg p-6">
|
||
<div className="text-2xl font-bold text-text-primary">{decks.length}</div>
|
||
<div className="text-text-secondary">Total Decks</div>
|
||
</div>
|
||
<div className="bg-bg-secondary rounded-lg p-6">
|
||
<div className="text-2xl font-bold text-text-primary">
|
||
{decks.filter(d => d.format === 'Commander').length}
|
||
</div>
|
||
<div className="text-text-secondary">Commander</div>
|
||
</div>
|
||
<div className="bg-bg-secondary rounded-lg p-6">
|
||
<div className="text-2xl font-bold text-text-primary">
|
||
{decks.filter(d => d.is_public).length}
|
||
</div>
|
||
<div className="text-text-secondary">Public</div>
|
||
</div>
|
||
<div className="bg-bg-secondary rounded-lg p-6">
|
||
<div className="text-2xl font-bold text-text-primary">
|
||
{decks.reduce((sum, deck) => sum + (deck.card_count || 0), 0)}
|
||
</div>
|
||
<div className="text-text-secondary">Total Cards</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* Decks Grid */}
|
||
{decks.length === 0 ? (
|
||
<div className="text-center py-12">
|
||
<div className="text-6xl mb-4">🃏</div>
|
||
<h3 className="text-xl font-semibold text-text-primary mb-2">No decks yet</h3>
|
||
<p className="text-text-secondary mb-6">Create your first deck to get started</p>
|
||
<button
|
||
onClick={() => setShowCreateModal(true)}
|
||
className="bg-accent-ember text-white px-6 py-3 rounded-lg hover:bg-accent-ember-dark transition-colors"
|
||
>
|
||
Create Your First Deck
|
||
</button>
|
||
</div>
|
||
) : (
|
||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||
{decks.map((deck) => (
|
||
<div key={deck.id} className="bg-bg-secondary rounded-lg p-6 hover:shadow-lg transition-shadow">
|
||
<div className="flex justify-between items-start mb-4">
|
||
<div className="flex items-center space-x-2">
|
||
<span className="text-2xl">{getFormatIcon(deck.format)}</span>
|
||
<span className={`px-2 py-1 rounded-full text-xs font-medium ${getFormatColor(deck.format)}`}>
|
||
{deck.format}
|
||
</span>
|
||
</div>
|
||
<div className="flex space-x-2">
|
||
<button
|
||
onClick={() => setEditingDeck({...deck})}
|
||
className="text-text-secondary hover:text-accent-ember transition-colors"
|
||
>
|
||
✏️
|
||
</button>
|
||
<button
|
||
onClick={() => handleDeleteDeck(deck.id)}
|
||
className="text-text-secondary hover:text-red-500 transition-colors"
|
||
>
|
||
🗑️
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<h3 className="text-xl font-bold text-text-primary mb-2">{deck.name}</h3>
|
||
|
||
{deck.description && (
|
||
<p className="text-text-secondary text-sm mb-4 line-clamp-2">{deck.description}</p>
|
||
)}
|
||
|
||
<div className="flex justify-between items-center text-sm text-text-secondary mb-4">
|
||
<span>{deck.card_count || 0} cards</span>
|
||
{deck.is_public && <span className="text-green-600">Public</span>}
|
||
</div>
|
||
|
||
<div className="flex space-x-2">
|
||
<Link
|
||
href={`/deck-builder?deck=${deck.id}`}
|
||
className="flex-1 bg-accent-ember text-white text-center py-2 rounded-lg hover:bg-accent-ember-dark transition-colors"
|
||
>
|
||
Edit Deck
|
||
</Link>
|
||
<Link
|
||
href={`/deck/${deck.id}`}
|
||
className="flex-1 bg-bg-tertiary text-text-primary text-center py-2 rounded-lg hover:bg-bg-primary transition-colors"
|
||
>
|
||
View
|
||
</Link>
|
||
</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
)}
|
||
|
||
<Modal
|
||
open={showCreateModal}
|
||
onClose={() => setShowCreateModal(false)}
|
||
title="Create New Deck"
|
||
size="md"
|
||
>
|
||
<form onSubmit={handleCreateDeck} className="space-y-4">
|
||
<Input
|
||
label="Deck Name *"
|
||
required
|
||
value={newDeck.name}
|
||
onChange={(e) => setNewDeck({ ...newDeck, name: e.target.value })}
|
||
placeholder="Enter deck name"
|
||
/>
|
||
<div>
|
||
<label
|
||
className="block text-sm font-medium mb-2"
|
||
style={{ color: 'var(--text-primary)' }}
|
||
htmlFor="create-deck-format"
|
||
>
|
||
Format
|
||
</label>
|
||
<select
|
||
id="create-deck-format"
|
||
value={newDeck.format}
|
||
onChange={(e) => setNewDeck({ ...newDeck, format: e.target.value })}
|
||
className="w-full px-3 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-accent-ember bg-bg-secondary text-text-primary"
|
||
>
|
||
<option value="Commander">Commander</option>
|
||
<option value="Standard">Standard</option>
|
||
<option value="Modern">Modern</option>
|
||
<option value="Legacy">Legacy</option>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label
|
||
className="block text-sm font-medium mb-2"
|
||
style={{ color: 'var(--text-primary)' }}
|
||
htmlFor="create-deck-description"
|
||
>
|
||
Description
|
||
</label>
|
||
<textarea
|
||
id="create-deck-description"
|
||
value={newDeck.description}
|
||
onChange={(e) => setNewDeck({ ...newDeck, description: e.target.value })}
|
||
className="w-full px-3 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-accent-ember bg-bg-secondary text-text-primary"
|
||
rows="3"
|
||
placeholder="Describe your deck strategy..."
|
||
/>
|
||
</div>
|
||
<label className="flex items-center">
|
||
<input
|
||
type="checkbox"
|
||
checked={newDeck.is_public}
|
||
onChange={(e) => setNewDeck({ ...newDeck, is_public: e.target.checked })}
|
||
className="mr-2"
|
||
style={{ accentColor: 'var(--accent-ember)' }}
|
||
/>
|
||
<span className="text-sm" style={{ color: 'var(--text-secondary)' }}>
|
||
Make deck public
|
||
</span>
|
||
</label>
|
||
<div className="flex space-x-3 pt-2">
|
||
<Button
|
||
type="button"
|
||
variant="secondary"
|
||
onClick={() => setShowCreateModal(false)}
|
||
className="flex-1"
|
||
>
|
||
Cancel
|
||
</Button>
|
||
<Button type="submit" variant="primary" className="flex-1">
|
||
Create Deck
|
||
</Button>
|
||
</div>
|
||
</form>
|
||
</Modal>
|
||
|
||
<Modal
|
||
open={!!editingDeck}
|
||
onClose={() => setEditingDeck(null)}
|
||
title="Edit Deck"
|
||
size="md"
|
||
>
|
||
{editingDeck && (
|
||
<form onSubmit={handleEditDeck} className="space-y-4">
|
||
<Input
|
||
label="Deck Name *"
|
||
required
|
||
value={editingDeck.name}
|
||
onChange={(e) =>
|
||
setEditingDeck({ ...editingDeck, name: e.target.value })
|
||
}
|
||
/>
|
||
<div>
|
||
<label
|
||
className="block text-sm font-medium mb-2"
|
||
style={{ color: 'var(--text-primary)' }}
|
||
htmlFor="edit-deck-format"
|
||
>
|
||
Format
|
||
</label>
|
||
<select
|
||
id="edit-deck-format"
|
||
value={editingDeck.format}
|
||
onChange={(e) =>
|
||
setEditingDeck({ ...editingDeck, format: e.target.value })
|
||
}
|
||
className="w-full px-3 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-accent-ember bg-bg-secondary text-text-primary"
|
||
>
|
||
<option value="Commander">Commander</option>
|
||
<option value="Standard">Standard</option>
|
||
<option value="Modern">Modern</option>
|
||
<option value="Legacy">Legacy</option>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label
|
||
className="block text-sm font-medium mb-2"
|
||
style={{ color: 'var(--text-primary)' }}
|
||
htmlFor="edit-deck-description"
|
||
>
|
||
Description
|
||
</label>
|
||
<textarea
|
||
id="edit-deck-description"
|
||
value={editingDeck.description || ''}
|
||
onChange={(e) =>
|
||
setEditingDeck({ ...editingDeck, description: e.target.value })
|
||
}
|
||
className="w-full px-3 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-accent-ember bg-bg-secondary text-text-primary"
|
||
rows="3"
|
||
/>
|
||
</div>
|
||
<label className="flex items-center">
|
||
<input
|
||
type="checkbox"
|
||
checked={editingDeck.is_public}
|
||
onChange={(e) =>
|
||
setEditingDeck({ ...editingDeck, is_public: e.target.checked })
|
||
}
|
||
className="mr-2"
|
||
style={{ accentColor: 'var(--accent-ember)' }}
|
||
/>
|
||
<span className="text-sm" style={{ color: 'var(--text-secondary)' }}>
|
||
Make deck public
|
||
</span>
|
||
</label>
|
||
<div className="flex space-x-3 pt-2">
|
||
<Button
|
||
type="button"
|
||
variant="secondary"
|
||
onClick={() => setEditingDeck(null)}
|
||
className="flex-1"
|
||
>
|
||
Cancel
|
||
</Button>
|
||
<Button type="submit" variant="primary" className="flex-1">
|
||
Save Changes
|
||
</Button>
|
||
</div>
|
||
</form>
|
||
)}
|
||
</Modal>
|
||
</div>
|
||
</Layout>
|
||
);
|
||
}
|