Merge branch 'main' into zed2-breadcrumbs

This commit is contained in:
Julia 2023-12-01 11:02:34 -05:00
commit 13f4cc563c
58 changed files with 2606 additions and 3167 deletions

View file

@ -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::*;

View 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()))
}
}

View file

@ -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,
@ -23,6 +24,7 @@ pub enum ComponentStory {
Keybinding,
Label,
List,
ListHeader,
ListItem,
Scroll,
Text,
@ -33,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(),
@ -44,6 +47,7 @@ impl ComponentStory {
Self::Keybinding => cx.build_view(|_| ui::KeybindingStory).into(),
Self::Label => cx.build_view(|_| ui::LabelStory).into(),
Self::List => cx.build_view(|_| ui::ListStory).into(),
Self::ListHeader => cx.build_view(|_| ui::ListHeaderStory).into(),
Self::ListItem => cx.build_view(|_| ui::ListItemStory).into(),
Self::Scroll => ScrollStory::view(cx).into(),
Self::Text => TextStory::view(cx).into(),