-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) Add pagination to resource list tables to mirror Detail View
- Loading branch information
1 parent
dc93b3f
commit e0fbaa2
Showing
5 changed files
with
163 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,65 @@ | ||
import React, { MouseEventHandler } from "react" | ||
import styled from "styled-components" | ||
import { Tags } from "./analytics" | ||
import { InstrumentedButton } from "./instrumentedComponents" | ||
import { | ||
AnimDuration, | ||
Color, | ||
Font, | ||
FontSize, | ||
mixinResetButtonStyle, | ||
} from "./style-helpers" | ||
|
||
const ShowMoreButtonRoot = styled(InstrumentedButton)` | ||
${mixinResetButtonStyle}; | ||
color: ${Color.gray6}; | ||
font-family: ${Font.sansSerif}; | ||
font-size: ${FontSize.small}; | ||
padding: 0 0.5em; | ||
transition: color ${AnimDuration.default} ease; | ||
&:hover, | ||
&:focus, | ||
&:active { | ||
color: ${Color.blue}; | ||
} | ||
` | ||
|
||
const ShowMoreCount = styled.span` | ||
color: ${Color.gray7}; | ||
font-family: ${Font.sansSerif}; | ||
font-size: ${FontSize.small}; | ||
` | ||
|
||
export function ShowMoreButton({ | ||
itemCount, | ||
currentListSize, | ||
onClick, | ||
analyticsTags, | ||
}: { | ||
itemCount: number | ||
currentListSize: number | ||
analyticsTags: Tags | ||
onClick: MouseEventHandler | ||
}) { | ||
if (itemCount <= currentListSize) { | ||
return null | ||
} | ||
|
||
const remainingCount = itemCount - currentListSize | ||
|
||
return ( | ||
<> | ||
<ShowMoreButtonRoot | ||
analyticsName="ui.web.showMore" | ||
analyticsTags={analyticsTags} | ||
onClick={onClick} | ||
> | ||
…Show more | ||
</ShowMoreButtonRoot> | ||
<ShowMoreCount aria-label={`${remainingCount} hidden resources`}> | ||
({remainingCount}) | ||
</ShowMoreCount> | ||
</> | ||
) | ||
} |
This file contains 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
This file contains 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
This file contains 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