From 1794a4c944bfdd013155c82e266726fc4dfb2da3 Mon Sep 17 00:00:00 2001 From: rays Date: Thu, 3 Dec 2026 12:38:43 -0500 Subject: [PATCH] An item row's date is short and smaller (#508) "Dec 3, 2026" at 15px took a third of a phone row and cut the title short. Now the time today, "Nov 20" this year, "May 2025" before, at 13px; the full date stays in the tooltip. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RqkrVCCH8YcP2Y3i8VNYWA --- tests/page-unit.ts | 9 +++++++++ web/CHANGELOG.md | 1 + web/app.css | 3 ++- web/src/items.ts | 2 +- web/src/util.ts | 10 ++++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/page-unit.ts b/tests/page-unit.ts index 20a5be0..79016fd 100644 --- a/tests/page-unit.ts +++ b/tests/page-unit.ts @@ -86,6 +86,15 @@ test('ago says how long since, and never for nothing', () => { assert.match(run(`ago(${NOW - 90 * 86400})`), /2026/); }); +test('a row date is short: the time today, the day this year, the month before (#508)', () => { + const now = 'new Date(2026, 11, 3, 15, 0)'; + assert.match(run(`rowDate(new Date(2026, 11, 3, 9, 36).getTime()/1000, ${now})`), /9:36/); + const day = run(`rowDate(new Date(2026, 10, 20).getTime()/1000, ${now})`); + assert.match(day, /20/); assert.doesNotMatch(day, /2026/); + assert.match(run(`rowDate(new Date(2025, 4, 2).getTime()/1000, ${now})`), /2025/); + assert.equal(run('rowDate(null)'), ''); +}); + test('due says how long until a feed is checked', () => { assert.equal(run(`due(${NOW - 1})`), 'due now'); assert.equal(run(`due(${NOW + 10})`), 'in 1m'); diff --git a/web/CHANGELOG.md b/web/CHANGELOG.md index b31d64c..e12e9fc 100644 --- a/web/CHANGELOG.md +++ b/web/CHANGELOG.md @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- An item row's date is short and smaller: the time today, the day and month this year, the month and year before; the full date on hover (#508). - A toolbar button that cannot act says why in its tooltip (Choose an item first, Open a feed to unsubscribe from it, Nothing to play in this item), and the admin page's Save says nothing has changed yet; on a phone a checkbox's row is 40 px to tap (#507). - On a phone the toolbar's buttons and the list's tabs are at least 40 px to tap, a chapter no longer stays lit after a tap, and an item's pin and download buttons have names a screen reader reads, as the style guide's design half asks (#507). - The page's words follow one style (docs/STYLE-GUIDE.md): failures say "Unable to …" and what to do, a podcast is a podcast rather than a show, a feed has an address rather than a URL, and the buttons Auto and Initials in a signal's icon picker read Pick for me and Use initials (#507). diff --git a/web/app.css b/web/app.css index 29395aa..c57f812 100644 --- a/web/app.css +++ b/web/app.css @@ -1580,7 +1580,8 @@ body:has(#player.on) #status{padding-bottom:3px} .ep{padding:10px 8px;border-radius:10px;min-height:44px} .ep.sel{border-color:var(--edge)} .ep .t{font-size:17px} - .ep .line,.ep .date{font-size:15px} + .ep .line{font-size:15px} + .ep .date{font-size:13px} .ep+.ep{background-image:linear-gradient(var(--line),var(--line));background-size:calc(100% - 8px) 1px;background-position:8px 0;background-repeat:no-repeat} .ep.sel,.ep.sel+.ep{background-image:none} .feed{padding:9px 10px;min-height:44px;border-radius:10px} diff --git a/web/src/items.ts b/web/src/items.ts index 68bf6ff..10d5bf0 100644 --- a/web/src/items.ts +++ b/web/src/items.ts @@ -219,7 +219,7 @@ function epEl(e: Entry){ ${enc&&!has?`
`:''} ${enc?mb(enc.length):''} - ${dateOf(e.published)} + ${rowDate(e.published)}
${enc&&playsKind(enc)?queueButton(e):''} ${playable?``: diff --git a/web/src/util.ts b/web/src/util.ts index 5e699a5..70b8afd 100644 --- a/web/src/util.ts +++ b/web/src/util.ts @@ -309,6 +309,16 @@ const ago = (t: number|null) => { // One formatter: toLocaleDateString with options makes a new one each call, every row of a list. const DATE_FMT = new Intl.DateTimeFormat(undefined,{month:'short',day:'numeric',year:'numeric'}); const dateOf = (t: number|null) => t?DATE_FMT.format(t*1000):''; +// A row's date is short (#508): the time today, the day this year, the month before that. +const TIME_FMT = new Intl.DateTimeFormat(undefined,{hour:'numeric',minute:'2-digit'}); +const DAY_FMT = new Intl.DateTimeFormat(undefined,{month:'short',day:'numeric'}); +const MONTH_FMT = new Intl.DateTimeFormat(undefined,{month:'short',year:'numeric'}); +const rowDate = (t: number|null, now=new Date()) => { + if(!t) return ''; + const d=new Date(t*1000); + if(d.toDateString()===now.toDateString()) return TIME_FMT.format(d); + return (d.getFullYear()===now.getFullYear()?DAY_FMT:MONTH_FMT).format(d); +}; // A podcast episode is tens of MB, an article's image a few KB: whole MB made the small ones "0 MB". const mb = (n: number|null) => !n?'' : n<1048576?Math.max(1,Math.round(n/1024))+' KB' : n<1073741824?Math.round(n/1048576)+' MB' : (n/1073741824).toFixed(1)+' GB';