Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions apps/game/src/components/end-play-cta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { cn } from "@repo/nativ/utils"
import { Link } from "@tanstack/react-router"
import type { ReactNode } from "react"
import { useTranslation } from "react-i18next"
import { BotFace } from "@/components/bot-face"
import {
PLAY_BUTTON_CLASS,
TEXT_LINK_CLASS,
} from "@/components/play-block"
import { COMPUTER_GAME } from "@/hooks/use-play-actions"
import { BOT_LEVELS } from "@/i18n/bots"

export type EndPlayCtaProps = {
/** The headline's anchor: the id the page's last chapter had, so the old link still lands here. */
id: string
/** What the page just taught, as a reason to play it. */
headline: string
/** The button's label: it opens the computer game. */
cta: string
/** The link's label: it goes home, to the choice of ways to play. */
more: string
/** Reading that belongs to the end of the page, under the panel. */
children?: ReactNode
}

/**
* The end of a guide: one block that asks the reader to play (the `design`
* document on TUD-5812, §2).
*
* The hero's `PlayBlock` is the same button, so at the end of the article it
* read as one more chapter. This one stops the reader: the eight bots say
* somebody is waiting, the headline says what to try, and the line under the
* button says it costs nothing and asks for no account.
*
* Not a `Chapter`: it has no number and no hairline of its own on a phone. The
* panel is a band from edge to edge there, where the button keeps one line at
* 320, and a card from `sm`. The page's column pads by 20px up to `sm`, which
* is what the band's negative margin takes back.
*
* Static and a plain link, so it works before the page has hydrated.
*/
export function EndPlayCta({
id,
headline,
cta,
more,
children,
}: EndPlayCtaProps) {
const { t } = useTranslation()

return (
<section
data-end-cta
aria-labelledby={id}
className="py-10 sm:border-t sm:border-border sm:py-16"
>
<div
data-end-cta-panel
className="-mx-5 flex flex-col gap-4 border-y border-border bg-surface px-5 py-7 sm:mx-0 sm:max-w-[62ch] sm:gap-5 sm:rounded-2xl sm:border sm:p-8"
>
{/* The eight of them: "eight bots" is a claim, the faces are the
evidence. Overlapped, and the row padded by the overlap so the last
face's tail does not push the caption off. */}
<div className="flex flex-wrap items-center gap-x-2.5 gap-y-1.5">
<div className="flex pe-2">
{BOT_LEVELS.map((level) => (
<BotFace
key={level}
level={level}
className="-me-2 ring-2 ring-surface"
/>
))}
</div>
<span className="text-sm text-faint">
{t("common:home.bots_caption")}
</span>
</div>

<h2
id={id}
className="scroll-mt-6 pb-0.5 font-display text-2xl leading-[1.2] font-bold text-balance text-foreground lg:text-[30px] lg:leading-[1.15]"
>
{headline}
</h2>

{/* One column on a phone: the button, the trust line, the link. From
`sm` the button and the link are a row and the trust line is under
both, which is why the three are placed rather than flowed. */}
<div className="flex flex-col gap-y-1 sm:grid sm:grid-cols-[auto_1fr] sm:items-center sm:gap-x-6 sm:gap-y-4">
<Link
{...COMPUTER_GAME}
className={cn(
PLAY_BUTTON_CLASS,
//20px a side under `sm`: "Play against the computer" is 238px
//wide and the band's button is 280, so it keeps one line at 320
"px-5 sm:col-start-1 sm:row-start-1 sm:px-8",
)}
>
{cta}
</Link>
<p className="py-2 text-center text-[15px] text-subtle sm:col-span-2 sm:row-start-2 sm:py-0 sm:text-left">
{t("game:end_cta.trust")}
</p>
<Link
to="/"
className={cn(
TEXT_LINK_CLASS,
"inline-flex min-h-11 items-center self-center sm:col-start-2 sm:row-start-1 sm:justify-self-start",
)}
>
{more}
</Link>
</div>
</div>

{children && (
<div className="mt-6 max-w-[62ch] text-base leading-[1.7] text-pretty text-subtle lg:text-[17px]">
{children}
</div>
)}
</section>
)
}
13 changes: 8 additions & 5 deletions apps/game/src/components/play-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import { Link } from "@tanstack/react-router"
import { buttonClassName } from "@/components/ui/button"
import { COMPUTER_GAME } from "@/hooks/use-play-actions"

const TEXT_LINK_CLASS =
export const TEXT_LINK_CLASS =
"font-semibold text-brand-light underline underline-offset-2 hover:text-white"

/** The computer-game button: a thumb wide on a phone, as wide as its label from `sm`. */
export const PLAY_BUTTON_CLASS = cn(
buttonClassName("primary", "lg"),
"h-auto min-h-[54px] w-full py-3 text-center text-balance sm:w-auto sm:px-8",
)

export type PlayBlockProps = {
/** The button's label: it opens the computer game. */
cta: string
Expand Down Expand Up @@ -44,10 +50,7 @@ export function PlayBlock({
moreLink = { to: "/" },
onPlay,
}: PlayBlockProps) {
const ctaClassName = cn(
buttonClassName("primary", "lg"),
"h-auto min-h-[54px] w-full py-3 text-center text-balance sm:w-auto sm:px-8",
)
const ctaClassName = PLAY_BUTTON_CLASS

return (
<div className="flex flex-col gap-y-1 sm:flex-row sm:items-center sm:gap-x-6">
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/de/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@
"moves_one": "{{count}} Zug",
"moves_other": "{{count}} Züge"
},
"end_cta": {
"trust": "Kostenlos, ohne Anmeldung, ohne Download.",
"rules": "Probiere die Regeln in einer echten Partie",
"strategy": "Probiere diese Tipps in einer echten Partie",
"openings": "Probiere diese Eröffnungen in einer echten Partie",
"positions": "Probiere diese Aufstellungen in einer echten Partie"
},
"rules": {
"title": "So wird gespielt",
"title": "Regeln",
"heading": "Abalone-Regeln: so wird gespielt",
"intro": "Abalone ist ein Strategiespiel für zwei Personen auf einem sechseckigen Brett. Jede Seite hat 14 Kugeln. Du gewinnst, wenn du sechs Kugeln deines Gegners vom Brett schiebst. Diese Seite erklärt jede Regel. Wenn du bereit bist, <online>spiele Abalone online</online> oder <offline>probiere es gegen den Computer</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/en/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"moves_other": "{{count}} moves"
},
"rules": {
"title": "How to play",
"title": "Rules",
"heading": "Abalone rules: how to play",
"intro": "You play Abalone by taking turns to move up to three marbles one space. A bigger group can push a smaller one. Push six of your opponent's marbles off the board to win. When you are ready, <online>play Abalone online</online> or <offline>try it against the computer</offline>.",
"goal": {
Expand Down Expand Up @@ -606,5 +606,12 @@
"more": "Other ways to play"
},
"rules_link": "New to the game? Follow <howto>how to play Abalone</howto> step by step."
},
"end_cta": {
"trust": "Free, no sign-up, no download.",
"rules": "Try the rules in a real game",
"strategy": "Try these tips in a real game",
"openings": "Try these openings in a real game",
"positions": "Try these layouts in a real game"
}
}
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/es/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@
"moves_one": "{{count}} jugada",
"moves_other": "{{count}} jugadas"
},
"end_cta": {
"trust": "Gratis, sin registro, sin descargas.",
"rules": "Prueba las reglas en una partida real",
"strategy": "Prueba estos consejos en una partida real",
"openings": "Prueba estas aperturas en una partida real",
"positions": "Prueba estas posiciones en una partida real"
},
"rules": {
"title": "Cómo jugar",
"title": "Reglas",
"heading": "Reglas de Abalone: cómo jugar",
"intro": "Abalone es un juego de estrategia para dos jugadores en un tablero hexagonal. Cada jugador tiene 14 bolas. Ganas si empujas seis bolas del rival fuera del tablero. Esta página explica todas las reglas. Cuando estés listo, <online>juega a Abalone en línea</online> o <offline>pruébalo contra el ordenador</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/fr/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@
"moves_one": "{{count}} coup",
"moves_other": "{{count}} coups"
},
"end_cta": {
"trust": "Gratuit, sans inscription, sans téléchargement.",
"rules": "Essayez les règles dans une vraie partie",
"strategy": "Essayez ces conseils dans une vraie partie",
"openings": "Essayez ces ouvertures dans une vraie partie",
"positions": "Essayez ces dispositions dans une vraie partie"
},
"rules": {
"title": "Comment jouer",
"title": "Règles",
"heading": "Règles d'Abalone : comment jouer",
"intro": "Abalone est un jeu de stratégie pour deux joueurs sur un plateau hexagonal. Chaque joueur a 14 billes. Tu gagnes en poussant six billes adverses hors du plateau. Cette page explique toutes les règles. Quand tu es prêt, <online>joue à Abalone en ligne</online> ou <offline>essaie contre l'ordinateur</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/hi/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@
"moves_one": "{{count}} चाल",
"moves_other": "{{count}} चालें"
},
"end_cta": {
"trust": "मुफ़्त, साइन-अप के बिना, डाउनलोड के बिना।",
"rules": "नियमों को असली खेल में आज़माएँ",
"strategy": "इन सुझावों को असली खेल में आज़माएँ",
"openings": "इन शुरुआती चालों को असली खेल में आज़माएँ",
"positions": "इन शुरुआती जमावटों को असली खेल में आज़माएँ"
},
"rules": {
"title": "कैसे खेलें",
"title": "नियम",
"heading": "Abalone के नियम: कैसे खेलें",
"intro": "Abalone षट्कोणीय बोर्ड पर दो खिलाड़ियों का रणनीति वाला खेल है। हर खिलाड़ी के पास 14 गोलियाँ होती हैं। विरोधी की छह गोलियाँ बोर्ड से बाहर धकेलकर आप जीतते हैं। यह पेज हर नियम समझाता है। जब आप तैयार हों, <online>Abalone ऑनलाइन खेलें</online> या <offline>कंप्यूटर के खिलाफ आज़माएँ</offline>।",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/it/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@
"moves_one": "{{count}} mossa",
"moves_other": "{{count}} mosse"
},
"end_cta": {
"trust": "Gratis, senza registrazione, senza download.",
"rules": "Prova le regole in una partita vera",
"strategy": "Prova questi consigli in una partita vera",
"openings": "Prova queste aperture in una partita vera",
"positions": "Prova queste disposizioni in una partita vera"
},
"rules": {
"title": "Come si gioca",
"title": "Regole",
"heading": "Regole di Abalone: come si gioca",
"intro": "Abalone è un gioco di strategia per due giocatori su una scacchiera esagonale. Ogni giocatore ha 14 biglie. Vinci spingendo sei biglie avversarie fuori dal tabellone. Questa pagina spiega ogni regola. Quando sei pronto, <online>gioca ad Abalone online</online> oppure <offline>prova contro il computer</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/ja/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@
"game_over": "対局終了",
"moves": "{{count}}手"
},
"end_cta": {
"trust": "無料、登録不要、ダウンロード不要。",
"rules": "ルールを実際の対局で試そう",
"strategy": "このコツを実際の対局で試そう",
"openings": "この序盤の手を実際の対局で試そう",
"positions": "この初期配置を実際の対局で試そう"
},
"rules": {
"title": "遊び方",
"title": "ルール",
"heading": "アバロンのルール:遊び方",
"intro": "アバロン(Abalone)は、六角形の盤で遊ぶ2人用の戦略ゲームです。各プレイヤーのボールは14個。相手のボールを6個、盤の外へ押し出すと勝ちです。このページでは全部のルールを説明します。準備ができたら、<online>オンラインでアバロンをプレイ</online>するか、<offline>コンピューターと対戦</offline>してみましょう。",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/ko/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@
"game_over": "게임 종료",
"moves": "{{count}}수"
},
"end_cta": {
"trust": "무료, 가입 없음, 다운로드 없음.",
"rules": "규칙을 실제 게임에서 써 보세요",
"strategy": "이 팁을 실제 게임에서 써 보세요",
"openings": "이 오프닝을 실제 게임에서 써 보세요",
"positions": "이 배치를 실제 게임에서 써 보세요"
},
"rules": {
"title": "게임 방법",
"title": "규칙",
"heading": "아발론 규칙: 게임 방법",
"intro": "아발론(Abalone)은 육각형 판에서 두 사람이 하는 전략 게임입니다. 각 플레이어는 구슬 14개를 가집니다. 상대 구슬 여섯 개를 판 밖으로 밀어내면 이깁니다. 이 페이지에서 모든 규칙을 설명합니다. 준비가 되었다면 <online>온라인으로 아발론을 플레이</online>하거나 <offline>컴퓨터와 대결</offline>해 보세요.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/nl/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@
"moves_one": "{{count}} zet",
"moves_other": "{{count}} zetten"
},
"end_cta": {
"trust": "Gratis, zonder account, zonder download.",
"rules": "Probeer de regels in een echt potje",
"strategy": "Probeer deze tips in een echt potje",
"openings": "Probeer deze openingen in een echt potje",
"positions": "Probeer deze opstellingen in een echt potje"
},
"rules": {
"title": "Zo speel je",
"title": "Regels",
"heading": "Abalone-regels: zo speel je",
"intro": "Abalone is een strategiespel voor twee spelers op een zeshoekig bord. Elke speler heeft 14 ballen. Je wint door zes ballen van je tegenstander van het bord te duwen. Op deze pagina staan alle regels. Ben je klaar, <online>speel dan Abalone online</online> of <offline>probeer het tegen de computer</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/pl/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@
"moves_few": "{{count}} ruchy",
"moves_many": "{{count}} ruchów"
},
"end_cta": {
"trust": "Za darmo, bez rejestracji, bez pobierania.",
"rules": "Wypróbuj zasady w prawdziwej grze",
"strategy": "Wypróbuj te wskazówki w prawdziwej grze",
"openings": "Wypróbuj te otwarcia w prawdziwej grze",
"positions": "Wypróbuj te ustawienia w prawdziwej grze"
},
"rules": {
"title": "Jak grać",
"title": "Zasady",
"heading": "Zasady Abalone: jak grać",
"intro": "Abalone to strategiczna gra dla dwóch osób, rozgrywana na sześciokątnej planszy. Każdy gracz ma 14 kul. Wygrywasz, wypychając poza planszę sześć kul przeciwnika. Ta strona wyjaśnia wszystkie zasady. Gdy będziesz gotowy, <online>zagraj w Abalone online</online> albo <offline>spróbuj z komputerem</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/pt/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@
"moves_one": "{{count}} jogada",
"moves_other": "{{count}} jogadas"
},
"end_cta": {
"trust": "Grátis, sem registo, sem transferência.",
"rules": "Experimenta as regras num jogo a sério",
"strategy": "Experimenta estas dicas num jogo a sério",
"openings": "Experimenta estas aberturas num jogo a sério",
"positions": "Experimenta estas posições num jogo a sério"
},
"rules": {
"title": "Como jogar",
"title": "Regras",
"heading": "Regras de Abalone: como jogar",
"intro": "O Abalone é um jogo de estratégia para dois jogadores num tabuleiro hexagonal. Cada jogador tem 14 bolas. Ganhas ao empurrar seis bolas do adversário para fora do tabuleiro. Esta página explica todas as regras. Quando estiveres pronto, <online>joga Abalone online</online> ou <offline>experimenta contra o computador</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/tr/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@
"game_over": "Oyun bitti",
"moves": "{{count}} hamle"
},
"end_cta": {
"trust": "Ücretsiz, kayıt yok, indirme yok.",
"rules": "Kuralları gerçek bir oyunda dene",
"strategy": "Bu ipuçlarını gerçek bir oyunda dene",
"openings": "Bu açılışları gerçek bir oyunda dene",
"positions": "Bu dizilişleri gerçek bir oyunda dene"
},
"rules": {
"title": "Nasıl oynanır",
"title": "Kurallar",
"heading": "Abalone kuralları: nasıl oynanır",
"intro": "Abalone, altıgen bir tahtada oynanan iki kişilik bir strateji oyunudur. Her oyuncunun 14 bilyesi vardır. Rakibin altı bilyesini tahtadan dışarı iterek kazanırsın. Bu sayfa tüm kuralları anlatır. Hazır olduğunda <online>Abalone'u çevrimiçi oyna</online> ya da <offline>bilgisayara karşı dene</offline>.",
"goal": {
Expand Down
9 changes: 8 additions & 1 deletion apps/game/src/i18n/locales/zh/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@
"game_over": "对局结束",
"moves": "{{count}} 步"
},
"end_cta": {
"trust": "免费,无需注册,无需下载。",
"rules": "在真实对局中试试规则",
"strategy": "在真实对局中试试这些技巧",
"openings": "在真实对局中试试这些开局",
"positions": "在真实对局中试试这些布局"
},
"rules": {
"title": "游戏玩法",
"title": "规则",
"heading": "Abalone 规则:怎么玩",
"intro": "Abalone 是一款在六边形棋盘上进行的双人策略游戏。每位玩家有 14 颗棋子。把对手的六颗棋子推出棋盘,你就赢了。本页讲解全部规则。准备好后,可以<online>在线玩 Abalone</online>,也可以<offline>先和电脑对战试试</offline>。",
"goal": {
Expand Down
Loading
Loading