-
Notifications
You must be signed in to change notification settings - Fork 0
Enhancement ItemTable Visual Improvements #155
Merged
+177
−55
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
140c71e
Removed Paper render to remove extraneous shadows
3a95107
Changed the table render to the small variant in order to reduce unee…
561d435
Styling fixes for sort by buttons to add visual weight and make them …
566efca
Add spacing for table
campb303 56d6f28
Remove unused classes
campb303 3effeb7
Refactored sorting to its own component
wrigh393 6019e2b
Fixed merge conflict
wrigh393 9aa5321
Fixed column border gap
wrigh393 3edc67a
Minor formatting
campb303 2595643
Refactored code to reduce number of props for ItemTableSortButtons co…
wrigh393 10de4bd
Fixed merge conflicts
wrigh393 0799a8f
Updated ItemTableSortButtons docs with examples of usage
wrigh393 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
43 changes: 43 additions & 0 deletions
43
src/components/ItemTableSortButtons/ItemTableSortButtons.js
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,43 @@ | ||
| import React from 'react'; | ||
| import PropTypes from "prop-types"; | ||
| import { ButtonGroup, IconButton } from "@material-ui/core"; | ||
| import { ArrowDownward, ArrowUpward } from "@material-ui/icons"; | ||
|
|
||
| export default function ItemTableSortButtons({ sortDirection, sortAscArrowProps, sortDescArrowProps }) { | ||
| return ( | ||
| <ButtonGroup orientation="vertical" size="small"> | ||
| <IconButton edge="start"> | ||
| <ArrowUpward | ||
| {...sortAscArrowProps} | ||
| // Inherit fontsize from containing element to avoid overflow. | ||
| fontSize="inherit" | ||
| color={sortDirection === 'asc' ? "secondary" : "default"} | ||
| /> | ||
| </IconButton> | ||
| <IconButton edge="start"> | ||
| <ArrowDownward | ||
| {...sortDescArrowProps} | ||
| // Inherit fontsize from containing element to avoid overflow. | ||
| fontSize="inherit" | ||
| color={sortDirection === 'desc' ? "secondary" : "default"} | ||
| /> | ||
| </IconButton> | ||
| </ButtonGroup> | ||
| ) | ||
| } | ||
|
|
||
| ItemTableSortButtons.propTypes = { | ||
| /** String representing sort direction. */ | ||
| "sortDirection": PropTypes.oneOf(['asc', 'desc', undefined ]), | ||
| /** Props passed to ArrowUpward component. */ | ||
| "sortAscArrowProps": PropTypes.object, | ||
| /** Props passed to ArrowDownward component. */ | ||
| "sortDescArrowProps": PropTypes.object | ||
| }; | ||
|
|
||
| ItemTableSortButtons.defaultProps = { | ||
| "sortDirection": undefined, | ||
| "sortAscArrowProps": { onClick: _ => alert("No onClick function set. This does nothing.") }, | ||
| "sortDescArrowProps": { onClick: _ => alert("No onClick function set. This does nothing.") } | ||
| }; | ||
|
|
68 changes: 68 additions & 0 deletions
68
src/components/ItemTableSortButtons/ItemTableSortButtons.md
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,68 @@ | ||
| The ItemTableSortButtons are used to sort in ascending or descending order based on which button is selected. It is to be used with the [ItemTable](/#/Components/ItemTable). | ||
|
|
||
| ## Default Usage | ||
| ```jsx | ||
| import React, { useState, useEffect } from "react"; | ||
| import { Paper, TableCell, } from "@material-ui/core"; | ||
| import ItemTableFilter from "../ItemTableFilter/"; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| <TableCell component={Paper}> | ||
| <ItemTableFilter label="Queue"/> | ||
| <ItemTableSortButtons/> | ||
| </TableCell> | ||
|
|
||
|
|
||
| ``` | ||
| ```jsx static | ||
| <ItemTableSortButtons sortDirection="sortDirection" sortAscArrowProps={someObject} sortDescArrowProps={someObject} /> | ||
|
|
||
| ``` | ||
| Used without any props, the ItemTableSort will display arrows with default styling. | ||
|
|
||
|
|
||
| ## Sorting by Ascending | ||
| If the `sortDirection` prop is passed `asc`, the ItemTableSortButtons will display the active styling for the ascending arrow. If a onClick function is present the table will run that function on button click | ||
| ```jsx | ||
| import React, { useState, useEffect } from "react"; | ||
| import { Paper, TableCell, } from "@material-ui/core"; | ||
| import ItemTableFilter from "../ItemTableFilter/"; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| <TableCell component={Paper}> | ||
| <ItemTableFilter label="Queue"/> | ||
| <ItemTableSortButtons sortDirection="asc" /> | ||
| </TableCell> | ||
|
|
||
|
|
||
| ``` | ||
| ```jsx static | ||
| <ItemTableSortButtons sortDirection="asc"/> | ||
| ``` | ||
| ## Sorting by Descending | ||
| If the `sortDirection` prop is passed `desc`, the ItemTableSortButtons will display the active styling for the descending arrow. If a onClick function is present the table will run that function on button click | ||
| ```jsx | ||
| import React, { useState, useEffect } from "react"; | ||
| import { Paper, TableCell, } from "@material-ui/core"; | ||
| import ItemTableFilter from "../ItemTableFilter/"; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| <TableCell component={Paper}> | ||
| <ItemTableFilter label="Queue"/> | ||
| <ItemTableSortButtons sortDirection="desc" /> | ||
| </TableCell> | ||
|
|
||
|
|
||
| ``` | ||
| ```jsx static | ||
| <ItemTableSortButtons sortDirection="desc"/> | ||
| ``` | ||
|
|
||
|
|
||
|
|
||
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,3 @@ | ||
| import ItemtTableSortButtons from './ItemTableSortButtons' | ||
|
|
||
| export default ItemtTableSortButtons; |
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.