Merge Component
and ComponentPreview
trait (#28365)
- Merge `Component` and `ComponentPreview` trait - Adds a number of component previews - Removes a number of stories Release Notes: - N/A
This commit is contained in:
parent
b15ee1b1cc
commit
c05bf096f8
52 changed files with 3276 additions and 1848 deletions
|
@ -3,7 +3,9 @@ use smallvec::SmallVec;
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(IntoElement)]
|
||||
use super::Checkbox;
|
||||
|
||||
#[derive(IntoElement, RegisterComponent)]
|
||||
pub struct SettingsContainer {
|
||||
children: SmallVec<[AnyElement; 2]>,
|
||||
}
|
||||
|
@ -33,3 +35,55 @@ impl RenderOnce for SettingsContainer {
|
|||
v_flex().px_2().gap_1().children(self.children)
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for SettingsContainer {
|
||||
fn scope() -> ComponentScope {
|
||||
ComponentScope::Layout
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"SettingsContainer"
|
||||
}
|
||||
|
||||
fn description() -> Option<&'static str> {
|
||||
Some("A container for organizing and displaying settings in a structured manner.")
|
||||
}
|
||||
|
||||
fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
|
||||
Some(
|
||||
v_flex()
|
||||
.gap_6()
|
||||
.children(vec![
|
||||
example_group_with_title(
|
||||
"Basic Usage",
|
||||
vec![
|
||||
single_example(
|
||||
"Empty Container",
|
||||
SettingsContainer::new().into_any_element(),
|
||||
),
|
||||
single_example(
|
||||
"With Content",
|
||||
SettingsContainer::new()
|
||||
.child(Label::new("Setting 1"))
|
||||
.child(Label::new("Setting 2"))
|
||||
.child(Label::new("Setting 3"))
|
||||
.into_any_element(),
|
||||
),
|
||||
],
|
||||
),
|
||||
example_group_with_title(
|
||||
"With Different Elements",
|
||||
vec![single_example(
|
||||
"Mixed Content",
|
||||
SettingsContainer::new()
|
||||
.child(Label::new("Text Setting"))
|
||||
.child(Checkbox::new("checkbox", ToggleState::Unselected))
|
||||
.child(Button::new("button", "Click me"))
|
||||
.into_any_element(),
|
||||
)],
|
||||
),
|
||||
])
|
||||
.into_any_element(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue