-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:equinor/fusion-react-components int…
…o main
- Loading branch information
Showing
28 changed files
with
368 additions
and
24 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
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 |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.1.8](https://github.com/equinor/fusion-react-components/compare/@equinor/[email protected]...@equinor/[email protected]) (2021-10-05) | ||
|
||
**Note:** Version bump only for package @equinor/fusion-react-filter | ||
|
||
|
||
|
||
|
||
|
||
## 1.1.7 (2021-10-05) | ||
|
||
|
||
|
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 |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.6.8](https://github.com/equinor/fusion-react-components/compare/@equinor/[email protected]...@equinor/[email protected]) (2021-10-11) | ||
|
||
**Note:** Version bump only for package @equinor/fusion-react-hanging-garden | ||
|
||
|
||
|
||
|
||
|
||
## [1.6.7](https://github.com/equinor/fusion-react-components/compare/@equinor/[email protected]...@equinor/[email protected]) (2021-09-30) | ||
|
||
**Note:** Version bump only for package @equinor/fusion-react-hanging-garden | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,23 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# 0.4.0 (2021-10-12) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* remove some comments ([51e4f93](https://github.com/equinor/fusion-react-components/commit/51e4f938ab36233fa4f5cd7a0291e66143db6600)) | ||
|
||
|
||
### Features | ||
|
||
* make pagination disabled by default and add option for pagesizes ([9888099](https://github.com/equinor/fusion-react-components/commit/98880994753c89ff5ebbdbb64a78e8cda74f3094)) | ||
* pagination for table ([f578745](https://github.com/equinor/fusion-react-components/commit/f578745abd916a36cdfb9bf618312f1563f18d66)) | ||
|
||
|
||
|
||
|
||
|
||
## [0.3.19](https://github.com/equinor/fusion-react-components/compare/@equinor/[email protected]...@equinor/[email protected]) (2021-09-30) | ||
|
||
**Note:** Version bump only for package @equinor/fusion-react-table | ||
|
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
19 changes: 19 additions & 0 deletions
19
packages/table/src/components/pagination/Buttons/PaginationBtnFirst.tsx
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,19 @@ | ||
import Button from '@equinor/fusion-react-button'; | ||
import { useTableContext } from '../../../TableProvider'; | ||
|
||
export const PaginationBtnFirst = (): JSX.Element => { | ||
const { instance } = useTableContext(); | ||
const { gotoPage, canPreviousPage } = instance; | ||
|
||
return ( | ||
<Button | ||
onClick={() => gotoPage(0)} | ||
icon="first_page" | ||
variant="ghost" | ||
disabled={!canPreviousPage} | ||
color={canPreviousPage ? 'primary' : 'secondary'} | ||
dense | ||
/> | ||
); | ||
}; | ||
export default PaginationBtnFirst; |
19 changes: 19 additions & 0 deletions
19
packages/table/src/components/pagination/Buttons/PaginationBtnLast.tsx
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,19 @@ | ||
import Button from '@equinor/fusion-react-button'; | ||
import { useTableContext } from '../../../TableProvider'; | ||
|
||
export const PaginationBtnLast = (): JSX.Element => { | ||
const { instance } = useTableContext(); | ||
const { gotoPage, pageCount, canNextPage } = instance; | ||
|
||
return ( | ||
<Button | ||
onClick={() => gotoPage(pageCount - 1)} | ||
icon="last_page" | ||
variant="ghost" | ||
disabled={!canNextPage} | ||
color={canNextPage ? 'primary' : 'secondary'} | ||
dense | ||
/> | ||
); | ||
}; | ||
export default PaginationBtnLast; |
20 changes: 20 additions & 0 deletions
20
packages/table/src/components/pagination/Buttons/PaginationBtnNext.tsx
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,20 @@ | ||
import Button from '@equinor/fusion-react-button'; | ||
import { useTableContext } from '../../../TableProvider'; | ||
|
||
export const PaginationBtnNext = (): JSX.Element => { | ||
const { instance } = useTableContext(); | ||
const { nextPage, canNextPage } = instance; | ||
|
||
return ( | ||
<Button | ||
onClick={() => nextPage()} | ||
icon="chevron_right" | ||
variant="ghost" | ||
disabled={!canNextPage} | ||
color={canNextPage ? 'primary' : 'secondary'} | ||
dense | ||
/> | ||
); | ||
}; | ||
|
||
export default PaginationBtnNext; |
18 changes: 18 additions & 0 deletions
18
packages/table/src/components/pagination/Buttons/PaginationBtnPrev.tsx
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,18 @@ | ||
import Button from '@equinor/fusion-react-button'; | ||
import { useTableContext } from '../../../TableProvider'; | ||
|
||
export const PaginationBtnPrev = (): JSX.Element => { | ||
const { instance } = useTableContext(); | ||
const { previousPage, canPreviousPage } = instance; | ||
|
||
return ( | ||
<Button | ||
onClick={() => previousPage()} | ||
icon="chevron_left" | ||
variant="ghost" | ||
disabled={!canPreviousPage} | ||
color={canPreviousPage ? 'primary' : 'secondary'} | ||
dense | ||
/> | ||
); | ||
}; |
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,4 @@ | ||
export { PaginationBtnFirst } from './PaginationBtnFirst'; | ||
export { PaginationBtnNext } from './PaginationBtnNext'; | ||
export { PaginationBtnPrev } from './PaginationBtnPrev'; | ||
export { PaginationBtnLast } from './PaginationBtnLast'; |
27 changes: 27 additions & 0 deletions
27
packages/table/src/components/pagination/Paginator.style.ts
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,27 @@ | ||
import { makeStyles, FusionTheme, createStyles, theme } from '@equinor/fusion-react-styles'; | ||
|
||
export type SpacingType = keyof typeof theme.spacing.comfortable; | ||
|
||
export type StyleProps = { | ||
spacing: SpacingType; | ||
}; | ||
|
||
export const useStyles = makeStyles<FusionTheme, StyleProps>( | ||
() => | ||
createStyles({ | ||
pagination: { | ||
display: 'flex', | ||
justifyContent: 'end', | ||
alignItems: 'center', | ||
}, | ||
select: { | ||
fontFamily: 'inherit', | ||
margin: '0 1em 0 1em', | ||
padding: '0 .5em 0 0', | ||
fontSize: '14px', | ||
}, | ||
}), | ||
{ name: 'fusion-table-pagination-layout' } | ||
); | ||
|
||
export default useStyles; |
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,69 @@ | ||
import { useTableContext } from '../../TableProvider'; | ||
import { PaginationBtnFirst, PaginationBtnPrev, PaginationBtnNext, PaginationBtnLast } from './Buttons'; | ||
import { StyleProps, useStyles } from './Paginator.style'; | ||
|
||
const defaultStyleProps: StyleProps = { | ||
spacing: 'small', | ||
}; | ||
type PaginatorProps = JSX.IntrinsicElements['div']; | ||
/** | ||
* Component for showing and controlling the pagination of the table component. | ||
* Returns null if `disablePagination` is set to `true`. | ||
* Set the boolean in the `options` prop to the `Table` component to enable pagination. | ||
* The `pageSize` is by default 10 (showing 10 records on each page), but can be changed. | ||
* Same goes for `pageSizes` | ||
* @param JSX.InstrinsicElements - HTML Attributes, e.g. styling. | ||
* @example | ||
* ```jsx | ||
* const options = { | ||
* data: data, | ||
* columns: columns, | ||
* disablePagination: false, | ||
* pageSizes: [20,30,40], | ||
* initialState: { | ||
* pageSize: 20 | ||
* }, | ||
* } | ||
* return <Table options={options}/> | ||
* ``` | ||
*/ | ||
export const Paginator = (props: PaginatorProps): JSX.Element | null => { | ||
const { instance, state } = useTableContext(); | ||
const { pageOptions, setPageSize, disablePagination = true, pageSizes = [10, 20, 30, 40, 50] } = instance; | ||
const { pageIndex, pageSize } = state; | ||
const styles = useStyles({ ...defaultStyleProps }); | ||
|
||
if (disablePagination) { | ||
return null; | ||
} | ||
return ( | ||
<div {...props} className={styles.pagination}> | ||
<div>Items per page: </div> | ||
{/*TODO: use fusion dropdown component */} | ||
<select | ||
className={styles.select} | ||
value={pageSize} | ||
onChange={(e) => { | ||
setPageSize(Number(e.target.value)); | ||
}} | ||
> | ||
{pageSizes.map((pageSize) => ( | ||
<option key={pageSize} value={pageSize}> | ||
{pageSize} | ||
</option> | ||
))} | ||
</select> | ||
|
||
<div> | ||
{/*TODO: pageIndex should might not be undefined? See types.ts */} | ||
{pageIndex !== undefined && `Page ${pageIndex + 1} of ${pageOptions.length}`} | ||
</div> | ||
<PaginationBtnFirst /> | ||
<PaginationBtnPrev /> | ||
<PaginationBtnNext /> | ||
<PaginationBtnLast /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Paginator; |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export * from './useTable'; | ||
export * from './components'; | ||
export * from './types'; | ||
|
||
export * from './Table'; | ||
export * from './TableProvider'; |
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
Oops, something went wrong.