From cb07e02ce93a0676dc31b6d3c84836e548b69802 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Sat, 27 Jul 2024 14:00:03 -0400 Subject: [PATCH] ui: Apply elevation outside `SettingsContainer` (#15346) This PR changes the `SettingsContainer` component such that the elevation styles are applied by the parent instead of `SettingsContainer` itself. This means that components using `SettingsContainer` can be embedded in different contexts, like the settings UI or a popover containing the settings. Release Notes: - N/A --- crates/settings_ui/src/settings_ui.rs | 20 ++++++++++--------- .../ui/src/components/settings_container.rs | 8 ++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index b7c2994fa280150e5800ed997ce6f87279f072a2..cf6177e9a8c9b68bbf4153acd1fe97a873d21b63 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -100,23 +100,25 @@ impl Item for SettingsPage { } impl Render for SettingsPage { - fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { v_flex() .p_4() .size_full() .gap_4() .child(Label::new("Settings").size(LabelSize::Large)) .child( - v_flex() - .gap_1() - .child(Label::new("Appearance")) - .child(AppearanceSettingsControls::new()), + v_flex().gap_1().child(Label::new("Appearance")).child( + v_flex() + .elevation_2(cx) + .child(AppearanceSettingsControls::new()), + ), ) .child( - v_flex() - .gap_1() - .child(Label::new("Editor")) - .child(EditorSettingsControls::new()), + v_flex().gap_1().child(Label::new("Editor")).child( + v_flex() + .elevation_2(cx) + .child(EditorSettingsControls::new()), + ), ) } } diff --git a/crates/ui/src/components/settings_container.rs b/crates/ui/src/components/settings_container.rs index a398c9070bd57f42e77fd6c325aaaf35f09ca93e..018b71900edde91c08d60f132b923ac8382f360e 100644 --- a/crates/ui/src/components/settings_container.rs +++ b/crates/ui/src/components/settings_container.rs @@ -23,11 +23,7 @@ impl ParentElement for SettingsContainer { } impl RenderOnce for SettingsContainer { - fn render(self, cx: &mut WindowContext) -> impl IntoElement { - v_flex() - .elevation_2(cx) - .px_2() - .gap_1() - .children(self.children) + fn render(self, _cx: &mut WindowContext) -> impl IntoElement { + v_flex().px_2().gap_1().children(self.children) } }