Compare commits

...
Sign in to create a new pull request.

5 commits

Author SHA1 Message Date
Danilo Leal
7a51c95dac
Merge branch 'main' into icon-button-square 2025-08-13 14:26:43 -03:00
Danilo Leal
2dab8a5586 Adjust tab icon size 2025-08-12 17:11:19 -03:00
Danilo Leal
0b47c5cdce Fix case where we want it to be wide 2025-08-12 17:11:05 -03:00
Danilo Leal
a040d7bc8d Adjust icon button padding value per size 2025-08-12 17:10:59 -03:00
Danilo Leal
641763029b Make square-shaped + small icon button the default 2025-08-12 17:10:48 -03:00
4 changed files with 45 additions and 6 deletions

View file

@ -3008,9 +3008,10 @@ impl EditorElement {
};
let toggle = IconButton::new(("expand", ix), icon_name)
.icon_color(Color::Custom(cx.theme().colors().editor_line_number))
.selected_icon_color(Color::Custom(cx.theme().colors().editor_foreground))
.icon_color(Color::Custom(cx.theme().colors().editor_line_number))
.icon_size(IconSize::Custom(rems(editor_font_size / window.rem_size())))
.shape(ui::IconButtonShape::Wide)
.width(width)
.on_click(move |_, window, cx| {
editor.update(cx, |editor, cx| {

View file

@ -31,9 +31,9 @@ impl IconButton {
pub fn new(id: impl Into<ElementId>, icon: IconName) -> Self {
let mut this = Self {
base: ButtonLike::new(id),
shape: IconButtonShape::Wide,
shape: IconButtonShape::Square,
icon,
icon_size: IconSize::default(),
icon_size: IconSize::Small,
icon_color: Color::Default,
selected_icon: None,
selected_icon_color: None,
@ -232,6 +232,43 @@ impl Component for IconButton {
example_group_with_title(
"Icon Button Styles",
vec![
// TODO: Remove/organize this later
single_example(
"SIZES",
h_flex()
.gap_0p5()
.child(
IconButton::new("tinted", IconName::Debug)
.icon_size(IconSize::Indicator)
.layer(ElevationIndex::Background)
.style(ButtonStyle::Tinted(TintColor::Accent)),
)
.child(
IconButton::new("tinted", IconName::Debug)
.icon_size(IconSize::XSmall)
.layer(ElevationIndex::Background)
.style(ButtonStyle::Tinted(TintColor::Accent)),
)
.child(
IconButton::new("tinted", IconName::Debug)
.icon_size(IconSize::Small)
.layer(ElevationIndex::Background)
.style(ButtonStyle::Tinted(TintColor::Accent)),
)
.child(
IconButton::new("tinted", IconName::Debug)
.icon_size(IconSize::Medium)
.layer(ElevationIndex::Background)
.style(ButtonStyle::Tinted(TintColor::Accent)),
)
.child(
IconButton::new("tinted", IconName::Debug)
.icon_size(IconSize::XLarge)
.layer(ElevationIndex::Background)
.style(ButtonStyle::Tinted(TintColor::Accent)),
)
.into_any_element(),
),
single_example(
"Default",
IconButton::new("default", IconName::Check)

View file

@ -84,11 +84,12 @@ impl IconSize {
/// 2. The padding of one side of the square
pub fn square_components(&self, window: &mut Window, cx: &mut App) -> (Pixels, Pixels) {
let icon_size = self.rems() * window.rem_size();
let padding = match self {
IconSize::Indicator => DynamicSpacing::Base00.px(cx),
IconSize::XSmall => DynamicSpacing::Base02.px(cx),
IconSize::Small => DynamicSpacing::Base02.px(cx),
IconSize::Medium => DynamicSpacing::Base02.px(cx),
IconSize::Small => DynamicSpacing::Base04.px(cx),
IconSize::Medium => DynamicSpacing::Base06.px(cx),
IconSize::XLarge => DynamicSpacing::Base02.px(cx),
// TODO: Wire into dynamic spacing
IconSize::Custom(size) => size.to_pixels(window.rem_size()),

View file

@ -2540,7 +2540,7 @@ impl Pane {
.shape(IconButtonShape::Square)
.icon_color(Color::Muted)
.size(ButtonSize::None)
.icon_size(IconSize::Small)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(move |pane, _, window, cx| {
pane.close_item_by_id(item_id, SaveIntent::Close, window, cx)
.detach_and_log_err(cx);