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
|
@ -7,7 +7,7 @@ enum LabelKind {
|
|||
Element(AnyElement),
|
||||
}
|
||||
|
||||
#[derive(IntoElement)]
|
||||
#[derive(IntoElement, RegisterComponent)]
|
||||
pub struct DropdownMenu {
|
||||
id: ElementId,
|
||||
label: LabelKind,
|
||||
|
@ -72,6 +72,69 @@ impl RenderOnce for DropdownMenu {
|
|||
}
|
||||
}
|
||||
|
||||
impl Component for DropdownMenu {
|
||||
fn scope() -> ComponentScope {
|
||||
ComponentScope::Input
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"DropdownMenu"
|
||||
}
|
||||
|
||||
fn description() -> Option<&'static str> {
|
||||
Some(
|
||||
"A dropdown menu displays a list of actions or options. A dropdown menu is always activated by clicking a trigger (or via a keybinding).",
|
||||
)
|
||||
}
|
||||
|
||||
fn preview(window: &mut Window, cx: &mut App) -> Option<AnyElement> {
|
||||
let menu = ContextMenu::build(window, cx, |this, _, _| {
|
||||
this.entry("Option 1", None, |_, _| {})
|
||||
.entry("Option 2", None, |_, _| {})
|
||||
.entry("Option 3", None, |_, _| {})
|
||||
.separator()
|
||||
.entry("Option 4", None, |_, _| {})
|
||||
});
|
||||
|
||||
Some(
|
||||
v_flex()
|
||||
.gap_6()
|
||||
.children(vec![
|
||||
example_group_with_title(
|
||||
"Basic Usage",
|
||||
vec![
|
||||
single_example(
|
||||
"Default",
|
||||
DropdownMenu::new("default", "Select an option", menu.clone())
|
||||
.into_any_element(),
|
||||
),
|
||||
single_example(
|
||||
"Full Width",
|
||||
DropdownMenu::new(
|
||||
"full-width",
|
||||
"Full Width Dropdown",
|
||||
menu.clone(),
|
||||
)
|
||||
.full_width(true)
|
||||
.into_any_element(),
|
||||
),
|
||||
],
|
||||
),
|
||||
example_group_with_title(
|
||||
"States",
|
||||
vec![single_example(
|
||||
"Disabled",
|
||||
DropdownMenu::new("disabled", "Disabled Dropdown", menu.clone())
|
||||
.disabled(true)
|
||||
.into_any_element(),
|
||||
)],
|
||||
),
|
||||
])
|
||||
.into_any_element(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(IntoElement)]
|
||||
struct DropdownMenuTrigger {
|
||||
label: LabelKind,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue