Unify theme sizing and spacing on Base UI metrics
- Read only mode, accent, accessibility, and native window material from the OS. - Replace platform palettes, metrics, type ramps, borders, and elevations with unified tokens. - Align controls, overlays, and data rows with Base UI sizing.
This commit is contained in:
@@ -150,7 +150,6 @@ impl RenderOnce for Alert {
|
||||
let metrics = theme.sizes.resolve(Size::Medium);
|
||||
let icon_size = metrics.icon_size;
|
||||
let dense_icon_size = metrics.dense_icon_size;
|
||||
let caption_size = metrics.caption_size;
|
||||
|
||||
let content = v_flex()
|
||||
.flex_1()
|
||||
@@ -171,7 +170,7 @@ impl RenderOnce for Alert {
|
||||
};
|
||||
alert.child(
|
||||
div()
|
||||
.text_size(caption_size)
|
||||
.text_size(metrics.text_size)
|
||||
.text_color(color)
|
||||
.child(message),
|
||||
)
|
||||
@@ -189,11 +188,7 @@ impl RenderOnce for Alert {
|
||||
match self.presentation {
|
||||
AlertStyle::Overlay => {
|
||||
let surface = theme.colors.surface;
|
||||
let border = if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
surface
|
||||
};
|
||||
let border = theme.colors.border;
|
||||
|
||||
div()
|
||||
.id(self.id.clone())
|
||||
|
||||
+25
-27
@@ -7,7 +7,7 @@ use gpui::{
|
||||
StyleRefinement, Styled as _, Window, canvas, relative, transparent_black,
|
||||
};
|
||||
use gpui_native_icons::Icon;
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, Size};
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
use gpui_native_utils::{focus_ring, record_anchor_bounds};
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -207,10 +207,8 @@ impl RenderOnce for Button {
|
||||
let theme = cx.theme();
|
||||
let colors = theme.colors;
|
||||
let ramps = theme.ramps;
|
||||
let borders = theme.borders;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
|
||||
let show_border = borders.buttons && self.variant != ButtonVariant::Ghost;
|
||||
let on_click = self.on_click;
|
||||
let a11y_label = self.a11y_label.or_else(|| self.label.clone());
|
||||
let is_icon_only = self.icon.is_some() && self.label.is_none() && self.children.is_empty();
|
||||
@@ -224,10 +222,10 @@ impl RenderOnce for Button {
|
||||
ramps.primary.pressed,
|
||||
),
|
||||
ButtonVariant::Secondary => (
|
||||
Some(colors.secondary),
|
||||
colors.secondary_foreground,
|
||||
ramps.secondary.hover,
|
||||
ramps.secondary.pressed,
|
||||
Some(colors.surface),
|
||||
colors.foreground,
|
||||
colors.muted,
|
||||
colors.muted_hover,
|
||||
),
|
||||
ButtonVariant::Ghost => (
|
||||
None,
|
||||
@@ -243,17 +241,23 @@ impl RenderOnce for Button {
|
||||
),
|
||||
};
|
||||
|
||||
let (border, hover_border, pressed_border) = if show_border {
|
||||
(colors.border, colors.border, colors.border)
|
||||
} else {
|
||||
match background {
|
||||
Some(fill) => (fill, hover, pressed),
|
||||
None => (
|
||||
transparent_black(),
|
||||
transparent_black(),
|
||||
transparent_black(),
|
||||
),
|
||||
}
|
||||
let (border, hover_border, pressed_border) = match self.variant {
|
||||
ButtonVariant::Primary => (
|
||||
ramps.primary.base,
|
||||
ramps.primary.hover,
|
||||
ramps.primary.pressed,
|
||||
),
|
||||
ButtonVariant::Secondary => (colors.border, colors.border, colors.border),
|
||||
ButtonVariant::Ghost => (
|
||||
transparent_black(),
|
||||
transparent_black(),
|
||||
transparent_black(),
|
||||
),
|
||||
ButtonVariant::Destructive => (
|
||||
ramps.destructive.base,
|
||||
ramps.destructive.hover,
|
||||
ramps.destructive.pressed,
|
||||
),
|
||||
};
|
||||
|
||||
h_flex()
|
||||
@@ -267,16 +271,10 @@ impl RenderOnce for Button {
|
||||
ButtonSide::Left => button.justify_start(),
|
||||
ButtonSide::Right => button.justify_end(),
|
||||
})
|
||||
.h(metrics.control_height + BORDER_WIDTH * 2.0)
|
||||
.when(is_icon_only, |button| {
|
||||
button.w(metrics.control_height + BORDER_WIDTH * 2.0)
|
||||
})
|
||||
.h(metrics.control_height)
|
||||
.when(is_icon_only, |button| button.w(metrics.control_height))
|
||||
.when(!is_icon_only && self.padded, |button| {
|
||||
button
|
||||
.when(self.icon.is_some(), |button| {
|
||||
button.px(metrics.dense_padding_x)
|
||||
})
|
||||
.when(self.icon.is_none(), |button| button.px(metrics.padding_x))
|
||||
button.px(metrics.padding_x)
|
||||
})
|
||||
.line_height(relative(1.0))
|
||||
.rounded(theme.radius.control)
|
||||
|
||||
@@ -123,7 +123,7 @@ impl RenderOnce for Checkbox {
|
||||
|
||||
h_flex()
|
||||
.id(self.id)
|
||||
.gap_1p5()
|
||||
.gap_2()
|
||||
.text_size(metrics.text_size)
|
||||
.refine_style(&self.style)
|
||||
.when_some(self.debug_selector, |checkbox, selector| {
|
||||
|
||||
@@ -17,7 +17,7 @@ use gpui::{
|
||||
};
|
||||
use gpui_native_icons::{IconRole, icon};
|
||||
use gpui_native_theme::ActiveTheme as _;
|
||||
use gpui_native_theme::{BORDER_WIDTH, POPUP_MAX_HEIGHT, Size};
|
||||
use gpui_native_theme::{POPUP_MAX_HEIGHT, Size};
|
||||
use gpui_native_utils::ResultLogErr as _;
|
||||
|
||||
use crate::common::{OVERLAY_LAYER, Sizable, StyledExt as _, h_flex, v_flex};
|
||||
@@ -479,16 +479,11 @@ where
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
|
||||
let panel_border = if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
theme.colors.surface
|
||||
};
|
||||
(
|
||||
metrics,
|
||||
theme.colors,
|
||||
theme.radius,
|
||||
panel_border,
|
||||
theme.colors.border,
|
||||
theme.spacing.unit,
|
||||
theme.elevations.popover.shadows(),
|
||||
)
|
||||
@@ -587,7 +582,7 @@ where
|
||||
h_flex()
|
||||
.absolute()
|
||||
.right(metrics.dense_padding_x)
|
||||
.top((metrics.input_height + BORDER_WIDTH * 2.0 - icon_size) / 2.)
|
||||
.top((metrics.input_height - icon_size) / 2.)
|
||||
.child(chevron),
|
||||
)
|
||||
.when(open, |wrapper| {
|
||||
@@ -618,6 +613,7 @@ where
|
||||
.gap_2()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.min_h(metrics.control_height)
|
||||
.rounded(radius.sm)
|
||||
.when(highlighted, |row| row.bg(colors.muted))
|
||||
.when(!highlighted, |row| row.hover(|row| row.bg(colors.muted)))
|
||||
|
||||
@@ -337,11 +337,7 @@ impl Render for CommandPaletteState {
|
||||
theme.colors,
|
||||
theme.radius,
|
||||
theme.sizes.resolve(Size::default()),
|
||||
if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
theme.colors.surface
|
||||
},
|
||||
theme.colors.border,
|
||||
theme.elevations.dialog.shadows(),
|
||||
)
|
||||
};
|
||||
@@ -370,6 +366,7 @@ impl Render for CommandPaletteState {
|
||||
.gap_2()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.min_h(metrics.control_height)
|
||||
.rounded(radius.sm)
|
||||
.when(highlighted, |row| row.bg(colors.muted))
|
||||
.when(!highlighted, |row| row.hover(|row| row.bg(colors.muted)))
|
||||
|
||||
@@ -160,11 +160,7 @@ impl RenderOnce for Dialog {
|
||||
let theme = cx.theme();
|
||||
(
|
||||
theme.colors.overlay,
|
||||
if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
theme.colors.surface
|
||||
},
|
||||
theme.colors.border,
|
||||
theme.colors.foreground,
|
||||
theme.colors.surface,
|
||||
theme.radius.overlay,
|
||||
@@ -207,11 +203,11 @@ impl RenderOnce for Dialog {
|
||||
.role(role)
|
||||
.aria_label(label)
|
||||
.when_some(self.min_width, |panel, width| panel.min_w(width))
|
||||
.when(self.min_width.is_none(), |panel| panel.min_w_80())
|
||||
.when(self.min_width.is_none(), |panel| panel.min_w_96())
|
||||
.max_w(relative(0.9))
|
||||
.when_some(height, |panel, height| panel.h(height))
|
||||
.p_4()
|
||||
.gap_3()
|
||||
.gap_4()
|
||||
.bg(surface)
|
||||
.text_color(foreground)
|
||||
.rounded(radius)
|
||||
@@ -278,7 +274,7 @@ impl RenderOnce for Dialog {
|
||||
})
|
||||
})
|
||||
.when_some(actions, |panel, actions| {
|
||||
panel.child(div().flex().justify_end().gap_2().children(actions))
|
||||
panel.child(div().flex().justify_end().gap_3().children(actions))
|
||||
})
|
||||
.child(
|
||||
canvas(|_, _, _| {}, {
|
||||
|
||||
@@ -11,7 +11,7 @@ use gpui::{
|
||||
div, relative,
|
||||
};
|
||||
use gpui_native_icons::{Icon, IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, Size};
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
use gpui_native_utils::{focus_handle, focus_ring};
|
||||
|
||||
use crate::button::ButtonVariant;
|
||||
@@ -186,7 +186,6 @@ impl RenderOnce for DropdownMenu {
|
||||
let radius = theme.radius.control;
|
||||
|
||||
let ring = colors.ring;
|
||||
let show_border = theme.borders.buttons && self.variant != ButtonVariant::Ghost;
|
||||
|
||||
let (panel_chrome, enter_duration) = MenuChrome::read(cx);
|
||||
let (background, foreground, hover, pressed) = match self.variant {
|
||||
@@ -197,10 +196,10 @@ impl RenderOnce for DropdownMenu {
|
||||
ramps.primary.pressed,
|
||||
),
|
||||
ButtonVariant::Secondary => (
|
||||
Some(colors.secondary),
|
||||
colors.secondary_foreground,
|
||||
ramps.secondary.hover,
|
||||
ramps.secondary.pressed,
|
||||
Some(colors.surface),
|
||||
colors.foreground,
|
||||
colors.muted,
|
||||
colors.muted_hover,
|
||||
),
|
||||
ButtonVariant::Ghost => (
|
||||
None,
|
||||
@@ -216,10 +215,11 @@ impl RenderOnce for DropdownMenu {
|
||||
),
|
||||
};
|
||||
|
||||
let border = if show_border {
|
||||
colors.border
|
||||
} else {
|
||||
background.unwrap_or_else(gpui::transparent_black)
|
||||
let border = match self.variant {
|
||||
ButtonVariant::Primary => ramps.primary.base,
|
||||
ButtonVariant::Secondary => colors.border,
|
||||
ButtonVariant::Ghost => gpui::transparent_black(),
|
||||
ButtonVariant::Destructive => ramps.destructive.base,
|
||||
};
|
||||
|
||||
let split = self.on_click.is_some();
|
||||
@@ -269,11 +269,7 @@ impl RenderOnce for DropdownMenu {
|
||||
.role(Role::Button)
|
||||
.when_some(a11y_label, |zone, label| zone.aria_label(label))
|
||||
.aria_expanded(self.open)
|
||||
.px(if split && self.icon.is_none() {
|
||||
metrics.padding_x
|
||||
} else {
|
||||
metrics.dense_padding_x
|
||||
})
|
||||
.px(metrics.padding_x)
|
||||
.when(split, |zone| zone.rounded_l(radius))
|
||||
.when(!split, |zone| {
|
||||
zone.rounded(radius)
|
||||
@@ -375,7 +371,7 @@ impl RenderOnce for DropdownMenu {
|
||||
);
|
||||
|
||||
let trigger = h_flex()
|
||||
.h(metrics.control_height + BORDER_WIDTH * 2.0)
|
||||
.h(metrics.control_height)
|
||||
.rounded(radius)
|
||||
.border_1()
|
||||
.border_color(border)
|
||||
|
||||
@@ -5,7 +5,7 @@ use gpui::{
|
||||
AnyElement, App, ElementId, InteractiveElement as _, IntoElement, ParentElement, RenderOnce,
|
||||
Role, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled, Window, div,
|
||||
};
|
||||
use gpui_native_theme::ActiveTheme as _;
|
||||
use gpui_native_theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::common::{StyledExt, h_flex, v_flex};
|
||||
|
||||
@@ -99,7 +99,7 @@ impl RenderOnce for Field {
|
||||
let id = id.clone();
|
||||
move || format!("{id}-label")
|
||||
})
|
||||
.text_size(metrics.text_size)
|
||||
.typeset(TextRole::Headline, cx)
|
||||
.child(self.label.clone());
|
||||
|
||||
let control = h_flex()
|
||||
|
||||
@@ -16,8 +16,7 @@ use gpui::{
|
||||
};
|
||||
use gpui_native_icons::IconRole;
|
||||
use gpui_native_theme::{
|
||||
ActiveTheme as _, BORDER_WIDTH, CARET_WIDTH, ColorTokens, Size, UNDERLINE_WIDTH,
|
||||
WHEEL_LINE_HEIGHT,
|
||||
ActiveTheme as _, CARET_WIDTH, ColorTokens, Size, UNDERLINE_WIDTH, WHEEL_LINE_HEIGHT,
|
||||
};
|
||||
use gpui_native_utils::focus_ring;
|
||||
|
||||
@@ -1991,7 +1990,7 @@ impl RenderOnce for Input {
|
||||
let recording = focused && !self.disabled && !self.state.read(cx).is_read_only();
|
||||
|
||||
let small = theme.sizes.resolve(Size::Small);
|
||||
let docked_height = small.control_height + BORDER_WIDTH * 2.0;
|
||||
let docked_height = small.control_height;
|
||||
let edge_inset = ((metrics.input_height - docked_height) / 2.0).max(Pixels::ZERO);
|
||||
|
||||
let vertical_inset = metrics.dense_padding_x * 0.5;
|
||||
@@ -2014,7 +2013,7 @@ impl RenderOnce for Input {
|
||||
|
||||
let field_height = line_height.map_or(metrics.input_height, |line_height| {
|
||||
line_height * self.rows as f32 + vertical_inset * 2.0
|
||||
}) + BORDER_WIDTH * 2.0;
|
||||
});
|
||||
|
||||
let fallback_label = self
|
||||
.a11y_label
|
||||
@@ -2154,22 +2153,13 @@ impl RenderOnce for Input {
|
||||
.text_size(metrics.text_size)
|
||||
.text_color(colors.foreground)
|
||||
.border_1()
|
||||
.border_color(if theme.borders.fields {
|
||||
colors.border
|
||||
} else {
|
||||
colors.input
|
||||
})
|
||||
.border_color(colors.border)
|
||||
.refine_style(&self.style)
|
||||
.when(self.disabled, |input| input.opacity(0.5))
|
||||
.when(!self.disabled, |input| {
|
||||
input.track_focus(&focus_handle).tab_stop(true)
|
||||
})
|
||||
.when(focused && !theme.borders.focus_ring, |input| {
|
||||
input.border_color(colors.ring)
|
||||
})
|
||||
.when(focused && theme.borders.focus_ring, |input| {
|
||||
input.shadow(focus_ring(colors.ring))
|
||||
})
|
||||
.when(focused, |input| input.shadow(focus_ring(colors.ring)))
|
||||
.when_some(self.prefix, |input, prefix| {
|
||||
input.child(edge_zone("input-prefix", prefix))
|
||||
})
|
||||
|
||||
+2
-13
@@ -171,7 +171,6 @@ impl FluentBuilder for MenuItem {}
|
||||
pub(crate) struct MenuChrome {
|
||||
surface: gpui::Hsla,
|
||||
border: gpui::Hsla,
|
||||
panel_border: gpui::Hsla,
|
||||
foreground: gpui::Hsla,
|
||||
muted_foreground: gpui::Hsla,
|
||||
muted_hover: gpui::Hsla,
|
||||
@@ -214,11 +213,6 @@ impl MenuChrome {
|
||||
Self {
|
||||
surface: theme.colors.surface,
|
||||
border: theme.colors.border,
|
||||
panel_border: if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
theme.colors.surface
|
||||
},
|
||||
foreground: theme.colors.foreground,
|
||||
muted_foreground: theme.colors.muted_foreground,
|
||||
muted_hover: theme.colors.muted_hover,
|
||||
@@ -697,12 +691,7 @@ fn menu_panel(
|
||||
.text_color(params.chrome.foreground)
|
||||
.rounded(params.chrome.radius_overlay)
|
||||
.border_1()
|
||||
// A flyout overlaps its parent, so it always wears a visible border.
|
||||
.border_color(if params.is_flyout {
|
||||
params.chrome.border
|
||||
} else {
|
||||
params.chrome.panel_border
|
||||
})
|
||||
.border_color(params.chrome.border)
|
||||
.shadow(params.chrome.shadow.clone())
|
||||
.overflow_hidden()
|
||||
.on_mouse_down_out({
|
||||
@@ -963,7 +952,7 @@ fn row_shell(
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.min_h(chrome.menu_item_height)
|
||||
.px(chrome.spacing_unit * 2.0)
|
||||
.px(chrome.spacing_unit * 4.0)
|
||||
.text_size(chrome.text_size)
|
||||
.line_height(relative(1.0))
|
||||
.rounded(chrome.radius_sm)
|
||||
|
||||
@@ -107,11 +107,7 @@ impl RenderOnce for Popover {
|
||||
theme.radius,
|
||||
theme.elevations.popover.shadows(),
|
||||
theme.motion.overlay,
|
||||
if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
theme.colors.surface
|
||||
},
|
||||
theme.colors.border,
|
||||
theme.spacing.unit,
|
||||
)
|
||||
};
|
||||
|
||||
@@ -189,7 +189,7 @@ where
|
||||
|
||||
h_flex()
|
||||
.id(radio.id)
|
||||
.gap_1p5()
|
||||
.gap_2()
|
||||
.role(Role::RadioButton)
|
||||
.when_some(a11y_label, |row, label| row.aria_label(label))
|
||||
.aria_toggled(Toggled::from(is_selected))
|
||||
|
||||
@@ -164,7 +164,7 @@ where
|
||||
let track_height = metrics.strip_height;
|
||||
let track_inset = metrics.plate_inset;
|
||||
let horizontal_padding = metrics.dense_padding_x;
|
||||
let text_size = metrics.caption_size;
|
||||
let text_size = metrics.text_size;
|
||||
let icon_size = metrics.icon_size;
|
||||
|
||||
let selected_index = self
|
||||
@@ -218,7 +218,7 @@ where
|
||||
|
||||
h_flex()
|
||||
.id((ElementId::from("segment"), segment.label.clone()))
|
||||
.gap_1p5()
|
||||
.gap_2()
|
||||
.justify_center()
|
||||
.cursor_pointer()
|
||||
.h_full()
|
||||
|
||||
@@ -7,7 +7,7 @@ use gpui::{
|
||||
Window, canvas,
|
||||
};
|
||||
use gpui_native_icons::{Icon, IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, Size};
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
use gpui_native_utils::{focus_handle, focus_ring};
|
||||
|
||||
use crate::common::{Sizable, StyledExt, h_flex};
|
||||
@@ -182,8 +182,6 @@ where
|
||||
let muted_foreground = theme.colors.muted_foreground;
|
||||
let radius = theme.radius.control;
|
||||
let icon_size = metrics.dense_icon_size;
|
||||
let fields_bordered = theme.borders.fields;
|
||||
let focus_ring_on = theme.borders.focus_ring;
|
||||
|
||||
let label = self
|
||||
.a11y_label
|
||||
@@ -209,18 +207,8 @@ where
|
||||
let is_open = *open.read(cx);
|
||||
let open_for_items = open.clone();
|
||||
|
||||
let (rest_border, hover_border) = if fields_bordered {
|
||||
(
|
||||
if is_open && !focus_ring_on {
|
||||
ring
|
||||
} else {
|
||||
border
|
||||
},
|
||||
border,
|
||||
)
|
||||
} else {
|
||||
(input, muted)
|
||||
};
|
||||
let rest_border = border;
|
||||
let hover_border = border;
|
||||
|
||||
let selected_index = self.selected.as_ref().and_then(|value| {
|
||||
self.options
|
||||
@@ -266,10 +254,11 @@ where
|
||||
})
|
||||
.cursor_pointer()
|
||||
.justify_between()
|
||||
.gap_2()
|
||||
.gap_3()
|
||||
.w_full()
|
||||
.h(metrics.input_height + BORDER_WIDTH * 2.0)
|
||||
.px(metrics.dense_padding_x)
|
||||
.h(metrics.input_height)
|
||||
.pl(metrics.dense_padding_x)
|
||||
.pr(metrics.plate_inset * 2.0)
|
||||
.rounded(radius)
|
||||
.border_1()
|
||||
.border_color(rest_border)
|
||||
@@ -280,9 +269,7 @@ where
|
||||
} else {
|
||||
muted_foreground
|
||||
})
|
||||
.when(is_open && focus_ring_on, |trigger| {
|
||||
trigger.shadow(focus_ring(ring))
|
||||
})
|
||||
.when(is_open, |trigger| trigger.shadow(focus_ring(ring)))
|
||||
.hover(|style| style.bg(muted).border_color(hover_border))
|
||||
.child(trigger_text.clone())
|
||||
.child(
|
||||
|
||||
@@ -133,9 +133,9 @@ impl RenderOnce for Slider {
|
||||
let radius = theme.radius;
|
||||
let metrics = theme.sizes.resolve(self.size);
|
||||
|
||||
let row_height = metrics.icon_size;
|
||||
let row_height = metrics.icon_size * 2.5;
|
||||
let track_height = metrics.icon_size / 4.0;
|
||||
let knob = metrics.icon_size * 1.25;
|
||||
let knob = metrics.indicator_size;
|
||||
|
||||
let value = self.value.clamp(self.min, self.max);
|
||||
let fraction = if self.max > self.min {
|
||||
|
||||
@@ -19,7 +19,7 @@ use gpui::{
|
||||
StyleRefinement, Styled, Subscription, Task, WeakEntity, Window, div, relative,
|
||||
};
|
||||
use gpui_native_icons::{IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, Size};
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
use gpui_native_utils::focus_ring;
|
||||
|
||||
use crate::common::{Sizable, StyledExt as _, h_flex};
|
||||
@@ -743,7 +743,7 @@ impl RenderOnce for SpeechButton {
|
||||
.group(group.clone())
|
||||
.role(Role::Button)
|
||||
.justify_center()
|
||||
.h(metrics.control_height + BORDER_WIDTH * 2.0)
|
||||
.h(metrics.control_height)
|
||||
.px(metrics.dense_padding_x)
|
||||
.gap_0p5()
|
||||
.rounded(theme.radius.control)
|
||||
|
||||
@@ -122,7 +122,7 @@ impl RenderOnce for Switch {
|
||||
|
||||
h_flex()
|
||||
.id(self.id)
|
||||
.gap_1p5()
|
||||
.gap_2()
|
||||
.text_size(metrics.text_size)
|
||||
.refine_style(&self.style)
|
||||
.role(Role::Switch)
|
||||
@@ -147,12 +147,16 @@ impl RenderOnce for Switch {
|
||||
.w(track_width)
|
||||
.h(track_height)
|
||||
.rounded(theme.radius.full)
|
||||
.border_1()
|
||||
.when(self.checked, |track| {
|
||||
track
|
||||
.bg(ramps.primary.base)
|
||||
.border_color(ramps.primary.base)
|
||||
.hover(|style| style.bg(ramps.primary.hover))
|
||||
})
|
||||
.when(!self.checked, |track| track.bg(colors.border))
|
||||
.when(!self.checked, |track| {
|
||||
track.bg(colors.input).border_color(colors.border)
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
|
||||
@@ -274,16 +274,12 @@ impl ToastEntry {
|
||||
fn pill(&self, toasts: &Entity<Toasts>, cx: &App) -> gpui::Stateful<gpui::Div> {
|
||||
let theme = cx.theme();
|
||||
let surface = theme.colors.surface;
|
||||
let border = if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
surface
|
||||
};
|
||||
let border = theme.colors.border;
|
||||
let foreground = theme.colors.foreground;
|
||||
let radius = theme.radius.full;
|
||||
let shadows = theme.elevations.popover.shadows();
|
||||
let icon_size = theme.sizes.small.icon_size;
|
||||
let text_size = theme.sizes.small.text_size;
|
||||
let icon_size = theme.sizes.medium.icon_size;
|
||||
let text_size = theme.sizes.medium.text_size;
|
||||
let toast = &self.toast;
|
||||
let toasts = toasts.clone();
|
||||
let id = self.id;
|
||||
|
||||
@@ -64,18 +64,14 @@ impl Render for Tooltip {
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
// Copied out: the mutable reads below need `cx` free of this borrow.
|
||||
let theme = cx.theme();
|
||||
let text_size = theme.sizes.small.text_size;
|
||||
let text_size = theme.sizes.medium.text_size;
|
||||
let spacing_unit = theme.spacing.unit;
|
||||
let surface = theme.colors.surface;
|
||||
let surface_foreground = theme.colors.surface_foreground;
|
||||
let radius_sm = theme.radius.sm;
|
||||
let shadows = theme.elevations.popover.shadows();
|
||||
|
||||
let border = if theme.borders.overlays {
|
||||
theme.colors.border
|
||||
} else {
|
||||
theme.colors.surface
|
||||
};
|
||||
let border = theme.colors.border;
|
||||
|
||||
let build_panel = || {
|
||||
div()
|
||||
|
||||
Reference in New Issue
Block a user