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:
51
memento-note/lib/editor/editor-back-context.ts
Normal file
51
memento-note/lib/editor/editor-back-context.ts
Normal 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'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user