Skip to content

Commit

Permalink
docs(core): remember card flips (nrwl#21041)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacplmann committed Jan 8, 2024
1 parent 16f2e17 commit 30e8e37
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions nx-dev/ui-common/src/lib/flip-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ export function FlipCard({
onClick?: () => void;
children: ReactNode;
}) {
const [flipped, setFlipped] = useState(() => isFlipped);

return (
<FlipCardContext.Provider value={{ fullDate: fullDate || '', onClick }}>
<span
onClick={(event) => {
if (isFlippable && !flipped) {
setFlipped(true);
if (isFlippable && !isFlipped) {
onFlip && onFlip(day, true);
event.preventDefault();
} else {
Expand All @@ -42,15 +39,17 @@ export function FlipCard({
}}
className={cx(
'block group perspective',
isFlippable && !flipped ? 'cursor-pointer' : 'cursor-default'
isFlippable && !isFlipped ? 'cursor-pointer' : 'cursor-default'
)}
>
<div
className={cx(
'relative preserve-3d transition w-full h-full duration-200 content-center rounded-lg border-2 shadow-sm focus-within:ring-offset-2 bg-white/60 dark:bg-slate-800/90',
flipped ? 'my-rotate-y-180 bg-white dark:bg-slate-800' : '',
isFlippable && isFlipped
? 'my-rotate-y-180 bg-white dark:bg-slate-800'
: '',
isFlippable
? flipped
? isFlipped
? 'border-blue-400 dark:border-slate-800'
: 'border-blue-400 dark:border-slate-800 hover:[transform:rotateY(10deg)]'
: 'border-1 border-slate-300 dark:border-slate-800'
Expand Down

0 comments on commit 30e8e37

Please sign in to comment.