From b040ae8d4dbf9a967112bfae72fd1851b32b509d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 17 Oct 2023 08:52:26 +0200 Subject: [PATCH] Checkpoint --- crates/gpui3/src/style.rs | 12 ++++++------ crates/storybook2/src/stories.rs | 9 +++++++-- crates/storybook2/src/stories/text.rs | 20 ++++++++++++++++++++ crates/storybook2/src/story_selector.rs | 15 +++++++-------- 4 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 crates/storybook2/src/stories/text.rs diff --git a/crates/gpui3/src/style.rs b/crates/gpui3/src/style.rs index 17cd2dc43f08e375eb9b89f7e615268f020360e0..f472e05c91c3c36e49a1612a0250efdc639a7d69 100644 --- a/crates/gpui3/src/style.rs +++ b/crates/gpui3/src/style.rs @@ -1,8 +1,8 @@ use crate::{ - phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask, Corners, - CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures, FontStyle, - FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rems, Result, SharedString, Size, - SizeRefinement, TextRun, ViewContext, WindowContext, + black, phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask, + Corners, CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures, + FontStyle, FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rems, Result, + SharedString, Size, SizeRefinement, TextRun, ViewContext, WindowContext, }; use refineable::{Cascade, Refineable}; use smallvec::SmallVec; @@ -125,8 +125,8 @@ pub struct TextStyle { impl Default for TextStyle { fn default() -> Self { TextStyle { - color: Hsla::default(), - font_family: SharedString::default(), + color: black(), + font_family: "Helvetica".into(), // todo!("Get a font we know exists on the system") font_features: FontFeatures::default(), font_size: rems(1.), line_height: phi(), diff --git a/crates/storybook2/src/stories.rs b/crates/storybook2/src/stories.rs index a7b09443e6f31347ab42daca79617d33311a3fe3..f731f7e4280c07503b734a54b35866acfdeba13d 100644 --- a/crates/storybook2/src/stories.rs +++ b/crates/storybook2/src/stories.rs @@ -1,2 +1,7 @@ -pub mod kitchen_sink; -pub mod z_index; +mod kitchen_sink; +mod text; +mod z_index; + +pub use kitchen_sink::*; +pub use text::*; +pub use z_index::*; diff --git a/crates/storybook2/src/stories/text.rs b/crates/storybook2/src/stories/text.rs new file mode 100644 index 0000000000000000000000000000000000000000..1f35d6372598f0d52b820ec0151c29dc6660077e --- /dev/null +++ b/crates/storybook2/src/stories/text.rs @@ -0,0 +1,20 @@ +use gpui3::{div, view, white, Context, ParentElement, StyleHelpers, View, WindowContext}; + +pub struct TextStory { + text: View<()>, +} + +impl TextStory { + pub fn view(cx: &mut WindowContext) -> View<()> { + view(cx.entity(|cx| ()), |_, cx| { + div() + .size_full() + .fill(white()) + .child(concat!( + "The quick brown fox jumps over the lazy dog. ", + "Meanwhile, the lazy dog decided it was time for a change. ", + "He started daily workout routines, ate healthier and became the fastest dog in town.", + )) + }) + } +} diff --git a/crates/storybook2/src/story_selector.rs b/crates/storybook2/src/story_selector.rs index 0f6159d40fa1c9645c8d8f634ad5d4b8fb5d7096..1603a46b19204d2e60d33de091767cd2296403bb 100644 --- a/crates/storybook2/src/story_selector.rs +++ b/crates/storybook2/src/story_selector.rs @@ -1,12 +1,12 @@ use std::str::FromStr; use std::sync::OnceLock; +use crate::stories::*; use anyhow::anyhow; use clap::builder::PossibleValue; use clap::ValueEnum; use gpui3::{view, AnyView, Context}; use strum::{EnumIter, EnumString, IntoEnumIterator}; - use ui::prelude::*; #[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)] @@ -18,6 +18,7 @@ pub enum ElementStory { Icon, Input, Label, + Text, ZIndex, } @@ -43,10 +44,10 @@ impl ElementStory { Self::Label => { view(cx.entity(|cx| ()), |_, _| ui::LabelStory::new().into_any()).into_any() } - Self::ZIndex => view(cx.entity(|cx| ()), |_, _| { - crate::stories::z_index::ZIndexStory::new().into_any() - }) - .into_any(), + Self::Text => TextStory::view(cx).into_any(), + Self::ZIndex => { + view(cx.entity(|cx| ()), |_, _| ZIndexStory::new().into_any()).into_any() + } } } } @@ -212,9 +213,7 @@ impl StorySelector { match self { Self::Element(element_story) => element_story.story(cx), Self::Component(component_story) => component_story.story(cx), - Self::KitchenSink => { - crate::stories::kitchen_sink::KitchenSinkStory::view(cx).into_any() - } + Self::KitchenSink => KitchenSinkStory::view(cx).into_any(), } } }