This commit is contained in:
Julian Chang 2026-10-02 04:42:04 -04:00
commit fb80e6eb60
No known key found for this signature in database
7 changed files with 27 additions and 74 deletions

View file

@ -42,7 +42,6 @@ impl Component for TilesRow {
};
let hero = hero_tile(
IconType::ClockRewind,
"Total playtime",
format_duration(stats.total_secs),
format!(
@ -53,32 +52,15 @@ impl Component for TilesRow {
);
let mut rest = vec![
stat_tile(IconType::Play, "Sessions", stats.session_count.to_string()),
stat_tile("Sessions", stats.session_count.to_string()),
stat_tile("Avg / session", format_duration(avg_session)),
stat_tile(
IconType::Sliders04,
"Avg / session",
format_duration(avg_session),
),
stat_tile(
IconType::Maximize01,
"Longest session",
format_duration(stats.longest_session_secs),
),
stat_tile(
IconType::Rocket02,
"Day streak",
streak_value(stats.current_streak),
),
stat_tile(
IconType::CheckCircle,
"Best streak",
streak_value(stats.longest_streak),
),
stat_tile(
IconType::Calendar,
"Days played",
stats.active_days.to_string(),
),
stat_tile("Day streak", streak_value(stats.current_streak)),
stat_tile("Best streak", streak_value(stats.longest_streak)),
stat_tile("Days played", stats.active_days.to_string()),
];
let mut root = rect().vertical().width(Size::fill()).spacing(TILE_GAP);
@ -135,18 +117,7 @@ fn streak_value(days: usize) -> String {
format!("{days}d")
}
fn icon_chip(icon: IconType, size: f32, tint: Color) -> Element {
rect()
.width(Size::px(size))
.height(Size::px(size))
.corner_radius(CornerRadius::new_all(size * 0.5))
.background(tint.with_a(38))
.center()
.child(Icon::new(icon).size(size * 0.52).color(tint))
.into_element()
}
fn hero_tile(icon: IconType, caption: &str, value: String, note: String) -> Element {
fn hero_tile(caption: &str, value: String, note: String) -> Element {
card()
.width(Size::fill())
.height(Size::fill())
@ -154,18 +125,11 @@ fn hero_tile(icon: IconType, caption: &str, value: String, note: String) -> Elem
.background(colors::brand().with_a(18))
.border(border_all_color(1., colors::brand().with_a(90)))
.child(
rect()
.horizontal()
.cross_align(Alignment::Center)
.spacing(8.)
.child(icon_chip(icon, 24., colors::brand()))
.child(
label()
.text(caption.to_string())
.font_size(12.)
.font_weight(FontWeight::MEDIUM)
.color(colors::fg_secondary()),
),
label()
.text(caption.to_string())
.font_size(12.)
.font_weight(FontWeight::MEDIUM)
.color(colors::fg_secondary()),
)
.child(
rect()
@ -193,25 +157,18 @@ fn hero_tile(icon: IconType, caption: &str, value: String, note: String) -> Elem
.into_element()
}
fn stat_tile(icon: IconType, caption: &str, value: String) -> Element {
fn stat_tile(caption: &str, value: String) -> Element {
card()
.width(Size::fill())
.height(Size::fill())
.main_align(Alignment::SpaceBetween)
.child(
rect()
.horizontal()
.cross_align(Alignment::Center)
.spacing(8.)
.child(icon_chip(icon, 24., colors::fg_secondary()))
.child(
label()
.text(caption.to_string())
.font_size(12.)
.max_lines(1)
.width(Size::fill())
.color(colors::fg_secondary()),
),
label()
.text(caption.to_string())
.font_size(12.)
.max_lines(1)
.width(Size::fill())
.color(colors::fg_secondary()),
)
.child(
label()

View file

@ -184,7 +184,7 @@ pub fn wide_card(card: WideCard) -> Element {
.cross_align(Alignment::Center)
.spacing(14.)
.child(marker(selected, false))
.child(Icon::new(icon).size(20.).color(if selected {
.child(Icon::new(icon).size(25.).color(if selected {
colors::fg_primary()
} else {
colors::fg_secondary()

View file

@ -157,7 +157,7 @@ impl Component for CreateInstanceModal {
shell(Shell {
rail: wizard_rail(wizard, &picks),
eyebrow: picks.progress(),
eyebrow: None,
title: title.to_string(),
subtitle,
body: steps::body(wizard, &picks),

View file

@ -78,10 +78,6 @@ impl Picks {
(Some(loader), None) => loader.to_string(),
}
}
pub fn progress(&self) -> String {
format!("Step {} of {}", self.index + 1, self.steps.len())
}
}
fn matches_filter(kind: GameVersionKind, filter: u8) -> bool {

View file

@ -116,7 +116,7 @@ impl Component for EditInstanceModal {
),
tags,
}),
eyebrow: "Instance details".to_string(),
eyebrow: Some("Instance details".to_string()),
title: "Edit the instance".to_string(),
subtitle: "Only how it is presented changes here. The version, loader and installed content stay as they are."
.to_string(),

View file

@ -11,7 +11,7 @@ pub const PANE_PADDING: f32 = 24.;
pub struct Shell {
pub rail: Element,
pub eyebrow: String,
pub eyebrow: Option<String>,
pub title: String,
pub subtitle: String,
pub body: Element,
@ -101,7 +101,7 @@ pub fn shell(parts: Shell) -> Element {
.into_element()
}
fn header(eyebrow: String, title: String, subtitle: String, on_close: EventHandler<()>) -> Element {
fn header(eyebrow: Option<String>, title: String, subtitle: String, on_close: EventHandler<()>) -> Element {
rect()
.horizontal()
.width(Size::fill())
@ -114,14 +114,14 @@ fn header(eyebrow: String, title: String, subtitle: String, on_close: EventHandl
.vertical()
.width(Size::flex(1.0))
.spacing(5.)
.child(
.maybe_child(eyebrow.map(|eyebrow| {
label()
.text(eyebrow)
.font_size(11.)
.font_weight(FontWeight::MEDIUM)
.letter_spacing(1.6)
.color(colors::fg_secondary()),
)
.color(colors::fg_secondary())
}))
.child(
label()
.text(title)

View file

@ -57,7 +57,7 @@ fn type_step(mut wizard: Wizard, picks: &Picks) -> Element {
let cards = [
(
TypeChoice::OneClient,
IconType::Rocket02,
IconType::IconLogo,
"OneClient",
Some("Recommended"),
"The most bleeding edge performance, QoL mods and world hosting in one instance.",