Togglable channels, the greatest since sliced bread

This commit is contained in:
Conrad Irwin 2023-11-28 16:52:12 -07:00
parent 4c2348eb53
commit 60ce75c34a
4 changed files with 61 additions and 26 deletions

View file

@ -1,4 +1,4 @@
use crate::{h_stack, prelude::*, Icon, IconElement};
use crate::{h_stack, prelude::*, Icon, IconElement, IconSize};
use gpui::{prelude::*, Action, AnyView, Div, MouseButton, MouseDownEvent, Stateful};
#[derive(IntoElement)]
@ -6,6 +6,7 @@ pub struct IconButton {
id: ElementId,
icon: Icon,
color: Color,
size: IconSize,
variant: ButtonVariant,
state: InteractionState,
selected: bool,
@ -50,7 +51,11 @@ impl RenderOnce for IconButton {
// place we use an icon button.
// .hover(|style| style.bg(bg_hover_color))
.active(|style| style.bg(bg_active_color))
.child(IconElement::new(self.icon).color(icon_color));
.child(
IconElement::new(self.icon)
.size(self.size)
.color(icon_color),
);
if let Some(click_handler) = self.on_mouse_down {
button = button.on_mouse_down(MouseButton::Left, move |event, cx| {
@ -76,6 +81,7 @@ impl IconButton {
id: id.into(),
icon,
color: Color::default(),
size: Default::default(),
variant: ButtonVariant::default(),
state: InteractionState::default(),
selected: false,
@ -94,6 +100,11 @@ impl IconButton {
self
}
pub fn size(mut self, size: IconSize) -> Self {
self.size = size;
self
}
pub fn variant(mut self, variant: ButtonVariant) -> Self {
self.variant = variant;
self