pub struct Col<M = ()>(/* private fields */);Expand description
col: a vertical stack.
Implementations§
Source§impl<M> Col<M>
impl<M> Col<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?
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }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 hovercard<N>(self, card: impl Into<Node<N>>) -> Self
pub fn hovercard<N>(self, card: impl Into<Node<N>>) -> Self
A floating card of card’s tree shown while the pointer rests on
the node, in place of title. Sent id-less (ids, keys and handlers
inside are ignored); an older Tern ignores it.
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 grow(self, grow: f64) -> Self
pub fn grow(self, grow: f64) -> Self
Flex grow inside a row or col.
Examples found in repository?
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }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.
Examples found in repository?
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }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 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; a menu, select or trace
line that opened is not 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.
Source§impl<M> Col<M>
impl<M> Col<M>
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?
62 fn view(&self) -> View<Msg> {
63 let messages = self.transcript.iter().enumerate().map(|(i, (who, text))| {
64 let node = ui::md(text.clone()).key(i);
65 if *who == "you" {
66 ui::card().key(i).tone("user").child(node.key("t"))
67 } else {
68 ui::card().key(i).variant("bare").child(node.key("t"))
69 }
70 });
71 let cursor: usize = self
72 .draft
73 .chars()
74 .take(self.cursor)
75 .map(char::len_utf16)
76 .sum();
77 View::new().main(ui::col().children(messages)).dock(nodes![
78 ui::editor()
79 .key("ed")
80 .text(self.draft.clone())
81 .cursor(cursor)
82 .placeholder("Message (Enter sends, Escape quits)")
83 .sendable(true)
84 .on_send(|text| Msg::Send(text.to_owned()))
85 .on_focus(Msg::Focus),
86 ui::status()
87 .key("bar")
88 .child(ui::seg("chat").icon("message"))
89 .child(
90 ui::seg(format!("{} messages", self.transcript.len()))
91 .side(Side::Right)
92 .tone(if self.transcript.is_empty() {
93 Tone::Muted
94 } else {
95 Tone::Success
96 }),
97 ),
98 ])
99 }More examples
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }Source§impl<M> Col<M>
impl<M> Col<M>
Sourcepub fn gap(self, value: impl Into<Gap>) -> Self
pub fn gap(self, value: impl Into<Gap>) -> Self
Space between children.
Examples found in repository?
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }