ui2: Get component stories compiling again (#3376)
This PR gets the component stories defined in `ui2` compiling again. Release Notes: - N/A
This commit is contained in:
parent
6cd0bcc578
commit
f4b4bdfd83
11 changed files with 399 additions and 455 deletions
|
@ -12,10 +12,12 @@ mod label;
|
||||||
mod list;
|
mod list;
|
||||||
mod slot;
|
mod slot;
|
||||||
mod stack;
|
mod stack;
|
||||||
mod stories;
|
|
||||||
mod toggle;
|
mod toggle;
|
||||||
mod tooltip;
|
mod tooltip;
|
||||||
|
|
||||||
|
#[cfg(feature = "stories")]
|
||||||
|
mod stories;
|
||||||
|
|
||||||
pub use avatar::*;
|
pub use avatar::*;
|
||||||
pub use button::*;
|
pub use button::*;
|
||||||
pub use checkbox::*;
|
pub use checkbox::*;
|
||||||
|
@ -30,6 +32,8 @@ pub use label::*;
|
||||||
pub use list::*;
|
pub use list::*;
|
||||||
pub use slot::*;
|
pub use slot::*;
|
||||||
pub use stack::*;
|
pub use stack::*;
|
||||||
pub use stories::*;
|
|
||||||
pub use toggle::*;
|
pub use toggle::*;
|
||||||
pub use tooltip::*;
|
pub use tooltip::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "stories")]
|
||||||
|
pub use stories::*;
|
||||||
|
|
8
crates/ui2/src/components/stories.rs
Normal file
8
crates/ui2/src/components/stories.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
mod avatar;
|
||||||
|
mod button;
|
||||||
|
mod checkbox;
|
||||||
|
mod context_menu;
|
||||||
|
mod icon;
|
||||||
|
mod input;
|
||||||
|
mod keybinding;
|
||||||
|
mod label;
|
|
@ -1,15 +1,11 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{Div, Render};
|
||||||
pub use stories::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{Avatar, Story};
|
||||||
use super::*;
|
|
||||||
use crate::Story;
|
|
||||||
use gpui::{Div, Render};
|
|
||||||
|
|
||||||
pub struct AvatarStory;
|
pub struct AvatarStory;
|
||||||
|
|
||||||
impl Render for AvatarStory {
|
impl Render for AvatarStory {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -23,5 +19,4 @@ mod stories {
|
||||||
"https://avatars.githubusercontent.com/u/326587?v=4",
|
"https://avatars.githubusercontent.com/u/326587?v=4",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{rems, Div, Render};
|
||||||
pub use stories::*;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{h_stack, v_stack, Button, Icon, IconPosition, Label, Story};
|
||||||
use super::*;
|
|
||||||
use crate::{h_stack, v_stack, Color, Story};
|
|
||||||
use gpui::{rems, Div, Render};
|
|
||||||
use strum::IntoEnumIterator;
|
|
||||||
|
|
||||||
pub struct ButtonStory;
|
pub struct ButtonStory;
|
||||||
|
|
||||||
impl Render for ButtonStory {
|
impl Render for ButtonStory {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -28,9 +24,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label").variant(ButtonVariant::Ghost), // .state(state),
|
Button::new("Label").variant(ButtonVariant::Ghost), // .state(state),
|
||||||
)
|
)
|
||||||
|
@ -39,9 +33,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label")
|
Button::new("Label")
|
||||||
.variant(ButtonVariant::Ghost)
|
.variant(ButtonVariant::Ghost)
|
||||||
|
@ -53,9 +45,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label")
|
Button::new("Label")
|
||||||
.variant(ButtonVariant::Ghost)
|
.variant(ButtonVariant::Ghost)
|
||||||
|
@ -70,9 +60,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label").variant(ButtonVariant::Filled), // .state(state),
|
Button::new("Label").variant(ButtonVariant::Filled), // .state(state),
|
||||||
)
|
)
|
||||||
|
@ -81,9 +69,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label")
|
Button::new("Label")
|
||||||
.variant(ButtonVariant::Filled)
|
.variant(ButtonVariant::Filled)
|
||||||
|
@ -95,9 +81,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label")
|
Button::new("Label")
|
||||||
.variant(ButtonVariant::Filled)
|
.variant(ButtonVariant::Filled)
|
||||||
|
@ -112,9 +96,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label")
|
Button::new("Label")
|
||||||
.variant(ButtonVariant::Filled)
|
.variant(ButtonVariant::Filled)
|
||||||
|
@ -126,9 +108,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label")
|
Button::new("Label")
|
||||||
.variant(ButtonVariant::Filled)
|
.variant(ButtonVariant::Filled)
|
||||||
|
@ -142,9 +122,7 @@ mod stories {
|
||||||
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
.child(h_stack().gap_2().children(states.clone().map(|state| {
|
||||||
v_stack()
|
v_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(Label::new(state.to_string()).color(Color::Muted))
|
||||||
Label::new(state.to_string()).color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
Button::new("Label")
|
Button::new("Label")
|
||||||
.variant(ButtonVariant::Filled)
|
.variant(ButtonVariant::Filled)
|
||||||
|
@ -163,5 +141,4 @@ mod stories {
|
||||||
.on_click(|_, cx| println!("Button clicked.")),
|
.on_click(|_, cx| println!("Button clicked.")),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{Div, Render, ViewContext};
|
||||||
pub use stories::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{h_stack, Checkbox, Story};
|
||||||
use super::*;
|
|
||||||
use crate::{h_stack, Story};
|
|
||||||
use gpui::{Div, Render, ViewContext};
|
|
||||||
|
|
||||||
pub struct CheckboxStory;
|
pub struct CheckboxStory;
|
||||||
|
|
||||||
impl Render for CheckboxStory {
|
impl Render for CheckboxStory {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -38,15 +34,9 @@ mod stories {
|
||||||
.rounded_md()
|
.rounded_md()
|
||||||
.border()
|
.border()
|
||||||
.border_color(cx.theme().colors().border)
|
.border_color(cx.theme().colors().border)
|
||||||
|
.child(Checkbox::new("checkbox-disabled", Selection::Unselected).disabled(true))
|
||||||
.child(
|
.child(
|
||||||
Checkbox::new("checkbox-disabled", Selection::Unselected)
|
Checkbox::new("checkbox-disabled-intermediate", Selection::Indeterminate)
|
||||||
.disabled(true),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
Checkbox::new(
|
|
||||||
"checkbox-disabled-intermediate",
|
|
||||||
Selection::Indeterminate,
|
|
||||||
)
|
|
||||||
.disabled(true),
|
.disabled(true),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
@ -55,5 +45,4 @@ mod stories {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{actions, Action, AnchorCorner, Div, Render, View};
|
||||||
pub use stories::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{menu_handle, ContextMenu, Label, ListItem, Story};
|
||||||
use super::*;
|
|
||||||
use crate::{story::Story, Label};
|
|
||||||
use gpui::{actions, Div, Render};
|
|
||||||
|
|
||||||
actions!(PrintCurrentDate, PrintBestFood);
|
actions!(PrintCurrentDate, PrintBestFood);
|
||||||
|
|
||||||
fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<ContextMenu> {
|
fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<ContextMenu> {
|
||||||
ContextMenu::build(cx, |menu, _| {
|
ContextMenu::build(cx, |menu, _| {
|
||||||
menu.header(header)
|
menu.header(header)
|
||||||
.separator()
|
.separator()
|
||||||
|
@ -25,11 +21,11 @@ mod stories {
|
||||||
|v, cx| cx.dispatch_action(PrintBestFood.boxed_clone()),
|
|v, cx| cx.dispatch_action(PrintBestFood.boxed_clone()),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ContextMenuStory;
|
pub struct ContextMenuStory;
|
||||||
|
|
||||||
impl Render for ContextMenuStory {
|
impl Render for ContextMenuStory {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -108,5 +104,4 @@ mod stories {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{Div, Render};
|
||||||
pub use stories::*;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{Icon, IconElement, Story};
|
||||||
use gpui::{Div, Render};
|
|
||||||
use strum::IntoEnumIterator;
|
|
||||||
|
|
||||||
use crate::Story;
|
pub struct IconStory;
|
||||||
|
|
||||||
use super::*;
|
impl Render for IconStory {
|
||||||
|
|
||||||
pub struct IconStory;
|
|
||||||
|
|
||||||
impl Render for IconStory {
|
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -23,5 +17,4 @@ mod stories {
|
||||||
.child(Story::label(cx, "All Icons"))
|
.child(Story::label(cx, "All Icons"))
|
||||||
.child(div().flex().gap_3().children(icons.map(IconElement::new)))
|
.child(div().flex().gap_3().children(icons.map(IconElement::new)))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{Div, Render};
|
||||||
pub use stories::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{Input, Story};
|
||||||
use super::*;
|
|
||||||
use crate::Story;
|
|
||||||
use gpui::{Div, Render};
|
|
||||||
|
|
||||||
pub struct InputStory;
|
pub struct InputStory;
|
||||||
|
|
||||||
impl Render for InputStory {
|
impl Render for InputStory {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -18,5 +14,4 @@ mod stories {
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(div().flex().child(Input::new("Search")))
|
.child(div().flex().child(Input::new("Search")))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,22 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{actions, Div, Render};
|
||||||
pub use stories::*;
|
use itertools::Itertools;
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{KeyBinding, Story};
|
||||||
use super::*;
|
|
||||||
pub use crate::KeyBinding;
|
|
||||||
use crate::Story;
|
|
||||||
use gpui::{actions, Div, Render};
|
|
||||||
use itertools::Itertools;
|
|
||||||
pub struct KeybindingStory;
|
|
||||||
|
|
||||||
actions!(NoAction);
|
pub struct KeybindingStory;
|
||||||
|
|
||||||
pub fn binding(key: &str) -> gpui::KeyBinding {
|
actions!(NoAction);
|
||||||
|
|
||||||
|
pub fn binding(key: &str) -> gpui::KeyBinding {
|
||||||
gpui::KeyBinding::new(key, NoAction {}, None)
|
gpui::KeyBinding::new(key, NoAction {}, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for KeybindingStory {
|
impl Render for KeybindingStory {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
let all_modifier_permutations =
|
let all_modifier_permutations = ["ctrl", "alt", "cmd", "shift"].into_iter().permutations(2);
|
||||||
["ctrl", "alt", "cmd", "shift"].into_iter().permutations(2);
|
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<KeyBinding>(cx))
|
.child(Story::title_for::<KeyBinding>(cx))
|
||||||
|
@ -62,5 +57,4 @@ mod stories {
|
||||||
.child(KeyBinding::new(binding("ctrl-a shift-z")))
|
.child(KeyBinding::new(binding("ctrl-a shift-z")))
|
||||||
.child(KeyBinding::new(binding("fn-s")))
|
.child(KeyBinding::new(binding("fn-s")))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
#[cfg(feature = "stories")]
|
use gpui::{Div, Render};
|
||||||
pub use stories::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
use crate::prelude::*;
|
||||||
mod stories {
|
use crate::{HighlightedLabel, Label, Story};
|
||||||
use super::*;
|
|
||||||
use crate::Story;
|
|
||||||
use gpui::{Div, Render};
|
|
||||||
|
|
||||||
pub struct LabelStory;
|
pub struct LabelStory;
|
||||||
|
|
||||||
impl Render for LabelStory {
|
impl Render for LabelStory {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -27,5 +23,4 @@ mod stories {
|
||||||
vec![0, 1, 3, 8, 9, 13],
|
vec![0, 1, 3, 8, 9, 13],
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue