euv_ui/component/calendar/view/struct.rs
1use super::*;
2
3/// One cell of the [`euv_calendar`] day grid.
4///
5/// The calendar is pure presentation: the caller computes the month, the
6/// leading/trailing spill-over cells and the today flag, then hands the
7/// finished grid in. This keeps the component free of date arithmetic.
8#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
9pub struct EuvCalendarDay {
10 /// The day-of-month number rendered inside the cell.
11 #[get(type(copy))]
12 pub day: u32,
13 /// Whether the cell belongs to the previous or next month.
14 ///
15 /// Drives the `_muted` modifier so spill-over cells read as secondary
16 /// without changing the grid's shape.
17 #[get(type(copy))]
18 pub muted: bool,
19 /// Whether the cell is today's date.
20 #[get(type(copy))]
21 pub today: bool,
22}
23
24/// The column headings of the [`euv_calendar`] day grid.
25///
26/// The order of the vector — not the enum order — decides the column order,
27/// so a locale that starts the week on Sunday simply passes
28/// `[EuvCalendarWeekday::Sun, ..]`.
29#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
30pub enum EuvCalendarWeekday {
31 /// Monday.
32 #[default]
33 Mon,
34 /// Tuesday.
35 Tue,
36 /// Wednesday.
37 Wed,
38 /// Thursday.
39 Thu,
40 /// Friday.
41 Fri,
42 /// Saturday.
43 Sat,
44 /// Sunday.
45 Sun,
46}
47
48/// Props for the [`euv_calendar`] component.
49///
50/// The component renders only what it is given: `weekdays` drives the header
51/// row and `days` the grid. No date is computed here.
52#[derive(Clone, CustomDebug, Default)]
53pub struct EuvCalendarProps {
54 /// The month caption rendered in the header row.
55 pub title: &'static str,
56 /// The column headings, in display order.
57 pub weekdays: Vec<EuvCalendarWeekday>,
58 /// The day cells, in display order.
59 pub days: Vec<EuvCalendarDay>,
60 /// The currently selected day number.
61 pub selected: Signal<u32>,
62}