diff --git a/crates/storybook/src/components.rs b/crates/storybook/src/components.rs index e0ba73b866..36ac1575f5 100644 --- a/crates/storybook/src/components.rs +++ b/crates/storybook/src/components.rs @@ -9,10 +9,14 @@ mod icon_button; mod tab; mod tool_divider; -pub(crate) use avatar::avatar; -pub(crate) use icon_button::icon_button; -pub(crate) use tab::tab; -pub(crate) use tool_divider::tool_divider; +pub use avatar::avatar; +pub use avatar::Avatar; +pub use icon_button::icon_button; +pub use icon_button::IconButton; +pub use tab::tab; +pub use tab::Tab; +pub use tool_divider::tool_divider; +pub use tool_divider::ToolDivider; struct ButtonHandlers { click: Option)>>, diff --git a/crates/storybook/src/components/avatar.rs b/crates/storybook/src/components/avatar.rs index 8eff055d75..6e136977c8 100644 --- a/crates/storybook/src/components/avatar.rs +++ b/crates/storybook/src/components/avatar.rs @@ -8,19 +8,24 @@ use gpui2::{Element, ViewContext}; pub type UnknownString = ArcCow<'static, str>; #[derive(Element)] -pub(crate) struct Avatar { +pub struct Avatar { src: ArcCow<'static, str>, shape: Shape, } -pub fn avatar(src: impl Into>, shape: Shape) -> impl Element { +pub fn avatar(src: impl Into>) -> Avatar { Avatar { src: src.into(), - shape, + shape: Shape::Circle, } } impl Avatar { + pub fn shape(mut self, shape: Shape) -> Self { + self.shape = shape; + self + } + fn render(&mut self, _: &mut V, cx: &mut ViewContext) -> impl IntoElement { let theme = theme(cx); diff --git a/crates/storybook/src/components/icon_button2 b/crates/storybook/src/components/icon_button2 new file mode 100644 index 0000000000..9fe738d5ac --- /dev/null +++ b/crates/storybook/src/components/icon_button2 @@ -0,0 +1,123 @@ +// use crate::prelude::{ButtonVariant, UIState}; +// use crate::theme::theme; +// use gpui2::elements::svg; +// use gpui2::style::{StyleHelpers, Styleable}; +// use gpui2::{elements::div, IntoElement}; +// use gpui2::{Element, ParentElement, ViewContext}; + +// #[derive(Element)] +// pub(crate) struct IconButton { +// path: &'static str, +// variant: ButtonVariant, +// state: UIState, +// } + +// pub fn icon_button(path: &'static str) -> IconButton { +// IconButton { +// path, +// variant: ButtonVariant::Filled, +// state: UIState::Default, +// } +// } + +// impl IconButton { +// fn variant(mut self, variant: ButtonVariant) -> Self { +// self.variant = variant; + +// // Example of more interesting setter behavior +// // FilledButtons must be disabled +// if self.variant == ButtonVariant::Filled { +// self.state = UIState::Disabled; +// } + +// self +// } + +// fn state(mut self, state: UIState) -> Self { +// // Example of more interesting setter behavior: +// // GhostButtons Cannot be disabled +// // Debug asserts are compiled out when we make a new release. +// // Useful for making sure developers develop correctly without breaking +// // everything +// debug_assert!(self.variant != ButtonVariant::Ghost && state != UIState::Disabled); + +// self.state = state; +// self +// } + +// // const state = { +// // foo: "foo", +// // bar: "bar" +// // } as const +// // +// // type State = typeof state[keyof typeof something] +// // +// // type Button { +// // style: State +// // } +// // +// //