Titre « mes listes » sur une ligne et formatage rustfmt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cbaab7234b
commit
e7df0edad2
2 files changed
+49
-10
No files matched your search
+15
-3
@@ -23,11 +23,23 @@ impl Auth {
|
||||
let register = ServerAction::<Register>::new();
|
||||
let logout = ServerAction::<Logout>::new();
|
||||
let me = Resource::new(
|
||||
move || (login.version().get(), register.version().get(), logout.version().get()),
|
||||
move || {
|
||||
(
|
||||
login.version().get(),
|
||||
register.version().get(),
|
||||
logout.version().get(),
|
||||
)
|
||||
},
|
||||
|_| get_me(),
|
||||
);
|
||||
let registration = Resource::new(|| (), |_| registration_enabled());
|
||||
let auth = Auth { me, login, register, logout, registration };
|
||||
let auth = Auth {
|
||||
me,
|
||||
login,
|
||||
register,
|
||||
logout,
|
||||
registration,
|
||||
};
|
||||
provide_context(auth);
|
||||
auth
|
||||
}
|
||||
@@ -73,7 +85,7 @@ fn AuthLayout(title: &'static str, children: Children) -> impl IntoView {
|
||||
<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">
|
||||
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight">
|
||||
"mes"<br />"listes"
|
||||
"mes listes"
|
||||
</h1>
|
||||
<section class="ticket relative mt-8 bg-paper px-5 pt-6 pb-8">
|
||||
<p class="font-mono text-sm tracking-[0.2em] text-ink/60 uppercase">"Lisette · Courses"</p>
|
||||
|
||||
+34
-7
@@ -154,7 +154,12 @@ fn ListsView(user: User) -> impl IntoView {
|
||||
provide_context(ctx);
|
||||
|
||||
let params = use_params_map();
|
||||
let active_id = Memo::new(move |_| params.read().get("id").and_then(|id| id.parse::<i64>().ok()));
|
||||
let active_id = Memo::new(move |_| {
|
||||
params
|
||||
.read()
|
||||
.get("id")
|
||||
.and_then(|id| id.parse::<i64>().ok())
|
||||
});
|
||||
|
||||
let lists = Resource::new(move || ctx.refresh.get(), |_| get_lists());
|
||||
let items = Resource::new(
|
||||
@@ -180,7 +185,7 @@ fn ListsView(user: User) -> impl IntoView {
|
||||
<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">
|
||||
<header class="flex items-start justify-between gap-4">
|
||||
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight">
|
||||
"mes"<br />"listes"
|
||||
"mes listes"
|
||||
</h1>
|
||||
<button
|
||||
class="grid size-14 shrink-0 place-items-center rounded-2xl bg-ink font-display text-lg font-bold text-lime"
|
||||
@@ -266,8 +271,24 @@ fn ListsContent(
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
});
|
||||
let to_get = Memo::new(move |_| current.with(|items| items.iter().filter(|i| !i.checked).cloned().collect::<Vec<_>>()));
|
||||
let in_basket = Memo::new(move |_| current.with(|items| items.iter().filter(|i| i.checked).cloned().collect::<Vec<_>>()));
|
||||
let to_get = Memo::new(move |_| {
|
||||
current.with(|items| {
|
||||
items
|
||||
.iter()
|
||||
.filter(|i| !i.checked)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
});
|
||||
let in_basket = Memo::new(move |_| {
|
||||
current.with(|items| {
|
||||
items
|
||||
.iter()
|
||||
.filter(|i| i.checked)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
});
|
||||
let total = move || current.with(Vec::len);
|
||||
let remaining = Signal::derive(move || to_get.with(Vec::len));
|
||||
|
||||
@@ -345,7 +366,11 @@ fn ListsContent(
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn ListTabs(lists: Vec<ShoppingList>, active: Option<i64>, #[prop(into)] remaining: Signal<usize>) -> impl IntoView {
|
||||
fn ListTabs(
|
||||
lists: Vec<ShoppingList>,
|
||||
active: Option<i64>,
|
||||
#[prop(into)] remaining: Signal<usize>,
|
||||
) -> impl IntoView {
|
||||
let ctx = expect_context::<Ctx>();
|
||||
view! {
|
||||
<nav class="-mx-4 mt-5 flex gap-3 overflow-x-auto px-4 pb-1 [scrollbar-width:none]">
|
||||
@@ -451,13 +476,15 @@ fn ticket_date(iso: &str) -> String {
|
||||
const OFFSETS: [i32; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];
|
||||
|
||||
let mut parts = iso.split('-').map(|p| p.parse::<i32>().ok());
|
||||
let (Some(Some(y)), Some(Some(m @ 1..=12)), Some(Some(d))) = (parts.next(), parts.next(), parts.next())
|
||||
let (Some(Some(y)), Some(Some(m @ 1..=12)), Some(Some(d))) =
|
||||
(parts.next(), parts.next(), parts.next())
|
||||
else {
|
||||
return String::new();
|
||||
};
|
||||
// Sakamoto's algorithm, 0 = Sunday.
|
||||
let y_adj = if m < 3 { y - 1 } else { y };
|
||||
let weekday = (y_adj + y_adj / 4 - y_adj / 100 + y_adj / 400 + OFFSETS[(m - 1) as usize] + d) % 7;
|
||||
let weekday =
|
||||
(y_adj + y_adj / 4 - y_adj / 100 + y_adj / 400 + OFFSETS[(m - 1) as usize] + d) % 7;
|
||||
format!("{} {d:02}/{m:02}", DAYS[weekday as usize])
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user