-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'enhancement-itemtable-visual-improvements' into staging
- Loading branch information
Showing
4 changed files
with
234 additions
and
107 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
43 changes: 43 additions & 0 deletions
43
src/components/ItemTableSortButtons/ItemTableSortButtons.js
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,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 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 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; |