Tokenize remaining component layout metrics
- Add combobox, alert edge, and code gutter tokens. - Replace rem-derived literals in alert, combobox, code, and diff.
This commit is contained in:
@@ -12,7 +12,8 @@ use gpui::{
|
||||
};
|
||||
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
|
||||
use gpui_native_theme::{
|
||||
ActiveTheme as _, CODE_LINE_HEIGHT, ColorTokens, MONO_ADVANCE_RATIO, Ramps, WASH_ALPHA_SOFT,
|
||||
ActiveTheme as _, CODE_GUTTER_WIDTH, CODE_LINE_HEIGHT, ColorTokens, MONO_ADVANCE_RATIO, Ramps,
|
||||
WASH_ALPHA_SOFT,
|
||||
};
|
||||
|
||||
use crate::highlight::{HighlightedCode, Language, Role, highlight};
|
||||
@@ -264,7 +265,7 @@ impl Render for CodeViewState {
|
||||
let state = cx.entity();
|
||||
let line_count = self.code.lines.len();
|
||||
let selection = self.selection();
|
||||
let gutter_width = root_font_size * 2.5;
|
||||
let gutter_width = CODE_GUTTER_WIDTH;
|
||||
|
||||
let bounds_cell: std::rc::Rc<std::cell::RefCell<Option<Bounds<Pixels>>>> =
|
||||
std::rc::Rc::new(std::cell::RefCell::new(None));
|
||||
|
||||
@@ -13,7 +13,7 @@ use gpui::{
|
||||
point, uniform_list,
|
||||
};
|
||||
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, MONO_ADVANCE_RATIO};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, CODE_GUTTER_WIDTH, MONO_ADVANCE_RATIO};
|
||||
use similar::{Change, ChangeTag, TextDiff};
|
||||
|
||||
use std::ops::Range;
|
||||
@@ -524,10 +524,10 @@ fn render_row(
|
||||
.text_color(colors.muted_foreground)
|
||||
.when(
|
||||
options.indicators == DiffIndicators::Classic,
|
||||
|row_element| row_element.child(div().w_10().flex_none()),
|
||||
|row_element| row_element.child(div().w(CODE_GUTTER_WIDTH).flex_none()),
|
||||
)
|
||||
.when(options.line_numbers, |row_element| {
|
||||
row_element.child(div().w_10().flex_none())
|
||||
row_element.child(div().w(CODE_GUTTER_WIDTH).flex_none())
|
||||
})
|
||||
.when(
|
||||
options.indicators == DiffIndicators::Bars && !options.line_numbers,
|
||||
@@ -654,7 +654,7 @@ fn render_row(
|
||||
.map(|number| number.to_string())
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.w_10()
|
||||
.w(CODE_GUTTER_WIDTH)
|
||||
.whitespace_nowrap()
|
||||
.bg(match row.kind {
|
||||
DiffRowKind::Context => wash_gutter(&colors),
|
||||
|
||||
@@ -11,7 +11,7 @@ use gpui::StyledText;
|
||||
#[cfg(any(feature = "code", feature = "markdown"))]
|
||||
use gpui::{App, HighlightStyle, Hsla, IntoElement, ParentElement as _, Styled as _, div};
|
||||
#[cfg(any(feature = "code", feature = "markdown"))]
|
||||
use gpui_native_theme::{ActiveTheme as _, ColorTokens, Ramps};
|
||||
use gpui_native_theme::{ActiveTheme as _, CODE_GUTTER_WIDTH, ColorTokens, Ramps};
|
||||
#[cfg(feature = "diff")]
|
||||
use gpui_native_theme::{WASH_ALPHA, WASH_ALPHA_GUTTER, WASH_ALPHA_STRONG};
|
||||
|
||||
@@ -74,7 +74,7 @@ where
|
||||
let theme = cx.theme();
|
||||
|
||||
div()
|
||||
.size_10()
|
||||
.size(CODE_GUTTER_WIDTH)
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
|
||||
Reference in New Issue
Block a user