Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
BROKEN: Checkpoint
Nate Butler6ecf629c6329
diff --git a/crates/ui2/src/components/label.rs b/crates/ui2/src/components/label.rsindex 3346d7835a2..827ba87918a 100644--- a/crates/ui2/src/components/label.rs+++ b/crates/ui2/src/components/label.rs@@ -2,6 +2,8 @@ use gpui::{relative, Hsla, WindowContext};use smallvec::SmallVec;use crate::prelude::*;+use crate::styled_ext::StyledExt;+#[derive(Default, PartialEq, Copy, Clone)]pub enum LabelColor {#[default]@@ -85,7 +87,7 @@ impl Label {.bg(LabelColor::Hidden.hsla(cx)),)})- .text_size(ui_text_default())+ .text_ui().when(self.line_height_style == LineHeightStyle::UILabel, |this| {this.line_height(relative(1.))})diff --git a/crates/ui2/src/lib.rs b/crates/ui2/src/lib.rsindex 5fb39984387..149dcd3fd04 100644--- a/crates/ui2/src/lib.rs+++ b/crates/ui2/src/lib.rs@@ -19,12 +19,14 @@ mod elevation;pub mod prelude;pub mod settings;mod static_data;+mod styled_ext;mod to_extract;pub mod utils;pub use components::*;pub use prelude::*;pub use static_data::*;+pub use styled_ext::*;pub use to_extract::*;// This needs to be fully qualified with `crate::` otherwise we get a panicdiff --git a/crates/ui2/src/prelude.rs b/crates/ui2/src/prelude.rsindex fc0adadb9cd..a99f84dcfe0 100644--- a/crates/ui2/src/prelude.rs+++ b/crates/ui2/src/prelude.rs@@ -12,6 +12,40 @@ pub use theme2::ActiveTheme;use gpui::Hsla;use strum::EnumIter;+#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]+pub enum UITextSize {+ #[default]+ Default,+ Small,+}++impl UITextSize {+ pub fn rems(self) -> Rems {+ match self {+ Self::Default => rems(0.875),+ Self::Small => rems(0.75),+ }+ }+}++/// The default text size for UI text+///+/// At a default 16px per rem, this is 14px.+///+/// Use [`ui_text_sm`] for smaller text.+pub fn ui_text_default() -> Rems {+ rems(0.875)+}++/// The small text size for UI text+///+/// At a default 16px per rem, this is 12px.+///+/// Use [`ui_text_default`] for regular-sized text.+pub fn ui_text_sm() -> Rems {+ rems(0.75)+}+#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]pub enum FileSystemStatus {#[default]@@ -75,24 +109,6 @@ impl std::fmt::Display for GitStatus {}}-/// The default text size for UI text-///-/// At a default 16px per rem, this is 14px.-///-/// Use [`ui_text_sm`] for smaller text.-pub fn ui_text_default() -> Rems {- rems(0.875)-}--/// The small text size for UI text-///-/// At a default 16px per rem, this is 12px.-///-/// Use [`ui_text_default`] for regular-sized text.-pub fn ui_text_sm() -> Rems {- rems(0.75)-}-#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]pub enum DiagnosticStatus {#[default]diff --git a/crates/ui2/src/styled_ext.rs b/crates/ui2/src/styled_ext.rsnew file mode 100644index 00000000000..70b2a072fc7--- /dev/null+++ b/crates/ui2/src/styled_ext.rs@@ -0,0 +1,30 @@+use gpui::Styled;++use crate::UITextSize;++pub trait StyledExt: Styled {+ fn text_ui_size(self, size: UITextSize) -> Self+ where+ Self: Sized,+ {+ let size = size.rems();++ self.text_size(size)+ }+ fn text_ui(self) -> Self+ where+ Self: Sized,+ {+ let size = UITextSize::default().rems();++ self.text_size(size)+ }+ fn text_ui_sm(self) -> Self+ where+ Self: Sized,+ {+ let size = UITextSize::Small.rems();++ self.text_size(size)+ }+}