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 ( +
+ {Array.from({ length: FAN }).map((_, i) => { + const className = [ + "tarot-fan-card", + picked.includes(i) ? "is-picked" : "", + lifted === i ? "is-lifted" : "", + ] + .filter(Boolean) + .join(" "); + const style = { "--i": i - (FAN - 1) / 2 } as React.CSSProperties; + return onPick ? ( + + ) : ( + + + + ); + })} +
+ ); +} + +/** + * The places of the spread: empty, a face-down card (`filled`), or the drawn + * card turning over (the first `revealed` of `cards`). + */ +export function TarotSlots({ + count, + filled, + cards, + revealed, +}: { + count: number; + filled: number; + cards?: TarotReading["cards"]; + revealed: number; +}) { + return ( +
    + {Array.from({ length: count }).map((_, i) => { + const drawn = cards?.[i]; + const card = drawn && i < filled ? tarotCard(drawn.card) : undefined; + const flipped = !!card && i < revealed; + return ( +
  1. +
    + {i < filled ? ( +
    + + {card && } +
    + ) : ( + + {drawn?.position ?? `${i + 1}. lap`} + {flipped && card && ( + + {card.nameHu} + {drawn?.reversed ? " · fordított" : ""} + + )} +
  2. + ); + })} +
+ ); +} diff --git a/services/frontend/src/components/tarot/TarotTable.tsx b/services/frontend/src/components/tarot/TarotTable.tsx index 11024e7..9f44446 100644 --- a/services/frontend/src/components/tarot/TarotTable.tsx +++ b/services/frontend/src/components/tarot/TarotTable.tsx @@ -8,11 +8,10 @@ import { SPREADS, TAROT_QUESTION_MAX, tarotCard, type SpreadId, type TarotReadin import type { PayMethod, UnitBalance } from "@/lib/types"; import { PackageChooser } from "../PackageCards"; -import { TarotCard, TarotCardBack } from "./TarotCard"; +import { TarotCard } from "./TarotCard"; import { TarotLive } from "./TarotLive"; +import { TarotFan, TarotSlots } from "./TarotSpread"; -/** Face-down cards in the fan to pick from. */ -const FAN = 21; /** Pause between two cards turning over. */ const REVEAL_MS = 650; @@ -224,52 +223,9 @@ export function TarotTable({

-
    - {Array.from({ length: slots }).map((_, i) => { - const drawn = current?.cards[i]; - const card = drawn ? tarotCard(drawn.card) : undefined; - const flipped = !!card && i < revealed; - return ( -
  1. -
    - {i < picked.length || drawn ? ( -
    - - {card && } -
    - ) : ( - - {drawn?.position ?? `${i + 1}. lap`} - {flipped && card && ( - - {card.nameHu} - {drawn?.reversed ? " · fordított" : ""} - - )} -
  2. - ); - })} -
+ - {phase === "picking" && ( -
- {Array.from({ length: FAN }).map((_, i) => ( - - ))} -
- )} + {phase === "picking" && } {phase === "picking" && (