Skip to content

Commit

Permalink
fix ui button and badge width
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Apr 29, 2024
1 parent 7aed493 commit 7f72a17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
1 change: 0 additions & 1 deletion gui/ui/src/component/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ pub fn badge_pill<'a, T: 'a>(label: &'a str, tooltip: &'a str) -> Container<'a,
tooltip::Tooltip::new(
Container::new(text::p2_regular(label))
.padding(10)
.width(Length::Fill)
.center_x()
.style(theme::Container::Pill(theme::Pill::Simple)),
tooltip,
Expand Down
29 changes: 16 additions & 13 deletions gui/ui/src/component/button.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
use crate::{color, theme, widget::*};
use iced::widget::{button, container, row};
use iced::{Alignment, Length};
use iced::Alignment;

use super::text::text;

pub fn menu<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
button::Button::new(content(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
button::Button::new(content_menu(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
.style(theme::Button::Menu(false))
}

pub fn menu_active<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
button::Button::new(content(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
button::Button::new(content_menu(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
.style(theme::Button::Menu(true))
}

fn content_menu<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Container<'a, T> {
match icon {
None => container(text(t)).padding(5),
Some(i) => {
container(row![i, text(t)].spacing(10).align_items(Alignment::Center)).padding(5)
}
}
}

pub fn alert<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
button::Button::new(content(icon, t)).style(theme::Button::Destructive)
}
Expand All @@ -40,15 +49,9 @@ pub fn transparent_border<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) ->

fn content<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Container<'a, T> {
match icon {
None => container(text(t)).width(Length::Fill).center_x().padding(5),
Some(i) => container(
row![i, text(t)]
.spacing(10)
.width(iced::Length::Fill)
.align_items(Alignment::Center),
)
.width(iced::Length::Fill)
.center_x()
.padding(5),
None => container(text(t)).center_x().padding(5),
Some(i) => container(row![i, text(t)].spacing(10).align_items(Alignment::Center))
.center_x()
.padding(5),
}
}

0 comments on commit 7f72a17

Please sign in to comment.