Skip to main content

euv_ui/component/button/view/
struct.rs

1use super::*;
2
3/// Props for the `euv_button` component.
4///
5/// Defines the strongly-typed interface for a versatile button.
6#[derive(Clone, CustomDebug, Default)]
7pub struct EuvButtonProps {
8    /// The visual variant determining colour scheme.
9    pub variant: EuvButtonVariant,
10    /// The size of the control.
11    pub size: EuvButtonSize,
12    /// The button label text, used as fallback when no children are provided.
13    pub label: &'static str,
14    /// An optional semantic slot name, defaulting to `button`.
15    pub data_slot: Option<&'static str>,
16    /// Optional click event handler.
17    #[debug(skip)]
18    pub onclick: Option<Rc<dyn Fn(Event)>>,
19    /// Whether the button is disabled.
20    pub disabled: Signal<bool>,
21    /// Whether the button submits the form it stands in.
22    ///
23    /// A button inside a form submits it by default, which is almost never
24    /// what a control that only performs an action wants. The button is
25    /// therefore inert unless the caller asks for the submission.
26    pub submit: bool,
27    /// The accessible name of the button.
28    ///
29    /// The name is the label the button shows unless the caller names one
30    /// of its own, which a button that carries a glyph rather than a word
31    /// needs.
32    pub aria_label: Option<String>,
33    /// Whether the button is busy.
34    ///
35    /// A busy button is one whose work has not finished yet. The state is
36    /// announced to the reader, so a control that is working says so.
37    pub busy: Signal<bool>,
38    /// A stable identifier for application integration tests.
39    pub data_testid: &'static str,
40}
41
42/// Props for the `euv_button_grouped` component.
43///
44/// A joined button is a button that sits inside a group of buttons, so
45/// it carries the same settings a plain button carries.
46#[derive(Clone, CustomDebug, Default)]
47pub struct EuvButtonGroupedProps {
48    /// The visual variant determining colour scheme.
49    pub variant: EuvButtonVariant,
50    /// The size of the control.
51    pub size: EuvButtonSize,
52    /// The button label text, used as fallback when no children are provided.
53    pub label: &'static str,
54    /// Optional click event handler.
55    #[debug(skip)]
56    pub onclick: Option<Rc<dyn Fn(Event)>>,
57    /// Whether the button is disabled.
58    pub disabled: Signal<bool>,
59}
60
61/// Props for the [`euv_button_link`] component.
62///
63/// A link that looks like a button: the anchor carries the appearance of
64/// the button, because a destination the reader follows is not an action
65/// the reader performs and the two want different affordances.
66#[derive(Clone, CustomDebug, Data, Default, New)]
67pub struct EuvButtonLinkProps {
68    /// The visual variant determining colour scheme.
69    pub variant: EuvButtonVariant,
70    /// The size of the control.
71    pub size: EuvButtonSize,
72    /// The label of the link.
73    pub label: ::euv::CowText,
74    /// The destination the link points at.
75    pub href: ::euv::CowText,
76    /// Whether the link opens in a new tab.
77    #[get(type(copy))]
78    pub new_tab: bool,
79    /// The accessible name of the link.
80    ///
81    /// The name is the label the link shows unless the caller names one of
82    /// its own, which a link that carries a glyph rather than a word needs.
83    pub aria_label: Option<::euv::CowText>,
84}