Add span method, fix primary button text color
This commit is contained in:
parent
a4601782f8
commit
4c278bfabc
4 changed files with 13 additions and 7 deletions
|
|
@ -6,6 +6,7 @@ use gpui::{
|
|||
|
||||
use crate::{
|
||||
label::Label,
|
||||
span,
|
||||
theme::{ActiveTheme, Colorize as _, ThemeMode},
|
||||
Clickable, Disableable, Selectable,
|
||||
};
|
||||
|
|
@ -175,7 +176,8 @@ impl RenderOnce for Button {
|
|||
normal_style.fg
|
||||
};
|
||||
|
||||
Label::new(self.label)
|
||||
span()
|
||||
.child(self.label)
|
||||
.text_color(text_color)
|
||||
.map(|this| match self.size {
|
||||
ButtonSize::Small => this.text_sm(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use gpui::{
|
||||
div, prelude::FluentBuilder as _, px, AbsoluteLength, DefiniteLength, Div, Hsla, IntoElement,
|
||||
ParentElement, RenderOnce, SharedString, Styled, WindowContext,
|
||||
ParentElement, RenderOnce, SharedString, Styled, TextStyleRefinement, WindowContext,
|
||||
};
|
||||
|
||||
use crate::theme::ActiveTheme;
|
||||
|
|
@ -35,8 +35,6 @@ impl Styled for Label {
|
|||
|
||||
impl RenderOnce for Label {
|
||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
|
||||
let text = if !self.multiple_lines {
|
||||
SharedString::from(self.label.replace('\n', ""))
|
||||
} else {
|
||||
|
|
@ -44,8 +42,8 @@ impl RenderOnce for Label {
|
|||
};
|
||||
|
||||
self.base
|
||||
.text_color(theme.foreground)
|
||||
.text_size(px(theme.font_size))
|
||||
.text_color(cx.theme().foreground)
|
||||
.text_size(px(cx.theme().font_size))
|
||||
.child(text)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub mod theme;
|
|||
pub mod title_bar;
|
||||
pub use styled_ext::StyledExt;
|
||||
pub mod divider;
|
||||
pub mod dropdown;
|
||||
pub mod picker;
|
||||
pub mod switch;
|
||||
pub mod tab;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::StyledExt as _;
|
||||
use gpui::{div, Div};
|
||||
use gpui::{div, Div, Styled};
|
||||
|
||||
/// Horizontally stacks elements. Sets `flex()`, `flex_row()`, `items_center()`
|
||||
#[track_caller]
|
||||
|
|
@ -12,3 +12,8 @@ pub fn h_flex() -> Div {
|
|||
pub fn v_flex() -> Div {
|
||||
div().v_flex()
|
||||
}
|
||||
|
||||
/// A horizontal divider. Sets `h_0.5()`, `bg()`, `bg_gray()`
|
||||
pub fn span() -> Div {
|
||||
div().w_auto()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue