-
Notifications
You must be signed in to change notification settings - Fork 142
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
Adds Pagination to Data Table #1367
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6019b4a
pagination added
joshri 27228eb
added tests
joshri cac66f9
added displayLabel key to fields to avoid manipulating string in data…
joshri da01366
added display label field to data table story
joshri 5229ca7
display label fix in commits table
joshri 3ff82f2
woke up in a cold sweat realizing that the indexing for the text was …
joshri 12401f9
redo w/o tests
joshri d1377fa
redo two with tests
joshri 068d1d8
data table styling changes
joshri aa51a5a
removed displayLabel and added textProps to Link in order to alter li…
joshri aef334d
got rid of TextProps it was bad
joshri File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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,118 @@ | ||
import { FormControl, MenuItem, Select } from "@material-ui/core"; | ||
import * as React from "react"; | ||
import styled from "styled-components"; | ||
import Button from "./Button"; | ||
import Flex from "./Flex"; | ||
import Icon, { IconType } from "./Icon"; | ||
import Spacer from "./Spacer"; | ||
import Text from "./Text"; | ||
|
||
export interface Props { | ||
/** CSS MUI Overrides or other styling. */ | ||
className?: string; | ||
/** func for forward one page button */ | ||
onForward: () => void; | ||
/** func for skip to last page button */ | ||
onSkipForward: () => void; | ||
/** func for back one page button */ | ||
onBack: () => void; | ||
/** func for skip to start button */ | ||
onSkipBack: () => void; | ||
/** onChange func for perPage select */ | ||
onSelect: (value: string) => void; | ||
/** options for perPage select */ | ||
perPageOptions?: number[]; | ||
/** starting index */ | ||
index: number; | ||
/** total rows */ | ||
length: number; | ||
/** all objects */ | ||
totalObjects: number; | ||
} | ||
|
||
function unstyledPagination({ | ||
className, | ||
onForward, | ||
onSkipForward, | ||
onBack, | ||
onSkipBack, | ||
onSelect, | ||
perPageOptions = [25, 50, 75, 100], | ||
index, | ||
length, | ||
totalObjects, | ||
}: Props) { | ||
return ( | ||
<Flex wide align end className={className}> | ||
<FormControl> | ||
<Flex align> | ||
<label htmlFor="pagination">Rows Per Page: </label> | ||
<Spacer padding="xxs" /> | ||
<Select | ||
id="pagination" | ||
variant="outlined" | ||
defaultValue={perPageOptions[0]} | ||
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => { | ||
onSelect(e.target.value); | ||
}} | ||
> | ||
{perPageOptions.map((option, index) => { | ||
return ( | ||
<MenuItem key={index} value={option}> | ||
{option} | ||
</MenuItem> | ||
); | ||
})} | ||
</Select> | ||
</Flex> | ||
</FormControl> | ||
<Spacer padding="base" /> | ||
<Text> | ||
{index + 1} - {index + length} out of {totalObjects} | ||
</Text> | ||
<Spacer padding="base" /> | ||
<Flex> | ||
<Button | ||
color="inherit" | ||
variant="text" | ||
aria-label="skip to first page" | ||
disabled={index === 0} | ||
onClick={onSkipBack} | ||
> | ||
<Icon type={IconType.SkipPreviousIcon} size="medium" /> | ||
</Button> | ||
<Button | ||
color="inherit" | ||
variant="text" | ||
aria-label="back one page" | ||
disabled={index === 0} | ||
onClick={onBack} | ||
> | ||
<Icon type={IconType.NavigateBeforeIcon} size="medium" /> | ||
</Button> | ||
<Button | ||
color="inherit" | ||
variant="text" | ||
aria-label="forward one page" | ||
disabled={index + length >= totalObjects} | ||
onClick={onForward} | ||
> | ||
<Icon type={IconType.NavigateNextIcon} size="medium" /> | ||
</Button> | ||
<Button | ||
color="inherit" | ||
variant="text" | ||
aria-label="skip to last page" | ||
disabled={index + length >= totalObjects} | ||
onClick={onSkipForward} | ||
> | ||
<Icon type={IconType.SkipNextIcon} size="medium" /> | ||
</Button> | ||
</Flex> | ||
</Flex> | ||
); | ||
} | ||
|
||
export const Pagination = styled(unstyledPagination)``; | ||
|
||
export default Pagination; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have played around with this in the inspector and for me this only renders bold (> 600) or regular (<600) – is semi-bold Proxima Nova not getting imported somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm...I feel like I've seen that before, but I just tested it here's the screenshots:
font-weight 800:
font-weight 600:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It DEFINITELY changes but it is subtle for sure