core: use typography roles for text styling

This commit is contained in:
2026-11-12 19:09:51 +07:00
parent 9528dcc54e
commit e2ec1fa7c2
6 changed files with 25 additions and 36 deletions
+2 -6
View File
@@ -7,7 +7,7 @@ use gpui::{
StatefulInteractiveElement as _, Styled as _, Window, deferred, div, ease_out_quint,
};
use gpui_native_icons::{Icon, IconRole, icon};
use gpui_native_theme::{ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size};
use gpui_native_theme::{ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size, TextRole, Typeset as _};
use gpui_native_utils::ResultLogErr as _;
use crate::button::{Button, ButtonVariant};
@@ -144,7 +144,6 @@ impl RenderOnce for Alert {
let shadows = theme.elevations.popover.shadows();
let metrics = theme.sizes.resolve(Size::Medium);
let icon_size = metrics.icon_size;
let title_size = metrics.text_size;
let caption_size = metrics.caption_size;
div()
@@ -178,11 +177,8 @@ impl RenderOnce for Alert {
.when_some(self.title.clone(), |alert, title| {
alert.child(
div()
.text_size(title_size)
.typeset(TextRole::Headline, cx)
.text_color(foreground)
.when(self.message.is_some(), |title| {
title.font_weight(gpui::FontWeight::SEMIBOLD)
})
.child(title),
)
})
+4 -11
View File
@@ -2,13 +2,13 @@ use gpui::prelude::FluentBuilder as _;
use std::rc::Rc;
use gpui::{
Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId, FontWeight,
Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId,
InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _,
RenderOnce, Role, ScrollHandle, SharedString, StatefulInteractiveElement as _, Styled as _,
Window, canvas, div, ease_out_quint, relative,
};
use gpui_native_icons::IconRole;
use gpui_native_theme::ActiveTheme as _;
use gpui_native_theme::{ActiveTheme as _, TextRole, Typeset as _};
use crate::button::{Button, ButtonVariant};
use crate::common::{Sizable, v_flex};
@@ -139,7 +139,7 @@ impl RenderOnce for Dialog {
return root;
}
let (scrim_color, border, foreground, surface, radius, shadows, title_size, enter_duration) = {
let (scrim_color, border, foreground, surface, radius, shadows, enter_duration) = {
let theme = cx.theme();
(
theme.colors.overlay,
@@ -152,7 +152,6 @@ impl RenderOnce for Dialog {
theme.colors.surface,
theme.radius.overlay,
theme.elevations.dialog.shadows(),
theme.sizes.medium.text_size,
theme.motion.overlay,
)
};
@@ -224,13 +223,7 @@ impl RenderOnce for Dialog {
.justify_end()
.gap_2()
.when_some(self.title.clone(), |row, title| {
row.child(
div()
.flex_1()
.text_size(title_size)
.font_weight(FontWeight::SEMIBOLD)
.child(title),
)
row.child(div().flex_1().typeset(TextRole::Title3, cx).child(title))
})
.when(show_close, |row| {
row.child(
+4 -6
View File
@@ -1,10 +1,10 @@
use gpui::prelude::FluentBuilder as _;
use gpui::{
App, IntoElement, ParentElement as _, RenderOnce, SharedString, StyleRefinement, Styled as _,
Window, div, relative,
Window, div,
};
use gpui_native_icons::Icon;
use gpui_native_theme::{ActiveTheme as _, Size};
use gpui_native_theme::{ActiveTheme as _, Size, TextRole, Typeset as _};
use crate::common::{StyledExt, v_flex};
@@ -91,16 +91,14 @@ impl RenderOnce for EmptyState {
})
.child(
div()
.text_size(metrics.text_size)
.font_weight(gpui::FontWeight::MEDIUM)
.typeset(TextRole::Title3, cx)
.text_color(foreground)
.line_height(relative(1.3))
.child(self.headline),
)
.when_some(self.hint, |state, hint| {
state.child(
div()
.text_size(metrics.caption_size)
.typeset(TextRole::Subheadline, cx)
.text_color(muted_foreground)
.child(hint),
)