🔗 Added Card Click Navigation to Detail Pages
✨ Card Navigation Features: - Click anywhere on card to navigate to detail page - Smart click detection avoids interference with interactive elements - Works in both grid and list view modes - Cursor pointer indicates clickable areas 🎯 Interaction Improvements: - Checkbox, buttons, and links don't trigger navigation - Side panel 'View Details' button uses same-tab navigation - Consistent behavior across all card interactions - Smooth user experience for card browsing 🚀 User Experience: - Natural card browsing workflow - Easy access to detailed card information - Maintains all existing functionality (selection, actions) - Professional click handling with event delegation Cards are now fully interactive - click to explore! 🃏✨
This commit is contained in:
parent
5d7a87374f
commit
a9c94b811f
1 changed files with 27 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
export default function CardItem({
|
||||
card,
|
||||
|
|
@ -11,6 +12,7 @@ export default function CardItem({
|
|||
isFavorited = false
|
||||
}) {
|
||||
const [imageError, setImageError] = useState(false);
|
||||
const router = useRouter();
|
||||
|
||||
const handleSelectChange = (e) => {
|
||||
e.stopPropagation();
|
||||
|
|
@ -21,6 +23,14 @@ export default function CardItem({
|
|||
setImageError(true);
|
||||
};
|
||||
|
||||
const handleCardClick = (e) => {
|
||||
// Don't navigate if clicking on interactive elements
|
||||
if (e.target.closest('input, button, a')) {
|
||||
return;
|
||||
}
|
||||
router.push(`/card/${card.id}`);
|
||||
};
|
||||
|
||||
// Get rarity-based styling
|
||||
const getRarityEffects = (rarity) => {
|
||||
const rarityLower = rarity?.toLowerCase() || '';
|
||||
|
|
@ -67,11 +77,14 @@ export default function CardItem({
|
|||
|
||||
if (viewMode === 'list') {
|
||||
return (
|
||||
<div className={`flex items-center p-4 border rounded-lg transition-all duration-200 ${
|
||||
isSelected
|
||||
? 'border-purple-500 bg-purple-50 shadow-md'
|
||||
: 'border-gray-200 hover:border-gray-300 hover:shadow-sm'
|
||||
}`}>
|
||||
<div
|
||||
className={`flex items-center p-4 border rounded-lg transition-all duration-200 cursor-pointer ${
|
||||
isSelected
|
||||
? 'border-purple-500 bg-purple-50 shadow-md'
|
||||
: 'border-gray-200 hover:border-gray-300 hover:shadow-sm'
|
||||
}`}
|
||||
onClick={handleCardClick}
|
||||
>
|
||||
{/* Selection Checkbox */}
|
||||
<div className="flex-shrink-0 mr-4">
|
||||
<input
|
||||
|
|
@ -175,11 +188,14 @@ export default function CardItem({
|
|||
isSelected ? 'selected scale-105' : ''
|
||||
}`}>
|
||||
{/* Main Card Container */}
|
||||
<div className={`relative bg-white rounded-xl border transition-all duration-300 overflow-hidden ${
|
||||
isSelected
|
||||
? 'border-purple-500 shadow-xl ring-2 ring-purple-200'
|
||||
: `${rarityEffects.border} group-hover:border-gray-300 group-hover:shadow-lg ${rarityEffects.shadow ? `shadow-lg ${rarityEffects.shadow}` : ''}`
|
||||
} ${rarityEffects.glow}`}>
|
||||
<div
|
||||
className={`relative bg-white rounded-xl border transition-all duration-300 overflow-hidden cursor-pointer ${
|
||||
isSelected
|
||||
? 'border-purple-500 shadow-xl ring-2 ring-purple-200'
|
||||
: `${rarityEffects.border} group-hover:border-gray-300 group-hover:shadow-lg ${rarityEffects.shadow ? `shadow-lg ${rarityEffects.shadow}` : ''}`
|
||||
} ${rarityEffects.glow}`}
|
||||
onClick={handleCardClick}
|
||||
>
|
||||
|
||||
{/* Rarity Particles */}
|
||||
{rarityEffects.particles && (
|
||||
|
|
@ -441,7 +457,7 @@ export default function CardItem({
|
|||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
window.open(`/card/${card.id}`, '_blank');
|
||||
router.push(`/card/${card.id}`);
|
||||
}}
|
||||
className="flex items-center justify-center p-2 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors"
|
||||
title="View Details"
|
||||
|
|
|
|||
Loading…
Reference in a new issue