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/[...path].astro b/web/src/pages/[...path].astro index f00c7c36..28f1b6ba 100644 --- a/web/src/pages/[...path].astro +++ b/web/src/pages/[...path].astro @@ -133,8 +133,8 @@ const title = page.type === 'poem' ? page.poem.title : page.type === 'poet' ? pa

کسی لفظ کو منتخب کریں تو اس کے معنی اور تلفظ ساتھ نظر آئیں گے۔

{page.divan && (

diff --git a/web/src/pages/index.astro b/web/src/pages/index.astro index 9fdc9070..39d45788 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})} ))}
@@ -45,9 +45,9 @@ const card = (p: Poet) => `poet-card${marked.includes(p.id) ? ' mark-bm' : ''}`;

{centuryName(century)}

{list.map((p) => ( - - {p.nickname} - {years(p)} + + {p.nickname} + {yearLines(p).map((y) => {y})} ))}
diff --git a/web/src/styles/global.css b/web/src/styles/global.css index 6ca35494..6bcf1c19 100644 --- a/web/src/styles/global.css +++ b/web/src/styles/global.css @@ -63,11 +63,17 @@ h1::after { content: ''; display: block; width: 140px; height: 2px; background: /* poet tiles (captions only, photos hidden for now) */ .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; + /* one size for every card: long names end in … (full name on hover) */ + width: 210px; max-width: calc(50% - 4px); min-height: 5.125rem; text-align: center; + display: flex; flex-direction: column; justify-content: center; background: var(--paper); border: 1.5px solid var(--border); + border-radius: 999px; padding: 6px 36px 8px; color: var(--ink); transition: transform .25s; position: relative; } +/* the bookmark sits in the top-left corner, inside the side padding (36px), so it never covers the name and a saved card keeps its size */ +.poet-card.mark-bm::after { position: absolute; top: 12px; left: 16px; 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 .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +/* years in Naskh: compact lines whatever the reading font (Nastaliq's tall line boxes made cards grow in some browsers) */ +.poet-card small { display: block; color: var(--muted); font-family: 'Noto Naskh Arabic', serif; font-size: .75rem; line-height: 1.6; white-space: nowrap; } .hero { text-align: center; } .hero p { margin: 0; } @@ -99,7 +105,7 @@ h1::after { content: ''; display: block; width: 140px; height: 2px; background: .couplet p, .couplet p + p { text-align: center; } .couplet::after { display: none; } } -.poem-nav { display: flex; justify-content: space-between; } +.poem-nav { display: flex; justify-content: center; gap: 12px; } /* RTL: پچھلا on the right, اگلا on the left */ .poem-nav a { border: 1.5px solid var(--border); background: var(--inner); border-radius: 10px; padding: 0 14px; } .source { text-align: center; font-size: .85rem; color: var(--muted); }