Add font-weight methods to styled: font_light, font_semibold, font_bold ... (#58)
https://tailwindcss.com/docs/font-weight
This commit is contained in:
parent
30f34dc780
commit
3ec35929ae
1 changed files with 19 additions and 0 deletions
|
|
@ -46,6 +46,15 @@ fn elevated<E: Styled>(this: E, cx: &WindowContext, index: ElevationIndex) -> E
|
|||
.shadow(index.shadow())
|
||||
}
|
||||
|
||||
macro_rules! font_weight {
|
||||
($fn:ident, $const:ident) => {
|
||||
/// [docs](https://tailwindcss.com/docs/font-weight)
|
||||
fn $fn(self) -> Self {
|
||||
self.font_weight(gpui::FontWeight::$const)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Extends [`gpui::Styled`] with specific styling methods.
|
||||
pub trait StyledExt: Styled + Sized {
|
||||
/// Horizontally stacks elements.
|
||||
|
|
@ -139,6 +148,16 @@ pub trait StyledExt: Styled + Sized {
|
|||
fn outline(self, cx: &WindowContext) -> Self {
|
||||
self.border_color(cx.theme().ring)
|
||||
}
|
||||
|
||||
font_weight!(font_thin, THIN);
|
||||
font_weight!(font_extralight, EXTRA_LIGHT);
|
||||
font_weight!(font_light, LIGHT);
|
||||
font_weight!(font_normal, NORMAL);
|
||||
font_weight!(font_medium, MEDIUM);
|
||||
font_weight!(font_semibold, SEMIBOLD);
|
||||
font_weight!(font_bold, BOLD);
|
||||
font_weight!(font_extrabold, EXTRA_BOLD);
|
||||
font_weight!(font_black, BLACK);
|
||||
}
|
||||
|
||||
impl<E: Styled> StyledExt for E {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue