add `ui_text_size` functions

Nate Butler created

Change summary

crates/ui2/src/components/label.rs |  4 ++--
crates/ui2/src/prelude.rs          | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)

Detailed changes

crates/ui2/src/components/label.rs 🔗

@@ -1,4 +1,4 @@
-use gpui::{relative, rems, Hsla, WindowContext};
+use gpui::{relative, Hsla, WindowContext};
 use smallvec::SmallVec;
 
 use crate::prelude::*;
@@ -85,7 +85,7 @@ impl Label {
                         .bg(LabelColor::Hidden.hsla(cx)),
                 )
             })
-            .text_size(rems(1.))
+            .text_size(ui_text_default())
             .when(self.line_height_style == LineHeightStyle::UILabel, |this| {
                 this.line_height(relative(1.))
             })

crates/ui2/src/prelude.rs 🔗

@@ -1,3 +1,5 @@
+use gpui::rems;
+use gpui::Rems;
 pub use gpui::{
     div, Component, Element, ElementId, ParentElement, SharedString, StatefulInteractive,
     StatelessInteractive, Styled, ViewContext, WindowContext,
@@ -73,6 +75,24 @@ 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]