fix: better sidebar layout

This commit is contained in:
Georg Bauer
2026-07-28 19:40:31 +02:00
parent eaa2fcfe42
commit 1f028950b3
2 changed files with 21 additions and 16 deletions

View File

@@ -29,6 +29,7 @@ use std::collections::VecDeque;
use std::path::Path;
const ICON_FOLDER: &[u8] = include_bytes!("../../assets/icons/folder.svg");
const ICON_FOLDER_OPEN: &[u8] = include_bytes!("../../assets/icons/folder-open.svg");
const ICON_FOLDER_PLUS: &[u8] = include_bytes!("../../assets/icons/folder-plus.svg");
const ICON_NEW_SESSION: &[u8] = include_bytes!("../../assets/icons/new-session.svg");
const ICON_SETTINGS: &[u8] = include_bytes!("../../assets/icons/settings.svg");
@@ -52,11 +53,9 @@ const TITLE_BAR_HEIGHT: f32 = 30.0;
const TITLE_BAR_CONTROL: f32 = 24.0;
/// Space the macOS traffic lights need before our own controls start.
const TRAFFIC_LIGHT_WIDTH: f32 = 78.0;
const PROJECT_DISCLOSURE_WIDTH: f32 = 12.0;
const PROJECT_ICON_WIDTH: u16 = 17;
const PROJECT_LABEL_SPACING: f32 = 9.0;
const SESSION_INDENT: f32 =
PROJECT_DISCLOSURE_WIDTH + PROJECT_ICON_WIDTH as f32 + PROJECT_LABEL_SPACING * 2.0;
const SESSION_INDENT: f32 = PROJECT_ICON_WIDTH as f32 + PROJECT_LABEL_SPACING;
impl App {
pub(crate) fn view(&self, id: window::Id) -> Element<'_, Message> {
@@ -332,10 +331,14 @@ impl App {
row![
button(
row![
text(if project.collapsed { "" } else { "" })
.size(12)
.width(PROJECT_DISCLOSURE_WIDTH),
icon(ICON_FOLDER, PROJECT_ICON_WIDTH),
icon(
if project.collapsed {
ICON_FOLDER
} else {
ICON_FOLDER_OPEN
},
PROJECT_ICON_WIDTH,
),
text(&project.name).size(14)
]
.spacing(PROJECT_LABEL_SPACING)
@@ -376,7 +379,6 @@ impl App {
.on_press(Message::DiscardSession(project.id))
.style(button::text),
]
.spacing(3)
.align_y(Alignment::Center),
);
}
@@ -398,14 +400,14 @@ impl App {
let expanded = self.expanded_archives.contains(&project.id);
projects = projects.push(
row![
Space::new().width(26),
Space::new().width(SESSION_INDENT),
button(
text(format!(
"{} Archived sessions ({})",
if expanded { "" } else { "" },
archived.len()
))
.size(12)
text(if expanded {
"Hide archived sessions"
} else {
"Show archived sessions"
})
.size(13)
.color(muted_text()),
)
.width(Length::Fill)
@@ -472,7 +474,6 @@ impl App {
.on_press(Message::RequestDeleteSession(session.id))
.style(button::text),
]
.spacing(3)
.align_y(Alignment::Center)
.into()
}