Skip to content

Commit

Permalink
Fix links in pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
aalin committed Sep 29, 2022
1 parent 9aceee1 commit a67aa8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions example/app/pages/pokemon/Pagination.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@
text-align: center;
}

.page[href]:link,
.page[href]:visited {
.page:link,
.page:visited {
text-decoration: none;
color: var(--blue);
}

.page[href]:active,
.page[href]:hover {
.page:active,
.page:hover {
color: var(--blue);
font-weight: bold;
text-decoration: underline;
}

.page:not([href]) {
.page[aria-current="page"] {
background: var(--blue);
color: var(--bright);
font-weight: bold;
Expand Down
16 changes: 7 additions & 9 deletions example/app/pages/pokemon/Pagination.rux
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def render

<div class={styles[:wrap]}>
<nav class={styles.buttons} aria-label="pagination">
{prev_page_link && <link rel="prev" href={prev_page_link} />}
<a href={prev_page_link} class={styles.button}>
<a href={prev_page_link} class={styles.button} rel="prev">
Previous page
</a>

Expand All @@ -37,17 +36,16 @@ def render
current_page: page,
total_pages: props[:total_pages].succ,
window_size: props[:window_size] || 7,
).map do |p|
href = p == page ? nil : "?page=#{p}"

<li key={p}>
<a class={styles[:page]} href={href}>{p}</a>
).map do |num|
<li key={num}>
<a class={styles[:page]} href={"?page=#{num}"} aria-current={page == num && "page"}>
{num}
</a>
</li>
end}
</ul>

{next_page_link && <link rel="next" href={next_page_link} />}
<a href={next_page_link} class={styles.button}>
<a href={next_page_link} class={styles.button} rel="next">
Next page
</a>
</nav>
Expand Down

0 comments on commit a67aa8d

Please sign in to comment.