Skip to content

Commit

Permalink
chore: Improve paging (#3265)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Jan 11, 2024
1 parent 0e28b6c commit 9b6da57
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 21 deletions.
46 changes: 31 additions & 15 deletions frontend/web/components/Paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ export default class Paging extends PureComponent {
(currentIndex || currentIndex + 1) + spaceBetween,
)
const range = _.range(from, to)
const noPages = range.length < 2
const noPages = range.length < 1
if (noPages && !(paging.next || paging.previous)) {
return null
}
return (
<Row className=' paging py-0' style={isLoading ? { opacity: 0.5 } : {}}>
<Row
className='paging justify-content-end table-column py-2'
style={isLoading ? { opacity: 0.5 } : {}}
>
{!!paging.count && (
<span className='fs-caption text-muted'>
{currentIndex * paging.pageSize + 1}-
{Math.min((currentIndex + 1) * paging.pageSize, paging.count)} of{' '}
{paging.count}
</span>
)}
<Button
disabled={isLoading || !paging.previous}
className='icon btn-paging mt-1'
className='icon fs-small page'
onClick={() => prevPage()}
>
<div>
Expand All @@ -53,21 +63,23 @@ export default class Paging extends PureComponent {
role='button'
className={cn({
'active': currentIndex === 1,
page: true,
'fs-small page': true,
})}
onClick={
paging.currentPage === 1 + 1 ? undefined : () => goToPage(1)
}
>
{1}
</div>
<div
className={cn({
page: true,
})}
>
...
</div>
{!range.includes(1) && !noPages && (
<div
className={cn({
'fs-small page': true,
})}
>
...
</div>
)}
</>
)}
{!noPages &&
Expand All @@ -77,7 +89,7 @@ export default class Paging extends PureComponent {
role='button'
className={cn({
'active': currentIndex === index,
page: true,
'fs-small page': true,
})}
onClick={
paging.currentPage === index + 1
Expand All @@ -88,7 +100,7 @@ export default class Paging extends PureComponent {
{index + 1}
</div>
))}
{!noPages && !range.includes(lastPage - 1) && (
{!noPages && !range.includes(lastPage - 2) && (
<>
<div
className={cn({
Expand All @@ -102,11 +114,15 @@ export default class Paging extends PureComponent {
>
...
</div>
</>
)}
{!noPages && !range.includes(lastPage - 1) && (
<>
<div
role='button'
className={cn({
'active': currentIndex === lastPage,
page: true,
'page fs-small': true,
})}
onClick={
paging.currentPage === lastPage
Expand All @@ -130,7 +146,7 @@ export default class Paging extends PureComponent {
)
)}
<Button
className='icon btn-paging mt-1'
className='icon fs-small page'
disabled={isLoading || !paging.next}
onClick={() => nextPage()}
>
Expand Down
29 changes: 23 additions & 6 deletions frontend/web/styles/components/_paging.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,33 @@
}
justify-content: center;
.page {
display: inline-block;
border-radius:34px;
margin-left: 10px;
margin-right: 10px;
>div {
height: 100%;
justify-content: center;
display: flex;
align-items: center;
}
border-radius: $border-radius;
margin-left: 4px;
margin-right: 4px;
min-width: 32px;
height: 32px;
line-height: 1;
font-weight: 500;
display: flex;
justify-content: center;
align-items: center;
border: 1px solid $hr-border-color;
text-align: center;
padding: 0;
background: transparent;
color: $text-icon-grey;
&:hover {
color: $bt-brand-primary;
color: $primary;
}
&.active {
color: $bt-brand-primary;
background-color: $primary-alfa-8;
color: $primary;
}
}
}
Expand Down

3 comments on commit 9b6da57

@vercel
Copy link

@vercel vercel bot commented on 9b6da57 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 9b6da57 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 9b6da57 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./docs

docs-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
docs-git-main-flagsmith.vercel.app

Please sign in to comment.