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.)
|
/// will skip this page.)
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub replace: bool,
|
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.
|
/// The nodes or elements to be shown inside the link.
|
||||||
pub children: Box<dyn Fn() -> Fragment>
|
pub children: Box<dyn Fn() -> Fragment>
|
||||||
}
|
}
|
||||||
|
@ -92,6 +95,8 @@ where
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let class = props.class;
|
||||||
|
|
||||||
Component::new("A", move |cx| {
|
Component::new("A", move |cx| {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
||||||
|
@ -101,6 +106,7 @@ where
|
||||||
prop:state={props.state.map(|s| s.to_js_value())}
|
prop:state={props.state.map(|s| s.to_js_value())}
|
||||||
prop:replace={props.replace}
|
prop:replace={props.replace}
|
||||||
aria-current=move || if is_active.get() { Some("page") } else { None }
|
aria-current=move || if is_active.get() { Some("page") } else { None }
|
||||||
|
class=move || class.as_ref().map(|class| class.get())
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</a>
|
</a>
|
||||||
|
@ -110,6 +116,7 @@ where
|
||||||
<a
|
<a
|
||||||
href=move || href().unwrap_or_default()
|
href=move || href().unwrap_or_default()
|
||||||
aria-current=move || if is_active() { Some("page") } else { None }
|
aria-current=move || if is_active() { Some("page") } else { None }
|
||||||
|
class=move || class.as_ref().map(|class| class.get())
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in a new issue