Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
chore: show dice count
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Nov 30, 2024
1 parent 8b70817 commit 7aef047
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { LevelInfo } from '@/components/mahjong/levels.ts'
import { FieldTemplate } from '@/components/mahjong/field-template.ts'
import { levels } from '@/components/mahjong/levels.ts'
import { Button } from '@/components/ui/button.tsx'
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card.tsx'
import { pluralize } from '@/lib/utils.ts'
import { createFileRoute, Link } from '@tanstack/react-router'
import { useMemo } from 'react'

export const Route = createFileRoute('/')({
component: RouteComponent,
Expand Down Expand Up @@ -32,12 +35,20 @@ function RouteComponent() {
}

function LevelCard({ level, isUnlocked }: { level: LevelInfo, isUnlocked: boolean }) {
const diceCount = useMemo(() => {
const decoded = FieldTemplate.decode(level.template)
return decoded.tileCoords.length
}, [level])

return (
<Card className="bg-black bg-opacity-40 backdrop-blur-md transition-all hover:border-emerald-500">
<CardHeader>
<CardTitle>{level.title}</CardTitle>
<CardDescription>
72 кости,
{diceCount}
{' '}
{pluralize(diceCount, 'кость', 'кости', 'костей')}
,
{' '}
{level.description}
</CardDescription>
Expand Down

0 comments on commit 7aef047

Please sign in to comment.