Add new Button and IconButton components (#3448)

This PR adds new `Button` and `IconButton` components built on top of
our new button abstractions.

Both of these buttons are built from the common `ButtonLike` base, and
implement the `ButtonCommon` (name TBD) trait in order to provide a
common interface.

There are still some visual tweaks that we'll need to make to the new
buttons, but those should be straightforward to make after we land this.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-11-29 17:41:44 -05:00 committed by GitHub
parent df5de47a78
commit b357ae4dc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 324 additions and 682 deletions

View file

@ -181,6 +181,7 @@ pub mod simple_message_notification {
};
use serde::Deserialize;
use std::{borrow::Cow, sync::Arc};
use ui::prelude::*;
use ui::{h_stack, v_stack, Button, Icon, IconElement, Label, StyledExt};
#[derive(Clone, Default, Deserialize, PartialEq)]
@ -287,12 +288,14 @@ pub mod simple_message_notification {
),
)
.children(self.click_message.iter().map(|message| {
Button::new(message.clone()).on_click(cx.listener(|this, _, cx| {
if let Some(on_click) = this.on_click.as_ref() {
(on_click)(cx)
};
this.dismiss(cx)
}))
Button::new(message.clone(), message.clone()).on_click(cx.listener(
|this, _, cx| {
if let Some(on_click) = this.on_click.as_ref() {
(on_click)(cx)
};
this.dismiss(cx)
},
))
}))
}
}

View file

@ -71,14 +71,14 @@ impl Render for StatusBar {
div()
.border()
.border_color(gpui::red())
.child(Button::new("15:22")),
.child(Button::new("status_line_column_numbers", "15:22")),
)
.child(
// TODO: Language picker
div()
.border()
.border_color(gpui::red())
.child(Button::new("Rust")),
.child(Button::new("status_buffer_language", "Rust")),
),
)
.child(

View file

@ -94,9 +94,9 @@ impl Render for Toolbar {
.border()
.border_color(gpui::red())
.p_1()
.child(Button::new("crates"))
.child(Button::new("breadcrumb_crates", "crates"))
.child(Label::new("/").color(Color::Muted))
.child(Button::new("workspace2")),
.child(Button::new("breadcrumb_workspace2", "workspace2")),
)
// Toolbar right side
.child(