use topcoat::{
Result,
view::{Attributes, Child, StaticClass, View, attributes, class, component, view},
};
use super::floating::{FloatingAlign, FloatingAnchor, FloatingSide, floating_variants};
/// A floating action menu controlled by a trigger.
///
/// Add a [`dropdown_menu_trigger`] and a [`dropdown_menu_content`] as children. Create
/// an ID with [`element_id`](topcoat::view::element_id) and use it for the trigger's
/// `target` and the content's `id`. The button opens and closes the menu without
/// JavaScript. Clicking outside or pressing Escape also closes it. The menu appears
/// above the page and is not cut off by a parent's overflow settings.
///
/// `attrs` adds attributes and classes to the wrapper `
`, which takes up no space
/// in the layout. Use Tab to move between items. Arrow-key menu navigation is not
/// provided.
///
/// ```ignore
/// view! {
/// let menu = element_id(cx);
/// dropdown_menu(
/// dropdown_menu_trigger(target: &menu, "Options")
/// dropdown_menu_content(
/// id: &menu,
/// align: FloatingAlign::Start,
/// dropdown_menu_item(close: Some(&menu), "Rename")
/// dropdown_menu_item(close: Some(&menu), "Duplicate")
/// dropdown_menu_separator()
/// dropdown_menu_item(
/// close: Some(&menu),
/// attrs: attributes! { class="text-destructive" },
/// "Delete"
/// )
/// )
/// )
/// }
/// ```
#[component]
pub async fn dropdown_menu(
#[default] mut attrs: Attributes,
#[default] child: Child<'_>,
) -> Result {
Ok(view! {
(child)
})
}
/// A button for opening and closing the dropdown menu.
///
/// Set `target` to the [`dropdown_menu_content`]'s `id` and put the button's label in
/// its children. Add [`button_variants`](super::button::button_variants) classes through
/// `attrs` to give it the standard button style. All attributes go on the `