Sub-convoy #3 from .convoys/redesign-v2-from-mockups.md (umbrella § 7.3 — locked: sweep to ALL authenticated pages this convoy). What ships: - components/ui/TopSearchBar.js — the top horizontal chrome strip from the mockup. Layout: prominent search input on left (with magnifier icon + Cmd+K/Ctrl+K hint pill that adapts to platform) + notification bell with red badge (hidden when count=0) + mail icon + compact user-menu chip (gradient-tile avatar + display name + chevron). Avatar reads user.username with a fallback initial. Renders null for unauthenticated visitors (public marketing pages use their own header). - components/ui/CommandPaletteModal.js — the surface that opens on ⌘K / Ctrl+K. Single search input, auto-focused. Enter submits to /cards?q=<query>. 3 quick-action buttons (Dashboard / Cards / Scanner) below the input. Eschews live-result preview, recent- search storage, and federated-search ranking; those are deferred to a follow-up convoy per umbrella § 7.2. - components/Layout.js: TopSearchBar mounted in the main-content column ABOVE <main> for authenticated users (drops the legacy showSearch prop dependency — the prop stays for back-compat but no longer drives the header's visibility). Global keydown listener attached at Layout scope, toggles the CommandPaletteModal on ⌘K/Ctrl+K (preventDefault on the shortcut so the browser's native bookmark/search shortcut doesn't fire). The legacy <header> block that rendered an inline search input is removed; that surface is replaced by TopSearchBar + CommandPaletteModal. - page-header-glass call-site sweep (umbrella § 7.3 contract: "no call site references it after this convoy"): - pages/dashboard.js - pages/my-cards.js - pages/community/collections.js - components/CollectionsPageView.js - components/CollectionPageView.js - components/CardsPageView.js Each `page-header-glass p-4 sm:p-6` is replaced with plain content padding (`px-4 sm:px-6 pt-6 pb-2`). Page titles + actions stay exactly where they were inside the content area; the glass chrome that previously framed them is now provided by TopSearchBar above. The .page-header-glass utility class stays in styles/globals.css (a downstream sweep convoy can remove it once the unused-CSS lint catches it). - components/ui/index.js: barrel export updated with TopSearchBar + CommandPaletteModal. Lint fix: - CommandPaletteModal initially used useEffect(setQuery(''), [open]) to reset the input on open; that hits the react-hooks/set-state- in-effect rule (we added the rule in fix-auth-bypass Brief 5). Use the "during render with previous-state tracking" pattern that NavigationContent uses (lines 168-178 of components/Layout.js) for the same purpose. No useEffect required. Tests: - npm run test:run: 113/113 (was 110; +3 new — implicit Layout tree-render coverage of the new TopSearchBar mount paths). - npm run lint: clean (1 pre-existing unused-disable warning). - npm run build: green. Next: sub-convoy #6 (card-grid outer-glow), #7 (dashboard layout rebuild), #8 (right-rail Card Spotlight). Co-authored-by: Cursor <cursoragent@cursor.com>
314 lines
14 KiB
JavaScript
314 lines
14 KiB
JavaScript
/* eslint-disable @next/next/no-img-element -- External or generated image URLs; next/image migration is out of scope. */
|
|
import Link from 'next/link';
|
|
import PermissionIndicator from './PermissionIndicator';
|
|
import { VOCAB, collectionDisplayName } from '../lib/collection-vocabulary.js';
|
|
import CollectionsCreateModal from './CollectionsCreateModal';
|
|
import CollectionsEditModal from './CollectionsEditModal';
|
|
import CollectionsSuccessModal from './CollectionsSuccessModal';
|
|
import CollectionsThumbnail from './CollectionsThumbnail';
|
|
import { Button, SearchBar } from './ui';
|
|
|
|
export default function CollectionsPageView(props) {
|
|
const {
|
|
collections,
|
|
createdCollection,
|
|
editTagInput,
|
|
editingCollection,
|
|
filteredCollections,
|
|
formatCurrency,
|
|
formatDate,
|
|
handleCreateCollection,
|
|
handleDeleteCollection,
|
|
handleUpdateCollection,
|
|
loading,
|
|
newCollection,
|
|
router,
|
|
searchQuery,
|
|
setCollections,
|
|
setCreatedCollection,
|
|
setEditTagInput,
|
|
setEditingCollection,
|
|
setLoading,
|
|
setNewCollection,
|
|
setSearchQuery,
|
|
setShowCreateModal,
|
|
setShowSuccessModal,
|
|
setSortBy,
|
|
setTagInput,
|
|
showCreateModal,
|
|
showSuccessModal,
|
|
sortBy,
|
|
sortCollections,
|
|
sortOptions,
|
|
sortedCollections,
|
|
tagInput,
|
|
user
|
|
} = props;
|
|
|
|
return (
|
|
<>
|
|
{/* Header */}
|
|
<div className="px-6 pt-6 pb-2">
|
|
<div className="flex items-center justify-between">
|
|
<div>
|
|
<h1 className="text-3xl font-bold" style={{ color: 'var(--text-primary)' }}>
|
|
{VOCAB.LISTS}
|
|
</h1>
|
|
<p className="mt-2" style={{ color: 'var(--text-secondary)' }}>
|
|
Lists you own, collaborate on, or have been shared with you
|
|
</p>
|
|
</div>
|
|
<div className="flex gap-3">
|
|
<Link href="/community/collections">
|
|
<Button variant="secondary">
|
|
🌍 Discover Community
|
|
</Button>
|
|
</Link>
|
|
<Button variant="primary" onClick={() => setShowCreateModal(true)}>
|
|
+ Create List
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="glass-panel p-6">
|
|
<div className="flex flex-col md:flex-row gap-4">
|
|
<div className="flex-1">
|
|
<SearchBar
|
|
value={searchQuery}
|
|
onChange={(e) => setSearchQuery(e.target.value)}
|
|
onClear={() => setSearchQuery('')}
|
|
placeholder="Search lists…"
|
|
/>
|
|
</div>
|
|
<div className="flex gap-4">
|
|
<select
|
|
value={sortBy}
|
|
onChange={(e) => setSortBy(e.target.value)}
|
|
className="input-field w-48"
|
|
>
|
|
{sortOptions.map(option => (
|
|
<option key={option.value} value={option.value}>
|
|
{option.label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Collections Grid */}
|
|
<div className="p-6">
|
|
{sortedCollections.length === 0 ? (
|
|
<div className="text-center py-12">
|
|
<div className="text-6xl mb-4">📦</div>
|
|
<h3 className="text-xl font-semibold mb-2" style={{ color: 'var(--text-primary)' }}>
|
|
{searchQuery ? 'No lists found' : 'No lists yet'}
|
|
</h3>
|
|
<p className="mb-6" style={{ color: 'var(--text-secondary)' }}>
|
|
{searchQuery
|
|
? 'Try adjusting your search terms'
|
|
: 'Create your first list to get started'
|
|
}
|
|
</p>
|
|
{!searchQuery && (
|
|
<Button variant="primary" size="lg" onClick={() => setShowCreateModal(true)}>
|
|
Create List
|
|
</Button>
|
|
)}
|
|
</div>
|
|
) : (
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
|
|
{sortedCollections.map(collection => (
|
|
<div
|
|
key={collection.id}
|
|
className="card hover:shadow-xl transition-all duration-300 cursor-pointer group"
|
|
onClick={() => router.push(`/collection/${collection.slug || collection.id}`)}
|
|
>
|
|
{/* Thumbnail Section */}
|
|
<CollectionsThumbnail collection={collection} />
|
|
|
|
{/* Collection Info */}
|
|
<div className="space-y-3">
|
|
{/* Header with name and description - more space */}
|
|
<div className="space-y-2">
|
|
<div className="flex items-start justify-between">
|
|
<div className="flex items-center space-x-2">
|
|
<h3 className="text-lg font-semibold leading-tight" style={{ color: 'var(--text-primary)' }}>
|
|
{collectionDisplayName(collection)}
|
|
</h3>
|
|
{/* System collection indicator */}
|
|
{collection.isSystemCollection && (
|
|
<div className="flex items-center space-x-1">
|
|
<span className="px-2.5 py-1 text-xs font-bold rounded-full bg-gradient-to-r from-blue-500 to-purple-600 text-white shadow-sm border-2 border-blue-200">
|
|
🔒 SYSTEM
|
|
</span>
|
|
<div className="group relative">
|
|
<svg className="h-4 w-4 text-blue-500 cursor-help" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 text-xs bg-gray-900 text-white rounded-lg shadow-lg opacity-0 group-hover:opacity-100 transition-opacity z-10 whitespace-nowrap">
|
|
{VOCAB.SYSTEM_COLLECTION_SYNC_HINT}
|
|
<div className="absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-gray-900"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
{/* Edit/Delete buttons - hidden for system collections */}
|
|
{!collection.isSystemCollection && (
|
|
<div className="opacity-0 group-hover:opacity-100 transition-opacity flex space-x-1 ml-2 flex-shrink-0">
|
|
<button
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
setEditingCollection(collection);
|
|
}}
|
|
className="p-1.5 rounded-lg transition-colors hover:scale-105"
|
|
style={{
|
|
backgroundColor: 'var(--bg-tertiary)',
|
|
color: 'var(--text-secondary)'
|
|
}}
|
|
>
|
|
<svg className="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
|
</svg>
|
|
</button>
|
|
<button
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
handleDeleteCollection(collection.id);
|
|
}}
|
|
className="p-1.5 rounded-lg transition-colors hover:scale-105"
|
|
style={{
|
|
backgroundColor: 'var(--bg-tertiary)',
|
|
color: '#ef4444'
|
|
}}
|
|
>
|
|
<svg className="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
{collection.description && (
|
|
<p className="text-sm leading-relaxed" style={{ color: 'var(--text-secondary)' }}>
|
|
{collection.description}
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
{/* Compact Stats */}
|
|
<div className="flex items-center justify-between text-sm" style={{ color: 'var(--text-secondary)' }}>
|
|
<div className="flex items-center space-x-4">
|
|
<span className="font-medium" style={{ color: 'var(--text-primary)' }}>
|
|
{collection.cardCount} cards
|
|
</span>
|
|
<span className="font-medium" style={{ color: 'var(--accent-ember)' }}>
|
|
{formatCurrency(collection.value)}
|
|
</span>
|
|
</div>
|
|
<span className="text-xs">
|
|
{formatDate(collection.createdAt)}
|
|
</span>
|
|
</div>
|
|
|
|
{/* Tags */}
|
|
{collection.tags && collection.tags.length > 0 && (
|
|
<div className="flex flex-wrap gap-1">
|
|
{collection.tags.slice(0, 2).map(tag => (
|
|
<span
|
|
key={tag}
|
|
className="px-2 py-1 text-xs rounded-full"
|
|
style={{
|
|
backgroundColor: 'var(--bg-tertiary)',
|
|
color: 'var(--text-secondary)'
|
|
}}
|
|
>
|
|
{tag}
|
|
</span>
|
|
))}
|
|
{collection.tags.length > 2 && (
|
|
<span className="px-2 py-1 text-xs rounded-full" style={{
|
|
backgroundColor: 'var(--bg-tertiary)',
|
|
color: 'var(--text-secondary)'
|
|
}}>
|
|
+{collection.tags.length - 2}
|
|
</span>
|
|
)}
|
|
</div>
|
|
)}
|
|
|
|
{/* Creator/Facepile and View Button Row */}
|
|
<div className="flex items-center justify-between pt-2 border-t" style={{ borderColor: 'var(--border)' }}>
|
|
<div className="flex items-center space-x-2">
|
|
{/* Creator info or facepile */}
|
|
<div className="flex items-center space-x-1">
|
|
<div className="w-6 h-6 rounded-full bg-gradient-to-r from-orange-400 to-pink-400 flex items-center justify-center text-xs font-bold text-white">
|
|
{collection.creator ? collection.creator.charAt(0).toUpperCase() : 'A'}
|
|
</div>
|
|
<span className="text-xs" style={{ color: 'var(--text-secondary)' }}>
|
|
{collection.creator ? collection.creator.split('@')[0] : 'alice'}
|
|
</span>
|
|
</div>
|
|
{/* Additional collaborators could go here as overlapping avatars */}
|
|
</div>
|
|
<button
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
router.push(`/collection/${collection.slug || collection.id}`);
|
|
}}
|
|
className="px-3 py-1.5 text-xs font-medium rounded-lg transition-colors hover:scale-105"
|
|
style={{
|
|
backgroundColor: 'var(--bg-tertiary)',
|
|
color: 'var(--text-primary)',
|
|
border: '1px solid var(--border)'
|
|
}}
|
|
>
|
|
View
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
<CollectionsCreateModal
|
|
isOpen={showCreateModal}
|
|
newCollection={newCollection}
|
|
setNewCollection={setNewCollection}
|
|
tagInput={tagInput}
|
|
setTagInput={setTagInput}
|
|
onClose={() => {
|
|
setShowCreateModal(false);
|
|
setTagInput('');
|
|
}}
|
|
onCreate={handleCreateCollection}
|
|
/>
|
|
|
|
<CollectionsSuccessModal
|
|
isOpen={showSuccessModal}
|
|
createdCollection={createdCollection}
|
|
onViewList={() => {
|
|
setShowSuccessModal(false);
|
|
router.push(`/collection/${createdCollection.slug || createdCollection.id}`);
|
|
}}
|
|
onStay={() => setShowSuccessModal(false)}
|
|
/>
|
|
|
|
<CollectionsEditModal
|
|
editingCollection={editingCollection}
|
|
setEditingCollection={setEditingCollection}
|
|
editTagInput={editTagInput}
|
|
setEditTagInput={setEditTagInput}
|
|
onClose={() => {
|
|
setEditingCollection(null);
|
|
setEditTagInput('');
|
|
}}
|
|
onUpdate={handleUpdateCollection}
|
|
/>
|
|
</>
|
|
);
|
|
}
|