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 register = ServerAction::<Register>::new();
|
||||||
let logout = ServerAction::<Logout>::new();
|
let logout = ServerAction::<Logout>::new();
|
||||||
let me = Resource::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(),
|
|_| get_me(),
|
||||||
);
|
);
|
||||||
let registration = Resource::new(|| (), |_| registration_enabled());
|
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);
|
provide_context(auth);
|
||||||
auth
|
auth
|
||||||
}
|
}
|
||||||
@@ -73,7 +85,7 @@ fn AuthLayout(title: &'static str, children: Children) -> impl IntoView {
|
|||||||
<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="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">
|
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight">
|
||||||
"mes"<br />"listes"
|
"mes listes"
|
||||||
</h1>
|
</h1>
|
||||||
<section class="ticket relative mt-8 bg-paper px-5 pt-6 pb-8">
|
<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>
|
<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);
|
provide_context(ctx);
|
||||||
|
|
||||||
let params = use_params_map();
|
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 lists = Resource::new(move || ctx.refresh.get(), |_| get_lists());
|
||||||
let items = Resource::new(
|
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">
|
<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">
|
<header class="flex items-start justify-between gap-4">
|
||||||
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight">
|
<h1 class="font-display text-5xl leading-[0.9] font-extrabold tracking-tight">
|
||||||
"mes"<br />"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="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<_>>()
|
.collect::<Vec<_>>()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
let to_get = Memo::new(move |_| current.with(|items| items.iter().filter(|i| !i.checked).cloned().collect::<Vec<_>>()));
|
let to_get = Memo::new(move |_| {
|
||||||
let in_basket = Memo::new(move |_| current.with(|items| items.iter().filter(|i| i.checked).cloned().collect::<Vec<_>>()));
|
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 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));
|
||||||
|
|
||||||
@@ -345,7 +366,11 @@ fn ListsContent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[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>();
|
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="-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];
|
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 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 {
|
else {
|
||||||
return String::new();
|
return String::new();
|
||||||
};
|
};
|
||||||
// Sakamoto's algorithm, 0 = Sunday.
|
// Sakamoto's algorithm, 0 = Sunday.
|
||||||
let y_adj = if m < 3 { y - 1 } else { y };
|
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])
|
format!("{} {d:02}/{m:02}", DAYS[weekday as usize])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user