yew_router_nested/components/
mod.rs

1//! Components that integrate with the [route agent](agent/struct.RouteAgent.html).
2//!
3//! At least one bridge to the agent needs to exist for these to work.
4//! This can be done transitively by using a `Router` component, which owns a bridge to the agent.
5
6mod router_button;
7mod router_link;
8
9use yew::{Children, Properties};
10
11#[allow(deprecated)]
12pub use self::{router_button::RouterButton, router_link::RouterAnchor, router_link::RouterLink};
13use crate::Switch;
14
15// TODO This should also be PartialEq and Clone. Its blocked on Children not supporting that.
16// TODO This should no longer take link & String, and instead take a route: SW implementing Switch
17/// Properties for `RouterButton` and `RouterLink`.
18#[derive(Properties, Clone, Default, Debug, PartialEq)]
19pub struct Props<SW>
20where
21    SW: Switch + PartialEq + Clone,
22{
23    /// The Switched item representing the route.
24    pub route: SW,
25    #[deprecated(note = "Use children field instead (nested html)")]
26    /// The text to display.
27    #[prop_or_default]
28    pub text: String,
29    /// Html inside the component.
30    #[prop_or_default]
31    pub children: Children,
32    /// Disable the component.
33    #[prop_or_default]
34    pub disabled: bool,
35    /// Classes to be added to component.
36    #[prop_or_default]
37    pub classes: String,
38}
39
40/// Message for `RouterButton` and `RouterLink`.
41#[derive(Clone, Copy, Debug)]
42pub enum Msg {
43    /// Tell the router to navigate the application to the Component's pre-defined route.
44    Clicked,
45}