feat(sponsors): drop the sidebar slot and simplify the Sponsors page

The sidebar no longer carries a sponsor card. The backend stops serving
the "sidebar" slot, so a sponsors.json entry that still lists it keeps
only its other slots and one listing nothing else is dropped. Its
rotation, three-sponsor cap and collapsed-rail logo rendering go with it.

The Sponsors page now lists only real sponsors: the "Your brand here"
card shows only as the empty state instead of sitting in the grid and
repeating the header's Become a sponsor button, and the Available
placements section and its slot-occupancy helper are removed. Cards are
larger, two per row on wide screens. Unused i18n keys are dropped from
every locale.
This commit is contained in:
MHSanaei
2026-10-13 23:32:56 +02:00
parent 319e693276
commit 6f1dd0d757
25 changed files with 68 additions and 545 deletions
+5 -56
View File
@@ -1,12 +1,6 @@
import { afterEach, describe, expect, test } from 'vitest';
import {
SPONSOR_DISMISS_MS,
dismissSponsor,
isSponsorDismissed,
pickLocale,
placementStatus,
} from '@/lib/sponsors';
import { SPONSOR_DISMISS_MS, dismissSponsor, isSponsorDismissed, pickLocale } from '@/lib/sponsors';
afterEach(() => {
localStorage.clear();
@@ -33,10 +27,10 @@ describe('sponsor dismissal', () => {
const t0 = 1_800_000_000_000;
test('hides only the dismissed slot until the window elapses', () => {
dismissSponsor('acme', 'sidebar', t0);
expect(isSponsorDismissed('acme', 'sidebar', t0 + SPONSOR_DISMISS_MS - 1)).toBe(true);
dismissSponsor('acme', 'login', t0);
expect(isSponsorDismissed('acme', 'login', t0 + SPONSOR_DISMISS_MS - 1)).toBe(true);
expect(isSponsorDismissed('acme', 'dashboard', t0)).toBe(false);
expect(isSponsorDismissed('acme', 'sidebar', t0 + SPONSOR_DISMISS_MS)).toBe(false);
expect(isSponsorDismissed('acme', 'login', t0 + SPONSOR_DISMISS_MS)).toBe(false);
});
test('prunes expired entries on the next dismiss', () => {
@@ -48,51 +42,6 @@ describe('sponsor dismissal', () => {
test('corrupt storage is treated as nothing dismissed', () => {
localStorage.setItem('xui.sponsor.dismissed', 'not json');
expect(isSponsorDismissed('acme', 'sidebar', t0)).toBe(false);
});
});
describe('placementStatus', () => {
const sp = (id: string, slots: string[], until: string) => ({
id,
name: id,
slots,
until,
title: {},
text: {},
link: 'https://x.example/',
});
test('exclusive slot is taken until the latest booking ends', () => {
const sponsors = [
sp('a', ['dashboard'], '2026-11-01T00:00:00Z'),
sp('b', ['dashboard'], '2026-12-15T00:00:00Z'),
];
expect(placementStatus(sponsors, 'dashboard')).toEqual({
count: 2,
capacity: 1,
takenUntil: '2026-12-15T00:00:00Z',
});
});
test('sidebar is full at three and frees up when the earliest ends', () => {
const sponsors = [
sp('a', ['sidebar'], '2026-12-01T00:00:00Z'),
sp('b', ['sidebar'], '2026-10-20T00:00:00Z'),
sp('c', ['sidebar'], '2026-11-10T00:00:00Z'),
];
expect(placementStatus(sponsors, 'sidebar')).toEqual({
count: 3,
capacity: 3,
takenUntil: '2026-10-20T00:00:00Z',
});
expect(placementStatus(sponsors.slice(0, 2), 'sidebar')).toEqual({ count: 2, capacity: 3 });
});
test('uncapped page slot reports only a count', () => {
expect(placementStatus([sp('a', ['page'], '2026-12-01T00:00:00Z')], 'page')).toEqual({
count: 1,
capacity: undefined,
});
expect(isSponsorDismissed('acme', 'login', t0)).toBe(false);
});
});