✨ (macros): Funde class="..." con clases abreviadas
This commit is contained in:
parent
d1d3a62c8f
commit
c3f45e7688
4 changed files with 392 additions and 8 deletions
|
|
@ -250,7 +250,7 @@ impl Component for Pager {
|
|||
}
|
||||
ul class="pagination" {
|
||||
@if show_prev_next {
|
||||
li.page-item.page-previous.disabled[first_disabled] {
|
||||
li class="page-item page-previous" .disabled[first_disabled] {
|
||||
a class="page-link"
|
||||
href=[(!first_disabled).then(|| Self::page_route(&route, page - 1))]
|
||||
aria-disabled=[first_disabled.then_some("true")]
|
||||
|
|
@ -265,7 +265,7 @@ impl Component for Pager {
|
|||
@match item {
|
||||
PageItem::Number(n) => {
|
||||
@let href = Self::page_route(&route, n);
|
||||
li.page-item.active[n == page] {
|
||||
li class="page-item" .active[n == page] {
|
||||
a class="page-link"
|
||||
href=(href)
|
||||
aria-current=[(n == page).then_some("page")] {
|
||||
|
|
@ -281,7 +281,7 @@ impl Component for Pager {
|
|||
}
|
||||
}
|
||||
@if show_prev_next {
|
||||
li.page-item.page-next.disabled[last_disabled] {
|
||||
li class="page-item page-next" .disabled[last_disabled] {
|
||||
a class="page-link"
|
||||
href=[(!last_disabled).then(|| Self::page_route(&route, page + 1))]
|
||||
aria-disabled=[last_disabled.then_some("true")]
|
||||
|
|
|
|||
|
|
@ -124,6 +124,25 @@ use std::sync::Arc;
|
|||
/// assert_eq!(markup.into_string(), r#"<span title="literal">OK</span>"#);
|
||||
/// ```
|
||||
///
|
||||
/// Con `class` ocurre lo mismo. Si el elemento escribe alguna clase propia, con `class="..."` o con
|
||||
/// la forma abreviada (`.clase`, `.clase[cond]`), se omiten **todas** las clases de `Props`. Para
|
||||
/// combinar las clases del componente con las que se añadan con `with_prop()`, el componente debe
|
||||
/// incorporarlas a sus `Props` en su `setup()`, por ejemplo con [`PropsOp::prepend_classes()`], y
|
||||
/// no las escribe en el elemento.
|
||||
///
|
||||
/// ```rust
|
||||
/// # use pagetop::prelude::*;
|
||||
/// # let mut cx = Context::default();
|
||||
/// let props = Props::classes("extra");
|
||||
///
|
||||
/// let markup = html! { div class="card" (props.unpack(&mut cx)) {} };
|
||||
/// assert_eq!(markup.into_string(), r#"<div class="card"></div>"#);
|
||||
///
|
||||
/// let props = props.with_prop(PropsOp::prepend_classes("card"));
|
||||
/// let markup = html! { div (props.unpack(&mut cx)) {} };
|
||||
/// assert_eq!(markup.into_string(), r#"<div class="card extra"></div>"#);
|
||||
/// ```
|
||||
///
|
||||
/// # Valores extra
|
||||
///
|
||||
/// Las variantes [`SetExtra`](PropsOp::SetExtra) y [`RemoveExtra`](PropsOp::RemoveExtra), usando
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue