material_dioxus/dialog/
dialog_action.rs1use dioxus::prelude::*;
2use std::fmt;
3
4#[derive(Clone, PartialEq)]
6pub enum ActionType {
7 Primary,
9 Secondary,
11}
12
13impl ActionType {
14 pub fn as_str(&self) -> &'static str {
15 match self {
16 ActionType::Primary => "primaryAction",
17 ActionType::Secondary => "secondaryAction",
18 }
19 }
20}
21
22impl fmt::Display for ActionType {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 write!(f, "{}", self.as_str())
25 }
26}
27
28#[derive(Props)]
30pub struct ActionProps<'a> {
31 pub action_type: ActionType,
32 #[props(into)]
33 pub action: Option<String>,
34 pub children: Element<'a>,
35}
36
37#[allow(non_snake_case)]
42pub fn MatDialogAction<'a>(cx: Scope<'a, ActionProps<'a>>) -> Element<'a> {
43 render! {
44 span {
45 slot: "{cx.props.action_type}",
46 "dialogAction": optional_string_attr!(cx.props.action),
47 &cx.props.children
48 }
49 }
50}