pub struct MultiToggleGroup<S> { /* private fields */ }Expand description
A group of toggles named label, each bound to a flag of its own.
The group has role="group" and each toggle is a toggle with
aria-pressed. Tab enters the group at its first toggle, and the arrow
keys, Home, and End move between toggles without flipping them, through
El::roving_focus. Enter and Space flip the toggle that has focus.
use hypersig::{Page, Signals};
use hypersig_ui::MultiToggleGroup;
use serde::{Deserialize, Serialize};
#[derive(Signals, Serialize, Deserialize)]
struct Editor {
bold: bool,
italic: bool,
}
let style = MultiToggleGroup::new("Text style")
.item(Editor::bold(), "Bold")
.item(Editor::italic(), "Italic");
let html = Page::new("Editor", Editor { bold: true, italic: false })
.child(style)
.render();
assert!(html.contains(r#"role="group""#));
assert!(html.contains(r#"aria-pressed="false""#));Implementations§
Source§impl<S> MultiToggleGroup<S>
impl<S> MultiToggleGroup<S>
Sourcepub fn new(label: impl Into<String>) -> Self
pub fn new(label: impl Into<String>) -> Self
An empty group named label for assistive technology.
Sourcepub fn item<R: Writable>(
self,
pressed: Sig<S, bool, R>,
text: impl Into<String>,
) -> Self
pub fn item<R: Writable>( self, pressed: Sig<S, bool, R>, text: impl Into<String>, ) -> Self
Adds a toggle showing text that flips pressed.
Trait Implementations§
Source§impl<S: Debug> Debug for MultiToggleGroup<S>
impl<S: Debug> Debug for MultiToggleGroup<S>
Source§impl<S> From<MultiToggleGroup<S>> for El<S>
impl<S> From<MultiToggleGroup<S>> for El<S>
Source§fn from(group: MultiToggleGroup<S>) -> Self
fn from(group: MultiToggleGroup<S>) -> Self
Converts to this type from the input type.
Source§impl<S> From<MultiToggleGroup<S>> for Node<S>
impl<S> From<MultiToggleGroup<S>> for Node<S>
Source§fn from(group: MultiToggleGroup<S>) -> Self
fn from(group: MultiToggleGroup<S>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<S> Freeze for MultiToggleGroup<S>
impl<S> RefUnwindSafe for MultiToggleGroup<S>
impl<S> Send for MultiToggleGroup<S>
impl<S> Sync for MultiToggleGroup<S>
impl<S> Unpin for MultiToggleGroup<S>
impl<S> UnsafeUnpin for MultiToggleGroup<S>
impl<S> UnwindSafe for MultiToggleGroup<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more