stack-the-deck (#1)
Allow for redrawing or explicitly selecting a card for replacement. Co-authored-by: Gavin McDonald <gavinmcdoh@gmail.com> Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import ToolTip from '@/components/ToolTip';
|
||||
import StackTheDeck from '@/components/StackTheDeck';
|
||||
import tarokkaCards from '@/constants/tarokkaCards';
|
||||
import getCardInfo from '@/tools/getCardInfo';
|
||||
import getURL from '@/tools/getURL';
|
||||
@@ -15,9 +17,21 @@ type CardProps = {
|
||||
position: Layout;
|
||||
settings: Settings;
|
||||
flipAction: () => void;
|
||||
redrawAction: () => void;
|
||||
selectAction: () => void;
|
||||
};
|
||||
|
||||
export default function Card({ dm, card, position, settings, flipAction }: CardProps) {
|
||||
export default function Card({
|
||||
dm,
|
||||
card,
|
||||
position,
|
||||
settings,
|
||||
flipAction,
|
||||
redrawAction,
|
||||
selectAction,
|
||||
}: CardProps) {
|
||||
const [tooltip, setTooltip] = useState<React.ReactNode>(null);
|
||||
|
||||
const { aria, flipped } = card;
|
||||
|
||||
const handleClick = () => {
|
||||
@@ -42,22 +56,39 @@ export default function Card({ dm, card, position, settings, flipAction }: CardP
|
||||
};
|
||||
|
||||
return (
|
||||
<ToolTip content={getTooltip()}>
|
||||
<ToolTip content={tooltip || getTooltip()}>
|
||||
<div
|
||||
className={`relative h-[21vh] w-[15vh] perspective transition-transform duration-200 hover:scale-150 z-0 hover:z-10 ${dm ? 'cursor-pointer' : ''} `}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<div
|
||||
className={`transition-transform duration-500 transform-style-preserve-3d ${flipped ? 'rotate-y-180' : ''}`}
|
||||
className={`absolute inset-0 transition-transform duration-500 transform-style-preserve-3d ${flipped ? 'rotate-y-180' : ''}`}
|
||||
>
|
||||
<div className="absolute group inset-0 backface-hidden">
|
||||
<div className="absolute inset-0 group backface-hidden">
|
||||
{dm && (
|
||||
<>
|
||||
<img src={getURL(card, settings)} alt={aria} className="absolute rounded-lg" />
|
||||
<img
|
||||
src={getURL(cardBack as TarokkaGameCard, settings)}
|
||||
alt=""
|
||||
className={`absolute rounded-lg see-through`}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<img
|
||||
src={getURL(cardBack as TarokkaGameCard, settings)}
|
||||
alt="Card Back"
|
||||
className={`rounded-lg ${settings.cardStyle === 'grayscale' ? 'border border-yellow-500/25 hover:drop-shadow-[0_0_3px_#ffd700/50]' : ''}`}
|
||||
className={`absolute rounded-lg ${dm ? 'transition duration-500 group-hover:opacity-0' : ''} ${settings.cardStyle === 'grayscale' ? 'border border-yellow-500/25 group-hover:drop-shadow-[0_0_3px_#ffd700/50]' : ''}`}
|
||||
/>
|
||||
{dm && !flipped && (
|
||||
<StackTheDeck
|
||||
onRedraw={redrawAction}
|
||||
onSelect={() => selectAction()}
|
||||
onHover={setTooltip}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="absolute group inset-0 backface-hidden rotate-y-180">
|
||||
<div className="absolute inset-0 backface-hidden rotate-y-180">
|
||||
<img
|
||||
src={getURL(card, settings)}
|
||||
alt={aria}
|
||||
|
||||
Reference in New Issue
Block a user