Checkpoint

Antonio Scandurra created

Change summary

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

Detailed changes

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(),

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

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.",
+                ))
+        })
+    }
+}

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