style(app): mobile-first layout polish
This commit is contained in:
1 parent
9a086cbe7b
commit
e9eb207b03
7 files changed
+49
-27
No files matched your search
+5
-2
@@ -29,8 +29,11 @@ describe('App', () => {
|
|||||||
|
|
||||||
renderApp()
|
renderApp()
|
||||||
|
|
||||||
const items = screen.getAllByRole('button').filter((b) => b.textContent !== '+')
|
const items = screen.getAllByRole('button', { name: /^Ouvrir la note/ })
|
||||||
expect(items.map((button) => button.textContent)).toEqual(['Alpha', 'Zebre'])
|
expect(items.map((button) => button.getAttribute('aria-label'))).toEqual([
|
||||||
|
'Ouvrir la note Alpha',
|
||||||
|
'Ouvrir la note Zebre',
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates a note with the + button and opens the editor in edit mode', () => {
|
it('creates a note with the + button and opens the editor in edit mode', () => {
|
||||||
|
|||||||
+4
-4
@@ -28,15 +28,15 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="mx-auto w-full max-w-2xl flex flex-col min-h-screen">
|
<main className="mx-auto w-full max-w-2xl flex flex-col min-h-dvh pb-28">
|
||||||
<header className="sticky top-0 bg-white border-b border-gray-200 px-4 py-3">
|
<header className="sticky top-0 z-10 bg-white/95 backdrop-blur border-b border-gray-200 px-4 py-3">
|
||||||
{selectedNote ? (
|
{selectedNote ? (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-1">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setSelectedId(null)}
|
onClick={() => setSelectedId(null)}
|
||||||
aria-label="Retour"
|
aria-label="Retour"
|
||||||
className="w-10 h-10 rounded-full text-xl hover:bg-gray-100"
|
className="flex items-center justify-center w-11 h-11 -ml-2 rounded-full text-xl text-gray-700 hover:bg-gray-100 active:bg-gray-200"
|
||||||
>
|
>
|
||||||
←
|
←
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ function DeleteModal({ open, title, onConfirm, onCancel }: DeleteModalProps) {
|
|||||||
if (!open) return null
|
if (!open) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 bg-black/40 flex items-center justify-center p-4 z-50">
|
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
||||||
<div
|
<div
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-labelledby="delete-confirm-title"
|
aria-labelledby="delete-confirm-title"
|
||||||
className="w-full max-w-sm bg-white rounded-lg p-5 flex flex-col gap-4"
|
className="flex w-full max-w-sm flex-col gap-4 rounded-xl bg-white p-5 shadow-xl"
|
||||||
>
|
>
|
||||||
<h2 id="delete-confirm-title" className="text-lg font-semibold">
|
<h2 id="delete-confirm-title" className="text-lg font-semibold">
|
||||||
Supprimer la note ?
|
Supprimer la note ?
|
||||||
@@ -24,14 +24,14 @@ function DeleteModal({ open, title, onConfirm, onCancel }: DeleteModalProps) {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onCancel}
|
onClick={onCancel}
|
||||||
className="px-4 py-2 rounded border border-gray-300 text-gray-600"
|
className="rounded-lg border border-gray-300 px-5 py-3 text-gray-600 hover:bg-gray-50 active:bg-gray-100"
|
||||||
>
|
>
|
||||||
Annuler
|
Annuler
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onConfirm}
|
onClick={onConfirm}
|
||||||
className="px-4 py-2 rounded bg-red-600 text-white"
|
className="rounded-lg bg-red-600 px-5 py-3 text-white hover:bg-red-700 active:bg-red-800"
|
||||||
>
|
>
|
||||||
Supprimer
|
Supprimer
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ function FloatingButton({ onClick, label = 'Créer une note' }: FloatingButtonPr
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
className="fixed bottom-6 right-6 w-14 h-14 rounded-full bg-amber-400 text-3xl text-gray-800 shadow-lg active:scale-95"
|
className="fixed bottom-6 right-6 z-20 flex h-14 w-14 items-center justify-center rounded-full bg-amber-400 text-3xl text-gray-800 shadow-lg transition-transform hover:bg-amber-500 active:scale-95 focus:outline-none focus:ring-2 focus:ring-amber-600 focus:ring-offset-2"
|
||||||
>
|
>
|
||||||
+
|
+
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function NoteEditor({ note, onUpdate, onDelete, autoEdit = false }: NoteEditorPr
|
|||||||
if (editing) {
|
if (editing) {
|
||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
className="flex flex-col gap-4"
|
className="flex flex-col gap-4 rounded-xl border border-gray-200 bg-white p-4 shadow-sm"
|
||||||
onSubmit={(event) => {
|
onSubmit={(event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
save()
|
save()
|
||||||
@@ -44,7 +44,7 @@ function NoteEditor({ note, onUpdate, onDelete, autoEdit = false }: NoteEditorPr
|
|||||||
<input
|
<input
|
||||||
value={title}
|
value={title}
|
||||||
onChange={(event) => setTitle(event.target.value)}
|
onChange={(event) => setTitle(event.target.value)}
|
||||||
className="w-full border border-gray-300 rounded px-3 py-2"
|
className="w-full rounded-lg border border-gray-300 px-3 py-3 text-base focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/30"
|
||||||
placeholder="Sans titre"
|
placeholder="Sans titre"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
@@ -53,19 +53,22 @@ function NoteEditor({ note, onUpdate, onDelete, autoEdit = false }: NoteEditorPr
|
|||||||
<textarea
|
<textarea
|
||||||
value={content}
|
value={content}
|
||||||
onChange={(event) => setContent(event.target.value)}
|
onChange={(event) => setContent(event.target.value)}
|
||||||
className="w-full border border-gray-300 rounded px-3 py-2 min-h-40"
|
className="w-full min-h-48 rounded-lg border border-gray-300 px-3 py-3 text-base focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/30"
|
||||||
placeholder="Écrire ici…"
|
placeholder="Écrire ici…"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-end gap-3">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={cancel}
|
onClick={cancel}
|
||||||
className="px-4 py-2 rounded border border-gray-300 text-gray-600"
|
className="rounded-lg border border-gray-300 px-5 py-3 text-gray-600 hover:bg-gray-50 active:bg-gray-100"
|
||||||
>
|
>
|
||||||
Annuler
|
Annuler
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" className="px-4 py-2 rounded bg-blue-600 text-white">
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="rounded-lg bg-blue-600 px-5 py-3 text-white hover:bg-blue-700 active:bg-blue-800"
|
||||||
|
>
|
||||||
Enregistrer
|
Enregistrer
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -74,26 +77,26 @@ function NoteEditor({ note, onUpdate, onDelete, autoEdit = false }: NoteEditorPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="flex flex-col gap-4">
|
<article className="flex flex-col gap-5 rounded-xl border border-gray-200 bg-white p-4 shadow-sm">
|
||||||
<div className="flex items-start justify-between gap-4">
|
<div className="flex items-start justify-between gap-4">
|
||||||
<h2 className="text-2xl font-semibold">{note.title || 'Sans titre'}</h2>
|
<h2 className="text-xl font-semibold leading-snug">{note.title || 'Sans titre'}</h2>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setConfirmDelete(true)}
|
onClick={() => setConfirmDelete(true)}
|
||||||
aria-label="Supprimer la note"
|
aria-label="Supprimer la note"
|
||||||
className="px-2 py-1 rounded text-gray-600 hover:text-red-600"
|
className="flex h-11 w-11 shrink-0 items-center justify-center rounded-full text-2xl leading-none text-gray-400 hover:bg-red-50 hover:text-red-600 active:bg-red-100"
|
||||||
>
|
>
|
||||||
×
|
×
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p className="whitespace-pre-wrap">
|
<p className="whitespace-pre-wrap text-base leading-relaxed">
|
||||||
{note.content || <span className="text-gray-400 italic">Note vide</span>}
|
{note.content || <span className="text-gray-400 italic">Note vide</span>}
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div className="flex justify-end">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={startEditing}
|
onClick={startEditing}
|
||||||
className="px-4 py-2 rounded bg-blue-600 text-white"
|
className="rounded-lg bg-blue-600 px-5 py-3 text-white hover:bg-blue-700 active:bg-blue-800"
|
||||||
>
|
>
|
||||||
Éditer
|
Éditer
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -9,19 +9,29 @@ const EMPTY_MESSAGE = 'Aucune note pour le moment. Touchez + pour en créer une.
|
|||||||
|
|
||||||
function NoteList({ notes, onSelect }: NoteListProps) {
|
function NoteList({ notes, onSelect }: NoteListProps) {
|
||||||
if (notes.length === 0) {
|
if (notes.length === 0) {
|
||||||
return <p className="text-center text-gray-500">{EMPTY_MESSAGE}</p>
|
return (
|
||||||
|
<div className="flex flex-col items-center justify-center gap-2 py-16 text-center">
|
||||||
|
<p className="text-gray-500">{EMPTY_MESSAGE}</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className="flex flex-col">
|
<ul className="flex flex-col divide-y divide-gray-100">
|
||||||
{notes.map((note) => (
|
{notes.map((note) => (
|
||||||
<li key={note.id}>
|
<li key={note.id}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onSelect(note.id)}
|
onClick={() => onSelect(note.id)}
|
||||||
className="w-full px-4 py-4 text-left hover:bg-gray-100"
|
aria-label={note.title ? `Ouvrir la note ${note.title}` : 'Ouvrir la note Sans titre'}
|
||||||
|
className="flex w-full items-center justify-between gap-3 px-2 py-4 text-left text-base hover:bg-gray-50 active:bg-gray-100"
|
||||||
>
|
>
|
||||||
{note.title || <span className="italic text-gray-400">Sans titre</span>}
|
<span className={note.title ? 'text-gray-800' : 'italic text-gray-400'}>
|
||||||
|
{note.title || 'Sans titre'}
|
||||||
|
</span>
|
||||||
|
<span aria-hidden="true" className="text-gray-400">
|
||||||
|
›
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1 +1,7 @@
|
|||||||
@import 'tailwindcss';
|
@import 'tailwindcss';
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
button {
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user