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
This commit is contained in:
Marshall Bowers 2024-07-27 14:00:03 -04:00 committed by GitHub
parent b05d532991
commit cb07e02ce9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 15 deletions

View File

@ -100,23 +100,25 @@ impl Item for SettingsPage {
}
impl Render for SettingsPage {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, cx: &mut ViewContext<Self>) -> 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()),
),
)
}
}

View File

@ -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)
}
}