feat(points): equipped looks on dashboard and public profile
Build, Test & Push Frontend / quality-check (push) Successful in 23s
Build, Test & Push Frontend / docker (push) Successful in 23s

Avatar borders frame the avatar on the dashboard, badges show next to the
heading, banner frames wrap the hero image, and equipped accents set the
color on both pages.
This commit is contained in:
lobo committed 2026-10-01 13:17:23 +02:00
1 parent ca3d34bad0
commit 0154202ddc
6 files changed
+112 -7

No files matched your search

+9 -3
View File
@@ -5,25 +5,30 @@ import {Hash, LayoutGrid, Link2, RefreshCw} from 'lucide-react';
import {Badge} from '@/components/ui/badge';
import {Button} from '@/components/ui/button';
import {Card} from '@/components/ui/card';
import {cn} from '@/lib/utils';
import HeroBanner from './HeroBanner.jsx';
import PointsBadge from './PointsBadge.jsx';
import SteamAvatar from './SteamAvatar.jsx';
import SyncStatusBadge from './SyncStatusBadge.jsx';
import {useCurrentUserContext} from '../context/CurrentUserContext.jsx';
import {lookClass} from '../utils/rewards.js';
export default function DashboardWelcomeCard({bannerAppid, avatarUrl, sync, forceSync, editing, onCustomize}) {
export default function DashboardWelcomeCard({bannerAppid, avatarUrl, sync, forceSync, editing, onCustomize, equipped}) {
const {t} = useTranslation();
const {user: userData} = useCurrentUserContext();
const hasSteamId = !!userData?.steamId;
const syncBusy = forceSync.busy || sync.isRunning;
return (
<Card className="relative overflow-hidden p-6 md:p-8 flex flex-col md:flex-row md:items-center md:justify-between gap-6">
<Card className={cn('relative overflow-hidden p-6 md:p-8 flex flex-col md:flex-row md:items-center md:justify-between gap-6',
lookClass(equipped, 'BANNER_FRAME'))}>
{/* A picked game, else the game played most in the last two weeks. */}
<HeroBanner appid={bannerAppid}/>
<div className="relative flex min-w-0 items-center gap-4">
{/* The slot is there before the avatar loads, so the title does not jump. */}
{hasSteamId && (
<span className="flex size-16 shrink-0 items-center justify-center rounded-full bg-muted ring-2 ring-primary/60">
<span className={cn('flex size-16 shrink-0 items-center justify-center rounded-full bg-muted',
lookClass(equipped, 'AVATAR_BORDER') ?? 'ring-2 ring-primary/60')}>
<SteamAvatar url={avatarUrl} className="size-16" iconClassName="size-8 text-muted-foreground"/>
</span>
)}
@@ -32,6 +37,7 @@ export default function DashboardWelcomeCard({bannerAppid, avatarUrl, sync, forc
<h1 className="mt-1 text-3xl md:text-4xl font-bold tracking-tight truncate">
{t('DASHBOARD.HELLO')} {userData?.displayName ?? userData?.email?.split('@')[0]} 👋
</h1>
<PointsBadge equipped={equipped} className="mt-2"/>
{hasSteamId ? (
<Badge variant="outline" className="mt-3 gap-1.5 font-mono text-muted-foreground">
<Hash className="size-3"/>
@@ -0,0 +1,38 @@
// @vitest-environment jsdom
import {afterEach, describe, expect, it, vi} from 'vitest';
import {cleanup, screen} from '@testing-library/react';
import DashboardWelcomeCard from './DashboardWelcomeCard.jsx';
import {fetchRoutes, json} from '../test/fetchRoutes.js';
import {renderWithProviders} from '../test/renderWithProviders.jsx';
vi.mock('react-i18next', () => import('../test/i18n-mock.js'));
afterEach(() => {
cleanup();
localStorage.clear();
});
const renderCard = async (equipped) => {
localStorage.setItem('tbp_session', '1');
fetchRoutes({'GET /api/users/me': json(200, {displayName: 'Lobo', steamId: '1'}), 'GET /api/library/hero-art': json(200, {})});
renderWithProviders(<DashboardWelcomeCard sync={{}} forceSync={{}} equipped={equipped}/>);
await screen.findByText(/Lobo/);
};
describe('DashboardWelcomeCard looks', () => {
it('wears the border, the frame and the badge from the shop', async () => {
await renderCard({AVATAR_BORDER: 'BORDER_GOLD', BANNER_FRAME: 'FRAME_NEON', BADGE: 'BADGE_COMPLETIONIST'});
const card = screen.getByText(/Lobo/).closest('[data-slot="card"]');
expect(card.className).toContain('ring-fuchsia-500');
expect(card.querySelector('.rounded-full').className).toContain('ring-amber-400');
expect(screen.getByText('POINTS.ITEMS.BADGE_COMPLETIONIST')).toBeTruthy();
});
it('keeps the default avatar ring without a worn border', async () => {
await renderCard({});
expect(screen.getByText(/Lobo/).closest('[data-slot="card"]').querySelector('.rounded-full').className)
.toContain('ring-primary/60');
});
});
+16
View File
@@ -0,0 +1,16 @@
import {useTranslation} from 'react-i18next';
import {cn} from '@/lib/utils';
import {equippedBadge} from '../utils/rewards.js';
/** The badge worn from the points shop as a small pill; nothing when none is worn. */
export default function PointsBadge({equipped, className}) {
const {t} = useTranslation();
const badge = equippedBadge(equipped);
if (!badge) return null;
return (
<span className={cn('inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium', badge.className, className)}>
<badge.Icon className="size-3.5"/>{t(`POINTS.ITEMS.${badge.code}`)}
</span>
);
}