pub struct El<M = ()>(/* private fields */);Expand description
el: one HTML element of an allowed tag, its text, then its
children.
Implementations§
Source§impl<M> El<M>
impl<M> El<M>
Sourcepub fn key(self, key: impl Into<NodeKey>) -> Self
pub fn key(self, key: impl Into<NodeKey>) -> Self
Identity among siblings: keeps the node’s id (and Tern’s view state) across reorders. A string, or an integer.
Examples found in repository?
27fn choice(value: &str, label: &str) -> El<()> {
28 html::label()
29 .key(value)
30 .child(html::radio("size", value).key("r"))
31 .child(html::span(label).key("t"))
32}
33
34/// The form.
35fn view() -> View<()> {
36 let sizes = SIZES.iter().map(|(value, label)| choice(value, label));
37 View::new().main([html::form()
38 .key("ask")
39 .class("ask")
40 .child(html::p("Which size?").key("q"))
41 .child(html::div().key("sizes").class("sizes").children(sizes))
42 .child(
43 html::button("Create")
44 .key("go")
45 .actions(Actions::new().click("submit")),
46 )])
47}Sourcepub fn role(self, role: impl Into<String>) -> Self
pub fn role(self, role: impl Into<String>) -> Self
A name of yours, exposed to CSS as data-role.
Keeps the node mounted but not laid out.
Sourcepub fn mark(self, mark: impl Into<Mark>) -> Self
pub fn mark(self, mark: impl Into<Mark>) -> Self
A transient selection mark drawn over the node.
Sourcepub fn aria(self, aria: impl Into<String>) -> Self
pub fn aria(self, aria: impl Into<String>) -> Self
The accessible name of a node that shows no text.
Sourcepub fn href(self, href: impl Into<String>) -> Self
pub fn href(self, href: impl Into<String>) -> Self
A link: ⌘-click opens it; copy and open use it.
Sourcepub fn basis(self, basis: impl Into<Basis>) -> Self
pub fn basis(self, basis: impl Into<Basis>) -> Self
Flex basis: a fraction of the parent, or the content’s size.
Sourcepub fn prop(self, name: &str, value: impl Serialize) -> Self
pub fn prop(self, name: &str, value: impl Serialize) -> Self
Sets any prop untyped; null removes it.
Sourcepub fn actions(self, actions: Actions) -> Self
pub fn actions(self, actions: Actions) -> Self
What a pointer does, by action name.
Examples found in repository?
35fn view() -> View<()> {
36 let sizes = SIZES.iter().map(|(value, label)| choice(value, label));
37 View::new().main([html::form()
38 .key("ask")
39 .class("ask")
40 .child(html::p("Which size?").key("q"))
41 .child(html::div().key("sizes").class("sizes").children(sizes))
42 .child(
43 html::button("Create")
44 .key("go")
45 .actions(Actions::new().click("submit")),
46 )])
47}Sourcepub fn on_click(self, msg: M) -> Self
pub fn on_click(self, msg: M) -> Self
Sends msg on a click (sets actions.click to "click" unless
the node names its click action itself).
Sourcepub fn on_dblclick(self, msg: M) -> Self
pub fn on_dblclick(self, msg: M) -> Self
Sends msg on a double click (sets actions.dblclick to
"dblclick" unless the node names it).
Adds act to the context menu and sends msg when it is picked.
Sourcepub fn on_action(self, act: impl Into<String>, msg: M) -> Self
pub fn on_action(self, act: impl Into<String>, msg: M) -> Self
Sends msg on action events whose action is act (name or
name=value).
Sourcepub fn on_action_with(
self,
act: impl Into<String>,
f: impl Fn(&Action) -> M + Send + Sync + 'static,
) -> Self
pub fn on_action_with( self, act: impl Into<String>, f: impl Fn(&Action) -> M + Send + Sync + 'static, ) -> Self
Maps action events whose action is act to a message.
Sourcepub fn on_toggle(self, f: impl Fn(bool) -> M + Send + Sync + 'static) -> Self
pub fn on_toggle(self, f: impl Fn(bool) -> M + Send + Sync + 'static) -> Self
Maps toggle events (the new collapsed) to a message.
Sourcepub fn on_select(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
pub fn on_select(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
Maps select events (the item) to a message. On a list’s item the
item’s own handler runs first.
Sourcepub fn on_activate(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
pub fn on_activate(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
Maps activate events (the item) to a message.
Sourcepub fn on_change(self, f: impl Fn(&Change) -> M + Send + Sync + 'static) -> Self
pub fn on_change(self, f: impl Fn(&Change) -> M + Send + Sync + 'static) -> Self
Maps change events to a message.
Sourcepub fn on_edit(self, f: impl Fn(&Edit) -> M + Send + Sync + 'static) -> Self
pub fn on_edit(self, f: impl Fn(&Edit) -> M + Send + Sync + 'static) -> Self
Maps edit events (native editing) to a message.
Sourcepub fn on_send(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
pub fn on_send(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
Maps send events (the text to submit) to a message.
Sourcepub fn child(self, child: impl Into<Node<M>>) -> Self
pub fn child(self, child: impl Into<Node<M>>) -> Self
Adds a child.
Examples found in repository?
27fn choice(value: &str, label: &str) -> El<()> {
28 html::label()
29 .key(value)
30 .child(html::radio("size", value).key("r"))
31 .child(html::span(label).key("t"))
32}
33
34/// The form.
35fn view() -> View<()> {
36 let sizes = SIZES.iter().map(|(value, label)| choice(value, label));
37 View::new().main([html::form()
38 .key("ask")
39 .class("ask")
40 .child(html::p("Which size?").key("q"))
41 .child(html::div().key("sizes").class("sizes").children(sizes))
42 .child(
43 html::button("Create")
44 .key("go")
45 .actions(Actions::new().click("submit")),
46 )])
47}More examples
47fn view(entries: &[Entry]) -> View {
48 let head = html::tr()
49 .child(html::th("Name"))
50 .child(html::th("Size").class("size"));
51 let rows = entries.iter().map(|e| {
52 let name = if e.dir {
53 format!("{}/", e.name)
54 } else {
55 e.name.clone()
56 };
57 let size = if e.dir { "-".to_owned() } else { human(e.size) };
58 html::tr()
59 .child(html::td(name).class(if e.dir { "dir" } else { "file" }))
60 .child(html::td(size).class("size"))
61 });
62 View::new().main([html::table()
63 .class("ls")
64 .child(html::thead().child(head))
65 .child(html::tbody().children(rows))])
66}Sourcepub fn children<C: Into<Node<M>>>(
self,
children: impl IntoIterator<Item = C>,
) -> Self
pub fn children<C: Into<Node<M>>>( self, children: impl IntoIterator<Item = C>, ) -> Self
Adds children.
Examples found in repository?
35fn view() -> View<()> {
36 let sizes = SIZES.iter().map(|(value, label)| choice(value, label));
37 View::new().main([html::form()
38 .key("ask")
39 .class("ask")
40 .child(html::p("Which size?").key("q"))
41 .child(html::div().key("sizes").class("sizes").children(sizes))
42 .child(
43 html::button("Create")
44 .key("go")
45 .actions(Actions::new().click("submit")),
46 )])
47}More examples
47fn view(entries: &[Entry]) -> View {
48 let head = html::tr()
49 .child(html::th("Name"))
50 .child(html::th("Size").class("size"));
51 let rows = entries.iter().map(|e| {
52 let name = if e.dir {
53 format!("{}/", e.name)
54 } else {
55 e.name.clone()
56 };
57 let size = if e.dir { "-".to_owned() } else { human(e.size) };
58 html::tr()
59 .child(html::td(name).class(if e.dir { "dir" } else { "file" }))
60 .child(html::td(size).class("size"))
61 });
62 View::new().main([html::table()
63 .class("ls")
64 .child(html::thead().child(head))
65 .child(html::tbody().children(rows))])
66}Sourcepub fn class(self, value: impl Into<String>) -> Self
pub fn class(self, value: impl Into<String>) -> Self
Space-separated class names for your stylesheets.
Examples found in repository?
35fn view() -> View<()> {
36 let sizes = SIZES.iter().map(|(value, label)| choice(value, label));
37 View::new().main([html::form()
38 .key("ask")
39 .class("ask")
40 .child(html::p("Which size?").key("q"))
41 .child(html::div().key("sizes").class("sizes").children(sizes))
42 .child(
43 html::button("Create")
44 .key("go")
45 .actions(Actions::new().click("submit")),
46 )])
47}More examples
47fn view(entries: &[Entry]) -> View {
48 let head = html::tr()
49 .child(html::th("Name"))
50 .child(html::th("Size").class("size"));
51 let rows = entries.iter().map(|e| {
52 let name = if e.dir {
53 format!("{}/", e.name)
54 } else {
55 e.name.clone()
56 };
57 let size = if e.dir { "-".to_owned() } else { human(e.size) };
58 html::tr()
59 .child(html::td(name).class(if e.dir { "dir" } else { "file" }))
60 .child(html::td(size).class("size"))
61 });
62 View::new().main([html::table()
63 .class("ls")
64 .child(html::thead().child(head))
65 .child(html::tbody().children(rows))])
66}Sourcepub fn input_type(self, value: impl Into<InputType>) -> Self
pub fn input_type(self, value: impl Into<InputType>) -> Self
input only: checkbox or radio.
Sourcepub fn name(self, value: impl Into<String>) -> Self
pub fn name(self, value: impl Into<String>) -> Self
input only: the name in its form’s values and its radio group.
Sourcepub fn value(self, value: impl Into<String>) -> Self
pub fn value(self, value: impl Into<String>) -> Self
input only: the value it reports (default "on").
Sourcepub fn disabled(self, value: impl Into<bool>) -> Self
pub fn disabled(self, value: impl Into<bool>) -> Self
input only: dimmed, never flips, left out of values.