History

Checkpoint

Antonio Scandurra committed 3 years ago

Commit b040ae81 parent c6e20ae4 files · +40 −16Browse files

Unified · Split

4 files
  1. crates/gpui3/src/style.rs +6 −6
  2. crates/storybook2/src/stories.rs +7 −2
  3. crates/storybook2/src/stories/text.rs +20 −0
  4. crates/storybook2/src/story_selector.rs +7 −8
crates/gpui3/src/style.rs+6−6
@@ -1,8 +1,8 @@
11 use crate::{
2− phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask, Corners,
3− CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures, FontStyle,
4− FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rems, Result, SharedString, Size,
5− SizeRefinement, TextRun, ViewContext, WindowContext,
2+ black, phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask,
3+ Corners, CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures,
4+ FontStyle, FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rems, Result,
5+ SharedString, Size, SizeRefinement, TextRun, ViewContext, WindowContext,
66 };
77 use refineable::{Cascade, Refineable};
88 use smallvec::SmallVec;
@@ -125,8 +125,8 @@ pub struct TextStyle { · 116 unmodified lines
125125 impl Default for TextStyle {
126126 fn default() -> Self {
127127 TextStyle {
128− color: Hsla::default(),
129− font_family: SharedString::default(),
128+ color: black(),
129+ font_family: "Helvetica".into(), // todo!("Get a font we know exists on the system")
130130 font_features: FontFeatures::default(),
131131 font_size: rems(1.),
132132 line_height: phi(),
crates/storybook2/src/stories.rs+7−2
@@ -1,2 +1,7 @@
1−pub mod kitchen_sink;
2−pub mod z_index;
1+mod kitchen_sink;
2+mod text;
3+mod z_index;
4+
5+pub use kitchen_sink::*;
6+pub use text::*;
7+pub use z_index::*;
crates/storybook2/src/stories/text.rs+20−0
@@ -0,0 +1,20 @@
1+use gpui3::{div, view, white, Context, ParentElement, StyleHelpers, View, WindowContext};
2+
3+pub struct TextStory {
4+ text: View<()>,
5+}
6+
7+impl TextStory {
8+ pub fn view(cx: &mut WindowContext) -> View<()> {
9+ view(cx.entity(|cx| ()), |_, cx| {
10+ div()
11+ .size_full()
12+ .fill(white())
13+ .child(concat!(
14+ "The quick brown fox jumps over the lazy dog. ",
15+ "Meanwhile, the lazy dog decided it was time for a change. ",
16+ "He started daily workout routines, ate healthier and became the fastest dog in town.",
17+ ))
18+ })
19+ }
20+}
crates/storybook2/src/story_selector.rs+7−8
@@ -1,12 +1,12 @@
11 use std::str::FromStr;
22 use std::sync::OnceLock;
33
4+use crate::stories::*;
45 use anyhow::anyhow;
56 use clap::builder::PossibleValue;
67 use clap::ValueEnum;
78 use gpui3::{view, AnyView, Context};
89 use strum::{EnumIter, EnumString, IntoEnumIterator};
9−
1010 use ui::prelude::*;
1111
1212 #[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]
@@ -18,6 +18,7 @@ pub enum ElementStory { · 5 unmodified lines
1818 Icon,
1919 Input,
2020 Label,
21+ Text,
2122 ZIndex,
2223 }
2324
@@ -43,10 +44,10 @@ impl ElementStory { · 19 unmodified lines
4344 Self::Label => {
4445 view(cx.entity(|cx| ()), |_, _| ui::LabelStory::new().into_any()).into_any()
4546 }
46− Self::ZIndex => view(cx.entity(|cx| ()), |_, _| {
47− crate::stories::z_index::ZIndexStory::new().into_any()
48− })
49− .into_any(),
47+ Self::Text => TextStory::view(cx).into_any(),
48+ Self::ZIndex => {
49+ view(cx.entity(|cx| ()), |_, _| ZIndexStory::new().into_any()).into_any()
50+ }
5051 }
5152 }
5253 }
@@ -212,9 +213,7 @@ impl StorySelector { · 159 unmodified lines
212213 match self {
213214 Self::Element(element_story) => element_story.story(cx),
214215 Self::Component(component_story) => component_story.story(cx),
215− Self::KitchenSink => {
216− crate::stories::kitchen_sink::KitchenSinkStory::view(cx).into_any()
217− }
216+ Self::KitchenSink => KitchenSinkStory::view(cx).into_any(),
218217 }
219218 }
220219 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t