ZIm/crates/ui/src/components/settings_container.rs
Marshall Bowers cb07e02ce9
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
2024-07-27 14:00:03 -04:00

29 lines
631 B
Rust

use gpui::AnyElement;
use smallvec::SmallVec;
use crate::prelude::*;
#[derive(IntoElement)]
pub struct SettingsContainer {
children: SmallVec<[AnyElement; 2]>,
}
impl SettingsContainer {
pub fn new() -> Self {
Self {
children: SmallVec::new(),
}
}
}
impl ParentElement for SettingsContainer {
fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
self.children.extend(elements)
}
}
impl RenderOnce for SettingsContainer {
fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
v_flex().px_2().gap_1().children(self.children)
}
}