BROKEN: Checkpoint
This commit is contained in:
parent
e4ca2cb20b
commit
6ecf629c63
4 changed files with 69 additions and 19 deletions
|
@ -2,6 +2,8 @@ use gpui::{relative, Hsla, WindowContext};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use crate::styled_ext::StyledExt;
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Copy, Clone)]
|
#[derive(Default, PartialEq, Copy, Clone)]
|
||||||
pub enum LabelColor {
|
pub enum LabelColor {
|
||||||
#[default]
|
#[default]
|
||||||
|
@ -85,7 +87,7 @@ impl Label {
|
||||||
.bg(LabelColor::Hidden.hsla(cx)),
|
.bg(LabelColor::Hidden.hsla(cx)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.text_size(ui_text_default())
|
.text_ui()
|
||||||
.when(self.line_height_style == LineHeightStyle::UILabel, |this| {
|
.when(self.line_height_style == LineHeightStyle::UILabel, |this| {
|
||||||
this.line_height(relative(1.))
|
this.line_height(relative(1.))
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,12 +19,14 @@ mod elevation;
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
mod static_data;
|
mod static_data;
|
||||||
|
mod styled_ext;
|
||||||
mod to_extract;
|
mod to_extract;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
pub use components::*;
|
pub use components::*;
|
||||||
pub use prelude::*;
|
pub use prelude::*;
|
||||||
pub use static_data::*;
|
pub use static_data::*;
|
||||||
|
pub use styled_ext::*;
|
||||||
pub use to_extract::*;
|
pub use to_extract::*;
|
||||||
|
|
||||||
// This needs to be fully qualified with `crate::` otherwise we get a panic
|
// This needs to be fully qualified with `crate::` otherwise we get a panic
|
||||||
|
|
|
@ -12,6 +12,40 @@ pub use theme2::ActiveTheme;
|
||||||
use gpui::Hsla;
|
use gpui::Hsla;
|
||||||
use strum::EnumIter;
|
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)]
|
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]
|
||||||
pub enum FileSystemStatus {
|
pub enum FileSystemStatus {
|
||||||
#[default]
|
#[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)]
|
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]
|
||||||
pub enum DiagnosticStatus {
|
pub enum DiagnosticStatus {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
30
crates/ui2/src/styled_ext.rs
Normal file
30
crates/ui2/src/styled_ext.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue