diff --git a/web/src/lib/urdu.ts b/web/src/lib/urdu.ts index 50a00dcc..8cfc642e 100644 --- a/web/src/lib/urdu.ts +++ b/web/src/lib/urdu.ts @@ -11,8 +11,11 @@ export const centuryName = (c: number | null) => (c ? `${ORDINALS[c] ?? ud(c)} const span = (a: number | null, b: number | null, mark: string) => a || b ? `${a ? ud(a) : '؟'} – ${b ? ud(b) : '؟'} ${mark}` : ''; // Hijri and Gregorian (عیسوی): "۱۲۹۴ – ۱۳۵۷ ھ · ۱۸۷۷ – ۱۹۳۸ ء" -export const years = (p: { birth_year_ah: number | null; death_year_ah: number | null; birth_year_ce?: number | null; death_year_ce?: number | null }) => - [span(p.birth_year_ah, p.death_year_ah, 'ھ'), span(p.birth_year_ce ?? null, p.death_year_ce ?? null, 'ء')].filter(Boolean).join(' · '); +type Years = { birth_year_ah: number | null; death_year_ah: number | null; birth_year_ce?: number | null; death_year_ce?: number | null }; +// Hijri and Gregorian spans, each on its own (poet cards show them as two lines) +export const yearLines = (p: Years) => + [span(p.birth_year_ah, p.death_year_ah, 'ھ'), span(p.birth_year_ce ?? null, p.death_year_ce ?? null, 'ء')].filter(Boolean) as string[]; +export const years = (p: Years) => yearLines(p).join(' · '); // search highlighting (same matching rules as the API's search) export { highlighter } from '../../../api/src/urdu.ts'; diff --git a/web/src/pages/index.astro b/web/src/pages/index.astro index 9fdc9070..eb275f91 100644 --- a/web/src/pages/index.astro +++ b/web/src/pages/index.astro @@ -2,7 +2,7 @@ import Base from '../layouts/Base.astro'; import { api } from '../lib/api'; import { asUser, COOKIE } from '../lib/auth'; -import { centuryOf, centuryName, years, ud } from '../lib/urdu'; +import { centuryOf, centuryName, yearLines, ud } from '../lib/urdu'; type Poet = { id: number; url: string; nickname: string; birth_year_ah: number | null; death_year_ah: number | null; pin_order: number | null }; const poets = (await api('/api/poets')) ?? []; @@ -34,7 +34,7 @@ const card = (p: Poet) => `poet-card${marked.includes(p.id) ? ' mark-bm' : ''}`;

مقبول شعرا

{pinned.map((p) => ( - {p.nickname}{years(p)} + {p.nickname}{yearLines(p).map((y) => {y})} ))}
@@ -47,7 +47,7 @@ const card = (p: Poet) => `poet-card${marked.includes(p.id) ? ' mark-bm' : ''}`; {list.map((p) => ( {p.nickname} - {years(p)} + {yearLines(p).map((y) => {y})} ))} diff --git a/web/src/styles/global.css b/web/src/styles/global.css index 6ca35494..2dac5bd7 100644 --- a/web/src/styles/global.css +++ b/web/src/styles/global.css @@ -64,10 +64,12 @@ h1::after { content: ''; display: block; width: 140px; height: 2px; background: .poets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; } .poet-card { min-width: 120px; text-align: center; background: var(--paper); border: 1.5px solid var(--border); - border-radius: 999px; padding: 2px 14px; color: var(--ink); transition: transform .25s; + border-radius: 999px; padding: 6px 26px 8px; color: var(--ink); transition: transform .25s; position: relative; } +/* the bookmark sits in the card's top-left corner, so a saved poet's card keeps its size */ +.poet-card.mark-bm::after { position: absolute; top: 12px; left: 18px; margin: 0; } .poet-card:hover { transform: translateY(-3px); border-color: var(--brand); color: var(--ink); } -.poet-card small { display: block; color: var(--muted); font-size: .75rem; line-height: 1.4; } +.poet-card small { display: block; color: var(--muted); font-size: .75rem; line-height: 1.5; white-space: nowrap; } .hero { text-align: center; } .hero p { margin: 0; }