chore: improve ui consistently #35

Merged
reya merged 5 commits from improve-consistent into master 2026-11-20 12:28:28 +00:00
2 changed files with 23 additions and 5 deletions
Showing only changes of commit 8153e5c28a - Show all commits
+1
View File
@@ -60,6 +60,7 @@ impl Render for SettingsDialog {
Dialog::new("settings-dialog")
.handle(self.handle.clone())
.width(px(600.))
.height(px(560.))
.title("Settings")
.content(move |_, cx| {
+22 -5
View File
@@ -33,8 +33,9 @@ use gpui::{
};
use crate::components::button::{Button, ButtonVariant};
use crate::components::common::h_flex;
use crate::components::common::{DIALOG_LAYER, Sizable, StyledExt as _, floating_panel, v_flex};
use crate::components::common::{
DIALOG_LAYER, Sizable, StyledExt as _, floating_panel, h_flex, v_flex,
};
use crate::components::grain::grain;
use crate::components::scroll_area::ScrollArea;
use crate::icons::IconRole;
@@ -98,6 +99,7 @@ pub struct Dialog {
content: Option<ContentFn>,
actions: Option<ActionsFn>,
min_width: Option<DefiniteLength>,
width: Option<DefiniteLength>,
height: Option<DefiniteLength>,
style: StyleRefinement,
}
@@ -122,6 +124,7 @@ impl Dialog {
content: None,
actions: None,
min_width: None,
width: None,
height: None,
style: StyleRefinement::default(),
}
@@ -217,6 +220,15 @@ impl Dialog {
self
}
/// Sets the panel's fixed width, capped at 90% of the window.
pub fn width<W>(mut self, width: W) -> Self
where
W: Into<DefiniteLength>,
{
self.width = Some(width.into());
self
}
/// Sets the panel's height, body content taller than the panel scrolls.
pub fn height<H>(mut self, height: H) -> Self
where
@@ -255,11 +267,12 @@ impl RenderOnce for Dialog {
})
});
let (scrim_color, foreground, radius, shadows, enter_duration) = {
let (scrim_color, foreground, background, radius, shadows, enter_duration) = {
let theme = cx.theme();
(
theme.colors.overlay,
theme.colors.foreground,
theme.colors.background,
theme.radius.overlay,
theme.elevations.dialog.shadows(),
theme.motion.overlay,
@@ -303,15 +316,19 @@ impl RenderOnce for Dialog {
.track_focus(&focus)
.role(role)
.aria_label(label)
.when_some(self.min_width, |panel, width| panel.min_w(width))
.when(self.min_width.is_none(), |panel| {
.when_some(self.width, |panel, width| panel.w(width))
.when(self.width.is_none() && self.min_width.is_none(), |panel| {
panel.min_w(DIALOG_MIN_WIDTH)
})
.when_some(self.min_width, |panel, width| panel.min_w(width))
.max_w(relative(0.9))
.when_some(height, |panel, height| panel.h(height))
.text_color(foreground),
shadows,
)
// The panel behind the dialog is `background` (pure white/black), so
// the dialog matches it instead of the muted `surface` tint.
.bg(background)
.overflow_hidden()
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
.on_key_down({