From 0e99219fe71c08adaab310f56a9d31285c112ea6 Mon Sep 17 00:00:00 2001 From: Fabio Date: Sat, 7 Nov 2026 18:38:49 -0300 Subject: [PATCH 1/3] feat: shrink long team names before ellipsis, "TT" app button, Help tab for editors Team names in the sidebar step down in size (then a third line) before they ellipsize. The header app-name button shows "TT" when the name does not fit. General and person notes open the Editor Help tab; day navigation moves to a Daily notes tab. Bump to 3.6.3. Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 7 +++ e2e/font-size-layout.spec.ts | 12 +++++ package-lock.json | 4 +- package.json | 2 +- src/core/i18n.ts | 2 - src/ui/fit-text.ts | 39 +++++++++++++++++ src/ui/help.ts | 6 +-- src/ui/shell.ts | 20 ++++++++- src/ui/sidebar.ts | 9 ++++ styles.css | 2 +- test/fit-text.test.ts | 85 ++++++++++++++++++++++++++++++++++++ test/help.test.ts | 8 ++-- 12 files changed, 181 insertions(+), 15 deletions(-) create mode 100644 src/ui/fit-text.ts create mode 100644 test/fit-text.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 2163ac37..b7b2f55f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to Team Tracker are documented here, written for people usin See [CLAUDE.md](CLAUDE.md#changelog) for how and when to update this file. +## [3.6.3] - 2026-11-07 + +### Changed +- Long team names in the sidebar shrink and wrap onto a third line before they are cut off with an ellipsis, so even longer names show in full. +- When the sidebar is too narrow for "Team Tracker", the header button shows "TT" instead of a cut-off name. +- F1 on General notes or a person's notes opens the Editor tab of Help; the day-navigation keys now live only on a Daily notes tab. + ## [3.6.2] - 2026-11-07 ### Changed diff --git a/e2e/font-size-layout.spec.ts b/e2e/font-size-layout.spec.ts index 0d42d24e..e53ab318 100644 --- a/e2e/font-size-layout.spec.ts +++ b/e2e/font-size-layout.spec.ts @@ -47,6 +47,18 @@ for (const size of ['XS', 'XL'] as const) { }) } +test('a long team name shrinks before it ellipsizes, and the app-name button becomes "TT" when the name does not fit', async ({ page }) => { + await openDoc(page, buildDoc('XL', { kind: 'general' })) + const name = page.locator('.tt-team-list .tt-team-name').first() + const label = page.locator('.tt-app-name-label') + // The fixture's team name needs more than two lines at full size. + expect(await name.evaluate((e) => e.style.fontSize)).not.toBe('') + await expect(label).toHaveText('TT') + // Collapsed, the button's column hugs its label, so the full name fits again. + await page.locator('.tt-sidebar-toggle').click() + await expect(label).toHaveText('Team Tracker') +}) + // pt-BR: the save pill's longest label is the widest header text, which is what squeezed the search box to an icon. test('header search keeps a usable width with the sidebar collapsed and a long team name (XL)', async ({ page }) => { await openDoc(page, buildDoc('XL', { kind: 'general' }, { sidebarCollapsed: true, locale: 'pt-BR' })) diff --git a/package-lock.json b/package-lock.json index 3cc62392..bd5b28b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "team-tracker", - "version": "3.6.2", + "version": "3.6.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "team-tracker", - "version": "3.6.2", + "version": "3.6.3", "license": "AGPL-3.0-only", "devDependencies": { "@axe-core/playwright": "^4.13.0", diff --git a/package.json b/package.json index 7f57ff20..fe165ac6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "team-tracker", - "version": "3.6.2", + "version": "3.6.3", "homepage": "https://fmpallini.github.io/team-tracker/", "repository": "fmpallini/team-tracker", "private": true, diff --git a/src/core/i18n.ts b/src/core/i18n.ts index 1903ae34..7bfca316 100644 --- a/src/core/i18n.ts +++ b/src/core/i18n.ts @@ -327,7 +327,6 @@ sidebar_teams_heading: 'Times', editor_help_title: 'Ajuda do editor', help_tab_global: 'Global', help_tab_editor: 'Editor', - help_tab_notes: 'Notas', help_tab_people: 'Pessoas', help_tab_pane: 'painel', help_tab_pane_title: 'Módulo do painel em foco', @@ -1025,7 +1024,6 @@ sidebar_teams_heading: 'Teams', editor_help_title: 'Editor help', help_tab_global: 'Global', help_tab_editor: 'Editor', - help_tab_notes: 'Notes', help_tab_people: 'People', help_tab_pane: 'pane', help_tab_pane_title: 'The focused pane\'s module', diff --git a/src/ui/fit-text.ts b/src/ui/fit-text.ts new file mode 100644 index 00000000..44adec60 --- /dev/null +++ b/src/ui/fit-text.ts @@ -0,0 +1,39 @@ +// src/ui/fit-text.ts — shrink-to-fit for line-clamped text. CSS can clamp a +// name to N lines with an ellipsis but cannot pick a smaller font first, so the +// clamped element is measured here: while its content is taller than its box, +// step the font down, and leave the ellipsis for what still overflows at the +// floor. Idempotent (every call starts again from the stylesheet's size), so a +// ResizeObserver can call it freely. + +/** Font-size multipliers tried in order after the stylesheet's own size; the smallest also gets a third line before the ellipsis. */ +const STEPS: readonly { scale: number; lines?: number }[] = [{ scale: 0.92 }, { scale: 0.85 }, { scale: 0.78, lines: 3 }] +/** The stylesheet sets both spellings of the clamp, so an override must too. */ +const CLAMP_PROPS = ['-webkit-line-clamp', 'line-clamp'] +/** Never go below this many px, whatever the user's text-size preference. */ +const MIN_PX = 10 + +function overflows(node: HTMLElement): boolean { + return node.scrollHeight > node.clientHeight + 1 +} + +/** Fits every `selector` match under `root`. A hidden or detached node measures 0 and keeps its normal size. */ +export function fitText(root: ParentNode, selector: string): void { + for (const node of root.querySelectorAll(selector)) { + node.style.fontSize = '' + for (const prop of CLAMP_PROPS) node.style.removeProperty(prop) + if (!overflows(node)) continue + const base = parseFloat(getComputedStyle(node).fontSize) + for (const { scale, lines } of STEPS) { + if (base * scale < MIN_PX) break + node.style.fontSize = `${scale}em` + if (lines) for (const prop of CLAMP_PROPS) node.style.setProperty(prop, String(lines)) + if (!overflows(node)) break + } + } +} + +/** Sets `full` as the node's text, or `short` when the full text is clipped horizontally (it must be `min-width: 0; overflow: hidden`). */ +export function abbreviateWhenClipped(node: HTMLElement, full: string, short: string): void { + node.textContent = full + if (node.scrollWidth > node.clientWidth + 1) node.textContent = short +} diff --git a/src/ui/help.ts b/src/ui/help.ts index c0108bd7..bc9a3922 100644 --- a/src/ui/help.ts +++ b/src/ui/help.ts @@ -20,7 +20,7 @@ export type HelpTab = 'global' | 'editor' | 'notes' | 'people' | 'tasks' | 'mile /** Which tab documents a pane showing `kind`. */ const PANE_TAB: Record = { - daily: 'notes', general: 'notes', person: 'notes', + daily: 'notes', general: 'editor', person: 'editor', stakeholders: 'people', members: 'people', actions: 'tasks', milestones: 'milestones', risks: 'risks', } @@ -259,18 +259,18 @@ const TABS: readonly TabDef[] = [ textSection(ctx, 'help_refs_heading', 'help_refs_text'), textSection(ctx, 'help_templates_heading', 'help_templates_text'), textSection(ctx, 'help_images_heading', 'help_images_text'), + rowsSection(ctx, 'help_sec_leave', [['Esc', 'help_notes_leave']]), rowsSection(ctx, 'help_sec_history', historyRows), ], }, { id: 'notes', - label: 'help_tab_notes', + label: 'module_daily', build: (ctx) => [ rowsSection(ctx, 'help_sec_days', [ ['Alt+[ / Alt+] / Alt+T', 'help_global_daily_nav'], ['Alt+, / Alt+.', 'help_global_daily_nav_content'], ]), - rowsSection(ctx, 'help_sec_leave', [['Esc', 'help_notes_leave']]), el( 'div', { class: 'tt-help-section' }, diff --git a/src/ui/shell.ts b/src/ui/shell.ts index bf574fda..17c72bbc 100644 --- a/src/ui/shell.ts +++ b/src/ui/shell.ts @@ -6,6 +6,7 @@ import { iconButton, setIconButtonTitle } from './icons' import { formatHHMM, formatAge } from '../core/date' import type { FileHealth } from '../core/file-snapshot' import { syncThemeColor } from '../core/theme-color' +import { abbreviateWhenClipped } from './fit-text' /** What the save pill reports. The file's own health, plus two conditions that outrank it. */ export type PillHealth = FileHealth['kind'] | 'store-error' | 'readonly' @@ -171,11 +172,24 @@ export function createShell(locale: Locale): Shell { '' const appNameBtn = el( 'button', - { class: 'tt-app-name', type: 'button', title: t(locale, 'app_name_button_title'), onclick: () => appNameHandler?.() }, + // The label can shrink to "TT" (below), so the button keeps the full name for assistive tech. + { class: 'tt-app-name', type: 'button', title: t(locale, 'app_name_button_title'), 'aria-label': t(locale, 'app_name'), onclick: () => appNameHandler?.() }, appNameLabel, appNameChevron ) headerLeft.appendChild(appNameBtn) + // Where the slot is too narrow for the name (sidebar open at a large text + // size) the label becomes "TT", the app icon's own monogram, instead of an + // ellipsized "Team T…". `fittedWidth` is the button's width right after the + // last fit: the swap itself can resize the button (collapsed sidebar: its + // column hugs the label), and that resize must not trigger a fit that undoes it. + let fittedWidth = -1 + function fitAppName(): void { + abbreviateWhenClipped(appNameLabel, t(currentLocale, 'app_name'), 'TT') + fittedWidth = appNameBtn.offsetWidth + } + const appNameObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => { if (appNameBtn.offsetWidth !== fittedWidth) fitAppName() }) + appNameObserver?.observe(appNameBtn) // An inline SVG (currentColor stroke) rather than a clock emoji: emoji // glyph metrics vary by platform font and never sit flush with the pill's @@ -339,13 +353,14 @@ export function createShell(locale: Locale): Shell { document.documentElement.dataset.size = prefs.fontSize if (localeChanged) { appNameBtn.title = t(currentLocale, 'app_name_button_title') - appNameLabel.textContent = t(currentLocale, 'app_name') + appNameBtn.setAttribute('aria-label', t(currentLocale, 'app_name')) setIconButtonTitle(fullscreenBtn, t(currentLocale, 'fullscreen')) setIconButtonTitle(closeFileBtn, t(currentLocale, 'close_file_title')) setIconButtonTitle(settingsBtn, t(currentLocale, 'settings')) setIconButtonTitle(helpBtn, t(currentLocale, 'help_global_title')) } if (localeChanged) renderSaveIndicator() + fitAppName() // the text size changes the label's width without changing the button's } function setTitle(fileName: string | null): void { @@ -399,6 +414,7 @@ export function createShell(locale: Locale): Shell { function dispose(): void { mq.removeEventListener('change', onSystemThemeChange) + appNameObserver?.disconnect() if (ageTimer !== null) clearInterval(ageTimer) ageTimer = null } diff --git a/src/ui/sidebar.ts b/src/ui/sidebar.ts index 0052c7ff..ac128456 100644 --- a/src/ui/sidebar.ts +++ b/src/ui/sidebar.ts @@ -21,6 +21,7 @@ import { attachEmojiPicker } from './emoji-picker' import { paintSelection, clampMove, selectableRowProps } from './select-list' import { openDuePanel } from './due-panel' import { revealLoc } from './reveal-loc' +import { fitText } from './fit-text' export interface SidebarActions { selectTeam(id: string): void @@ -311,6 +312,7 @@ export function mountSidebar(shell: Shell, store: Store, pm: PaneManager, action }) switcherEl = el('div', { class: 'tt-team-switcher-dropdown' }, switcherListEl) document.body.appendChild(switcherEl) + fitText(switcherListEl, '.tt-team-name') const rect = headerTeamIndicator.getBoundingClientRect() switcherEl.style.left = `${rect.left}px` switcherEl.style.top = `${rect.bottom + 4}px` @@ -335,6 +337,11 @@ export function mountSidebar(shell: Shell, store: Store, pm: PaneManager, action const contentEl = el('div', { class: 'tt-sidebar-content' }) const listEl = el('div', { class: 'tt-team-list' }) + // Names shrink before they ellipsize (fit-text.ts). A row built while the + // sidebar was collapsed or not yet attached measured 0, so the list's own + // size change — expanding, first layout, a text-size preference — refits it. + const fitObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => fitText(listEl, '.tt-team-name')) + fitObserver?.observe(listEl) const addBtn = el( 'button', { @@ -712,6 +719,7 @@ export function mountSidebar(shell: Shell, store: Store, pm: PaneManager, action listEl.appendChild(item) }) + fitText(listEl, '.tt-team-name') } function buildTeamForm(initial?: { name: string; emoji: string }): { @@ -881,6 +889,7 @@ export function mountSidebar(shell: Shell, store: Store, pm: PaneManager, action closeTeamSwitcher() unsubscribeContent() unsubscribeMutate() + fitObserver?.disconnect() document.removeEventListener(ADD_TEAM_REQUEST_EVENT, onAddTeamRequest) stopDayWatch() }, diff --git a/styles.css b/styles.css index 7f553cb3..23eb543e 100644 --- a/styles.css +++ b/styles.css @@ -751,7 +751,7 @@ body { background: var(--bg); color: var(--fg); } .tt-team-item.active { border-left-color: var(--accent); background: var(--selected); --row-bg: color-mix(in srgb, var(--accent) 20%, var(--panel)); } .tt-team-num { color: var(--muted); font-size: .8rem; min-width: 1.4em; text-align: right; } .tt-team-emoji { font-size: 1rem; } -/* Long names wrap to two lines, then ellipsis; anywhere-breaking keeps one +/* Long names wrap to two lines, then shrink (ui/fit-text.ts sets font-size inline), then ellipsis; anywhere-breaking keeps one unbroken word from forcing the row wider than the sidebar. */ .tt-team-name { font-family: var(--font-display); flex: 1; min-width: 0; line-height: 1.25; diff --git a/test/fit-text.test.ts b/test/fit-text.test.ts new file mode 100644 index 00000000..d1170102 --- /dev/null +++ b/test/fit-text.test.ts @@ -0,0 +1,85 @@ +import { afterEach, describe, expect, test } from 'vitest' +import { abbreviateWhenClipped, fitText } from '../src/ui/fit-text' + +// jsdom has no layout, so the box is faked: the content needs `need` px of height at font-size 1em and +// scales with the inline font-size; the box is `box` px tall. +const realComputedStyle = window.getComputedStyle +afterEach(() => { window.getComputedStyle = realComputedStyle }) + +function fakeName(need: number, box: number, basePx = 16): HTMLElement & { box: number } { + const node = Object.assign(document.createElement('span'), { box }) + node.className = 'tt-team-name' + Object.defineProperty(node, 'clientHeight', { get: () => node.box }) + Object.defineProperty(node, 'scrollHeight', { get: () => need * (parseFloat(node.style.fontSize) || 1) }) + window.getComputedStyle = ((n: Element) => (n === node ? ({ fontSize: `${basePx}px` } as CSSStyleDeclaration) : realComputedStyle(n))) as typeof window.getComputedStyle + return node +} + +function fit(node: HTMLElement): string { + const root = document.createElement('div') + root.append(node) + fitText(root, '.tt-team-name') + return node.style.fontSize +} + +describe('fitText', () => { + test('text that fits keeps the stylesheet size', () => { + expect(fit(fakeName(30, 40))).toBe('') + }) + + test('steps down to the first size that fits', () => { + expect(fit(fakeName(44, 40))).toBe('0.92em') + expect(fit(fakeName(46, 40))).toBe('0.85em') + }) + + test('the smallest step also allows a third line, and a later fit clears it', () => { + const node = fakeName(100, 40) + expect(fit(node)).toBe('0.78em') + expect(node.style.getPropertyValue('-webkit-line-clamp')).toBe('3') + node.box = 100 + fitText(node.parentElement!, '.tt-team-name') + expect(node.style.getPropertyValue('-webkit-line-clamp')).toBe('') + }) + + test('never goes below the pixel floor', () => { + expect(fit(fakeName(100, 40, 12))).toBe('0.85em') + }) + + test('is idempotent: a name that fits again after growing resets', () => { + const node = fakeName(46, 40) + const root = document.createElement('div') + root.append(node) + fitText(root, '.tt-team-name') + expect(node.style.fontSize).toBe('0.85em') + node.box = 60 + fitText(root, '.tt-team-name') + expect(node.style.fontSize).toBe('') + }) + + test('a node with no layout (hidden, detached) is left alone', () => { + const node = document.createElement('span') + node.className = 'tt-team-name' + expect(fit(node)).toBe('') + }) +}) + +describe('abbreviateWhenClipped', () => { + const label = (scroll: number, client: number): HTMLElement => { + const node = document.createElement('span') + Object.defineProperty(node, 'scrollWidth', { get: () => scroll }) + Object.defineProperty(node, 'clientWidth', { get: () => client }) + return node + } + + test('keeps the full text when it fits', () => { + const node = label(80, 80) + abbreviateWhenClipped(node, 'Team Tracker', 'TT') + expect(node.textContent).toBe('Team Tracker') + }) + + test('falls back to the short text when the full one is clipped', () => { + const node = label(90, 60) + abbreviateWhenClipped(node, 'Team Tracker', 'TT') + expect(node.textContent).toBe('TT') + }) +}) diff --git a/test/help.test.ts b/test/help.test.ts index 60f5b561..8faa23c7 100644 --- a/test/help.test.ts +++ b/test/help.test.ts @@ -117,7 +117,7 @@ test('the app name button keeps its chevron affordance across a locale switch', describe('tabs', () => { test('one tab per module family, Global first, in a vertical tablist', () => { showHelp('en-US') - expect(tabButtons().map((b) => b.textContent)).toEqual(['Global', 'Editor', 'Notes', 'People', 'Tasks', 'Milestones', 'Risks']) + expect(tabButtons().map((b) => b.textContent)).toEqual(['Global', 'Editor', 'Daily notes', 'People', 'Tasks', 'Milestones', 'Risks']) expect(document.querySelector('[role="tablist"]')!.getAttribute('aria-orientation')).toBe('vertical') expect(document.querySelector('[role="tabpanel"]')).not.toBeNull() }) @@ -144,7 +144,7 @@ describe('tabs', () => { test('every module kind maps to a tab, and an empty pane to Global', () => { const expected: Record = { - daily: 'notes', general: 'notes', person: 'notes', stakeholders: 'people', members: 'people', + daily: 'notes', general: 'editor', person: 'editor', stakeholders: 'people', members: 'people', actions: 'tasks', milestones: 'milestones', risks: 'risks', } for (const [kind, tab] of Object.entries(expected)) { @@ -317,7 +317,7 @@ describe('Editor tab', () => { test('groups the shortcuts by what they do and puts undo/redo last, not first', () => { showHelp('en-US', { tab: 'editor' }) - expect(headings()).toEqual(['Inline formatting', 'Blocks', 'Links', 'Markdown syntax', 'References (@)', 'Templates (/)', 'Pictures', 'History']) + expect(headings()).toEqual(['Inline formatting', 'Blocks', 'Links', 'Markdown syntax', 'References (@)', 'Templates (/)', 'Pictures', 'Leaving the editor', 'History']) const shortcuts = codes() expect(shortcuts[0]).toBe('Ctrl+B') const text = panelText() @@ -438,7 +438,7 @@ describe('module tabs', () => { } }) - test('Notes list the day navigation keys and send formatting questions to the Editor tab', () => { + test('Daily notes list the day navigation keys and send formatting questions to the Editor tab', () => { showHelp('en-US', { tab: 'notes' }) expect(codes()).toContain('Alt+[ / Alt+] / Alt+T') expect(codes()).toContain('Alt+, / Alt+.') From 67288856f15332835e851ca5c225d3071a789d29 Mon Sep 17 00:00:00 2001 From: Fabio Date: Sat, 7 Nov 2026 19:21:01 -0300 Subject: [PATCH 2/3] test(e2e): Help opens on the Editor tab for General notes Co-Authored-By: Claude Sonnet 5.5 --- e2e/help.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/help.spec.ts b/e2e/help.spec.ts index 4bd799b6..cf81f2ed 100644 --- a/e2e/help.spec.ts +++ b/e2e/help.spec.ts @@ -24,7 +24,7 @@ test.describe('help', () => { const activeTab = page.locator('.tt-prefs-tab-btn.active') await page.locator('.tt-btn-help').click() - await expect(activeTab).toContainText('Notes') + await expect(activeTab).toContainText('Editor') await page.keyboard.press('Escape') await expect(page.getByRole('dialog')).toHaveCount(0) @@ -41,7 +41,7 @@ test.describe('help', () => { await page.keyboard.press('F1') await expect(dialog).toBeVisible() - await expect(page.locator('.tt-prefs-tab-btn.active')).toContainText('Notes') + await expect(page.locator('.tt-prefs-tab-btn.active')).toContainText('Editor') await page.keyboard.press('F1') await expect(dialog).toHaveCount(0) From 15dc61270ab3f82c2f9f3f594a02934aa3f86236 Mon Sep 17 00:00:00 2001 From: Fabio Date: Sat, 7 Nov 2026 19:27:16 -0300 Subject: [PATCH 3/3] feat: Alt+C toggles the daily-notes calendar and opens a date field's calendar Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 3 +++ src/core/i18n.ts | 6 ++++-- src/main.ts | 5 ++++- src/modules/daily-notes.ts | 17 ++++++++++++----- src/ui/app-hotkeys.ts | 4 ++++ src/ui/date-picker.ts | 7 ++++--- src/ui/help.ts | 3 ++- test/app-hotkeys.test.ts | 7 +++++++ test/daily-notes.test.ts | 18 +++++++++++++++++- test/date-picker.test.ts | 12 ++++++++++++ test/help.test.ts | 3 ++- 11 files changed, 71 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b2f55f..13500321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ See [CLAUDE.md](CLAUDE.md#changelog) for how and when to update this file. ## [3.6.3] - 2026-11-07 +### Added +- Alt+C shows or hides the calendar on Daily notes, and also opens the calendar on a date field. + ### Changed - Long team names in the sidebar shrink and wrap onto a third line before they are cut off with an ellipsis, so even longer names show in full. - When the sidebar is too narrow for "Team Tracker", the header button shows "TT" instead of a cut-off name. diff --git a/src/core/i18n.ts b/src/core/i18n.ts index 7bfca316..6a1e9b92 100644 --- a/src/core/i18n.ts +++ b/src/core/i18n.ts @@ -401,6 +401,7 @@ sidebar_teams_heading: 'Times', help_global_pane_module: 'Trocar módulo do painel em foco', help_global_daily_nav: 'Dia anterior / próximo / hoje (notas diárias)', help_global_daily_nav_content: 'Pular para o dia anterior / próximo que tem uma nota', + help_global_calendar_toggle: 'Mostrar/ocultar o calendário (notas diárias)', help_global_fullscreen: 'Tela cheia', help_global_row_nav: 'Navegar entre linhas e cartões (riscos, marcos, tarefas)', help_global_move_item: 'Mover o item focado (time, tarefa, risco, pessoa) — os detalhes estão na aba de cada módulo', @@ -461,7 +462,7 @@ sidebar_teams_heading: 'Times', template_picker_empty: 'Nenhum template disponível', calendar_prev_month_title: 'Mês anterior', calendar_next_month_title: 'Próximo mês', - calendar_toggle_title: 'Mostrar/ocultar calendário', + calendar_toggle_title: 'Mostrar/ocultar calendário (Alt+C)', calendar_weekday_0: 'Dom', calendar_weekday_1: 'Seg', calendar_weekday_2: 'Ter', @@ -1098,6 +1099,7 @@ sidebar_teams_heading: 'Teams', help_global_pane_module: 'Switch the focused pane\'s module', help_global_daily_nav: 'Previous / next / today (daily notes)', help_global_daily_nav_content: 'Jump to the previous / next day that has a note', + help_global_calendar_toggle: 'Show/hide the calendar (daily notes)', help_global_fullscreen: 'Fullscreen', help_global_row_nav: 'Navigate between rows and cards (risks, milestones, tasks)', help_global_move_item: 'Move the focused item (team, task, risk, person) — details are on each module\'s tab', @@ -1154,7 +1156,7 @@ sidebar_teams_heading: 'Teams', template_picker_empty: 'No templates available', calendar_prev_month_title: 'Previous month', calendar_next_month_title: 'Next month', - calendar_toggle_title: 'Show/hide calendar', + calendar_toggle_title: 'Show/hide calendar (Alt+C)', calendar_weekday_0: 'Sun', calendar_weekday_1: 'Mon', calendar_weekday_2: 'Tue', diff --git a/src/main.ts b/src/main.ts index 3ecb1619..9e76175d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,7 +24,7 @@ import { t, todayIso } from './core/i18n' import { currentLoc } from './core/nav' import { addDaysIso } from './core/date' import { findTeam, nearestDatedNote } from './core/document' -import { renderDailyNotes, setDailyCalendarSpaceConstrained } from './modules/daily-notes' +import { renderDailyNotes, setDailyCalendarSpaceConstrained, toggleDailyCalendar } from './modules/daily-notes' import { renderGeneralNotes } from './modules/general-notes' import { renderPeopleTree } from './modules/people-tree' import { renderPersonNotes } from './modules/person-notes' @@ -657,6 +657,9 @@ async function onDocumentOpened(opened: OpenedDocument): Promise { pm.openInPane(idx, { teamId: loc.teamId, ref: { kind: 'daily', date } }, { flashTitle }) return } + case 'toggleCalendar': + toggleDailyCalendar(store) + return case 'selectPane': if (navPastModelessCard()) pm.switchPane(action.index) return diff --git a/src/modules/daily-notes.ts b/src/modules/daily-notes.ts index 181fa5ff..1bba2ae7 100644 --- a/src/modules/daily-notes.ts +++ b/src/modules/daily-notes.ts @@ -82,6 +82,17 @@ function applyCalendarCollapsed(entry: CalendarColEntry): void { entry.toggleBtn.hidden = calendarSpaceConstrained } +/** + * Shows/hides the calendar column of every mounted daily pane (nav.calendarCollapsed + * is per document, so they all follow). A no-op while the window is too narrow for + * the column: nothing is visible to toggle, and the pref must not flip unseen. + */ +export function toggleDailyCalendar(store: Store): void { + if (calendarSpaceConstrained) return + store.updateNav((d) => { d.nav.calendarCollapsed = !d.nav.calendarCollapsed }) + for (const entry of mountedCalendarCols) if (entry.store === store) applyCalendarCollapsed(entry) +} + export function setDailyCalendarSpaceConstrained(constrained: boolean): void { calendarSpaceConstrained = constrained for (const entry of mountedCalendarCols) applyCalendarCollapsed(entry) @@ -194,11 +205,7 @@ export const renderDailyNotes = withDisposal((container: HTMLElement, loc: Loc, class: 'tt-daily-calendar-toggle', title: t(lc, 'calendar_toggle_title'), icon: 'calendar', - onclick: () => { - const collapsed = !ctx.store.doc.nav.calendarCollapsed - ctx.store.updateNav((d) => { d.nav.calendarCollapsed = collapsed }) - applyCalendarCollapsed(calendarColEntry) - }, + onclick: () => toggleDailyCalendar(ctx.store), }) // Registered for the lifetime of this mount so setDailyCalendarSpaceConstrained() // can fold/unfold it as the window crosses the narrow threshold; unregistered diff --git a/src/ui/app-hotkeys.ts b/src/ui/app-hotkeys.ts index 0484688d..773940ad 100644 --- a/src/ui/app-hotkeys.ts +++ b/src/ui/app-hotkeys.ts @@ -38,6 +38,8 @@ export type AppHotkeyAction = * stable `e.code` on every layout. */ | { type: 'dayNav'; to: 'prev' | 'next' | 'today' | 'prevWithContent' | 'nextWithContent' } + /** Alt+C → show/hide the daily-notes calendar (only while the focused pane shows a daily note). */ + | { type: 'toggleCalendar' } /** Alt+Left / Alt+Right → focus pane 0 / pane 1. */ | { type: 'selectPane'; index: 0 | 1 } /** Alt+Up → toggle single/dual pane. */ @@ -162,6 +164,8 @@ export function resolveAppHotkey(e: KeyboardEvent, ctx: AppHotkeyContext): AppHo return { type: 'dayNav', to: dayPrevContent ? 'prevWithContent' : 'nextWithContent' } } + if (matchKey(e, 'c')) return ctx.focusedPaneShowsDailyNote ? { type: 'toggleCalendar' } : null + if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') { return { type: 'selectPane', index: e.key === 'ArrowLeft' ? 0 : 1 } } diff --git a/src/ui/date-picker.ts b/src/ui/date-picker.ts index 50f5257a..d75befd8 100644 --- a/src/ui/date-picker.ts +++ b/src/ui/date-picker.ts @@ -15,7 +15,7 @@ import { createCalendar, type CalendarMarks } from './calendar' import { placePopover } from '../core/popover-place' import { isReadOnlyLocked } from './readonly-lock' import { el, bindOutsideDismiss, blurOnEnter } from './dom' -import { isPlainKey } from './hotkeys' +import { isPlainKey, matchKey } from './hotkeys' const NO_MARKS: CalendarMarks = { hasNote: () => false, milestones: () => [], actionItems: () => [], backlinks: () => 0 } @@ -212,10 +212,11 @@ export function createDatePicker(opts: DatePickerOptions): DatePickerHandle { // Keys on the field. Up/Down step a day and t is today, from what the field // holds (today when empty); Alt+Down opens the calendar and goes into it, as - // on a native date field. That chord is also the pane swap, so it stops here. + // on a native date field, and Alt+C does the same (the key that shows or hides + // the daily-notes calendar). Alt+Down is also the pane swap, so both stop here. function onFieldKeydown(e: KeyboardEvent): void { if (isReadOnlyLocked()) return - if (e.key === 'ArrowDown' && e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) { + if (e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey && (e.key === 'ArrowDown' || matchKey(e, 'c'))) { e.preventDefault() e.stopPropagation() if (!popover) openPopover() diff --git a/src/ui/help.ts b/src/ui/help.ts index bc9a3922..718b0c05 100644 --- a/src/ui/help.ts +++ b/src/ui/help.ts @@ -113,7 +113,7 @@ const listRows = (lc: Locale): Rows => [ ['Delete', 'help_global_row_delete'], ] -const dateRows: Rows = [['↑ / ↓, t, Alt+↓', 'help_global_date_keys']] +const dateRows: Rows = [['↑ / ↓, t, Alt+C / Alt+↓', 'help_global_date_keys']] // --- App window ------------------------------------------------------------ @@ -270,6 +270,7 @@ const TABS: readonly TabDef[] = [ rowsSection(ctx, 'help_sec_days', [ ['Alt+[ / Alt+] / Alt+T', 'help_global_daily_nav'], ['Alt+, / Alt+.', 'help_global_daily_nav_content'], + ['Alt+C', 'help_global_calendar_toggle'], ]), el( 'div', diff --git a/test/app-hotkeys.test.ts b/test/app-hotkeys.test.ts index 418a3120..a8d9fea5 100644 --- a/test/app-hotkeys.test.ts +++ b/test/app-hotkeys.test.ts @@ -172,6 +172,13 @@ describe('Alt+[ / Alt+] / Alt+T — daily-note day nav', () => { }) }) +describe('Alt+C — show/hide the daily-notes calendar', () => { + test('claimed only when the focused pane shows a daily note', () => { + expect(resolve({ key: 'c', code: 'KeyC', altKey: true }, { focusedPaneShowsDailyNote: true })).toEqual({ type: 'toggleCalendar' }) + expect(resolve({ key: 'c', code: 'KeyC', altKey: true }, { focusedPaneShowsDailyNote: false })).toBeNull() + }) +}) + describe('Alt+, / Alt+. — jump to prev/next day that has a note', () => { test('claimed only when the focused pane shows a daily note', () => { expect(resolve({ key: ',', code: 'Comma', altKey: true }, { focusedPaneShowsDailyNote: true })) diff --git a/test/daily-notes.test.ts b/test/daily-notes.test.ts index e0c0ddc2..2a4ddf6b 100644 --- a/test/daily-notes.test.ts +++ b/test/daily-notes.test.ts @@ -1,4 +1,4 @@ -import { renderDailyNotes, setDailyCalendarSpaceConstrained } from '../src/modules/daily-notes' +import { renderDailyNotes, setDailyCalendarSpaceConstrained, toggleDailyCalendar } from '../src/modules/daily-notes' import { createStore, type Store } from '../src/core/store' import { createEmptyDocument } from '../src/core/document' import { createSearchIndex } from '../src/core/search' @@ -678,6 +678,22 @@ describe('calendar auto-collapse when the window is space-constrained', () => { expect(calToggle(container).hidden).toBe(false) }) + test('toggleDailyCalendar flips the preference and the mounted column, and does nothing while constrained', () => { + const { container, store, pm, loc } = setup(makeTeam()) + render(container, loc, store, pm) + + toggleDailyCalendar(store) + expect(store.doc.nav.calendarCollapsed).toBe(true) + expect(calCol(container).classList.contains('tt-daily-collapsed')).toBe(true) + toggleDailyCalendar(store) + expect(store.doc.nav.calendarCollapsed).toBe(false) + expect(calCol(container).classList.contains('tt-daily-collapsed')).toBe(false) + + setDailyCalendarSpaceConstrained(true) + toggleDailyCalendar(store) + expect(store.doc.nav.calendarCollapsed).toBe(false) + }) + test('a pane mounted while already constrained comes up folded', () => { setDailyCalendarSpaceConstrained(true) const { container, store, pm, loc } = setup(makeTeam()) diff --git a/test/date-picker.test.ts b/test/date-picker.test.ts index 4a1e65a8..9077f7d2 100644 --- a/test/date-picker.test.ts +++ b/test/date-picker.test.ts @@ -327,6 +327,18 @@ describe('keyboard', () => { handle.destroy() }) + test('Alt+C does the same, whatever character the layout types for the key', () => { + const handle = mount({ value: '2026-07-20', locale: 'en-US', onChange: () => {} }) + const reached = vi.fn() + document.addEventListener('keydown', reached, { once: true }) + input(handle).focus() + press(input(handle), { key: 'ç', code: 'KeyC', altKey: true }) + expect((document.activeElement as HTMLElement).dataset.date).toBe('2026-07-20') + expect(reached).not.toHaveBeenCalled() + document.removeEventListener('keydown', reached) + handle.destroy() + }) + test('picking by keyboard commits and puts focus back on the field', () => { const handle = mount({ value: '2026-07-20', locale: 'en-US', onChange: () => {} }) input(handle).focus() diff --git a/test/help.test.ts b/test/help.test.ts index 8faa23c7..6114fc56 100644 --- a/test/help.test.ts +++ b/test/help.test.ts @@ -262,7 +262,7 @@ describe('Global tab', () => { test('keeps module-only keys off the page: rows, board, days and the editor live on their own tabs', () => { showHelp('en-US') const rows = codes() - for (const gone of ['Alt+N', 'Delete', 'Home / End / PgUp / PgDn', 'Alt+[ / Alt+] / Alt+T', '↑ / ↓, t, Alt+↓', 'Esc']) expect(rows).not.toContain(gone) + for (const gone of ['Alt+N', 'Delete', 'Home / End / PgUp / PgDn', 'Alt+[ / Alt+] / Alt+T', '↑ / ↓, t, Alt+C / Alt+↓', 'Esc']) expect(rows).not.toContain(gone) expect(rows).toContain('Ctrl+Enter') }) @@ -442,6 +442,7 @@ describe('module tabs', () => { showHelp('en-US', { tab: 'notes' }) expect(codes()).toContain('Alt+[ / Alt+] / Alt+T') expect(codes()).toContain('Alt+, / Alt+.') + expect(codes()).toContain('Alt+C') const link = Array.from(document.querySelectorAll('.tt-prefs-content button')).find((b) => b.textContent!.includes('Editor tab'))! link.click() expect(activeTab().textContent).toBe('Editor')