Compare commits

..
3 Commits
Author SHA1 Message Date
Romulus21andClaude Opus 5.5 ca42b85f24 Retire les suggestions et le décompte sous le titre de la liste
Les tuiles « + Beurre » disparaissent avec leur requête, leur fonction
SQL et leurs styles. La ligne « Encore N articles à attraper. » est
retirée : le nombre reste affiché dans l'onglet de la liste.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:43:45 +01:00
Romulus21andClaude Opus 5.5 e47db8b070 Remplace Tailwind par une feuille de style classique
style/main.css est désormais servi tel quel par cargo-leptos (style-file) :
remise à zéro des styles du navigateur, couleurs en variables CSS et
classes nommées par composant à la place des classes utilitaires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:39:42 +01:00
Romulus21andClaude Opus 5.5 6b5eaa0ba6 Remplace « + article » par une recherche dans la liste
Le bouton « ajouter » ouvre un champ unique : il retrouve les articles
de la liste et du panier, un appui les fait passer de l'un à l'autre, et
un bouton ajoute le nom saisi s'il n'existe pas encore.

Le fond de la page et la couleur de la barre d'état prennent aussi la
couleur de la liste ouverte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:30:57 +01:00
11 changed files with 1218 additions and 396 deletions

No files matched your search

+2 -2
View File
@@ -22,7 +22,7 @@ dotenvy = { version = "0.15", optional = true }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
wasm-bindgen = { version = "=0.2.128", optional = true } wasm-bindgen = { version = "=0.2.128", optional = true }
js-sys = { version = "0.3", optional = true } js-sys = { version = "0.3", optional = true }
web-sys = { version = "0.3", features = ["CloseEvent", "Document", "Location", "MessageEvent", "VisibilityState", "WebSocket", "Window"], optional = true } web-sys = { version = "0.3", features = ["CloseEvent", "Document", "Element", "Location", "MessageEvent", "VisibilityState", "WebSocket", "Window"], optional = true }
send_wrapper = { version = "0.6", optional = true } send_wrapper = { version = "0.6", optional = true }
console_error_panic_hook = { version = "0.1", optional = true } console_error_panic_hook = { version = "0.1", optional = true }
@@ -61,7 +61,7 @@ panic = "abort"
output-name = "lisette" output-name = "lisette"
site-root = "target/site" site-root = "target/site"
site-pkg-dir = "pkg" site-pkg-dir = "pkg"
tailwind-input-file = "style/main.css" style-file = "style/main.css"
assets-dir = "public" assets-dir = "public"
site-addr = "127.0.0.1:3002" site-addr = "127.0.0.1:3002"
reload-port = 3001 reload-port = 3001
+1 -10
View File
@@ -1,7 +1,7 @@
use leptos::prelude::*; use leptos::prelude::*;
use leptos::server_fn::codec::Json; use leptos::server_fn::codec::Json;
use crate::model::{Account, Item, ItemOp, ListColor, Member, ShoppingList, Suggestion, SyncReport, User}; use crate::model::{Account, Item, ItemOp, ListColor, Member, ShoppingList, SyncReport, User};
pub const NOT_LOGGED_IN: &str = "Session expirée, reconnecte-toi."; pub const NOT_LOGGED_IN: &str = "Session expirée, reconnecte-toi.";
@@ -452,12 +452,3 @@ pub async fn sync_items(ops: Vec<ItemOp>) -> Result<SyncReport, ServerFnError> {
notify(users); notify(users);
Ok(SyncReport { created, rejected }) Ok(SyncReport { created, rejected })
} }
#[server]
pub async fn get_suggestions(list_id: i64) -> Result<Vec<Suggestion>, ServerFnError> {
use server::*;
let pool = pool()?;
let user = require_user(&pool).await?;
require_list(&pool, &user, list_id).await?;
crate::db::suggestions(&pool, user.id, list_id, 3).await.map_err(db_err)
}
+20 -20
View File
@@ -83,13 +83,13 @@ fn RedirectIfSignedIn() -> impl IntoView {
fn AuthLayout(title: &'static str, children: Children) -> impl IntoView { fn AuthLayout(title: &'static str, children: Children) -> impl IntoView {
view! { view! {
<RedirectIfSignedIn /> <RedirectIfSignedIn />
<main class="mx-auto flex min-h-dvh max-w-md flex-col px-4 pt-[max(1.5rem,env(safe-area-inset-top))] pb-16"> <main class="page page-auth">
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight"> <h1 class="page-title">
"mes listes" "mes listes"
</h1> </h1>
<section class="ticket relative mt-8 bg-paper px-5 pt-6 pb-8"> <section class="ticket">
<p class="font-mono text-sm tracking-[0.2em] text-ink/60 uppercase">"Lisette · Courses"</p> <p class="eyebrow">"Lisette · Courses"</p>
<h2 class="mt-1 font-display text-[1.7rem] leading-tight font-bold tracking-tight">{title}</h2> <h2 class="ticket-title">{title}</h2>
{children()} {children()}
</section> </section>
</main> </main>
@@ -101,7 +101,7 @@ pub fn FormError(#[prop(into)] error: Signal<Option<String>>) -> impl IntoView {
move || { move || {
error.get().map(|msg| { error.get().map(|msg| {
view! { view! {
<p role="alert" class="rounded-xl border-2 border-ink bg-pink px-3 py-2 font-medium"> <p role="alert" class="form-error">
{msg} {msg}
</p> </p>
} }
@@ -114,7 +114,7 @@ pub fn LoginPage() -> impl IntoView {
let auth = expect_context::<Auth>(); let auth = expect_context::<Auth>();
view! { view! {
<AuthLayout title="Connexion"> <AuthLayout title="Connexion">
<ActionForm action=auth.login attr:class="mt-5 flex flex-col gap-4"> <ActionForm action=auth.login attr:class="form form-compact">
<FormError error=Signal::derive(move || auth.login.value().get().and_then(Result::err).map(error_message)) /> <FormError error=Signal::derive(move || auth.login.value().get().and_then(Result::err).map(error_message)) />
<Field label="Email"> <Field label="Email">
<input class="field" type="email" name="email" required autocomplete="email" /> <input class="field" type="email" name="email" required autocomplete="email" />
@@ -135,9 +135,9 @@ pub fn LoginPage() -> impl IntoView {
matches!(auth.registration.await, Ok(true)) matches!(auth.registration.await, Ok(true))
.then(|| { .then(|| {
view! { view! {
<p class="mt-6 text-center text-ink/70"> <p class="footnote">
"Pas encore de compte ? " "Pas encore de compte ? "
<A href="/inscription" attr:class="font-semibold text-ink underline"> <A href="/inscription">
"Créer un compte" "Créer un compte"
</A> </A>
</p> </p>
@@ -158,14 +158,14 @@ pub fn RegisterPage() -> impl IntoView {
{move || Suspend::new(async move { {move || Suspend::new(async move {
if !matches!(auth.registration.await, Ok(true)) { if !matches!(auth.registration.await, Ok(true)) {
return view! { return view! {
<p class="mt-4 text-lg text-ink/70"> <p class="lead">
"Les inscriptions sont fermées pour le moment." "Les inscriptions sont fermées pour le moment."
</p> </p>
} }
.into_any(); .into_any();
} }
view! { view! {
<ActionForm action=auth.register attr:class="mt-5 flex flex-col gap-4"> <ActionForm action=auth.register attr:class="form form-compact">
<FormError error=Signal::derive(move || auth.register.value().get().and_then(Result::err).map(error_message)) /> <FormError error=Signal::derive(move || auth.register.value().get().and_then(Result::err).map(error_message)) />
<Field label="Prénom ou pseudo"> <Field label="Prénom ou pseudo">
<input <input
@@ -196,9 +196,9 @@ pub fn RegisterPage() -> impl IntoView {
.into_any() .into_any()
})} })}
</Suspense> </Suspense>
<p class="mt-6 text-center text-ink/70"> <p class="footnote">
"Déjà inscrit·e ? " "Déjà inscrit·e ? "
<A href="/connexion" attr:class="font-semibold text-ink underline"> <A href="/connexion">
"Se connecter" "Se connecter"
</A> </A>
</p> </p>
@@ -209,8 +209,8 @@ pub fn RegisterPage() -> impl IntoView {
#[component] #[component]
pub fn Field(label: &'static str, children: Children) -> impl IntoView { pub fn Field(label: &'static str, children: Children) -> impl IntoView {
view! { view! {
<label class="flex flex-col gap-1.5"> <label class="field-group">
<span class="font-mono text-xs tracking-[0.2em] text-ink/60 uppercase">{label}</span> <span class="label">{label}</span>
{children()} {children()}
</label> </label>
} }
@@ -221,7 +221,7 @@ fn SubmitButton(#[prop(into)] pending: Signal<bool>, label: &'static str) -> imp
view! { view! {
<button <button
type="submit" type="submit"
class="tile-shadow mt-2 rounded-2xl border-2 border-ink bg-pink px-4 py-3 font-display text-lg font-bold active:translate-y-1 active:shadow-none disabled:opacity-60" class="button button-primary"
disabled=move || pending.get() disabled=move || pending.get()
> >
{label} {label}
@@ -240,23 +240,23 @@ pub fn AccountSheet(user: User) -> impl IntoView {
view! { view! {
<Show when=move || ctx.account_open.get()> <Show when=move || ctx.account_open.get()>
<Sheet title=user.with_value(|u| u.name.clone()) on_close=close> <Sheet title=user.with_value(|u| u.name.clone()) on_close=close>
<p class="mt-1 text-ink/70">{user.with_value(|u| u.email.clone())}</p> <p class="sheet-text">{user.with_value(|u| u.email.clone())}</p>
{user {user
.with_value(|u| u.is_admin) .with_value(|u| u.is_admin)
.then(|| { .then(|| {
view! { view! {
<A <A
href="/admin" href="/admin"
attr:class="mt-6 block w-full rounded-2xl border-2 border-ink bg-lime px-4 py-3 text-center font-semibold" attr:class="button button-lime button-block"
> >
"Gérer les utilisateurs" "Gérer les utilisateurs"
</A> </A>
} }
})} })}
<ActionForm action=auth.logout attr:class="mt-3"> <ActionForm action=auth.logout>
<button <button
type="submit" type="submit"
class="w-full rounded-2xl border-2 border-ink px-4 py-3 font-semibold" class="button button-block"
> >
"Se déconnecter" "Se déconnecter"
</button> </button>
+25 -26
View File
@@ -25,8 +25,8 @@ fn AdminView(me: User) -> impl IntoView {
if !me.is_admin { if !me.is_admin {
return view! { return view! {
<AdminLayout> <AdminLayout>
<section class="ticket relative mt-6 bg-paper px-5 pt-6 pb-8"> <section class="ticket">
<p class="text-lg text-ink/70">"Cette page est réservée aux administrateurs."</p> <p class="lead">"Cette page est réservée aux administrateurs."</p>
</section> </section>
</AdminLayout> </AdminLayout>
} }
@@ -40,17 +40,17 @@ fn AdminView(me: User) -> impl IntoView {
view! { view! {
<AdminLayout> <AdminLayout>
<section class="ticket relative mt-6 bg-paper px-5 pt-6 pb-8"> <section class="ticket">
<p class="font-mono text-sm tracking-[0.2em] text-ink/60 uppercase">"Lisette · Comptes"</p> <p class="eyebrow">"Lisette · Comptes"</p>
<h2 class="mt-1 font-display text-[1.7rem] leading-tight font-bold tracking-tight"> <h2 class="ticket-title">
"Utilisateurs" "Utilisateurs"
</h2> </h2>
<Transition fallback=|| view! { <p class="mt-4 text-ink/50">"…"</p> }> <Transition fallback=|| view! { <p class="loading">"…"</p> }>
{move || Suspend::new(async move { {move || Suspend::new(async move {
match accounts.await { match accounts.await {
Ok(accounts) => view! { <AccountRows accounts me_id editor /> }.into_any(), Ok(accounts) => view! { <AccountRows accounts me_id editor /> }.into_any(),
Err(err) => { Err(err) => {
view! { <p class="mt-4 font-medium">{error_message(err)}</p> }.into_any() view! { <p class="lead">{error_message(err)}</p> }.into_any()
} }
} }
})} })}
@@ -58,7 +58,7 @@ fn AdminView(me: User) -> impl IntoView {
</section> </section>
<button <button
class="tile-shadow fixed right-[max(1rem,calc(50vw-14rem+1rem))] bottom-[max(1.25rem,env(safe-area-inset-bottom))] z-10 rounded-2xl border-2 border-ink bg-pink px-6 py-4 font-display text-xl font-bold active:translate-y-1 active:shadow-none" class="fab"
on:click=move |_| editor.set(Some(AccountEditor::New)) on:click=move |_| editor.set(Some(AccountEditor::New))
> >
"+ compte" "+ compte"
@@ -86,12 +86,12 @@ fn AdminView(me: User) -> impl IntoView {
#[component] #[component]
fn AdminLayout(children: Children) -> impl IntoView { fn AdminLayout(children: Children) -> impl IntoView {
view! { view! {
<main class="mx-auto flex min-h-dvh max-w-md flex-col px-4 pt-[max(1.5rem,env(safe-area-inset-top))] pb-32"> <main class="page">
<header class="flex items-start justify-between gap-4"> <header class="page-header">
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight">"admin"</h1> <h1 class="page-title">"admin"</h1>
<A <A
href="/" href="/"
attr:class="shrink-0 rounded-2xl border-2 border-ink bg-paper px-4 py-3 font-semibold" attr:class="button button-paper"
> >
"← mes listes" "← mes listes"
</A> </A>
@@ -108,13 +108,13 @@ fn AccountRows(
editor: RwSignal<Option<AccountEditor>>, editor: RwSignal<Option<AccountEditor>>,
) -> impl IntoView { ) -> impl IntoView {
view! { view! {
<p class="mt-1 text-lg text-ink/70"> <p class="lead">
{match accounts.len() { {match accounts.len() {
1 => "1 compte.".to_owned(), 1 => "1 compte.".to_owned(),
n => format!("{n} comptes."), n => format!("{n} comptes."),
}} }}
</p> </p>
<ul class="mt-5 flex flex-col gap-2"> <ul class="people">
{accounts {accounts
.into_iter() .into_iter()
.map(|Account { user, created_at }| { .map(|Account { user, created_at }| {
@@ -123,22 +123,22 @@ fn AccountRows(
view! { view! {
<li> <li>
<button <button
class="flex w-full items-center justify-between gap-3 rounded-xl bg-mist px-3 py-2 text-left active:bg-ink/10" class="person"
on:click=move |_| editor.set(Some(AccountEditor::Edit(edited.clone()))) on:click=move |_| editor.set(Some(AccountEditor::Edit(edited.clone())))
> >
<div class="min-w-0"> <div class="person-info">
<p class="truncate font-semibold"> <p class="person-name">
{user.name.clone()} {user.name.clone()}
{is_me.then_some(" (toi)")} {is_me.then_some(" (toi)")}
</p> </p>
<p class="truncate text-sm text-ink/60">{user.email.clone()}</p> <p class="person-email">{user.email.clone()}</p>
<p class="text-sm text-ink/50">{format!("Inscrit·e le {}", french_date(&created_at))}</p> <p class="person-date">{format!("Inscrit·e le {}", french_date(&created_at))}</p>
</div> </div>
{user {user
.is_admin .is_admin
.then(|| { .then(|| {
view! { view! {
<span class="shrink-0 rounded-lg border-2 border-ink bg-lime px-2 py-0.5 font-mono text-xs uppercase"> <span class="badge">
"admin" "admin"
</span> </span>
} }
@@ -234,7 +234,7 @@ fn AccountForm(
view! { view! {
<Sheet title=title.to_owned() on_close> <Sheet title=title.to_owned() on_close>
<form class="mt-4 flex flex-col gap-4" on:submit=submit> <form class="form form-compact" on:submit=submit>
<FormError error=error /> <FormError error=error />
<Field label="Prénom ou pseudo"> <Field label="Prénom ou pseudo">
<input class="field" required maxlength="40" autocomplete="off" bind:value=name /> <input class="field" required maxlength="40" autocomplete="off" bind:value=name />
@@ -253,23 +253,22 @@ fn AccountForm(
bind:value=password bind:value=password
/> />
</Field> </Field>
<label class="flex items-center gap-3 font-medium"> <label class="checkbox">
<input <input
type="checkbox" type="checkbox"
class="size-6 accent-ink"
disabled=is_me disabled=is_me
bind:checked=is_admin bind:checked=is_admin
/> />
"Administrateur" "Administrateur"
</label> </label>
<div class="mt-2 flex gap-3"> <div class="actions">
{(user_id.is_some() && !is_me) {(user_id.is_some() && !is_me)
.then(|| { .then(|| {
view! { view! {
<button <button
type="button" type="button"
class="rounded-2xl border-2 border-ink px-4 py-3 font-semibold" class="button"
disabled=move || pending.get() disabled=move || pending.get()
on:click=delete on:click=delete
> >
@@ -279,7 +278,7 @@ fn AccountForm(
})} })}
<button <button
type="submit" type="submit"
class="tile-shadow flex-1 rounded-2xl border-2 border-ink bg-pink px-4 py-3 font-display text-lg font-bold active:translate-y-1 active:shadow-none disabled:opacity-60" class="button button-primary"
disabled=move || pending.get() disabled=move || pending.get()
> >
{if user_id.is_some() { "Enregistrer" } else { "Créer" }} {if user_id.is_some() { "Enregistrer" } else { "Créer" }}
+55 -94
View File
@@ -16,13 +16,13 @@ use leptos_router::components::{A, Redirect, Route, Router, Routes};
use leptos_router::hooks::use_params_map; use leptos_router::hooks::use_params_map;
use leptos_router::path; use leptos_router::path;
use crate::api::{get_items, get_lists, get_suggestions}; use crate::api::{get_items, get_lists};
use crate::model::{Item, ItemOp, ShoppingList, Suggestion, User}; use crate::model::{Item, ItemOp, ShoppingList, User};
use account::{AccountSheet, Auth, LoginPage, RegisterPage, RequireUser}; use account::{AccountSheet, Auth, LoginPage, RegisterPage, RequireUser};
use admin::AdminPage; use admin::AdminPage;
use sheets::{ItemEditor, ItemSheet, ListEditor, ListSheet}; use sheets::{ItemEditor, ItemSheet, ListEditor, ListSheet};
use sync::Sync; use sync::Sync;
use tiles::{BasketTile, ItemTile, SuggestionTile}; use tiles::{BasketTile, ItemTile};
pub fn shell(options: LeptosOptions) -> impl IntoView { pub fn shell(options: LeptosOptions) -> impl IntoView {
view! { view! {
@@ -41,7 +41,7 @@ pub fn shell(options: LeptosOptions) -> impl IntoView {
"if ('serviceWorker' in navigator) navigator.serviceWorker.register('/sw.js');" "if ('serviceWorker' in navigator) navigator.serviceWorker.register('/sw.js');"
</script> </script>
</head> </head>
<body class="bg-lime text-ink font-sans antialiased"> <body>
<App /> <App />
</body> </body>
</html> </html>
@@ -71,7 +71,7 @@ pub fn App() -> impl IntoView {
<Title text="Lisette" /> <Title text="Lisette" />
<Router> <Router>
<Routes fallback=|| view! { <p class="p-4">"Page introuvable."</p> }> <Routes fallback=|| view! { <p class="page-not-found">"Page introuvable."</p> }>
<Route path=path!("/") view=ListsPage /> <Route path=path!("/") view=ListsPage />
<Route path=path!("/l/:id") view=ListsPage /> <Route path=path!("/l/:id") view=ListsPage />
<Route path=path!("/connexion") view=LoginPage /> <Route path=path!("/connexion") view=LoginPage />
@@ -186,24 +186,25 @@ fn ListsView(user: User) -> impl IntoView {
} }
}, },
); );
let suggestions = Resource::new(
move || (active_id.get(), ctx.refresh.get()), // Items of the open list with unsaved changes, for the add sheet.
|(id, _)| async move { let list_items = Memo::new(move |_| match (active_id.get(), items.get()) {
match id { (Some(id), Some(Ok((items, _)))) => {
Some(id) => get_suggestions(id).await, let mut items = ctx.sync.apply(id, &items);
None => Ok(Vec::new()), items.sort_by_cached_key(|item| crate::model::fold_name(&item.name));
items
} }
}, _ => Vec::new(),
); });
view! { view! {
<main class="mx-auto flex min-h-dvh max-w-md flex-col px-4 pt-[max(1.5rem,env(safe-area-inset-top))] pb-32"> <main class="page">
<header class="flex items-start justify-between gap-4"> <header class="page-header">
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight"> <h1 class="page-title">
"mes listes" "mes listes"
</h1> </h1>
<button <button
class="grid size-14 shrink-0 place-items-center rounded-2xl bg-ink font-display text-lg font-bold text-lime" class="avatar"
aria-label="Mon compte" aria-label="Mon compte"
on:click=move |_| ctx.account_open.set(true) on:click=move |_| ctx.account_open.set(true)
> >
@@ -213,7 +214,7 @@ fn ListsView(user: User) -> impl IntoView {
<ErrorBanner /> <ErrorBanner />
<Show when=move || ctx.sync.offline()> <Show when=move || ctx.sync.offline()>
<p class="mt-4 rounded-2xl bg-paper/70 px-4 py-3 font-medium text-ink/70"> <p class="notice">
"Réseau indisponible : tes changements partiront dès que possible." "Réseau indisponible : tes changements partiront dès que possible."
</p> </p>
</Show> </Show>
@@ -221,7 +222,7 @@ fn ListsView(user: User) -> impl IntoView {
<Transition fallback=|| view! { <TicketSkeleton /> }> <Transition fallback=|| view! { <TicketSkeleton /> }>
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { view! {
<p class="mt-6 rounded-2xl bg-paper p-4"> <p class="panel">
"Oups : " "Oups : "
{move || { {move || {
errors.get().into_iter().map(|(_, e)| e.to_string()).collect::<Vec<_>>().join(", ") errors.get().into_iter().map(|(_, e)| e.to_string()).collect::<Vec<_>>().join(", ")
@@ -232,16 +233,15 @@ fn ListsView(user: User) -> impl IntoView {
{move || Suspend::new(async move { {move || Suspend::new(async move {
let lists = lists.await?; let lists = lists.await?;
let (items, saved) = items.await?; let (items, saved) = items.await?;
let suggestions = suggestions.await?;
Ok::<_, ServerFnError>(view! { Ok::<_, ServerFnError>(view! {
<ListsContent lists items saved suggestions active_id=active_id.get() /> <ListsContent lists items saved active_id=active_id.get() />
}) })
})} })}
</ErrorBoundary> </ErrorBoundary>
</Transition> </Transition>
</main> </main>
<ItemSheet list_id=active_id /> <ItemSheet list_id=active_id items=list_items />
<ListSheet /> <ListSheet />
<AccountSheet user /> <AccountSheet user />
} }
@@ -253,7 +253,6 @@ fn ListsContent(
items: Vec<Item>, items: Vec<Item>,
/// Batches of changes saved when `items` was fetched. /// Batches of changes saved when `items` was fetched.
saved: u32, saved: u32,
suggestions: Vec<Suggestion>,
active_id: Option<i64>, active_id: Option<i64>,
) -> impl IntoView { ) -> impl IntoView {
let ctx = expect_context::<Ctx>(); let ctx = expect_context::<Ctx>();
@@ -271,7 +270,7 @@ fn ListsContent(
let Some(list) = lists.iter().find(|l| l.id == active_id).cloned() else { let Some(list) = lists.iter().find(|l| l.id == active_id).cloned() else {
return view! { return view! {
<ListTabs lists active=None remaining=0 /> <ListTabs lists active=None remaining=0 />
<p class="mt-6 rounded-2xl bg-paper p-4">"Cette liste n'existe plus."</p> <p class="panel">"Cette liste n'existe plus."</p>
} }
.into_any(); .into_any();
}; };
@@ -285,19 +284,6 @@ fn ListsContent(
items.sort_by_cached_key(Item::sort_key); items.sort_by_cached_key(Item::sort_key);
items items
}); });
// Hides a suggestion as soon as it is added.
let suggestions = StoredValue::new(suggestions);
let suggestions = Memo::new(move |_| {
current.with(|items| {
suggestions.with_value(|suggestions| {
suggestions
.iter()
.filter(|s| !items.iter().any(|i| i.name.to_lowercase() == s.name.to_lowercase()))
.cloned()
.collect::<Vec<_>>()
})
})
});
let to_get = Memo::new(move |_| { let to_get = Memo::new(move |_| {
current.with(|items| { current.with(|items| {
items items
@@ -319,25 +305,34 @@ fn ListsContent(
let total = move || current.with(Vec::len); let total = move || current.with(Vec::len);
let remaining = Signal::derive(move || to_get.with(Vec::len)); let remaining = Signal::derive(move || to_get.with(Vec::len));
// The page takes the color of the open list.
let color = list.color;
Effect::new(move |_| {
if let Ok(Some(meta)) = document().query_selector("meta[name=theme-color]") {
_ = meta.set_attribute("content", color.hex());
}
});
let edit_list = { let edit_list = {
let list = list.clone(); let list = list.clone();
move |_| ctx.list_editor.set(Some(ListEditor::Edit(list.clone()))) move |_| ctx.list_editor.set(Some(ListEditor::Edit(list.clone())))
}; };
view! { view! {
<div class=format!("page-bg {}", color.dot_class()) aria-hidden="true"></div>
<ListTabs lists active=Some(active_id) remaining /> <ListTabs lists active=Some(active_id) remaining />
<section class="ticket relative mt-6 bg-paper px-5 pt-6 pb-8"> <section class="ticket">
<div class="flex items-start justify-between gap-2"> <div class="ticket-head">
<h2 class="font-display text-[1.7rem] leading-tight font-bold tracking-tight"> <h2 class="ticket-title">
{list.name.clone()} {list.name.clone()}
</h2> </h2>
<button <button
class="-mt-1 -mr-2 grid size-11 shrink-0 place-items-center rounded-full text-ink/60 active:bg-ink/5" class="icon-button"
aria-label="Modifier la liste" aria-label="Modifier la liste"
on:click=edit_list on:click=edit_list
> >
<svg viewBox="0 0 24 24" fill="currentColor" class="size-6" aria-hidden="true"> <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<circle cx="5" cy="12" r="2" /> <circle cx="5" cy="12" r="2" />
<circle cx="12" cy="12" r="2" /> <circle cx="12" cy="12" r="2" />
<circle cx="19" cy="12" r="2" /> <circle cx="19" cy="12" r="2" />
@@ -347,29 +342,25 @@ fn ListsContent(
{(!list.is_owner) {(!list.is_owner)
.then(|| { .then(|| {
view! { view! {
<p class="mt-1 font-medium text-ink/60"> <p class="ticket-owner">
{format!("Partagée par {}", list.owner_name)} {format!("Partagée par {}", list.owner_name)}
</p> </p>
} }
})} })}
<p class="mt-1 text-lg text-ink/70">{move || remaining_text(remaining.get(), total())}</p>
<div class="mt-5 grid grid-cols-3 gap-3"> <div class="tiles">
<For each=move || to_get.get() key=|item| (item.id, item.quantity.map(|q| q.label()), item.name.clone(), item.icon, item.category) let:item> <For each=move || to_get.get() key=|item| (item.id, item.quantity.map(|q| q.label()), item.name.clone(), item.icon, item.category) let:item>
<ItemTile item /> <ItemTile item />
</For> </For>
<For each=move || suggestions.get() key=|suggestion| suggestion.name.clone() let:suggestion>
<SuggestionTile suggestion list_id=active_id />
</For>
</div> </div>
<Show when=move || !in_basket.with(Vec::is_empty)> <Show when=move || !in_basket.with(Vec::is_empty)>
<div class="mt-6 border-t-2 border-dashed border-ink/15 pt-5"> <div class="basket">
<div class="flex justify-between font-mono text-sm tracking-[0.2em] text-ink/60 uppercase"> <div class="basket-head">
<span>"Déjà dans le panier"</span> <span>"Déjà dans le panier"</span>
<span>{move || format!("{}/{}", in_basket.with(Vec::len), total())}</span> <span>{move || format!("{}/{}", in_basket.with(Vec::len), total())}</span>
</div> </div>
<div class="mt-4 grid grid-cols-4 gap-2"> <div class="tiles">
<For each=move || in_basket.get() key=|item| (item.id, item.name.clone(), item.icon) let:item> <For each=move || in_basket.get() key=|item| (item.id, item.name.clone(), item.icon) let:item>
<BasketTile item /> <BasketTile item />
</For> </For>
@@ -379,10 +370,10 @@ fn ListsContent(
</section> </section>
<button <button
class="tile-shadow fixed right-[max(1rem,calc(50vw-14rem+1rem))] bottom-[max(1.25rem,env(safe-area-inset-bottom))] z-10 rounded-2xl border-2 border-ink bg-pink px-6 py-4 font-display text-xl font-bold active:translate-y-1 active:shadow-none" class="fab"
on:click=move |_| ctx.item_editor.set(Some(ItemEditor::New)) on:click=move |_| ctx.item_editor.set(Some(ItemEditor::New))
> >
"+ article" "ajouter"
</button> </button>
} }
.into_any() .into_any()
@@ -396,30 +387,21 @@ fn ListTabs(
) -> impl IntoView { ) -> impl IntoView {
let ctx = expect_context::<Ctx>(); let ctx = expect_context::<Ctx>();
view! { view! {
<nav class="-mx-4 mt-5 flex gap-3 overflow-x-auto px-4 pb-1 [scrollbar-width:none]"> <nav class="tabs">
{lists {lists
.into_iter() .into_iter()
.map(|list| { .map(|list| {
let is_active = active == Some(list.id); let is_active = active == Some(list.id);
let class = if is_active { let class = if is_active { "tab tab-active" } else { "tab" };
"border-ink bg-ink text-paper"
} else {
"border-ink bg-paper"
};
view! { view! {
<A <A
href=format!("/l/{}", list.id) href=format!("/l/{}", list.id)
attr:class=format!( attr:class=class
"flex shrink-0 items-center gap-2 rounded-2xl border-2 px-5 py-3 text-lg font-semibold whitespace-nowrap {class}",
)
> >
{(!is_active) {(!is_active)
.then(|| { .then(|| {
view! { view! {
<span class=format!( <span class=format!("dot {}", list.color.dot_class()) />
"size-4 rounded-full border-2 border-ink {}",
list.color.dot_class(),
) />
} }
})} })}
{list.name.clone()} {list.name.clone()}
@@ -429,7 +411,7 @@ fn ListTabs(
}) })
.collect_view()} .collect_view()}
<button <button
class="shrink-0 rounded-2xl border-2 border-dashed border-ink/50 px-5 py-3 text-lg font-semibold text-ink/70" class="tab tab-new"
aria-label="Nouvelle liste" aria-label="Nouvelle liste"
on:click=move |_| ctx.list_editor.set(Some(ListEditor::New)) on:click=move |_| ctx.list_editor.set(Some(ListEditor::New))
> >
@@ -450,10 +432,10 @@ fn ErrorBanner() -> impl IntoView {
view! { view! {
<div <div
role="alert" role="alert"
class="mt-4 flex items-center justify-between gap-3 rounded-2xl border-2 border-ink bg-pink px-4 py-3 font-medium" class="alert"
> >
<span>{msg}</span> <span>{msg}</span>
<button class="font-bold" on:click=move |_| ctx.error.set(None)> <button on:click=move |_| ctx.error.set(None)>
"OK" "OK"
</button> </button>
</div> </div>
@@ -467,10 +449,10 @@ fn ErrorBanner() -> impl IntoView {
fn EmptyState() -> impl IntoView { fn EmptyState() -> impl IntoView {
let ctx = expect_context::<Ctx>(); let ctx = expect_context::<Ctx>();
view! { view! {
<section class="ticket relative mt-6 bg-paper px-5 pt-6 pb-8 text-center"> <section class="ticket ticket-empty">
<p class="text-lg text-ink/70">"Aucune liste pour l'instant."</p> <p class="lead">"Aucune liste pour l'instant."</p>
<button <button
class="tile-shadow mt-4 rounded-2xl border-2 border-ink bg-pink px-5 py-3 font-display font-bold" class="button button-primary"
on:click=move |_| ctx.list_editor.set(Some(ListEditor::New)) on:click=move |_| ctx.list_editor.set(Some(ListEditor::New))
> >
"Créer une liste" "Créer une liste"
@@ -481,26 +463,5 @@ fn EmptyState() -> impl IntoView {
#[component] #[component]
fn TicketSkeleton() -> impl IntoView { fn TicketSkeleton() -> impl IntoView {
view! { <div class="ticket mt-20 h-96 animate-pulse bg-paper/60"></div> } view! { <div class="ticket ticket-skeleton"></div> }
}
fn remaining_text(remaining: usize, total: usize) -> String {
match (remaining, total) {
(_, 0) => "Liste vide : ajoute ton premier article.".to_owned(),
(0, _) => "Tout est dans le panier !".to_owned(),
(1, _) => "Encore 1 article à attraper.".to_owned(),
(n, _) => format!("Encore {n} articles à attraper."),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn remaining_wording() {
assert_eq!(remaining_text(5, 7), "Encore 5 articles à attraper.");
assert_eq!(remaining_text(1, 2), "Encore 1 article à attraper.");
assert_eq!(remaining_text(0, 2), "Tout est dans le panier !");
}
} }
+208 -110
View File
@@ -5,7 +5,7 @@ use leptos_router::hooks::use_navigate;
use super::Ctx; use super::Ctx;
use super::icons::{IconSvg, icon_label}; use super::icons::{IconSvg, icon_label};
use crate::api::get_members; use crate::api::get_members;
use crate::model::{Category, Icon, Item, ItemInput, ItemOp, ListColor, Quantity, ShoppingList, Unit}; use crate::model::{Category, Icon, Item, ItemInput, ItemOp, ListColor, Quantity, ShoppingList, Unit, fold_name};
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum ItemEditor { pub enum ItemEditor {
@@ -30,11 +30,11 @@ pub fn Sheet(title: String, on_close: impl Fn() + Copy + Send + Sync + 'static,
on_cleanup(move || handle.remove()); on_cleanup(move || handle.remove());
view! { view! {
<div class="fixed inset-0 z-20 flex items-end justify-center" role="dialog" aria-modal="true"> <div class="sheet" role="dialog" aria-modal="true">
<div class="absolute inset-0 bg-ink/50" on:click=move |_| on_close()></div> <div class="sheet-backdrop" on:click=move |_| on_close()></div>
<div class="relative max-h-[90dvh] w-full max-w-md overflow-y-auto rounded-t-3xl border-2 border-b-0 border-ink bg-paper px-5 pt-3 pb-[max(1.5rem,env(safe-area-inset-bottom))]"> <div class="sheet-panel">
<div class="mx-auto mb-4 h-1.5 w-12 rounded-full bg-ink/20"></div> <div class="sheet-handle"></div>
<h2 class="font-display text-2xl font-bold">{title}</h2> <h2 class="sheet-title">{title}</h2>
{children()} {children()}
</div> </div>
</div> </div>
@@ -42,36 +42,174 @@ pub fn Sheet(title: String, on_close: impl Fn() + Copy + Send + Sync + 'static,
} }
#[component] #[component]
pub fn ItemSheet(#[prop(into)] list_id: Signal<Option<i64>>) -> impl IntoView { pub fn ItemSheet(
#[prop(into)] list_id: Signal<Option<i64>>,
/// Items of the open list, searched by the add sheet.
items: Memo<Vec<Item>>,
) -> impl IntoView {
let ctx = expect_context::<Ctx>(); let ctx = expect_context::<Ctx>();
move || { move || {
let editor = ctx.item_editor.get()?; let editor = ctx.item_editor.get()?;
let list_id = list_id.get()?; let list_id = list_id.get()?;
Some(view! { <ItemForm editor list_id /> }) Some(match editor {
ItemEditor::New => view! { <AddForm list_id items /> }.into_any(),
ItemEditor::Edit(item) => view! { <ItemForm item /> }.into_any(),
})
}
}
/// Search box over the list: a match is tapped to put it on the list or in
/// the basket, and an unknown name is added.
#[component]
fn AddForm(list_id: i64, items: Memo<Vec<Item>>) -> impl IntoView {
let ctx = expect_context::<Ctx>();
let close = move || ctx.item_editor.set(None);
let query = RwSignal::new(String::new());
let input = NodeRef::<leptos::html::Input>::new();
let refocus = move || {
query.set(String::new());
if let Some(input) = input.get_untracked() {
_ = input.focus();
}
};
// `autofocus` is ignored on elements added after page load.
Effect::new(move |_| {
if let Some(input) = input.get() {
_ = input.focus();
}
});
let needle = Memo::new(move |_| fold_name(query.read().trim()));
let matches = Memo::new(move |_| {
let needle = needle.get();
if needle.is_empty() {
return Vec::new();
}
items.with(|items| {
items
.iter()
.filter(|item| fold_name(&item.name).contains(&needle))
.cloned()
.collect::<Vec<_>>()
})
});
let exact = move || {
let needle = needle.get();
matches.with(|items| items.iter().find(|item| fold_name(&item.name) == needle).cloned())
};
let can_add = move || !needle.with(String::is_empty) && exact().is_none();
let submit = move |ev: ev::SubmitEvent| {
ev.prevent_default();
match exact() {
// Enter on a name already in the basket puts it back on the list.
Some(item) => {
if item.checked {
ctx.change(ItemOp::SetChecked { id: item.id, checked: false });
}
}
None if can_add() => {
let input = ItemInput {
name: query.get_untracked().trim().to_owned(),
quantity: None,
icon: Icon::Basket,
category: Category::Autre,
};
ctx.change(ItemOp::Add { id: 0, list_id, input });
}
None => return,
}
refocus();
};
view! {
<Sheet title="Ajouter".to_owned() on_close=close>
<form class="form form-compact" on:submit=submit>
<input
class="field"
type="search"
enterkeyhint="done"
maxlength="60"
placeholder="Avocats, pain…"
aria-label="Article"
node_ref=input
bind:value=query
/>
<Show when=move || !matches.with(Vec::is_empty)>
<ul class="tiles">
<For
each=move || matches.get()
key=|item| (item.id, item.checked, item.name.clone(), item.icon)
let:item
>
<SearchResult item on_pick=refocus />
</For>
</ul>
</Show>
<Show when=can_add>
<button
type="submit"
class="button button-primary button-add"
>
{move || format!("+ Ajouter « {} »", query.read().trim())}
</button>
</Show>
</form>
</Sheet>
}
}
/// A list item found by the search: tap moves it between the list and the basket.
#[component]
fn SearchResult(item: Item, on_pick: impl Fn() + Copy + Send + Sync + 'static) -> impl IntoView {
let ctx = expect_context::<Ctx>();
let selected = !item.checked;
let (id, icon, name) = (item.id, item.icon, item.name);
// Same looks as the tiles of the list and of the basket.
let class = if selected {
format!("tile tile-item {}", item.category.tile_class())
} else {
"tile tile-off".to_owned()
};
let aria_label = format!("{name} : {}", if selected { "mettre dans le panier" } else { "remettre dans la liste" });
view! {
<li>
<button
type="button"
class=class
aria-label=aria_label
aria-pressed=selected.to_string()
on:click=move |_| {
ctx.change(ItemOp::SetChecked { id, checked: selected });
on_pick();
}
>
<IconSvg icon />
<span class="tile-label">
{name}
</span>
</button>
</li>
} }
} }
#[component] #[component]
fn ItemForm(editor: ItemEditor, list_id: i64) -> impl IntoView { fn ItemForm(item: Item) -> impl IntoView {
let ctx = expect_context::<Ctx>(); let ctx = expect_context::<Ctx>();
let close = move || ctx.item_editor.set(None); let close = move || ctx.item_editor.set(None);
let existing = match &editor { let name = RwSignal::new(item.name.clone());
ItemEditor::Edit(item) => Some(item.clone()),
ItemEditor::New => None,
};
let name = RwSignal::new(existing.as_ref().map(|i| i.name.clone()).unwrap_or_default());
let amount = RwSignal::new( let amount = RwSignal::new(
existing item.quantity
.as_ref()
.and_then(|i| i.quantity)
.map(|q| q.amount.to_string().replace('.', ",")) .map(|q| q.amount.to_string().replace('.', ","))
.unwrap_or_default(), .unwrap_or_default(),
); );
let unit = RwSignal::new(existing.as_ref().and_then(|i| i.quantity).map_or(Unit::Piece, |q| q.unit)); let unit = RwSignal::new(item.quantity.map_or(Unit::Piece, |q| q.unit));
let icon = RwSignal::new(existing.as_ref().map_or(Icon::Basket, |i| i.icon)); let icon = RwSignal::new(item.icon);
let category = RwSignal::new(existing.as_ref().map_or(Category::Autre, |i| i.category)); let category = RwSignal::new(item.category);
let item_id = existing.as_ref().map(|i| i.id); let item_id = item.id;
let invalid_amount = Memo::new(move |_| amount.with(|a| !a.trim().is_empty() && parse_amount(a).is_none())); let invalid_amount = Memo::new(move |_| amount.with(|a| !a.trim().is_empty() && parse_amount(a).is_none()));
@@ -86,43 +224,35 @@ fn ItemForm(editor: ItemEditor, list_id: i64) -> impl IntoView {
icon: icon.get(), icon: icon.get(),
category: category.get(), category: category.get(),
}; };
ctx.change(match item_id { ctx.change(ItemOp::Update { id: item_id, input });
Some(id) => ItemOp::Update { id, input },
None => ItemOp::Add { id: 0, list_id, input },
});
close(); close();
}; };
let delete = move |_| { let delete = move |_| {
if let Some(id) = item_id { ctx.change(ItemOp::Delete { id: item_id });
ctx.change(ItemOp::Delete { id });
close(); close();
}
}; };
let title = if item_id.is_some() { "Modifier l'article" } else { "Nouvel article" };
view! { view! {
<Sheet title=title.to_owned() on_close=close> <Sheet title="Modifier l'article".to_owned() on_close=close>
<form class="mt-4 flex flex-col gap-5" on:submit=submit> <form class="form" on:submit=submit>
<label class="flex flex-col gap-1.5"> <label class="field-group">
<span class="font-mono text-xs tracking-[0.2em] text-ink/60 uppercase">"Nom"</span> <span class="label">"Nom"</span>
<input <input
class="field" class="field"
required required
maxlength="60" maxlength="60"
autofocus
placeholder="Avocats" placeholder="Avocats"
bind:value=name bind:value=name
/> />
</label> </label>
<div class="flex flex-col gap-1.5"> <div class="field-group">
<span class="font-mono text-xs tracking-[0.2em] text-ink/60 uppercase"> <span class="label">
"Quantité (facultatif)" "Quantité (facultatif)"
</span> </span>
<div class="flex gap-2"> <div class="quantity">
<input <input
class="field w-28" class="field"
inputmode="decimal" inputmode="decimal"
placeholder="3" placeholder="3"
aria-label="Quantité" aria-label="Quantité"
@@ -130,7 +260,7 @@ fn ItemForm(editor: ItemEditor, list_id: i64) -> impl IntoView {
bind:value=amount bind:value=amount
/> />
<select <select
class="field flex-1" class="field"
aria-label="Unité" aria-label="Unité"
on:change=move |ev| { on:change=move |ev| {
if let Some(u) = Unit::parse(&event_target_value(&ev)) { if let Some(u) = Unit::parse(&event_target_value(&ev)) {
@@ -151,28 +281,22 @@ fn ItemForm(editor: ItemEditor, list_id: i64) -> impl IntoView {
</select> </select>
</div> </div>
<Show when=move || invalid_amount.get()> <Show when=move || invalid_amount.get()>
<p class="text-sm text-red-700">"Quantité invalide."</p> <p class="field-error">"Quantité invalide."</p>
</Show> </Show>
</div> </div>
<fieldset class="flex flex-col gap-1.5"> <fieldset class="field-group">
<legend class="mb-1.5 font-mono text-xs tracking-[0.2em] text-ink/60 uppercase"> <legend class="label">
"Rayon" "Rayon"
</legend> </legend>
<div class="flex flex-wrap gap-2"> <div class="chips">
{Category::ALL {Category::ALL
.iter() .iter()
.map(|&c| { .map(|&c| {
view! { view! {
<button <button
type="button" type="button"
class=move || { class=format!("chip {}", c.tile_class())
format!(
"rounded-full border-2 px-3 py-1.5 text-sm font-semibold {} {}",
c.tile_class(),
if category.get() == c { "border-ink" } else { "border-transparent opacity-70" },
)
}
aria-pressed=move || (category.get() == c).to_string() aria-pressed=move || (category.get() == c).to_string()
on:click=move |_| category.set(c) on:click=move |_| category.set(c)
> >
@@ -184,64 +308,44 @@ fn ItemForm(editor: ItemEditor, list_id: i64) -> impl IntoView {
</div> </div>
</fieldset> </fieldset>
// New items keep the basket: the icon can be changed when editing. <fieldset class="field-group">
{item_id <legend class="label">
.map(|_| {
view! {
<fieldset class="flex flex-col gap-1.5">
<legend class="mb-1.5 font-mono text-xs tracking-[0.2em] text-ink/60 uppercase">
"Icône" "Icône"
</legend> </legend>
<div class="grid grid-cols-6 gap-2"> <div class="icon-grid">
{Icon::ALL {Icon::ALL
.iter() .iter()
.map(|&i| { .map(|&i| {
view! { view! {
<button <button
type="button" type="button"
class=move || { class="icon-choice"
format!(
"grid aspect-square place-items-center rounded-xl border-2 {}",
if icon.get() == i {
"border-ink bg-lime"
} else {
"border-ink/10 bg-mist"
},
)
}
title=icon_label(i) title=icon_label(i)
aria-label=icon_label(i) aria-label=icon_label(i)
aria-pressed=move || (icon.get() == i).to_string() aria-pressed=move || (icon.get() == i).to_string()
on:click=move |_| icon.set(i) on:click=move |_| icon.set(i)
> >
<IconSvg icon=i class="size-7" /> <IconSvg icon=i />
</button> </button>
} }
}) })
.collect_view()} .collect_view()}
</div> </div>
</fieldset> </fieldset>
}
})}
<div class="flex gap-3"> <div class="actions">
{item_id
.map(|_| {
view! {
<button <button
type="button" type="button"
class="rounded-2xl border-2 border-ink px-4 py-3 font-semibold" class="button"
on:click=delete on:click=delete
> >
"Supprimer" "Supprimer"
</button> </button>
}
})}
<button <button
type="submit" type="submit"
class="tile-shadow flex-1 rounded-2xl border-2 border-ink bg-pink px-4 py-3 font-display text-lg font-bold active:translate-y-1 active:shadow-none" class="button button-primary"
> >
{if item_id.is_some() { "Enregistrer" } else { "Ajouter" }} "Enregistrer"
</button> </button>
</div> </div>
</form> </form>
@@ -314,9 +418,9 @@ fn ListForm(editor: ListEditor) -> impl IntoView {
view! { view! {
<Sheet title=title.to_owned() on_close=close> <Sheet title=title.to_owned() on_close=close>
<form class="mt-4 flex flex-col gap-5" on:submit=submit> <form class="form" on:submit=submit>
<label class="flex flex-col gap-1.5"> <label class="field-group">
<span class="font-mono text-xs tracking-[0.2em] text-ink/60 uppercase">"Nom"</span> <span class="label">"Nom"</span>
<input <input
class="field" class="field"
required required
@@ -329,23 +433,17 @@ fn ListForm(editor: ListEditor) -> impl IntoView {
<Show when=move || list_id.is_none()> <Show when=move || list_id.is_none()>
<fieldset> <fieldset>
<legend class="mb-1.5 font-mono text-xs tracking-[0.2em] text-ink/60 uppercase"> <legend class="label">
"Couleur" "Couleur"
</legend> </legend>
<div class="flex gap-3"> <div class="swatches">
{ListColor::ALL {ListColor::ALL
.iter() .iter()
.map(|&c| { .map(|&c| {
view! { view! {
<button <button
type="button" type="button"
class=move || { class=format!("swatch {}", c.dot_class())
format!(
"size-11 rounded-full border-2 {} {}",
c.dot_class(),
if color.get() == c { "border-ink ring-2 ring-ink ring-offset-2 ring-offset-paper" } else { "border-ink/40" },
)
}
aria-label=c.as_str() aria-label=c.as_str()
aria-pressed=move || (color.get() == c).to_string() aria-pressed=move || (color.get() == c).to_string()
on:click=move |_| color.set(c) on:click=move |_| color.set(c)
@@ -357,13 +455,13 @@ fn ListForm(editor: ListEditor) -> impl IntoView {
</fieldset> </fieldset>
</Show> </Show>
<div class="flex gap-3"> <div class="actions">
{list_id {list_id
.map(|_| { .map(|_| {
view! { view! {
<button <button
type="button" type="button"
class="rounded-2xl border-2 border-ink px-4 py-3 font-semibold" class="button"
on:click=delete on:click=delete
> >
"Supprimer" "Supprimer"
@@ -372,7 +470,7 @@ fn ListForm(editor: ListEditor) -> impl IntoView {
})} })}
<button <button
type="submit" type="submit"
class="tile-shadow flex-1 rounded-2xl border-2 border-ink bg-pink px-4 py-3 font-display text-lg font-bold active:translate-y-1 active:shadow-none" class="button button-primary"
> >
{if list_id.is_some() { "Enregistrer" } else { "Créer" }} {if list_id.is_some() { "Enregistrer" } else { "Créer" }}
</button> </button>
@@ -401,29 +499,29 @@ fn SharePanel(list_id: i64) -> impl IntoView {
}; };
view! { view! {
<section class="mt-6 border-t-2 border-dashed border-ink/15 pt-5"> <section class="section">
<h3 class="font-mono text-xs tracking-[0.2em] text-ink/60 uppercase">"Partagée avec"</h3> <h3 class="label">"Partagée avec"</h3>
<Transition fallback=|| view! { <p class="mt-2 text-ink/50">"…"</p> }> <Transition fallback=|| view! { <p class="section-text">"…"</p> }>
{move || Suspend::new(async move { {move || Suspend::new(async move {
let members = members.await.unwrap_or_default(); let members = members.await.unwrap_or_default();
if members.is_empty() { if members.is_empty() {
return view! { <p class="mt-2 text-ink/60">"Personne pour l'instant."</p> }.into_any(); return view! { <p class="section-text">"Personne pour l'instant."</p> }.into_any();
} }
view! { view! {
<ul class="mt-2 flex flex-col gap-2"> <ul class="people">
{members {members
.into_iter() .into_iter()
.map(|member| { .map(|member| {
let user_id = member.user_id; let user_id = member.user_id;
view! { view! {
<li class="flex items-center justify-between gap-3 rounded-xl bg-mist px-3 py-2"> <li class="person">
<div class="min-w-0"> <div class="person-info">
<p class="truncate font-semibold">{member.name}</p> <p class="person-name">{member.name}</p>
<p class="truncate text-sm text-ink/60">{member.email}</p> <p class="person-email">{member.email}</p>
</div> </div>
<button <button
type="button" type="button"
class="shrink-0 rounded-lg px-2 py-1 text-sm font-semibold underline" class="link-button"
on:click=move |_| { on:click=move |_| {
ctx.mutate(crate::api::remove_member(list_id, user_id), move |_| bump()) ctx.mutate(crate::api::remove_member(list_id, user_id), move |_| bump())
} }
@@ -439,16 +537,16 @@ fn SharePanel(list_id: i64) -> impl IntoView {
.into_any() .into_any()
})} })}
</Transition> </Transition>
<form class="mt-3 flex gap-2" on:submit=share> <form class="share-form" on:submit=share>
<input <input
class="field min-w-0 flex-1" class="field"
type="email" type="email"
required required
placeholder="email@exemple.fr" placeholder="email@exemple.fr"
aria-label="Email de la personne" aria-label="Email de la personne"
bind:value=email bind:value=email
/> />
<button type="submit" class="shrink-0 rounded-2xl border-2 border-ink bg-lime px-4 font-semibold"> <button type="submit" class="button button-lime">
"Partager" "Partager"
</button> </button>
</form> </form>
@@ -477,10 +575,10 @@ fn SharedListInfo(list: ShoppingList) -> impl IntoView {
view! { view! {
<Sheet title=list.name.clone() on_close=close> <Sheet title=list.name.clone() on_close=close>
<p class="mt-1 text-ink/70">{format!("Liste de {}, partagée avec toi.", list.owner_name)}</p> <p class="sheet-text">{format!("Liste de {}, partagée avec toi.", list.owner_name)}</p>
<button <button
type="button" type="button"
class="mt-6 w-full rounded-2xl border-2 border-ink px-4 py-3 font-semibold" class="button button-block"
on:click=leave on:click=leave
> >
"Quitter la liste" "Quitter la liste"
+8 -36
View File
@@ -4,7 +4,7 @@ use leptos::prelude::*;
use super::icons::IconSvg; use super::icons::IconSvg;
use super::transition; use super::transition;
use super::{Ctx, ItemEditor}; use super::{Ctx, ItemEditor};
use crate::model::{Item, ItemInput, ItemOp, Suggestion}; use crate::model::Item;
const LONG_PRESS_MS: u64 = 450; const LONG_PRESS_MS: u64 = 450;
@@ -52,10 +52,7 @@ pub fn ItemTile(item: Item) -> impl IntoView {
view! { view! {
<button <button
class=format!( class=format!("tile tile-item {}", category.tile_class())
"tile-shadow relative flex aspect-square touch-manipulation flex-col items-center gap-1 rounded-2xl border-2 border-ink p-2 pb-2.5 text-center select-none active:translate-y-1 active:shadow-none [-webkit-touch-callout:none] {}",
category.tile_class(),
)
style:view-transition-name=transition::item_name(id) style:view-transition-name=transition::item_name(id)
aria-label=aria_label aria-label=aria_label
on:click=on_click on:click=on_click
@@ -68,44 +65,19 @@ pub fn ItemTile(item: Item) -> impl IntoView {
{badge {badge
.map(|badge| { .map(|badge| {
view! { view! {
<span class="absolute top-2 right-2 rounded-lg bg-ink px-1.5 py-0.5 font-mono text-xs text-paper"> <span class="tile-badge">
{badge} {badge}
</span> </span>
} }
})} })}
<IconSvg icon class="min-h-0 w-full flex-1 text-ink" /> <IconSvg icon />
<span class="line-clamp-2 text-[0.95rem] leading-tight font-semibold break-words hyphens-auto"> <span class="tile-label">
{name} {name}
</span> </span>
</button> </button>
} }
} }
/// Dashed "+ Beurre" tile: one tap adds a frequently bought product.
#[component]
pub fn SuggestionTile(suggestion: Suggestion, list_id: i64) -> impl IntoView {
let ctx = expect_context::<Ctx>();
let Suggestion { name, icon, category } = suggestion;
let label = format!("+ {name}");
let transition_name = transition::suggestion_name(&name);
let add = move |_| {
let input = ItemInput { name: name.clone(), quantity: None, icon, category };
ctx.change(ItemOp::Add { id: 0, list_id, input });
};
view! {
<button
class="relative flex aspect-square flex-col items-center gap-1 rounded-2xl border-2 border-dashed border-ink/35 p-2 pb-2.5 text-center text-ink/55 active:bg-ink/5"
style:view-transition-name=transition_name
on:click=add
>
<IconSvg icon class="min-h-0 w-full flex-1 opacity-60" />
<span class="line-clamp-2 text-[0.95rem] leading-tight font-semibold">{label}</span>
</button>
}
}
/// Greyed tile in "Déjà dans le panier": tap puts the item back on the list. /// Greyed tile in "Déjà dans le panier": tap puts the item back on the list.
#[component] #[component]
pub fn BasketTile(item: Item) -> impl IntoView { pub fn BasketTile(item: Item) -> impl IntoView {
@@ -116,13 +88,13 @@ pub fn BasketTile(item: Item) -> impl IntoView {
view! { view! {
<button <button
class="flex aspect-square flex-col items-center gap-0.5 rounded-2xl bg-mist p-1.5 text-center text-ink/45 active:bg-ink/10" class="tile tile-off"
style:view-transition-name=transition::item_name(id) style:view-transition-name=transition::item_name(id)
aria-label=aria_label aria-label=aria_label
on:click=move |_| item.with_value(|item| ctx.toggle(item)) on:click=move |_| item.with_value(|item| ctx.toggle(item))
> >
<IconSvg icon class="min-h-0 w-full flex-1" /> <IconSvg icon />
<span class="line-clamp-2 text-xs leading-tight font-medium line-through decoration-ink/30"> <span class="tile-label">
{name} {name}
</span> </span>
</button> </button>
-7
View File
@@ -15,13 +15,6 @@ pub fn item_name(id: i64) -> String {
format!("item-{id}") format!("item-{id}")
} }
/// `view-transition-name` of a suggestion tile. Product names may contain
/// spaces or accents, which are not allowed in an identifier: hex-encode them.
pub fn suggestion_name(name: &str) -> String {
let hex: String = name.bytes().map(|b| format!("{b:02x}")).collect();
format!("suggestion-{hex}")
}
#[cfg(feature = "hydrate")] #[cfg(feature = "hydrate")]
mod browser { mod browser {
use js_sys::{Function, Promise, Reflect}; use js_sys::{Function, Promise, Reflect};
+1 -44
View File
@@ -3,7 +3,7 @@ use sqlx::{Row, SqliteConnection};
use std::str::FromStr; use std::str::FromStr;
use crate::model::{ use crate::model::{
Account, Category, Icon, Item, ItemInput, ItemOp, ListColor, Member, Quantity, ShoppingList, Suggestion, Unit, User, Account, Category, Icon, Item, ItemInput, ItemOp, ListColor, Member, Quantity, ShoppingList, Unit, User,
}; };
pub async fn connect(url: &str) -> Result<SqlitePool, sqlx::Error> { pub async fn connect(url: &str) -> Result<SqlitePool, sqlx::Error> {
@@ -439,32 +439,6 @@ pub async fn apply_item_ops(pool: &SqlitePool, user_id: i64, ops: &[ItemOp]) ->
Ok(created) Ok(created)
} }
/// The user's most used products not already on the list.
pub async fn suggestions(pool: &SqlitePool, user_id: i64, list_id: i64, limit: i64) -> Result<Vec<Suggestion>, sqlx::Error> {
sqlx::query(
"SELECT name, icon, category FROM catalog c
WHERE c.user_id = ? AND NOT EXISTS (
SELECT 1 FROM items i WHERE i.list_id = ? AND i.name = c.name COLLATE NOCASE
)
ORDER BY use_count DESC, name
LIMIT ?",
)
.bind(user_id)
.bind(list_id)
.bind(limit)
.fetch_all(pool)
.await?
.iter()
.map(|row| {
Ok(Suggestion {
name: row.try_get("name")?,
icon: decode(Icon::parse(row.try_get("icon")?), "icon")?,
category: decode(Category::parse(row.try_get("category")?), "category")?,
})
})
.collect()
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@@ -587,23 +561,6 @@ mod tests {
assert!(all[0].checked); assert!(all[0].checked);
} }
#[tokio::test]
async fn suggestions_skip_items_on_list() {
let pool = pool().await;
let me = user(&pool, "a@x.fr").await;
let list = lists(&pool, me).await.unwrap()[0].id;
add_item(&mut *conn(&pool).await, me, list, &input("beurre")).await.unwrap();
let names: Vec<_> = suggestions(&pool, me, list, 3)
.await
.unwrap()
.into_iter()
.map(|s| s.name)
.collect();
assert!(!names.iter().any(|n| n.eq_ignore_ascii_case("beurre")));
assert_eq!(names.len(), 3);
}
#[tokio::test] #[tokio::test]
async fn deleting_list_cascades() { async fn deleting_list_cascades() {
let pool = pool().await; let pool = pool().await;
+12 -10
View File
@@ -95,6 +95,16 @@ impl ListColor {
ListColor::Peach => "bg-peach", ListColor::Peach => "bg-peach",
} }
} }
/// Same color as `dot_class`, for the browser's `theme-color`.
pub fn hex(self) -> &'static str {
match self {
ListColor::Lime => "#bfe383",
ListColor::Pink => "#ffadd6",
ListColor::Sky => "#7fdffb",
ListColor::Peach => "#ffbd76",
}
}
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
@@ -117,7 +127,7 @@ impl Item {
/// Lowercases and strips French accents so "Œufs" sorts with "o" and /// Lowercases and strips French accents so "Œufs" sorts with "o" and
/// "Épinards" with "e". /// "Épinards" with "e".
fn fold_name(name: &str) -> String { pub fn fold_name(name: &str) -> String {
let mut folded = String::with_capacity(name.len()); let mut folded = String::with_capacity(name.len());
for c in name.chars().flat_map(char::to_lowercase) { for c in name.chars().flat_map(char::to_lowercase) {
match c { match c {
@@ -218,7 +228,7 @@ impl Category {
} }
} }
/// Tailwind background class for the item tile. /// Background class for the item tile (see style/main.css).
pub fn tile_class(self) -> &'static str { pub fn tile_class(self) -> &'static str {
match self { match self {
Category::FruitsLegumes => "bg-lime", Category::FruitsLegumes => "bg-lime",
@@ -272,14 +282,6 @@ text_enum!(Icon {
Basket => "basket", Basket => "basket",
}); });
/// A frequently bought product, offered as a dashed "+ Beurre" tile.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Suggestion {
pub name: String,
pub icon: Icon,
pub category: Category,
}
/// Payload for creating or editing an item. /// Payload for creating or editing an item.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ItemInput { pub struct ItemInput {
+886 -37
View File
@@ -1,66 +1,911 @@
@import "tailwindcss"; /* Lisette — feuille de style unique, servie telle quelle par cargo-leptos. */
@theme { :root {
--color-lime: #bfe383; --lime: #bfe383;
--color-sky: #7fdffb; --sky: #7fdffb;
--color-peach: #ffbd76; --peach: #ffbd76;
--color-pink: #ffadd6; --pink: #ffadd6;
--color-rose: #ff9b8a; --rose: #ff9b8a;
--color-sand: #f2d9a4; --sand: #f2d9a4;
--color-lilac: #cdb8ff; --lilac: #cdb8ff;
--color-ink: #1c1c24; --ink: #1c1c24;
--color-paper: #fdfcf7; --paper: #fdfcf7;
--color-mist: #efede8; --mist: #efede8;
--error: #c10007;
--ink-5: color-mix(in oklab, var(--ink) 5%, transparent);
--ink-10: color-mix(in oklab, var(--ink) 10%, transparent);
--ink-15: color-mix(in oklab, var(--ink) 15%, transparent);
--ink-20: color-mix(in oklab, var(--ink) 20%, transparent);
--ink-30: color-mix(in oklab, var(--ink) 30%, transparent);
--ink-35: color-mix(in oklab, var(--ink) 35%, transparent);
--ink-40: color-mix(in oklab, var(--ink) 40%, transparent);
--ink-45: color-mix(in oklab, var(--ink) 45%, transparent);
--ink-50: color-mix(in oklab, var(--ink) 50%, transparent);
--ink-55: color-mix(in oklab, var(--ink) 55%, transparent);
--ink-60: color-mix(in oklab, var(--ink) 60%, transparent);
--ink-70: color-mix(in oklab, var(--ink) 70%, transparent);
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif; --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
--font-display: "Unbounded", "Inter", ui-sans-serif, sans-serif; --font-display: "Unbounded", "Inter", ui-sans-serif, sans-serif;
--font-mono: "JetBrains Mono", ui-monospace, monospace; --font-mono: "JetBrains Mono", ui-monospace, monospace;
--radius: 1rem;
--shadow: 0 5px 0 0 var(--ink);
} }
/* Hard drop shadow under tiles and buttons. */ /* ---------- Base ---------- */
@utility tile-shadow {
box-shadow: 0 5px 0 0 var(--color-ink); *,
::before,
::after {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0 solid;
} }
@utility field { html {
border-radius: 0.875rem; line-height: 1.5;
border: 2px solid var(--color-ink); -webkit-text-size-adjust: 100%;
background: white; -webkit-tap-highlight-color: transparent;
padding: 0.75rem 0.875rem;
font-size: 1.0625rem; /* ≥16px: no zoom on iOS focus */
outline: none;
&:focus {
box-shadow: 0 0 0 3px var(--color-lime);
}
&[aria-invalid="true"] {
border-color: var(--color-rose);
}
} }
/* Torn receipt edge along the bottom of the ticket. */ body {
@layer components { background: var(--lime);
.ticket::after { color: var(--ink);
font-family: var(--font-sans);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1,
h2,
h3 {
font-size: inherit;
font-weight: inherit;
}
a {
color: inherit;
text-decoration: inherit;
}
ul {
list-style: none;
}
svg {
display: block;
}
button,
input,
select {
font: inherit;
color: inherit;
letter-spacing: inherit;
background: transparent;
border-radius: 0;
}
button {
cursor: pointer;
}
:disabled {
cursor: default;
}
fieldset {
min-width: 0;
}
/* ---------- Couleurs ---------- */
.bg-lime { background-color: var(--lime); }
.bg-sky { background-color: var(--sky); }
.bg-peach { background-color: var(--peach); }
.bg-pink { background-color: var(--pink); }
.bg-rose { background-color: var(--rose); }
.bg-sand { background-color: var(--sand); }
.bg-lilac { background-color: var(--lilac); }
/* Fond plein écran à la couleur de la liste ouverte. */
.page-bg {
position: fixed;
inset: 0;
z-index: -10;
}
/* ---------- Mise en page ---------- */
.page {
display: flex;
flex-direction: column;
max-width: 28rem;
min-height: 100dvh;
margin-inline: auto;
padding: max(1.5rem, env(safe-area-inset-top)) 1rem 8rem;
}
.page-auth {
padding-bottom: 4rem;
}
.page-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.page-title {
font-family: var(--font-display);
font-size: 3rem;
font-weight: 800;
line-height: 0.9;
letter-spacing: -0.025em;
}
.page-not-found {
padding: 1rem;
}
.avatar {
display: grid;
place-items: center;
flex-shrink: 0;
width: 3.5rem;
height: 3.5rem;
border-radius: var(--radius);
background: var(--ink);
color: var(--lime);
font-family: var(--font-display);
font-size: 1.125rem;
font-weight: 700;
}
.notice {
margin-top: 1rem;
padding: 0.75rem 1rem;
border-radius: var(--radius);
background: color-mix(in oklab, var(--paper) 70%, transparent);
color: var(--ink-70);
font-weight: 500;
}
.panel {
margin-top: 1.5rem;
padding: 1rem;
border-radius: var(--radius);
background: var(--paper);
}
.alert {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
margin-top: 1rem;
padding: 0.75rem 1rem;
border: 2px solid var(--ink);
border-radius: var(--radius);
background: var(--pink);
font-weight: 500;
}
.alert button {
font-weight: 700;
}
.form-error {
padding: 0.5rem 0.75rem;
border: 2px solid var(--ink);
border-radius: 0.75rem;
background: var(--pink);
font-weight: 500;
}
/* ---------- Ticket (carte papier à bord déchiré) ---------- */
.ticket {
position: relative;
margin-top: 1.5rem;
padding: 1.5rem 1.25rem 2rem;
background: var(--paper);
}
.ticket::after {
content: ""; content: "";
position: absolute; position: absolute;
inset-inline: 0; inset-inline: 0;
top: 100%; top: 100%;
height: 10px; height: 10px;
background: background:
linear-gradient(135deg, var(--color-paper) 50%, transparent 50%) 0 0 / 14px 10px repeat-x, linear-gradient(135deg, var(--paper) 50%, transparent 50%) 0 0 / 14px 10px repeat-x,
linear-gradient(225deg, var(--color-paper) 50%, transparent 50%) 0 0 / 14px 10px repeat-x; linear-gradient(225deg, var(--paper) 50%, transparent 50%) 0 0 / 14px 10px repeat-x;
}
.page-auth .ticket {
margin-top: 2rem;
}
.ticket-empty {
text-align: center;
}
.ticket-skeleton {
height: 24rem;
margin-top: 5rem;
background: color-mix(in oklab, var(--paper) 60%, transparent);
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
50% {
opacity: 0.5;
} }
} }
html { .ticket-head {
-webkit-tap-highlight-color: transparent; display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 0.5rem;
} }
/* Tiles moving between the list and the basket (see src/app/transition.rs). */ .eyebrow {
color: var(--ink-60);
font-family: var(--font-mono);
font-size: 0.875rem;
line-height: 1.25rem;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.ticket-title {
font-family: var(--font-display);
font-size: 1.7rem;
font-weight: 700;
line-height: 1.25;
letter-spacing: -0.025em;
}
.eyebrow + .ticket-title {
margin-top: 0.25rem;
}
.ticket-owner {
margin-top: 0.25rem;
color: var(--ink-60);
font-weight: 500;
}
.lead {
margin-top: 0.25rem;
color: var(--ink-70);
font-size: 1.125rem;
line-height: 1.75rem;
}
.ticket-empty .lead {
margin-top: 0;
}
.loading {
margin-top: 1rem;
color: var(--ink-50);
}
.footnote {
margin-top: 1.5rem;
color: var(--ink-70);
text-align: center;
}
.footnote a {
font-weight: 600;
text-decoration: underline;
}
.icon-button {
display: grid;
place-items: center;
flex-shrink: 0;
width: 2.75rem;
height: 2.75rem;
margin: -0.25rem -0.5rem 0 0;
border-radius: 9999px;
color: var(--ink-60);
}
.icon-button:active {
background: var(--ink-5);
}
.icon-button svg {
width: 1.5rem;
height: 1.5rem;
}
/* ---------- Onglets des listes ---------- */
.tabs {
display: flex;
gap: 0.75rem;
margin: 1.25rem -1rem 0;
padding: 0 1rem 0.25rem;
overflow-x: auto;
scrollbar-width: none;
}
.tab {
display: flex;
flex-shrink: 0;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.25rem;
border: 2px solid var(--ink);
border-radius: var(--radius);
background: var(--paper);
font-size: 1.125rem;
font-weight: 600;
line-height: 1.75rem;
white-space: nowrap;
}
.tab-active {
background: var(--ink);
color: var(--paper);
}
.tab-new {
border-style: dashed;
border-color: var(--ink-50);
background: transparent;
color: var(--ink-70);
}
.dot {
width: 1rem;
height: 1rem;
border: 2px solid var(--ink);
border-radius: 9999px;
}
/* ---------- Tuiles ---------- */
.tiles {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 0.75rem;
}
.ticket .tiles {
margin-top: 1.25rem;
}
.tile {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
gap: 0.25rem;
width: 100%;
aspect-ratio: 1;
padding: 0.5rem 0.5rem 0.625rem;
border: 2px solid var(--ink);
border-radius: var(--radius);
text-align: center;
}
.tile svg {
flex: 1;
width: 100%;
min-height: 0;
}
.tile-label {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
font-size: 0.95rem;
font-weight: 600;
line-height: 1.25;
overflow-wrap: break-word;
hyphens: auto;
}
/* Article à acheter : tuile colorée qui s'enfonce au toucher. */
.tile-item {
box-shadow: var(--shadow);
touch-action: manipulation;
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
}
.tile-item:active {
transform: translateY(0.25rem);
box-shadow: none;
}
.tile-badge {
position: absolute;
top: 0.5rem;
right: 0.5rem;
padding: 0.125rem 0.375rem;
border-radius: 0.5rem;
background: var(--ink);
color: var(--paper);
font-family: var(--font-mono);
font-size: 0.75rem;
line-height: 1rem;
}
/* Article dans le panier : tuile grise barrée. */
.tile-off {
border-color: transparent;
background: var(--mist);
color: var(--ink-45);
}
.tile-off:active {
background: var(--ink-10);
}
.tile-off .tile-label {
font-weight: 500;
text-decoration: line-through;
text-decoration-color: var(--ink-30);
}
.basket {
margin-top: 1.5rem;
padding-top: 1.25rem;
border-top: 2px dashed var(--ink-15);
}
.basket-head {
display: flex;
justify-content: space-between;
color: var(--ink-60);
font-family: var(--font-mono);
font-size: 0.875rem;
line-height: 1.25rem;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.basket .tiles {
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 0.5rem;
margin-top: 1rem;
}
.basket .tile {
gap: 0.125rem;
padding: 0.375rem;
border: 0;
}
.basket .tile-label {
font-size: 0.75rem;
}
/* ---------- Boutons ---------- */
.button {
padding: 0.75rem 1rem;
border: 2px solid var(--ink);
border-radius: var(--radius);
font-weight: 600;
text-align: center;
}
.button:disabled {
opacity: 0.6;
}
.button-primary {
background: var(--pink);
box-shadow: var(--shadow);
font-family: var(--font-display);
font-size: 1.125rem;
font-weight: 700;
line-height: 1.75rem;
}
.button-primary:active:not(:disabled) {
transform: translateY(0.25rem);
box-shadow: none;
}
.button-lime {
background: var(--lime);
}
.button-paper {
flex-shrink: 0;
background: var(--paper);
}
.button-block {
display: block;
width: 100%;
}
.button-add {
text-align: left;
}
/* Gros bouton flottant en bas à droite. */
.fab {
position: fixed;
right: max(1rem, calc(50vw - 14rem + 1rem));
bottom: max(1.25rem, env(safe-area-inset-bottom));
z-index: 10;
padding: 1rem 1.5rem;
border: 2px solid var(--ink);
border-radius: var(--radius);
background: var(--pink);
box-shadow: var(--shadow);
font-family: var(--font-display);
font-size: 1.25rem;
font-weight: 700;
line-height: 1.75rem;
}
.fab:active {
transform: translateY(0.25rem);
box-shadow: none;
}
.ticket-empty .button {
margin-top: 1rem;
padding-inline: 1.25rem;
font-size: 1rem;
}
.actions {
display: flex;
gap: 0.75rem;
}
.actions .button-primary {
flex: 1;
}
.link-button {
flex-shrink: 0;
padding: 0.25rem 0.5rem;
border-radius: 0.5rem;
font-size: 0.875rem;
font-weight: 600;
line-height: 1.25rem;
text-decoration: underline;
}
/* ---------- Feuilles (panneaux du bas) ---------- */
.sheet {
position: fixed;
inset: 0;
z-index: 20;
display: flex;
align-items: flex-end;
justify-content: center;
}
.sheet-backdrop {
position: absolute;
inset: 0;
background: var(--ink-50);
}
.sheet-panel {
position: relative;
width: 100%;
max-width: 28rem;
max-height: 90dvh;
overflow-y: auto;
padding: 0.75rem 1.25rem max(1.5rem, env(safe-area-inset-bottom));
border: 2px solid var(--ink);
border-bottom: 0;
border-radius: 1.5rem 1.5rem 0 0;
background: var(--paper);
}
.sheet-handle {
width: 3rem;
height: 0.375rem;
margin: 0 auto 1rem;
border-radius: 9999px;
background: var(--ink-20);
}
.sheet-title {
font-family: var(--font-display);
font-size: 1.5rem;
font-weight: 700;
line-height: 2rem;
}
.sheet-text {
margin-top: 0.25rem;
color: var(--ink-70);
}
.sheet-panel > .button-block {
margin-top: 1.5rem;
}
.sheet-panel > form > .button-block {
margin-top: 0.75rem;
}
/* ---------- Formulaires ---------- */
.form {
display: flex;
flex-direction: column;
gap: 1.25rem;
margin-top: 1rem;
}
.form-compact {
gap: 1rem;
}
.ticket .form {
margin-top: 1.25rem;
}
.form > .button-primary:last-child {
margin-top: 0.5rem;
}
.form > .actions:last-child {
margin-top: 0.5rem;
}
.field-group {
display: flex;
flex-direction: column;
gap: 0.375rem;
}
.label {
color: var(--ink-60);
font-family: var(--font-mono);
font-size: 0.75rem;
line-height: 1rem;
letter-spacing: 0.2em;
text-transform: uppercase;
}
legend.label {
margin-bottom: 0.375rem;
}
.field {
min-width: 0;
padding: 0.75rem 0.875rem;
border: 2px solid var(--ink);
border-radius: 0.875rem;
background: white;
font-size: 1.0625rem; /* ≥16px : pas de zoom sur iOS au focus */
outline: none;
}
.field:focus {
box-shadow: 0 0 0 3px var(--lime);
}
.field[aria-invalid="true"] {
border-color: var(--rose);
}
.field-error {
color: var(--error);
font-size: 0.875rem;
line-height: 1.25rem;
}
.quantity {
display: flex;
gap: 0.5rem;
}
.quantity .field {
flex: 1;
}
.quantity .field:first-child {
flex: 0 0 7rem;
}
.checkbox {
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 500;
}
.checkbox input {
width: 1.5rem;
height: 1.5rem;
accent-color: var(--ink);
}
/* Rayons : pastilles colorées. */
.chips {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.chip {
padding: 0.375rem 0.75rem;
border: 2px solid transparent;
border-radius: 9999px;
font-size: 0.875rem;
font-weight: 600;
line-height: 1.25rem;
opacity: 0.7;
}
.chip[aria-pressed="true"] {
border-color: var(--ink);
opacity: 1;
}
/* Choix de l'icône. */
.icon-grid {
display: grid;
grid-template-columns: repeat(6, minmax(0, 1fr));
gap: 0.5rem;
}
.icon-choice {
display: grid;
place-items: center;
aspect-ratio: 1;
border: 2px solid var(--ink-10);
border-radius: 0.75rem;
background: var(--mist);
}
.icon-choice[aria-pressed="true"] {
border-color: var(--ink);
background: var(--lime);
}
.icon-choice svg {
width: 1.75rem;
height: 1.75rem;
}
/* Choix de la couleur d'une liste. */
.swatches {
display: flex;
gap: 0.75rem;
}
.swatch {
width: 2.75rem;
height: 2.75rem;
border: 2px solid var(--ink-40);
border-radius: 9999px;
}
.swatch[aria-pressed="true"] {
border-color: var(--ink);
box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}
/* ---------- Partage et comptes ---------- */
.section {
margin-top: 1.5rem;
padding-top: 1.25rem;
border-top: 2px dashed var(--ink-15);
}
.section-text {
margin-top: 0.5rem;
color: var(--ink-60);
}
.people {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-top: 0.5rem;
}
.ticket .people {
margin-top: 1.25rem;
}
.person {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
width: 100%;
padding: 0.5rem 0.75rem;
border-radius: 0.75rem;
background: var(--mist);
text-align: left;
}
button.person:active {
background: var(--ink-10);
}
.person-info {
min-width: 0;
}
.person-name,
.person-email {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.person-name {
font-weight: 600;
}
.person-email,
.person-date {
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--ink-60);
}
.person-date {
color: var(--ink-50);
}
.badge {
flex-shrink: 0;
padding: 0.125rem 0.5rem;
border: 2px solid var(--ink);
border-radius: 0.5rem;
background: var(--lime);
font-family: var(--font-mono);
font-size: 0.75rem;
line-height: 1rem;
text-transform: uppercase;
}
.share-form {
display: flex;
gap: 0.5rem;
margin-top: 0.75rem;
}
.share-form .field {
flex: 1;
}
.share-form .button {
flex-shrink: 0;
padding-block: 0;
}
/* ---------- Animations entre la liste et le panier (voir src/app/transition.rs) ---------- */
::view-transition-group(*) { ::view-transition-group(*) {
animation-duration: 320ms; animation-duration: 320ms;
animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
} }
::view-transition-old(*), ::view-transition-old(*),
::view-transition-new(*) { ::view-transition-new(*) {
animation-duration: 200ms; animation-duration: 200ms;
@@ -72,4 +917,8 @@ html {
::view-transition-new(*) { ::view-transition-new(*) {
animation: none; animation: none;
} }
.ticket-skeleton {
animation: none;
}
} }