diff --git a/Cargo.toml b/Cargo.toml
index a0fd924..b6aa36b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ dotenvy = { version = "0.15", optional = true }
serde = { version = "1", features = ["derive"] }
wasm-bindgen = { version = "=0.2.128", 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 }
console_error_panic_hook = { version = "0.1", optional = true }
diff --git a/src/app/mod.rs b/src/app/mod.rs
index dc39003..50cb331 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -196,6 +196,16 @@ fn ListsView(user: User) -> impl IntoView {
},
);
+ // Items of the open list with unsaved changes, for the add sheet.
+ let list_items = Memo::new(move |_| match (active_id.get(), items.get()) {
+ (Some(id), Some(Ok((items, _)))) => {
+ let mut items = ctx.sync.apply(id, &items);
+ items.sort_by_cached_key(|item| crate::model::fold_name(&item.name));
+ items
+ }
+ _ => Vec::new(),
+ });
+
view! {
@@ -241,7 +251,7 @@ fn ListsView(user: User) -> impl IntoView {
-
+
}
@@ -319,12 +329,21 @@ fn ListsContent(
let total = move || current.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 list = list.clone();
move |_| ctx.list_editor.set(Some(ListEditor::Edit(list.clone())))
};
view! {
+
@@ -382,7 +401,7 @@ fn ListsContent(
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"
on:click=move |_| ctx.item_editor.set(Some(ItemEditor::New))
>
- "+ article"
+ "ajouter"
}
.into_any()
diff --git a/src/app/sheets.rs b/src/app/sheets.rs
index 4b3c671..a431f75 100644
--- a/src/app/sheets.rs
+++ b/src/app/sheets.rs
@@ -5,7 +5,7 @@ use leptos_router::hooks::use_navigate;
use super::Ctx;
use super::icons::{IconSvg, icon_label};
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)]
pub enum ItemEditor {
@@ -42,36 +42,177 @@ pub fn Sheet(title: String, on_close: impl Fn() + Copy + Send + Sync + 'static,
}
#[component]
-pub fn ItemSheet(#[prop(into)] list_id: Signal