
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
29 lines
631 B
Rust
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)
|
|
}
|
|
}
|