From 2e2e4b113d4c07532a18fdd8f2d0fd296043e1cd Mon Sep 17 00:00:00 2001
From: feco
Date: Fri, 20 Nov 2026 15:51:23 +0000
Subject: [PATCH] Tarot example: the draw played as an animation, and a love
reading
The example page now plays each reading: cards are picked from the
fanned deck, laid out and turned over, then the written reading
appears below. A second example, a five-card love reading, sits next
to the work one in a tab. The fan and the spread are shared with the
real draw (TarotSpread).
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
---
docs/kartyajoslas.md | 2 +-
services/frontend/src/app/globals.css | 13 +-
.../src/app/kartyajoslas/pelda/page.tsx | 20 +--
.../src/components/tarot/TarotDemo.tsx | 102 ++++++++++++
.../src/components/tarot/TarotSpread.tsx | 106 +++++++++++++
.../src/components/tarot/TarotTable.tsx | 52 +------
.../frontend/src/content/tarot-pelda.json | 146 +++++++++++++-----
7 files changed, 339 insertions(+), 102 deletions(-)
create mode 100644 services/frontend/src/components/tarot/TarotDemo.tsx
create mode 100644 services/frontend/src/components/tarot/TarotSpread.tsx
diff --git a/docs/kartyajoslas.md b/docs/kartyajoslas.md
index 0ec02a0..95a92a1 100644
--- a/docs/kartyajoslas.md
+++ b/docs/kartyajoslas.md
@@ -1,6 +1,6 @@
# Kártyajóslás
-A `/kartyajoslas` oldalon a felhasználó kirakást választ, opcionálisan kérdést ír (legfeljebb 300 karakter), és a legyezőbe terített, lefordított pakliból kiválasztja a lapokat. Ezután a lapok sorban felfordulnak, és elkészül a személyre szabott jóslás. A korábbi jóslások ugyanitt listázódnak, egyenként a `/kartyajoslas/{id}` oldalon nyithatók meg. A nyilvános példa a `/kartyajoslas/pelda` oldalon van (`src/content/tarot-pelda.json`).
+A `/kartyajoslas` oldalon a felhasználó kirakást választ, opcionálisan kérdést ír (legfeljebb 300 karakter), és a legyezőbe terített, lefordított pakliból kiválasztja a lapokat. Ezután a lapok sorban felfordulnak, és elkészül a személyre szabott jóslás. A korábbi jóslások ugyanitt listázódnak, egyenként a `/kartyajoslas/{id}` oldalon nyithatók meg. A nyilvános példaoldal (`/kartyajoslas/pelda`) két előre megírt jóslást mutat fülekkel, egy munkáról (3 lap) és egy szerelemről (Képlet-kereszt, 5 lap). Mindkettőnél animáció játssza le a húzást: lapválasztás a legyezőből, kirakás, felfordítás, végül megjelenik a szöveg (`src/components/tarot/TarotDemo.tsx`, a szövegek: `src/content/tarot-pelda.json`). Mozgáscsökkentő beállításnál rögtön a végállapot látszik.
## Működés
diff --git a/services/frontend/src/app/globals.css b/services/frontend/src/app/globals.css
index f1c60d2..c983145 100644
--- a/services/frontend/src/app/globals.css
+++ b/services/frontend/src/app/globals.css
@@ -1007,6 +1007,17 @@ a.pair-row:hover strong { color: var(--gold); }
.tarot-fan-card .tarot-card { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4); }
.tarot-fan-card:hover:not(:disabled), .tarot-fan-card:focus-visible { transform: rotate(calc(var(--i) * var(--step))) translateY(-14px); }
.tarot-fan-card.is-picked { opacity: 0; transform: rotate(calc(var(--i) * var(--step))) translateY(-60px); cursor: default; }
+.tarot-fan-card { animation: tarot-deal 0.7s cubic-bezier(0.3, 0.7, 0.3, 1) backwards; }
+@keyframes tarot-deal { from { transform: rotate(0deg); } }
+span.tarot-fan-card { cursor: default; }
+.tarot-fan-card.is-lifted { transform: rotate(calc(var(--i) * var(--step))) translateY(-26px); }
+.tarot-fan-card.is-lifted .tarot-card { box-shadow: 0 0 0 1px var(--gold), 0 10px 26px rgba(217, 180, 106, 0.35); }
+
+/* The example page: a reading played from the deck to the text. */
+.tarot-demo { display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }
+.tarot-demo-status { text-align: center; min-height: 36px; display: flex; align-items: center; justify-content: center; }
+.tarot-demo-text { max-height: 0; overflow: hidden; opacity: 0; transform: translateY(16px); }
+.tarot-demo-text.is-shown { max-height: none; overflow: visible; opacity: 1; transform: none; transition: opacity 0.8s ease, transform 0.8s ease; }
.tarot-result { display: flex; flex-direction: column; gap: 28px; }
.tarot-result-head { display: flex; flex-direction: column; gap: 10px; }
@@ -1034,5 +1045,5 @@ a.pair-row:hover strong { color: var(--gold); }
.tarot-history-cards .tarot-card-xs:nth-child(n + 4) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
- .tarot-flip-inner, .tarot-fan-card { transition: none; animation: none; }
+ .tarot-flip-inner, .tarot-fan-card, .tarot-demo-text { transition: none; animation: none; }
}
diff --git a/services/frontend/src/app/kartyajoslas/pelda/page.tsx b/services/frontend/src/app/kartyajoslas/pelda/page.tsx
index 8e52421..e38501b 100644
--- a/services/frontend/src/app/kartyajoslas/pelda/page.tsx
+++ b/services/frontend/src/app/kartyajoslas/pelda/page.tsx
@@ -2,14 +2,14 @@ import type { Metadata } from "next";
import Link from "next/link";
import { PublicHeader } from "@/components/SiteHeader";
-import { TarotResult } from "@/components/tarot/TarotResult";
-import example from "@/content/tarot-pelda.json";
+import { TarotDemo, type TarotExample } from "@/components/tarot/TarotDemo";
+import data from "@/content/tarot-pelda.json";
import { getMe } from "@/lib/server";
-import type { TarotContent, TarotReading } from "@/lib/tarot";
export const metadata: Metadata = {
title: "Példajóslás",
- description: "Így néz ki egy Sorsfonalak-kártyajóslás: három lap egy kitalált kérdésre, személyre szabott értelmezéssel.",
+ description:
+ "Így néz ki egy Sorsfonalak-kártyajóslás: lapválasztás a pakliból, kirakás és személyre szabott értelmezés, munkáról és szerelemről.",
};
/** A full example tarot reading for a made-up question, for visitors and users without readings. */
@@ -23,17 +23,11 @@ export default async function TarotExamplePage() {
Példajóslás
Így néz ki egy kártyajóslás
- A kérdés és a képlet kitalált ({example.signs}), a kirakás: {example.spread_name}. A saját jóslásod a te
- kérdésedre, a te lapjaidra és a képletedre készül.
+ Két kitalált kérdés, két kirakás: nézd meg, hogyan választ a pakliból, hogyan fordulnak fel a lapok, és mit
+ mondanak együtt. A saját jóslásod a te kérdésedre, a te lapjaidra és a képletedre készül.
-
-
-
+
{me
diff --git a/services/frontend/src/components/tarot/TarotDemo.tsx b/services/frontend/src/components/tarot/TarotDemo.tsx
new file mode 100644
index 0000000..cdac994
--- /dev/null
+++ b/services/frontend/src/components/tarot/TarotDemo.tsx
@@ -0,0 +1,102 @@
+"use client";
+
+import { useEffect, useState } from "react";
+
+import type { TarotContent, TarotReading } from "@/lib/tarot";
+
+import { TarotResult } from "./TarotResult";
+import { TarotFan, TarotSlots } from "./TarotSpread";
+
+export interface TarotExample {
+ id: string;
+ label: string;
+ signs: string;
+ spread_name: string;
+ question: string;
+ cards: TarotReading["cards"];
+ content: TarotContent;
+}
+
+/** The fan cards the demo "picks", in order. */
+const PICKS = [4, 13, 8, 17, 2];
+
+/**
+ * Plays a reading: the cards are picked from the fanned deck one by one,
+ * laid out, turned over, then the written reading appears below. The text is
+ * on the page from the start (hidden while the animation plays).
+ */
+function Demo({ example }: { example: TarotExample }) {
+ const n = example.cards.length;
+ const done = 3 * n + 2;
+ const [step, setStep] = useState(0);
+
+ // Without motion the end state shows at once.
+ useEffect(() => {
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) setStep(done);
+ }, [done]);
+
+ useEffect(() => {
+ if (step >= done) return;
+ const picking = step <= 2 * n;
+ const delay = step === 0 ? 900 : picking ? (step % 2 === 1 ? 420 : 520) : 680;
+ const t = setTimeout(() => setStep((s) => s + 1), delay);
+ return () => clearTimeout(t);
+ }, [step, done, n]);
+
+ const pickedCount = Math.min(n, Math.floor(step / 2));
+ const lifted = step % 2 === 1 && step < 2 * n ? PICKS[(step - 1) / 2] : null;
+ const revealed = Math.max(0, Math.min(n, step - (2 * n + 1)));
+ const finished = step >= done;
+
+ return (
+
+
+ {example.spread_name}
+
„{example.question}”
+
A kérdés és a képlet kitalált ({example.signs}).
+
+
+ {!finished && }
+
+ {finished ? (
+
+ ) : pickedCount < n ? (
+ `Lapválasztás a pakliból: ${pickedCount}/${n}`
+ ) : (
+ "A lapok felfordulnak…"
+ )}
+
+
+
+
+
+ );
+}
+
+/** The example readings, one tab each. */
+export function TarotDemo({ examples }: { examples: TarotExample[] }) {
+ const [active, setActive] = useState(examples[0]?.id);
+ const example = examples.find((e) => e.id === active) ?? examples[0];
+ if (!example) return null;
+ return (
+
+
+ {examples.map((e) => (
+
+ ))}
+
+
+
+ );
+}
diff --git a/services/frontend/src/components/tarot/TarotSpread.tsx b/services/frontend/src/components/tarot/TarotSpread.tsx
new file mode 100644
index 0000000..7f591f9
--- /dev/null
+++ b/services/frontend/src/components/tarot/TarotSpread.tsx
@@ -0,0 +1,106 @@
+"use client";
+
+import { tarotCard, type TarotReading } from "@/lib/tarot";
+
+import { TarotCard, TarotCardBack } from "./TarotCard";
+
+/** Face-down cards in the fan to pick from. */
+export const FAN = 21;
+
+/**
+ * The shuffled deck fanned out. With `onPick` the cards are buttons; without
+ * it (the demo) they are only a picture, and `lifted` is the card about to go.
+ */
+export function TarotFan({
+ picked,
+ lifted,
+ onPick,
+}: {
+ picked: number[];
+ lifted?: number | null;
+ onPick?: (i: number) => void;
+}) {
+ return (
+