utils: add shared StyledExt styling helper
This commit is contained in:
@@ -4,14 +4,14 @@ use std::rc::Rc;
|
||||
use gpui::{
|
||||
Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId,
|
||||
InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _,
|
||||
RenderOnce, Role, ScrollHandle, SharedString, StatefulInteractiveElement as _, Styled as _,
|
||||
Window, canvas, deferred, div, ease_out_quint, relative,
|
||||
RenderOnce, Role, ScrollHandle, SharedString, StatefulInteractiveElement as _, StyleRefinement,
|
||||
Styled as _, Window, canvas, deferred, div, ease_out_quint, relative,
|
||||
};
|
||||
use gpui_native_icons::IconRole;
|
||||
use gpui_native_theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
|
||||
use crate::button::{Button, ButtonVariant};
|
||||
use crate::common::{DIALOG_LAYER, Sizable, v_flex};
|
||||
use crate::common::{DIALOG_LAYER, Sizable, StyledExt as _, v_flex};
|
||||
use crate::grain::grain;
|
||||
use crate::scroll_area::ScrollArea;
|
||||
|
||||
@@ -35,6 +35,7 @@ pub struct Dialog {
|
||||
actions: Option<ActionsFn>,
|
||||
min_width: Option<DefiniteLength>,
|
||||
height: Option<DefiniteLength>,
|
||||
style: StyleRefinement,
|
||||
}
|
||||
|
||||
impl Dialog {
|
||||
@@ -55,6 +56,7 @@ impl Dialog {
|
||||
actions: None,
|
||||
min_width: None,
|
||||
height: None,
|
||||
style: StyleRefinement::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +142,12 @@ impl Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
impl gpui::Styled for Dialog {
|
||||
fn style(&mut self) -> &mut StyleRefinement {
|
||||
&mut self.style
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderOnce for Dialog {
|
||||
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||
let root = div().absolute().inset_0();
|
||||
@@ -307,6 +315,7 @@ impl RenderOnce for Dialog {
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.p_4()
|
||||
.refine_style(&self.style)
|
||||
.child(scrim.with_animation(
|
||||
"dialog-scrim-enter",
|
||||
Animation::new(enter_duration).with_easing(ease_out_quint()),
|
||||
|
||||
Reference in New Issue
Block a user