mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
Merge class prop back into A component
This commit is contained in:
parent
9c0d813697
commit
035f929d3b
1 changed files with 7 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue