Start sketching a collab panel in storybook

Co-Authored-By: Nate Butler <nate@zed.dev>
This commit is contained in:
Nathan Sobo 2023-09-05 10:02:36 -06:00
parent 2fa9c037c8
commit 0307cb8a88
4 changed files with 83 additions and 3 deletions

View file

@ -0,0 +1,34 @@
use crate::theme::theme;
use gpui2::{elements::div, style::StyleHelpers, Element, IntoElement, ParentElement, ViewContext};
use std::marker::PhantomData;
#[derive(Element)]
pub struct CollabPanelElement<V: 'static> {
view_type: PhantomData<V>,
}
pub fn collab_panel<V: 'static>() -> CollabPanelElement<V> {
CollabPanelElement {
view_type: PhantomData,
}
}
impl<V: 'static> CollabPanelElement<V> {
fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
let theme = theme(cx);
div()
.full()
.text_color(theme.middle.variant.default.foreground)
.fill(theme.middle.base.default.background)
.py_2()
.child(
div()
.px_2()
.flex()
.justify_between()
.child("#CRDB")
.child("V"),
)
}
}

View file

@ -1,14 +1,15 @@
#![allow(dead_code, unused_variables)]
use crate::theme::Theme;
use ::theme as legacy_theme;
use collab_panel::collab_panel;
use element_ext::ElementExt;
use gpui2::{serde_json, vec2f, view, Element, RectF, ViewContext, WindowBounds};
use legacy_theme::ThemeSettings;
use log::LevelFilter;
use settings::{default_settings, SettingsStore};
use simplelog::SimpleLogger;
use workspace::workspace;
mod collab_panel;
mod components;
mod element_ext;
mod theme;
@ -27,7 +28,7 @@ fn main() {
cx.add_window(
gpui2::WindowOptions {
bounds: WindowBounds::Fixed(RectF::new(vec2f(0., 0.), vec2f(400., 300.))),
bounds: WindowBounds::Fixed(RectF::new(vec2f(0., 0.), vec2f(260., 800.))),
center: true,
..Default::default()
},
@ -38,7 +39,7 @@ fn main() {
}
fn storybook<V: 'static>(cx: &mut ViewContext<V>) -> impl Element<V> {
workspace().themed(current_theme(cx))
collab_panel().themed(current_theme(cx))
}
// Nathan: During the transition, we will include the base theme on the legacy Theme struct.