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:
@@ -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'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user