Add support for optional icon to Button
(#3479)
This PR extends `Button` with support for an optional icon to be displayed next to the label. As part of this, the functionality for displaying an icon within a button has been factored out into an internal `ButtonIcon` component. `ButtonIcon` is now used by both `IconButton` and `Button` to encapsulate the concerns of an icon that is rendered within a button. Release Notes: - N/A
This commit is contained in:
parent
4b23c5c658
commit
c3e7732eab
5 changed files with 157 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
|||
use gpui::{Div, Render};
|
||||
use story::Story;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{prelude::*, Icon};
|
||||
use crate::{Button, ButtonStyle};
|
||||
|
||||
pub struct ButtonStory;
|
||||
|
@ -24,6 +24,14 @@ impl Render for ButtonStory {
|
|||
)
|
||||
.child(Story::label("With `label_color`"))
|
||||
.child(Button::new("filled_with_label_color", "Click me").color(Color::Created))
|
||||
.child(Story::label("With `icon`"))
|
||||
.child(Button::new("filled_with_icon", "Click me").icon(Icon::FileGit))
|
||||
.child(Story::label("Selected with `icon`"))
|
||||
.child(
|
||||
Button::new("filled_and_selected_with_icon", "Click me")
|
||||
.selected(true)
|
||||
.icon(Icon::FileGit),
|
||||
)
|
||||
.child(Story::label("Default (Subtle)"))
|
||||
.child(Button::new("default_subtle", "Click me").style(ButtonStyle::Subtle))
|
||||
.child(Story::label("Default (Transparent)"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue