Merge class prop back into A component

This commit is contained in:
Greg Johnston 2022-12-12 13:39:19 -05:00
parent 9c0d813697
commit 035f929d3b

View file

@ -61,6 +61,9 @@ where
/// will skip this page.)
#[builder(default)]
pub replace: bool,
/// Sets the `class` attribute on the underlying `<a>` tag, making it easier to style.
#[builder(default, setter(strip_option, into))]
pub class: Option<MaybeSignal<String>>,
/// The nodes or elements to be shown inside the link.
pub children: Box<dyn Fn() -> 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}
</a>
@ -110,6 +116,7 @@ where
<a
href=move || href().unwrap_or_default()
aria-current=move || if is_active() { Some("page") } else { None }
class=move || class.as_ref().map(|class| class.get())
>
{props.children}
</a>