Favorite team: star a side, get its next match pinned on Live
A star on the team page (localStorage, no accounts) pins that team's next or running match in a My team section at the top of the Live tab. EN/DE strings + aria-pressed on the toggle. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Link, useParams } from '@tanstack/react-router';
|
||||
import { ArrowLeft, Shield } from 'lucide-react';
|
||||
import { ArrowLeft, Shield, Star } from 'lucide-react';
|
||||
import { useFavoriteStore } from '@/stores/favoriteStore';
|
||||
import { Card, CardBody, CardHeader } from '@/components/ui/Card';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import { teamFlag } from '@/lib/teams';
|
||||
@@ -31,6 +32,24 @@ function FixtureRow({ f, team }: { f: Fixture; team: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
function FavoriteStar({ team }: { team: string }) {
|
||||
const t = useT();
|
||||
const favorite = useFavoriteStore((s) => s.favorite);
|
||||
const toggle = useFavoriteStore((s) => s.toggleFavorite);
|
||||
const active = favorite === team;
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => toggle(team)}
|
||||
aria-label={active ? t.team.unfollow : t.team.follow}
|
||||
aria-pressed={active}
|
||||
className={`grid h-9 w-9 place-items-center rounded-md transition-colors ${active ? 'text-gold' : 'text-faint hover:text-ink'}`}
|
||||
>
|
||||
<Star size={20} fill={active ? 'currentColor' : 'none'} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export function TeamProfilePage() {
|
||||
const { name } = useParams({ strict: false }) as { name: string };
|
||||
const t = useT();
|
||||
@@ -62,7 +81,10 @@ export function TeamProfilePage() {
|
||||
<CardBody className="flex flex-wrap items-center gap-4">
|
||||
<span aria-hidden className="text-5xl">{teamFlag(profile.team)}</span>
|
||||
<div>
|
||||
<h1 className="font-display text-2xl font-extrabold text-ink">{profile.team}</h1>
|
||||
<h1 className="flex items-center gap-2 font-display text-2xl font-extrabold text-ink">
|
||||
{profile.team}
|
||||
<FavoriteStar team={profile.team} />
|
||||
</h1>
|
||||
<div className="mt-1 flex flex-wrap items-center gap-2 text-sm">
|
||||
{profile.group && <Badge tone="neutral">{fmt(t.common.group, { group: profile.group })}</Badge>}
|
||||
<Badge tone="muted">{fmt(t.team.eloBadge, { rating: profile.elo })}</Badge>
|
||||
|
||||
Reference in New Issue
Block a user