commit
c9be637b6b
14 changed files with 211 additions and 698 deletions
|
@ -1,3 +1,4 @@
|
|||
mod auto_height_editor;
|
||||
mod focus;
|
||||
mod kitchen_sink;
|
||||
mod picker;
|
||||
|
@ -5,6 +6,7 @@ mod scroll;
|
|||
mod text;
|
||||
mod z_index;
|
||||
|
||||
pub use auto_height_editor::*;
|
||||
pub use focus::*;
|
||||
pub use kitchen_sink::*;
|
||||
pub use picker::*;
|
||||
|
|
34
crates/storybook2/src/stories/auto_height_editor.rs
Normal file
34
crates/storybook2/src/stories/auto_height_editor.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
use editor::Editor;
|
||||
use gpui::{
|
||||
div, white, Div, KeyBinding, ParentElement, Render, Styled, View, ViewContext, VisualContext,
|
||||
WindowContext,
|
||||
};
|
||||
|
||||
pub struct AutoHeightEditorStory {
|
||||
editor: View<Editor>,
|
||||
}
|
||||
|
||||
impl AutoHeightEditorStory {
|
||||
pub fn new(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.bind_keys([KeyBinding::new("enter", editor::Newline, Some("Editor"))]);
|
||||
cx.build_view(|cx| Self {
|
||||
editor: cx.build_view(|cx| {
|
||||
let mut editor = Editor::auto_height(3, cx);
|
||||
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::EditorWidth, cx);
|
||||
editor
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for AutoHeightEditorStory {
|
||||
type Element = Div;
|
||||
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
div()
|
||||
.size_full()
|
||||
.bg(white())
|
||||
.text_sm()
|
||||
.child(div().w_32().bg(gpui::black()).child(self.editor.clone()))
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ use ui::prelude::*;
|
|||
#[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum ComponentStory {
|
||||
AutoHeightEditor,
|
||||
Avatar,
|
||||
Button,
|
||||
Checkbox,
|
||||
|
@ -34,6 +35,7 @@ pub enum ComponentStory {
|
|||
impl ComponentStory {
|
||||
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
|
||||
match self {
|
||||
Self::AutoHeightEditor => AutoHeightEditorStory::new(cx).into(),
|
||||
Self::Avatar => cx.build_view(|_| ui::AvatarStory).into(),
|
||||
Self::Button => cx.build_view(|_| ui::ButtonStory).into(),
|
||||
Self::Checkbox => cx.build_view(|_| ui::CheckboxStory).into(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue