Use shared theme tokens across components

- Replace remaining raw component metrics with theme constants.
- Share disabled opacity, focus ring alpha, and code line height.
- Route editor borders, weights, and links through the theme.
- Align tab, alert, toast, panel, and resize spacing.
This commit is contained in:
2026-11-16 18:35:00 +07:00
parent 9e61147ca9
commit 1dafa87bef
27 changed files with 136 additions and 89 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ use gpui::{
};
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
use gpui_native_theme::{
ActiveTheme as _, ColorTokens, MONO_ADVANCE_RATIO, Ramps, WASH_ALPHA_SOFT,
ActiveTheme as _, CODE_LINE_HEIGHT, ColorTokens, MONO_ADVANCE_RATIO, Ramps, WASH_ALPHA_SOFT,
};
use crate::highlight::{HighlightedCode, Language, Role, highlight};
@@ -256,7 +256,7 @@ impl Render for CodeViewState {
let colors = theme.colors;
let mono_font = theme.mono_font;
let text_size = theme.sizes.small.text_size;
let line_height = text_size * 1.5;
let line_height = text_size * CODE_LINE_HEIGHT;
let char_width = text_size * MONO_ADVANCE_RATIO;
let root_font_size = theme.root_font_size;
+6 -4
View File
@@ -13,7 +13,7 @@ use gpui::{
point, uniform_list,
};
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
use gpui_native_theme::{ActiveTheme as _, MONO_ADVANCE_RATIO};
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, MONO_ADVANCE_RATIO};
use similar::{Change, ChangeTag, TextDiff};
use std::ops::Range;
@@ -535,7 +535,7 @@ fn render_row(
row_element.child(
div()
.flex_none()
.border_l_4()
.border_l(BORDER_WIDTH * 4.0)
.border_color(gpui::transparent_black()),
)
},
@@ -661,7 +661,9 @@ fn render_row(
_ => wash_strong(change_color),
})
.when(options.indicators == DiffIndicators::Bars, |number| {
number.border_l_4().border_color(change_color)
number
.border_l(BORDER_WIDTH * 4.0)
.border_color(change_color)
}),
)
})
@@ -672,7 +674,7 @@ fn render_row(
div()
.h_full()
.flex_none()
.border_l_4()
.border_l(BORDER_WIDTH * 4.0)
.border_color(change_color),
)
},
+17 -17
View File
@@ -9,19 +9,20 @@
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, Bounds, ClipboardItem, Context, Div, Element, ElementId, Entity, FontStyle,
FontWeight, GlobalElementId, HighlightStyle, InspectorElementId, InteractiveElement as _,
InteractiveText, IntoElement, KeyBinding, LayoutId, ListAlignment, ListOffset, ListState,
MouseButton, MouseDownEvent, MouseMoveEvent, ObjectFit, ParentElement as _, Pixels,
Refineable as _, Render, SharedString, StatefulInteractiveElement as _, StrikethroughStyle,
StyleRefinement, Styled, StyledImage as _, StyledText, TextLayout, UnderlineStyle, Window,
actions, div, img, list, px, relative,
GlobalElementId, HighlightStyle, InspectorElementId, InteractiveElement as _, InteractiveText,
IntoElement, KeyBinding, LayoutId, ListAlignment, ListOffset, ListState, MouseButton,
MouseDownEvent, MouseMoveEvent, ObjectFit, ParentElement as _, Pixels, Refineable as _, Render,
SharedString, StatefulInteractiveElement as _, StrikethroughStyle, StyleRefinement, Styled,
StyledImage as _, StyledText, TextLayout, UnderlineStyle, Window, actions, div, img, list, px,
relative,
};
use gpui_native_core::button::{Button, ButtonVariant};
use gpui_native_core::checkbox::Checkbox;
use gpui_native_core::common::Sizable as _;
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarVisibility};
use gpui_native_theme::{
ActiveTheme as _, BORDER_WIDTH, CODE_OVERSCROLL_MAX, Size, TextRole, Typeset as _,
ActiveTheme as _, BORDER_WIDTH, CODE_LINE_HEIGHT, CODE_OVERSCROLL_MAX, Size, TextRole,
Typeset as _,
};
use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
@@ -46,8 +47,6 @@ const QUOTE_INSET: f32 = 1.0;
const INDENT_STEP: f32 = 1.5;
/// The body line height.
const BODY_LINE_HEIGHT: f32 = 1.6;
/// The code line height inside fenced blocks.
const CODE_LINE_HEIGHT: f32 = 1.5;
/// The tallest a standalone image renders, in root font sizes.
const IMAGE_MAX_HEIGHT: f32 = 14.0;
/// The side of an inline image atom relative to the body text size.
@@ -1469,7 +1468,7 @@ fn block_frame(quote: bool, top: Pixels, bottom: Pixels, id: &ElementId, cx: &Ap
.pb(bottom)
.when(quote, |frame| {
frame
.border_l_2()
.border_l(BORDER_WIDTH * 2.0)
.border_color(theme.colors.border)
.pl(theme.root_font_size * QUOTE_INSET)
})
@@ -1546,8 +1545,9 @@ fn text_row(
.pr_1()
.child(match marker {
ListMarker::Bullet => div()
.text_color(theme.colors.muted_foreground)
.child("•")
.size(theme.spacing.unit)
.rounded(theme.radius.full)
.bg(theme.colors.muted_foreground)
.into_any_element(),
ListMarker::Ordered(number) => div()
.text_color(theme.colors.muted_foreground)
@@ -1721,7 +1721,7 @@ fn code_row(
.when_some(language.cloned(), |row, language| {
row.child(
div()
.text_xs()
.typeset(TextRole::Caption, cx)
.text_color(theme.colors.muted_foreground)
.child(language),
)
@@ -1845,7 +1845,7 @@ fn table_row(
.px_2()
.py_1()
.when(row.header, |cell_element| {
cell_element.font_weight(FontWeight::SEMIBOLD)
cell_element.font_weight(theme.typography.headline.weight)
})
.child(text_child(&cell.spans, &cell_id, piece, cx))
})
@@ -1981,7 +1981,7 @@ where
InlineStyle::Strong => highlights.push((
range,
HighlightStyle {
font_weight: Some(FontWeight::SEMIBOLD),
font_weight: Some(theme.typography.headline.weight),
..Default::default()
},
)),
@@ -1989,7 +1989,7 @@ where
range,
HighlightStyle {
font_style: Some(FontStyle::Italic),
font_weight: Some(FontWeight::SEMIBOLD),
font_weight: Some(theme.typography.headline.weight),
..Default::default()
},
)),
@@ -2017,7 +2017,7 @@ where
highlights.push((
range.clone(),
HighlightStyle {
color: Some(theme.colors.accent),
color: Some(theme.ramps.primary.base),
underline: Some(UnderlineStyle {
thickness: BORDER_WIDTH,
color: None,