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 @@
1use crate::{1use crate::{
2 phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask, Corners,2 black, phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask,
3 CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures, FontStyle,3 Corners, CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures,
4 FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rems, Result, SharedString, Size,4 FontStyle, FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Rems, Result,
5 SizeRefinement, TextRun, ViewContext, WindowContext,5 SharedString, Size, SizeRefinement, TextRun, ViewContext, WindowContext,
6};6};
7use refineable::{Cascade, Refineable};7use refineable::{Cascade, Refineable};
8use smallvec::SmallVec;8use smallvec::SmallVec;
@@ -125,8 +125,8 @@ pub struct TextStyle { · 116 unmodified lines
125impl Default for TextStyle {125impl Default for TextStyle {
126 fn default() -> Self {126 fn default() -> Self {
127 TextStyle {127 TextStyle {
128 color: Hsla::default(),128 color: black(),
129 font_family: SharedString::default(),129 font_family: "Helvetica".into(), // todo!("Get a font we know exists on the system")
130 font_features: FontFeatures::default(),130 font_features: FontFeatures::default(),
131 font_size: rems(1.),131 font_size: rems(1.),
132 line_height: phi(),132 line_height: phi(),
crates/storybook2/src/stories.rs+7−2
@@ -1,2 +1,7 @@
1pub mod kitchen_sink;1mod kitchen_sink;
2pub mod z_index;2mod text;
3mod z_index;
4
5pub use kitchen_sink::*;
6pub use text::*;
7pub use z_index::*;
crates/storybook2/src/stories/text.rs+20−0
@@ -0,0 +1,20 @@
1use gpui3::{div, view, white, Context, ParentElement, StyleHelpers, View, WindowContext};
2
3pub struct TextStory {
4 text: View<()>,
5}
6
7impl 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 @@
1use std::str::FromStr;1use std::str::FromStr;
2use std::sync::OnceLock;2use std::sync::OnceLock;
3 3
4use crate::stories::*;
4use anyhow::anyhow;5use anyhow::anyhow;
5use clap::builder::PossibleValue;6use clap::builder::PossibleValue;
6use clap::ValueEnum;7use clap::ValueEnum;
7use gpui3::{view, AnyView, Context};8use gpui3::{view, AnyView, Context};
8use strum::{EnumIter, EnumString, IntoEnumIterator};9use strum::{EnumIter, EnumString, IntoEnumIterator};
9
10use ui::prelude::*;10use ui::prelude::*;
11 11
12#[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]12#[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]
@@ -18,6 +18,7 @@ pub enum ElementStory { · 5 unmodified lines
18 Icon,18 Icon,
19 Input,19 Input,
20 Label,20 Label,
21 Text,
21 ZIndex,22 ZIndex,
22}23}
23 24
@@ -43,10 +44,10 @@ impl ElementStory { · 19 unmodified lines
43 Self::Label => {44 Self::Label => {
44 view(cx.entity(|cx| ()), |_, _| ui::LabelStory::new().into_any()).into_any()45 view(cx.entity(|cx| ()), |_, _| ui::LabelStory::new().into_any()).into_any()
45 }46 }
46 Self::ZIndex => view(cx.entity(|cx| ()), |_, _| {47 Self::Text => TextStory::view(cx).into_any(),
47 crate::stories::z_index::ZIndexStory::new().into_any()48 Self::ZIndex => {
48 })49 view(cx.entity(|cx| ()), |_, _| ZIndexStory::new().into_any()).into_any()
49 .into_any(),50 }
50 }51 }
51 }52 }
52}53}
@@ -212,9 +213,7 @@ impl StorySelector { · 159 unmodified lines
212 match self {213 match self {
213 Self::Element(element_story) => element_story.story(cx),214 Self::Element(element_story) => element_story.story(cx),
214 Self::Component(component_story) => component_story.story(cx),215 Self::Component(component_story) => component_story.story(cx),
215 Self::KitchenSink => {216 Self::KitchenSink => KitchenSinkStory::view(cx).into_any(),
216 crate::stories::kitchen_sink::KitchenSinkStory::view(cx).into_any()
217 }
218 }217 }
219 }218 }
220}219}

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