feat(ui): panneau repliable, carnets plus lisibles et accueil plus clair

Harmonise la liste des notes et l’éditeur (titres, dates, retour),
rend la saisie rapide et les raccourcis de l’accueil utilisables
sur téléphone, et conserve le panneau latéral repliable.
This commit is contained in:
Antigravity
2026-09-05 20:53:48 +00:00
parent a7b16870a4
commit 3bdbec575a
37 changed files with 1138 additions and 482 deletions

View File

@@ -0,0 +1,51 @@
export type EditorBackKind =
| 'dashboard'
| 'search'
| 'inbox'
| 'notebook'
| 'archive'
| 'shared'
| 'reminders'
| 'generic'
type SearchLike = Pick<URLSearchParams, 'get'>
/**
* Destination of the editor back button, from the URL that opened the note.
* Never inferred from the note's own notebook.
*/
export function resolveEditorBackKind(
pathname: string,
searchParams: SearchLike,
): EditorBackKind {
const from = searchParams.get('from')
if (from === 'dashboard' || searchParams.get('peekNote')) return 'dashboard'
if (from === 'search' || Boolean(searchParams.get('search')?.trim())) return 'search'
if (pathname.startsWith('/archive')) return 'archive'
if (searchParams.get('reminders') === '1') return 'reminders'
if (searchParams.get('shared') === '1') return 'shared'
if (searchParams.get('notebook')) return 'notebook'
if (from === 'inbox' || searchParams.get('forceList') === '1') return 'inbox'
return 'generic'
}
export function editorBackLabelKey(kind: EditorBackKind): string {
switch (kind) {
case 'dashboard':
return 'notes.backToHome'
case 'search':
return 'notes.backToSearchResults'
case 'inbox':
return 'notes.backToInbox'
case 'notebook':
return 'notes.backToNotebook'
case 'archive':
return 'notes.backToArchive'
case 'shared':
return 'notes.backToShared'
case 'reminders':
return 'notes.backToReminders'
default:
return 'general.back'
}
}

View File

@@ -0,0 +1,25 @@
export const SEARCH_RESTORE_EVENT = 'memento-restore-search'
export const SEARCH_RESTORE_QUERY_KEY = 'memento-search-restore-query'
export function rememberSearchQuery(query: string) {
try {
sessionStorage.setItem(SEARCH_RESTORE_QUERY_KEY, query)
} catch {
/* ignore quota / private mode */
}
}
export function consumeRememberedSearchQuery(): string {
try {
const q = sessionStorage.getItem(SEARCH_RESTORE_QUERY_KEY) || ''
if (q) sessionStorage.removeItem(SEARCH_RESTORE_QUERY_KEY)
return q
} catch {
return ''
}
}
export function requestSearchRestore() {
if (typeof window === 'undefined') return
window.dispatchEvent(new CustomEvent(SEARCH_RESTORE_EVENT))
}

View File

@@ -72,3 +72,42 @@ export function formatAbsoluteDateLocalized(
}
return format(d, pattern, { locale })
}
const INTL_LOCALE: Record<string, string> = {
zh: 'zh-CN',
fa: 'fa-IR',
}
/**
* Calendar day for note lists and the editor, in the user's locale.
* Uses the local timezone (same as `formatAbsoluteDateLocalized`) so a late-evening
* note does not jump to the previous UTC day. Persian uses Jalali + Persian digits.
*/
export function formatNoteCalendarDate(
date: Date | string,
language: string,
): string {
const d = typeof date === 'string' ? new Date(date) : date
if (Number.isNaN(d.getTime())) return ''
if (language === 'fa') {
return formatJalaliAbsolute(d, 'd MMM yyyy')
}
const locale = INTL_LOCALE[language] || language
try {
return new Intl.DateTimeFormat(locale, {
day: 'numeric',
month: 'long',
year: 'numeric',
}).format(d)
} catch {
return new Intl.DateTimeFormat('en', {
day: 'numeric',
month: 'long',
year: 'numeric',
}).format(d)
}
}
export function dateTextDirection(language: string): 'rtl' | 'ltr' {
return language === 'fa' || language === 'ar' ? 'rtl' : 'ltr'
}