Diagnosics styling

It looks nice now
This commit is contained in:
2026-05-05 16:34:09 +02:00
parent 7bde1470a1
commit d41b31b5af
3 changed files with 183 additions and 16 deletions

View File

@@ -254,7 +254,7 @@ pub fn submit_stats_component() -> Html {
.unwrap_or((0, ())); .unwrap_or((0, ()));
html! { html! {
<div> <div class="diagnostics-section">
if *loading { if *loading {
<p>{ "Loading..." }</p> <p>{ "Loading..." }</p>
} }
@@ -262,17 +262,32 @@ pub fn submit_stats_component() -> Html {
<p style="color: red;">{ e.clone() }</p> <p style="color: red;">{ e.clone() }</p>
} }
<h3>{ "Tickets per weekday" }</h3> <h3>{ "Tickets per weekday" }</h3>
<ul> <div class="weekday-chart">
{ for (0..7).map(|i| { <div class="weekday-bars">
let is_max = i == max_idx; { for (0..7).map(|i| {
html! { let is_max = i == max_idx;
<li style={ if is_max { "font-weight: bold; color: green;" } else { "" } }> let max_value = counts.iter().cloned().max().unwrap_or(1).max(1);
{ format!("{}: {:3}", weekdays[i], avg[i]) } let bar_height_percent = if max_value > 0 { (avg[i] / max_value as f64) * 100.0 } else { 0.0 };
{ if is_max { html!{ <span>{ " ← most" }</span> } } else { html!{} } } let bar_height_px = (bar_height_percent * 200.0 / 100.0) as i32;
</li> html! {
} <div class="weekday-bar">
})} <div class={format!("bar{}", if is_max { " max" } else { "" })} style={format!("height: {}px;", bar_height_px)}>
</ul> </div>
</div>
}
})}
</div>
<div class="weekday-labels">
{ for (0..7).map(|i| {
html! {
<div class="label-item">
<div class="day">{ weekdays[i] }</div>
<div class="value">{ format!("{:.1}", avg[i]) }</div>
</div>
}
})}
</div>
</div>
<RoomTotalTickets tickets={(*tickets).clone()}/> <RoomTotalTickets tickets={(*tickets).clone()}/>
</div> </div>
} }
@@ -288,15 +303,29 @@ fn room_total_component(props: &RoomTotalsProps) -> Html {
let mut totals_vec: Vec<(i16, usize)> = totals.into_iter().collect(); let mut totals_vec: Vec<(i16, usize)> = totals.into_iter().collect();
totals_vec.sort_by(|a, b| b.1.cmp(&a.1)); totals_vec.sort_by(|a, b| b.1.cmp(&a.1));
let max_count = totals_vec.iter().map(|(_, c)| *c).max().unwrap_or(1).max(1);
html! { html! {
<div> <div class="diagnostics-section">
<h3>{ "Tickets pro Raum" }</h3> <h3>{ "Tickets pro Raum" }</h3>
<ul> <div class="room-chart">
{ for totals_vec.into_iter().map(|(room, count)| { { for totals_vec.into_iter().map(|(room, count)| {
let label = parse_room(room); let label = parse_room(room);
html! { <li>{ format!("{}: {}", label, count) }</li> } let bar_width_percent = (count as f64 / max_count as f64) * 100.0;
html! {
<div class="room-bar-item">
<div class="room-header">
<span class="room-label">{ label }</span>
<span class="room-count">{ count }</span>
</div>
<div class="room-bar-container">
<div class="room-bar" style={format!("width: {}%;", bar_width_percent)}>
</div>
</div>
</div>
}
}) } }) }
</ul> </div>
</div> </div>
} }
} }

View File

@@ -0,0 +1,137 @@
@use "../mixins" as *;
@use "../variables" as *;
.diagnostics-container {
display: flex;
flex-direction: column;
gap: $spacing-md;
}
.diagnostics-section {
background-color: $color-bg;
border-radius: $border-radius;
padding: $spacing-md;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
h3 {
margin: 0 0 $spacing-md 0;
color: #1f2937;
font-size: 1.1rem;
font-weight: 600;
}
}
.weekday-chart {
display: flex;
flex-direction: column;
gap: 12px;
border: 1px solid #e5e7eb;
border-radius: $border-radius;
background-color: #f9fafb;
}
.weekday-bars {
display: flex;
gap: 12px;
align-items: flex-end;
height: 205px;
padding: $spacing-md;
overflow-x: auto;
padding-bottom: 0px;
}
.weekday-bar {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
min-width: 60px;
height: 100%;
.bar {
width: 100%;
background-color: $color-accent;
border-radius: 4px 4px 0 0;
transition: background-color 0.2s ease;
&.max {
background-color: #10b981;
}
}
}
.weekday-labels {
display: flex;
gap: 12px;
padding: $spacing-md;
padding-top: 0;
overflow-x: auto;
.label-item {
flex: 1;
min-width: 60px;
text-align: center;
white-space: nowrap;
.day {
font-weight: 600;
font-size: 12px;
color: #1f2937;
margin-bottom: 2px;
}
.value {
font-size: 11px;
color: $color-muted;
}
}
}
.room-chart {
display: flex;
flex-direction: column;
gap: 12px;
padding: $spacing-md;
border: 1px solid #e5e7eb;
border-radius: $border-radius;
background-color: #f9fafb;
}
.room-bar-item {
display: flex;
flex-direction: column;
gap: 4px;
.room-header {
display: flex;
justify-content: space-between;
align-items: center;
.room-label {
font-weight: 600;
font-size: 14px;
color: #1f2937;
min-width: 50px;
}
.room-count {
font-size: 12px;
color: $color-muted;
font-weight: 500;
}
}
.room-bar-container {
width: 100%;
height: 24px;
background-color: #e5e7eb;
border-radius: 4px;
overflow: hidden;
.room-bar {
height: 100%;
background-color: #f97316;
transition: width 0.3s ease;
}
}
}

View File

@@ -3,6 +3,7 @@
@use "utilities"; @use "utilities";
@use "components/sidebar"; @use "components/sidebar";
@use "components/tickets"; @use "components/tickets";
@use "components/diagnostics";
body { body {
background: variables.$color-bg; background: variables.$color-bg;