🔗 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 { useState } from 'react';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
|
|
||||||
export default function CardItem({
|
export default function CardItem({
|
||||||
card,
|
card,
|
||||||
|
|
@ -11,6 +12,7 @@ export default function CardItem({
|
||||||
isFavorited = false
|
isFavorited = false
|
||||||
}) {
|
}) {
|
||||||
const [imageError, setImageError] = useState(false);
|
const [imageError, setImageError] = useState(false);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const handleSelectChange = (e) => {
|
const handleSelectChange = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
@ -21,6 +23,14 @@ export default function CardItem({
|
||||||
setImageError(true);
|
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
|
// Get rarity-based styling
|
||||||
const getRarityEffects = (rarity) => {
|
const getRarityEffects = (rarity) => {
|
||||||
const rarityLower = rarity?.toLowerCase() || '';
|
const rarityLower = rarity?.toLowerCase() || '';
|
||||||
|
|
@ -67,11 +77,14 @@ export default function CardItem({
|
||||||
|
|
||||||
if (viewMode === 'list') {
|
if (viewMode === 'list') {
|
||||||
return (
|
return (
|
||||||
<div className={`flex items-center p-4 border rounded-lg transition-all duration-200 ${
|
<div
|
||||||
isSelected
|
className={`flex items-center p-4 border rounded-lg transition-all duration-200 cursor-pointer ${
|
||||||
? 'border-purple-500 bg-purple-50 shadow-md'
|
isSelected
|
||||||
: 'border-gray-200 hover:border-gray-300 hover:shadow-sm'
|
? 'border-purple-500 bg-purple-50 shadow-md'
|
||||||
}`}>
|
: 'border-gray-200 hover:border-gray-300 hover:shadow-sm'
|
||||||
|
}`}
|
||||||
|
onClick={handleCardClick}
|
||||||
|
>
|
||||||
{/* Selection Checkbox */}
|
{/* Selection Checkbox */}
|
||||||
<div className="flex-shrink-0 mr-4">
|
<div className="flex-shrink-0 mr-4">
|
||||||
<input
|
<input
|
||||||
|
|
@ -175,11 +188,14 @@ export default function CardItem({
|
||||||
isSelected ? 'selected scale-105' : ''
|
isSelected ? 'selected scale-105' : ''
|
||||||
}`}>
|
}`}>
|
||||||
{/* Main Card Container */}
|
{/* Main Card Container */}
|
||||||
<div className={`relative bg-white rounded-xl border transition-all duration-300 overflow-hidden ${
|
<div
|
||||||
isSelected
|
className={`relative bg-white rounded-xl border transition-all duration-300 overflow-hidden cursor-pointer ${
|
||||||
? 'border-purple-500 shadow-xl ring-2 ring-purple-200'
|
isSelected
|
||||||
: `${rarityEffects.border} group-hover:border-gray-300 group-hover:shadow-lg ${rarityEffects.shadow ? `shadow-lg ${rarityEffects.shadow}` : ''}`
|
? 'border-purple-500 shadow-xl ring-2 ring-purple-200'
|
||||||
} ${rarityEffects.glow}`}>
|
: `${rarityEffects.border} group-hover:border-gray-300 group-hover:shadow-lg ${rarityEffects.shadow ? `shadow-lg ${rarityEffects.shadow}` : ''}`
|
||||||
|
} ${rarityEffects.glow}`}
|
||||||
|
onClick={handleCardClick}
|
||||||
|
>
|
||||||
|
|
||||||
{/* Rarity Particles */}
|
{/* Rarity Particles */}
|
||||||
{rarityEffects.particles && (
|
{rarityEffects.particles && (
|
||||||
|
|
@ -441,7 +457,7 @@ export default function CardItem({
|
||||||
<button
|
<button
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
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"
|
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"
|
title="View Details"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue