BROKEN: Checkpoint

This commit is contained in:
Nate Butler 2023-11-08 14:29:38 -05:00
parent e4ca2cb20b
commit 6ecf629c63
4 changed files with 69 additions and 19 deletions

View file

@ -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.))
})

View file

@ -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 panic

View file

@ -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]

View file

@ -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)
}
}