Compare commits
2
Commits
9aa81a22fe
...
444319f9a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
444319f9a5 | ||
|
|
a34e86dea6 |
No files matched your search
+4
-32
@@ -329,11 +329,11 @@ fn ListsContent(
|
||||
|
||||
<section class="ticket relative mt-6 bg-paper px-5 pt-6 pb-8">
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<p class="font-mono text-sm tracking-[0.2em] text-ink/60 uppercase">
|
||||
{format!("Ticket N°{:03} · {}", list.id, ticket_date(&list.created_at))}
|
||||
</p>
|
||||
<h2 class="font-display text-[1.7rem] leading-tight font-bold tracking-tight">
|
||||
{list.name.clone()}
|
||||
</h2>
|
||||
<button
|
||||
class="-mt-2 -mr-2 grid size-11 place-items-center rounded-full text-ink/60 active:bg-ink/5"
|
||||
class="-mt-1 -mr-2 grid size-11 shrink-0 place-items-center rounded-full text-ink/60 active:bg-ink/5"
|
||||
aria-label="Modifier la liste"
|
||||
on:click=edit_list
|
||||
>
|
||||
@@ -344,9 +344,6 @@ fn ListsContent(
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<h2 class="mt-1 font-display text-[1.7rem] leading-tight font-bold tracking-tight">
|
||||
{list.name.clone()}
|
||||
</h2>
|
||||
{(!list.is_owner)
|
||||
.then(|| {
|
||||
view! {
|
||||
@@ -496,35 +493,10 @@ fn remaining_text(remaining: usize, total: usize) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// "2026-10-07" → "mer. 07/10" (upper-cased by CSS).
|
||||
fn ticket_date(iso: &str) -> String {
|
||||
const DAYS: [&str; 7] = ["dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."];
|
||||
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())
|
||||
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;
|
||||
format!("{} {d:02}/{m:02}", DAYS[weekday as usize])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn formats_ticket_date() {
|
||||
assert_eq!(ticket_date("2026-10-07"), "mer. 07/10");
|
||||
assert_eq!(ticket_date("2024-02-29"), "jeu. 29/02");
|
||||
assert_eq!(ticket_date("garbage"), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remaining_wording() {
|
||||
assert_eq!(remaining_text(5, 7), "Encore 5 articles à attraper.");
|
||||
|
||||
+39
-33
@@ -184,39 +184,45 @@ fn ItemForm(editor: ItemEditor, list_id: i64) -> impl IntoView {
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<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"
|
||||
</legend>
|
||||
<div class="grid grid-cols-6 gap-2">
|
||||
{Icon::ALL
|
||||
.iter()
|
||||
.map(|&i| {
|
||||
view! {
|
||||
<button
|
||||
type="button"
|
||||
class=move || {
|
||||
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)
|
||||
aria-label=icon_label(i)
|
||||
aria-pressed=move || (icon.get() == i).to_string()
|
||||
on:click=move |_| icon.set(i)
|
||||
>
|
||||
<IconSvg icon=i class="size-7" />
|
||||
</button>
|
||||
}
|
||||
})
|
||||
.collect_view()}
|
||||
</div>
|
||||
</fieldset>
|
||||
// New items keep the basket: the icon can be changed when editing.
|
||||
{item_id
|
||||
.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"
|
||||
</legend>
|
||||
<div class="grid grid-cols-6 gap-2">
|
||||
{Icon::ALL
|
||||
.iter()
|
||||
.map(|&i| {
|
||||
view! {
|
||||
<button
|
||||
type="button"
|
||||
class=move || {
|
||||
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)
|
||||
aria-label=icon_label(i)
|
||||
aria-pressed=move || (icon.get() == i).to_string()
|
||||
on:click=move |_| icon.set(i)
|
||||
>
|
||||
<IconSvg icon=i class="size-7" />
|
||||
</button>
|
||||
}
|
||||
})
|
||||
.collect_view()}
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
||||
})}
|
||||
|
||||
<div class="flex gap-3">
|
||||
{item_id
|
||||
|
||||
Reference in new issue
Block a user