Compare commits

..

3 Commits

Author SHA1 Message Date
Gavin McDonald
fc0466ae89 flippable sheen 2025-07-03 16:38:53 -04:00
Gavin McDonald
22f949aaf8 gussy up Notes 2025-07-03 16:15:08 -04:00
Gavin McDonald
f0aee17ea0 fix default settings values 2025-07-03 15:54:34 -04:00
5 changed files with 124 additions and 38 deletions

View File

@@ -5,6 +5,7 @@ import { useAppContext } from '@/app/AppContext';
import TiltCard from '@/components/TiltCard';
import ToolTip from '@/components/ToolTip';
import StackTheDeck from '@/components/StackTheDeck';
import Sheen from '@/components/Sheen';
import getCardInfo from '@/tools/getCardInfo';
import getURL from '@/tools/getURL';
@@ -84,6 +85,7 @@ export default function Card({ card, cardIndex }: CardProps) {
onHover={setTooltip}
/>
)}
<Sheen cardIndex={cardIndex} />
</div>
<div className="absolute inset-0 backface-hidden rotate-y-180">
<img
@@ -91,6 +93,7 @@ export default function Card({ card, cardIndex }: CardProps) {
alt={aria}
className="rounded-lg border border-yellow-500/25 hover:drop-shadow-[0_0_3px_#ffd700/50]"
/>
<Sheen cardIndex={cardIndex} />
</div>
</div>
</TiltCard>

View File

@@ -1,7 +1,7 @@
'use client';
import { useMemo, useState } from 'react';
import { ScrollText } from 'lucide-react';
import { CircleX, ScrollText } from 'lucide-react';
import { useAppContext } from '@/app/AppContext';
import CopyButton from '@/components/CopyButton';
@@ -51,13 +51,24 @@ export default function Notes() {
className={`transition-all duration-250 ${showNotes ? 'pointer-events-auto opacity-100' : 'pointer-events-none opacity-0'}`}
>
<div
className={`fixed bottom-4 right-4 transition-all duration-250 bg-slate-800 border border-yellow-400 rounded-lg space-y-2 ${showNotes ? 'sm:w-[33vw] sm:h-[67vh] w-[80vw] h-[80vh]' : 'w-0 h-0'}`}
className={`
fixed bottom-4 right-4
transition-all duration-250
bg-slate-800
border border-yellow-400 rounded-lg
${showNotes ? 'sm:w-[50vw] sm:h-[67vh] w-[80vw] h-[80vh]' : 'w-0 h-0'}
`}
>
<CopyButton
copy={notes.map((note) => note!.join('\n')).join('\n\n')}
className="text-yellow-400 hover:drop-shadow-[0_0_1px_#ffd700] absolute top-2 right-2 p-2 transition-all duration-250 bg-black/20 hover:bg-black/40 rounded-full cursor-pointer"
className={`
absolute top-2 right-2
cursor-pointer p-2
transition-all duration-250
text-yellow-400 hover:text-yellow-300 hover:drop-shadow-[0_0_3px_#ffd700]
`}
/>
<div className="text-yellow-400 h-full overflow-scroll p-6 transition-all delay-200 duration-50 ${showNotes ? 'opacity-100' : 'opacity-0'}">
<div className="text-yellow-400 h-full overflow-scroll p-8 transition-all delay-200 duration-50 ${showNotes ? 'opacity-100' : 'opacity-0'}">
{notes.map((note, index) => (
<div key={index}>
<div className="flex flex-col gap-2">
@@ -70,6 +81,17 @@ export default function Notes() {
))}
</div>
</div>
<button
className={`
fixed bottom-4 right-4
cursor-pointer p-2
transition-all duration-250
text-yellow-400 hover:text-yellow-300 hover:drop-shadow-[0_0_3px_#ffd700]
`}
onClick={() => setOpen((prev) => !prev)}
>
<CircleX className="w-5 h-5" />
</button>
</Scrim>
</div>
);

88
components/Sheen.tsx Normal file
View File

@@ -0,0 +1,88 @@
import { useEffect, useRef, useState } from 'react';
import { useAppContext } from '@/app/AppContext';
const tiltSheen = (sheen: HTMLDivElement, tiltX: number, tiltY: number) => {
const rect = sheen.getBoundingClientRect();
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const sheenX = centerX + (tiltY / -20) * centerX;
const sheenY = centerY + (tiltX / 20) * centerY;
sheen.style.opacity = '1';
sheen.style.backgroundImage = `
radial-gradient(
circle at
${sheenX}px ${sheenY}px,
#ffffff44,
#0000000f
)
`;
};
export default function Sheen({ cardIndex, className }: { cardIndex: number; className?: string }) {
const sheenRef = useRef<HTMLDivElement>(null);
const [untilt, setUntilt] = useState(false);
const {
gameData,
settings: { tilt, remoteTilt },
tilt: localTilts,
} = useAppContext();
useEffect(() => {
const sheen = sheenRef.current;
if (!sheen) return;
if (tilt) {
const rotateX = localTilts[cardIndex]?.rotateX || 0;
const rotateY = localTilts[cardIndex]?.rotateY || 0;
const tilts = remoteTilt
? [...gameData.tilts[cardIndex], { rotateX, rotateY }]
: [{ rotateX, rotateY }];
const { totalX, totalY, count } = tilts
.filter(({ rotateX, rotateY }) => !!rotateX && !!rotateY)
.reduce(
({ totalX, totalY, count }, { rotateX, rotateY }) => ({
totalX: totalX + rotateX,
totalY: totalY + rotateY,
count: ++count,
}),
{ totalX: 0, totalY: 0, count: 0 },
);
if (count && (totalX || totalY)) {
setUntilt(false);
const x = totalX / count;
const y = totalY / count;
tiltSheen(sheen, x, y);
} else {
setUntilt(true);
}
} else {
setUntilt(true);
}
}, [tilt, localTilts, gameData]);
useEffect(() => {
const sheen = sheenRef.current;
if (!sheen || !untilt) return;
sheen.style.opacity = '0';
}, [untilt]);
return (
<div
ref={sheenRef}
className={`
absolute inset-0
rounded-lg pointer-events-none
transition-opacity duration-500
bg-gradient-to-tr from-transparent via-white/20 to-transparent mix-blend-screen opacity-0
${className}
`}
/>
);
}

View File

@@ -7,24 +7,6 @@ import type { Tilt } from '@/types';
const ZERO_ROTATION = 'rotateX(0deg) rotateY(0deg)';
const tiltSheen = (sheen: HTMLDivElement, tiltX: number, tiltY: number) => {
const rect = sheen.getBoundingClientRect();
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const sheenX = centerX + (tiltY / -20) * centerX;
const sheenY = centerY + (tiltX / 20) * centerY;
sheen.style.opacity = '1';
sheen.style.backgroundImage = `
radial-gradient(
circle at
${sheenX}px ${sheenY}px,
#ffffff44,
#0000000f
)
`;
};
export default function TiltCard({
children,
cardIndex,
@@ -35,7 +17,6 @@ export default function TiltCard({
className?: string;
}) {
const cardRef = useRef<HTMLDivElement>(null);
const sheenRef = useRef<HTMLDivElement>(null);
const [untilt, setUntilt] = useState(false);
const {
gameData,
@@ -46,8 +27,7 @@ export default function TiltCard({
useEffect(() => {
const card = cardRef.current;
const sheen = sheenRef.current;
if (!card || !sheen) return;
if (!card) return;
if (tilt) {
const rotateX = localTilts[cardIndex]?.rotateX || 0;
@@ -75,7 +55,6 @@ export default function TiltCard({
const y = totalY / count;
card.style.transform = `rotateX(${x}deg) rotateY(${y}deg)`;
tiltSheen(sheen, x, y);
} else {
setUntilt(true);
}
@@ -86,11 +65,9 @@ export default function TiltCard({
useEffect(() => {
const card = cardRef.current;
const sheen = sheenRef.current;
if (!card || !sheen || !untilt) return;
if (!card || !untilt) return;
card.style.transform = ZERO_ROTATION;
sheen.style.opacity = '0';
}, [untilt]);
const handleMouseMove = throttle((e: React.MouseEvent) => {
@@ -128,10 +105,6 @@ export default function TiltCard({
className={`h-full w-full transition-transform ${untilt ? 'duration-500' : 'duration-0'}`}
>
{children}
<div
ref={sheenRef}
className="pointer-events-none absolute inset-0 rounded-lg bg-gradient-to-tr from-transparent via-white/20 to-transparent mix-blend-screen opacity-0 transition-opacity duration-500"
/>
</div>
</div>
);

View File

@@ -7,12 +7,12 @@ import type { GameUpdate, LocalSettings, Settings } from '@/types';
export const SETTINGS: Settings = {
cardStyle: 'color',
notes: false,
positionBack: false,
positionFront: false,
prophecy: false,
notes: true,
positionBack: true,
positionFront: true,
prophecy: true,
tilt: true,
remoteTilt: false,
remoteTilt: true,
};
export const GAME_START: GameUpdate = {