subspace-dashboard 0.2.0

Subspace Framework board kit: the Dashboard trait, shared widgets and design tokens. Internal crate; apps depend on `subspace-framework`.
Documentation
//! The type scale: each text role's size from its density setting.

use gpui_kit::{Pixels, px};

use super::Tokens;
use crate::density::{
    BODY_FONT_DEFAULT, HEADING_FONT_DEFAULT, MONO_FONT_DEFAULT, TAB_FONT_DEFAULT,
};

const CAPTION_FONT_DEFAULT: f32 = 11.;
const SECONDARY_FONT_DEFAULT: f32 = 12.;

impl Tokens {
    /// Scale an existing heading size without changing its default hierarchy.
    pub fn heading_size(&self, default: f32) -> Pixels {
        px(default) * (f32::from(self.heading_font) / HEADING_FONT_DEFAULT)
    }

    /// Scale a tab label size by the tab setting, as headings scale.
    pub fn tab_size(&self, default: f32) -> Pixels {
        px(default) * (f32::from(self.tab_font) / TAB_FONT_DEFAULT)
    }

    /// Small labels, key hints and badges, scaled from the row font.
    pub fn caption_size(&self) -> Pixels {
        self.row_font * (CAPTION_FONT_DEFAULT / BODY_FONT_DEFAULT)
    }

    /// Supporting text, scaled from the row font.
    pub fn secondary_size(&self) -> Pixels {
        self.row_font * (SECONDARY_FONT_DEFAULT / BODY_FONT_DEFAULT)
    }

    /// Scale an existing monospace size without changing its default hierarchy.
    pub fn mono_size(&self, default: f32) -> Pixels {
        px(default) * (f32::from(self.mono_font) / MONO_FONT_DEFAULT)
    }
}