Repository navigation
refactor(credits-page): standardized styling and added pagination #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Ryan-Millard
merged 15 commits into
Ryan-Millard:main
from
laxitajain:fix/grammar-on-credits
Jan 26, 2026
Merged
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0e02196
fix grammar on the credits page
laxitajain f9b328a
Update src/pages/Credits/ContributorsCreditsCard.jsx
laxitajain 0f3b224
style(credits): enhanced ux and made styles consistent
laxitajain e5f90e6
style(credits): enhanced ux and made styles consistent
laxitajain 788aa44
style(credits): enhanced ux and made styles consistent
laxitajain cecbd3e
style(credits): enhanced ux and made styles consistent
laxitajain c4aaaa8
style(credits): enhanced ux and made styles consistent
laxitajain 066a8ff
Update src/components/Pagination.jsx
laxitajain 9aed920
Update ContributorsCreditsCard.jsx
laxitajain 739108f
Update Pagination.jsx
laxitajain 2d90df9
Merge branch 'main' into fix/grammar-on-credits
Ryan-Millard 854ac30
Merge branch 'main' into fix/grammar-on-credits
Ryan-Millard 19379f5
Update src/components/Pagination.module.css
laxitajain 77401e2
added docs and tests for the pagination components, fixed it's styling
laxitajain 7616f3d
Merge branch 'main' into fix/grammar-on-credits
Ryan-Millard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { useEffect } from 'react'; | ||
| import styles from './Pagination.module.css'; | ||
|
|
||
| function getVisiblePages(current, total, delta = 1) { | ||
| const pages = []; | ||
| const left = Math.max(0, current - delta); | ||
| const right = Math.min(total - 1, current + delta); | ||
|
|
||
| for (let i = left; i <= right; i++) { | ||
| pages.push(i); | ||
| } | ||
|
|
||
| return pages; | ||
| } | ||
|
|
||
| export default function Pagination({ page, totalPages, onChange }) { | ||
| // ⌨️ keyboard navigation | ||
| useEffect(() => { | ||
| const handler = (e) => { | ||
| if (e.key === 'ArrowRight' && page < totalPages - 1) { | ||
| onChange(page + 1); | ||
| } | ||
| if (e.key === 'ArrowLeft' && page > 0) { | ||
| onChange(page - 1); | ||
| } | ||
| }; | ||
|
|
||
| window.addEventListener('keydown', handler); | ||
| return () => window.removeEventListener('keydown', handler); | ||
| }, [page, totalPages, onChange]); | ||
|
|
||
| if (totalPages <= 1) return null; | ||
|
|
||
| const visiblePages = getVisiblePages(page, totalPages); | ||
|
|
||
| return ( | ||
| <nav className={styles.pagination} aria-label="Pagination"> | ||
| {/* Previous */} | ||
| <button | ||
| className={styles.arrow} | ||
| onClick={() => onChange(page - 1)} | ||
| disabled={page === 0} | ||
| aria-label="Previous page"> | ||
| ‹ | ||
| </button> | ||
|
|
||
| {/* First page */} | ||
| {visiblePages[0] > 0 && ( | ||
| <> | ||
| <button className={styles.page} onClick={() => onChange(0)}> | ||
| 1 | ||
| </button> | ||
| <span className={styles.ellipsis}>…</span> | ||
| </> | ||
| )} | ||
|
|
||
| {/* Visible pages */} | ||
| {visiblePages.map((p) => ( | ||
| <button | ||
| key={p} | ||
| onClick={() => onChange(p)} | ||
| className={`${styles.page} ${p === page ? styles.active : ''}`} | ||
| aria-current={p === page ? 'page' : undefined}> | ||
| {p + 1} | ||
| </button> | ||
| ))} | ||
|
|
||
| {/* Last page */} | ||
| {visiblePages.at(-1) < totalPages - 1 && ( | ||
| <> | ||
| <span className={styles.ellipsis}>…</span> | ||
| <button className={styles.page} onClick={() => onChange(totalPages - 1)}> | ||
| {totalPages} | ||
| </button> | ||
| </> | ||
| )} | ||
|
|
||
| {/* Next */} | ||
| <button | ||
| className={styles.arrow} | ||
| onClick={() => onChange(page + 1)} | ||
| disabled={page === totalPages - 1} | ||
| aria-label="Next page"> | ||
| › | ||
| </button> | ||
| </nav> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| .pagination { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| gap: 0.4rem; | ||
| margin-top: 1rem; | ||
| flex-wrap: wrap; | ||
| } | ||
|
|
||
| /* arrows + pages */ | ||
| .arrow, | ||
| .page { | ||
| background: transparent; | ||
| border: none; | ||
| color: var(--color-text-light); | ||
| font-size: 0.95rem; | ||
| padding: 0.35rem 0.6rem; | ||
| border-radius: 6px; | ||
| cursor: pointer; | ||
| transition: | ||
| background 0.2s ease, | ||
| color 0.2s ease; | ||
| } | ||
|
|
||
| .arrow { | ||
| font-size: 1.2rem; | ||
| } | ||
|
|
||
| /* hover */ | ||
| .arrow:hover, | ||
| .page:hover { | ||
| background: var(--color-glass-border); | ||
| } | ||
|
|
||
| /* active page */ | ||
| .active { | ||
| background: var(--color-accent); | ||
| color: var(--color-text-dark); | ||
| } | ||
|
laxitajain marked this conversation as resolved.
Resolved
|
||
|
|
||
| /* disabled */ | ||
| .arrow:disabled { | ||
| opacity: 0.4; | ||
| cursor: not-allowed; | ||
| } | ||
|
|
||
| /* ellipsis */ | ||
| .ellipsis { | ||
| padding: 0 0.25rem; | ||
| color: var(--color-text-muted); | ||
| } | ||
|
|
||
| /* 📱 mobile optimization */ | ||
| @media (max-width: 480px) { | ||
| .page { | ||
| min-width: 2rem; | ||
| padding: 0.3rem 0.45rem; | ||
| font-size: 0.85rem; | ||
| } | ||
|
|
||
| .arrow { | ||
| font-size: 1rem; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,66 @@ | ||
| import { useState, useEffect } from 'react'; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| import GlassCard from '@components/GlassCard'; | ||
| import contributors from '@data/contributor-credits.json'; | ||
| import styles from './ContributorsCreditsCard.module.css'; | ||
| import FallbackImage from '@components/FallbackImage'; | ||
| import Pagination from '@components/Pagination'; | ||
| import Tooltip from '@components/Tooltip'; | ||
| import { User } from 'lucide-react'; | ||
|
|
||
| export default function ContributorsCreditsCard() { | ||
| const chunk = (arr, size) => | ||
| Array.from({ length: Math.ceil(arr.length / size) }, (_, i) => arr.slice(i * size, i * size + size)); | ||
|
|
||
| const chunkSize = 13; | ||
| const chunkSize = 10; | ||
| const tables = chunk(contributors, chunkSize); | ||
|
|
||
| const [page, setPage] = useState(0); | ||
|
|
||
| return ( | ||
| <GlassCard> | ||
| <h2>Contributors</h2> | ||
|
|
||
| <div className={styles.contributorsGrid}> | ||
| {tables.map((group, i) => ( | ||
| <table key={i}> | ||
| <tbody> | ||
| {group.map((c) => ( | ||
| <tr key={c.id}> | ||
| <td> | ||
| <Tooltip content={`Open ${c.login}'s GitHub profile`}> | ||
| <a href={c.html_url} target="_blank" rel="noopener noreferrer"> | ||
| <FallbackImage | ||
| src={c.avatar_url} | ||
| fallback={<User color="var(--color-text-light)" />} | ||
| alt={c.login} | ||
| width="28" | ||
| height="28" | ||
| className={styles.avatar} | ||
| /> | ||
| </a> | ||
| </Tooltip> | ||
| </td> | ||
|
|
||
| <td> | ||
| <Tooltip content={`Visit ${c.login}'s GitHub profile`}> | ||
| <a href={c.html_url} target="_blank" rel="noopener noreferrer"> | ||
| {c.login} | ||
| </a> | ||
| </Tooltip> | ||
| </td> | ||
|
|
||
| <td>{c.contributions} commits</td> | ||
| </tr> | ||
| ))} | ||
| </tbody> | ||
| </table> | ||
| ))} | ||
| {tables.map( | ||
| (group, i) => | ||
| i === page && ( | ||
| <table key={i}> | ||
| <tbody> | ||
| {group.map((c) => ( | ||
| <tr key={c.id}> | ||
| <td> | ||
| <Tooltip content={`Open ${c.login}'s GitHub profile`}> | ||
| <a href={c.html_url} target="_blank" rel="noopener noreferrer"> | ||
| <FallbackImage | ||
| src={c.avatar_url} | ||
| fallback={<User color="var(--color-text-light)" />} | ||
| alt={c.login} | ||
| width="28" | ||
| height="28" | ||
| className={styles.avatar} | ||
| /> | ||
| </a> | ||
| </Tooltip> | ||
| </td> | ||
|
|
||
| <td> | ||
| <Tooltip content={`Visit ${c.login}'s GitHub profile`}> | ||
| <a href={c.html_url} target="_blank" rel="noopener noreferrer"> | ||
| {c.login} | ||
| </a> | ||
| </Tooltip> | ||
| </td> | ||
|
|
||
| <td>{c.contributions} commits</td> | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| </tr> | ||
| ))} | ||
| </tbody> | ||
| </table> | ||
| ) | ||
| )} | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| </div> | ||
|
|
||
| <Pagination page={page} totalPages={tables.length} onChange={setPage} /> | ||
| </GlassCard> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| .container { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 2rem; | ||
| max-width: 1200px; | ||
| gap: 1rem; | ||
| margin: 0 auto; | ||
| text-align: center; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.