From 035f929d3b2a53d2cad8eb29cdd84dc52f9fa749 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Mon, 12 Dec 2022 13:39:19 -0500 Subject: [PATCH] Merge class prop back into A component --- router/src/components/link.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/router/src/components/link.rs b/router/src/components/link.rs index 0fa7440ef..92bcd44be 100644 --- a/router/src/components/link.rs +++ b/router/src/components/link.rs @@ -61,6 +61,9 @@ where /// will skip this page.) #[builder(default)] pub replace: bool, + /// Sets the `class` attribute on the underlying `` tag, making it easier to style. + #[builder(default, setter(strip_option, into))] + pub class: Option>, /// The nodes or elements to be shown inside the link. pub children: Box Fragment> } @@ -92,6 +95,8 @@ where } }); + let class = props.class; + Component::new("A", move |cx| { cfg_if! { if #[cfg(any(feature = "csr", feature = "hydrate"))] { @@ -101,6 +106,7 @@ where prop:state={props.state.map(|s| s.to_js_value())} prop:replace={props.replace} aria-current=move || if is_active.get() { Some("page") } else { None } + class=move || class.as_ref().map(|class| class.get()) > {props.children} @@ -110,6 +116,7 @@ where {props.children}