This commit is contained in:
Nathan Sobo 2023-08-13 01:40:05 -06:00
parent 0d31d6dac5
commit 1ef486b227
7 changed files with 1249 additions and 1561 deletions

11
Cargo.lock generated
View file

@ -5303,6 +5303,7 @@ dependencies = [
"gpui", "gpui",
"log", "log",
"optional_struct", "optional_struct",
"playground_macros",
"serde", "serde",
"simplelog", "simplelog",
"smallvec", "smallvec",
@ -5310,6 +5311,16 @@ dependencies = [
"util", "util",
] ]
[[package]]
name = "playground_macros"
version = "0.1.0"
dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "plist" name = "plist"
version = "1.5.0" version = "1.5.0"

View file

@ -29,6 +29,7 @@ members = [
"crates/go_to_line", "crates/go_to_line",
"crates/gpui", "crates/gpui",
"crates/gpui/playground", "crates/gpui/playground",
"crates/gpui/playground_macros",
"crates/gpui_macros", "crates/gpui_macros",
"crates/install_cli", "crates/install_cli",
"crates/journal", "crates/journal",

View file

@ -13,6 +13,7 @@ derive_more.workspace = true
gpui = { path = ".." } gpui = { path = ".." }
log.workspace = true log.workspace = true
optional_struct = "0.3.1" optional_struct = "0.3.1"
playground_macros = { path = "../playground_macros" }
serde.workspace = true serde.workspace = true
simplelog = "0.9" simplelog = "0.9"
smallvec.workspace = true smallvec.workspace = true

View file

@ -99,7 +99,7 @@ impl Into<gpui::color::Color> for Rgba {
} }
} }
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Default, Copy, Clone, Debug, PartialEq)]
pub struct Hsla { pub struct Hsla {
pub h: f32, pub h: f32,
pub s: f32, pub s: f32,

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,6 @@
#![allow(dead_code, unused_variables)] #![allow(dead_code, unused_variables)]
use gpui::{ use gpui::{elements::Empty, Element};
platform::{TitlebarOptions, WindowOptions},
AnyElement, Element,
};
use log::LevelFilter; use log::LevelFilter;
use simplelog::SimpleLogger; use simplelog::SimpleLogger;
@ -12,24 +9,21 @@ fn main() {
gpui::App::new(()).unwrap().run(|cx| { gpui::App::new(()).unwrap().run(|cx| {
cx.platform().activate(true); cx.platform().activate(true);
cx.add_window( // cx.add_window(
WindowOptions { // WindowOptions {
titlebar: Some(TitlebarOptions { // titlebar: Some(TitlebarOptions {
appears_transparent: true, // appears_transparent: true,
..Default::default() // ..Default::default()
}), // }),
..Default::default() // ..Default::default()
}, // },
|_| view(|_| Playground::new()), // |_| view(|_| Playground::new()),
); // );
}); });
} }
use frame::{length::auto, *}; use std::marker::PhantomData;
use gpui::{LayoutContext, ViewContext}; use themes::ThemeColors;
use std::{borrow::Cow, cell::RefCell, marker::PhantomData, rc::Rc};
use themes::{rose_pine, ThemeColors};
use tokens::{margin::m4, text::lg};
mod color; mod color;
mod frame; mod frame;
@ -45,19 +39,21 @@ impl<V> Playground<V> {
} }
pub fn render(&mut self, _: &mut V, _: &mut gpui::ViewContext<V>) -> impl Element<V> { pub fn render(&mut self, _: &mut V, _: &mut gpui::ViewContext<V>) -> impl Element<V> {
workspace(&rose_pine::dawn()) Empty::new()
// workspace(&rose_pine::dawn())
} }
} }
fn workspace<V: 'static>(theme: &ThemeColors) -> impl Element<V> { // fn workspace<V: 'static>(theme: &ThemeColors) -> impl Element<V> {
column() // todo!()
// .size(auto()) // // column()
// .fill(theme.base(0.5)) // // .size(auto())
// .text_color(theme.text(0.5)) // // .fill(theme.base(0.5))
// .child(title_bar(theme)) // // .text_color(theme.text(0.5))
// .child(stage(theme)) // // .child(title_bar(theme))
// .child(status_bar(theme)) // // .child(stage(theme))
} // // .child(status_bar(theme))
// }
// fn title_bar<V: 'static>(theme: &ThemeColors) -> impl Element<V> { // fn title_bar<V: 'static>(theme: &ThemeColors) -> impl Element<V> {
// row() // row()

View file

@ -8,159 +8,3 @@ pub mod color {
scale([start_color, color, end_color]) scale([start_color, color, end_color])
} }
} }
pub mod text {
use crate::frame::length::{rems, Rems};
pub fn xs() -> Rems {
rems(0.75)
}
pub fn sm() -> Rems {
rems(0.875)
}
pub fn base() -> Rems {
rems(1.0)
}
pub fn lg() -> Rems {
rems(1.125)
}
pub fn xl() -> Rems {
rems(1.25)
}
pub fn xxl() -> Rems {
rems(1.5)
}
pub fn xxxl() -> Rems {
rems(1.875)
}
pub fn xxxxl() -> Rems {
rems(2.25)
}
pub fn xxxxxl() -> Rems {
rems(3.0)
}
pub fn xxxxxxl() -> Rems {
rems(4.0)
}
}
pub mod padding {
use crate::frame::length::{rems, Rems};
pub fn p1() -> Rems {
rems(0.25)
}
pub fn p2() -> Rems {
rems(0.5)
}
pub fn p3() -> Rems {
rems(0.75)
}
pub fn p4() -> Rems {
rems(1.0)
}
pub fn p5() -> Rems {
rems(1.25)
}
pub fn p6() -> Rems {
rems(1.5)
}
pub fn p8() -> Rems {
rems(2.0)
}
pub fn p10() -> Rems {
rems(2.5)
}
pub fn p12() -> Rems {
rems(3.0)
}
pub fn p16() -> Rems {
rems(4.0)
}
pub fn p20() -> Rems {
rems(5.0)
}
pub fn p24() -> Rems {
rems(6.0)
}
pub fn p32() -> Rems {
rems(8.0)
}
}
pub mod margin {
use crate::frame::length::{rems, Rems};
pub fn m1() -> Rems {
rems(0.25)
}
pub fn m2() -> Rems {
rems(0.5)
}
pub fn m3() -> Rems {
rems(0.75)
}
pub fn m4() -> Rems {
rems(1.0)
}
pub fn m5() -> Rems {
rems(1.25)
}
pub fn m6() -> Rems {
rems(1.5)
}
pub fn m8() -> Rems {
rems(2.0)
}
pub fn m10() -> Rems {
rems(2.5)
}
pub fn m12() -> Rems {
rems(3.0)
}
pub fn m16() -> Rems {
rems(4.0)
}
pub fn m20() -> Rems {
rems(5.0)
}
pub fn m24() -> Rems {
rems(6.0)
}
pub fn m32() -> Rems {
rems(8.0)
}
}