Skip to content
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

[EuiPagination] Added first/last buttons for compressed and allowing for indeterminate pageCount #5362

Merged
merged 28 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
756d2e4
Fix console error of Custom table example
Nov 1, 2021
86a36a1
[EuiPagination] Allowing `null` if `pageCount` is unknown
Nov 1, 2021
faf9b6d
[EuiPagination] Added tooltip around prev/next buttons and added `'ar…
Nov 1, 2021
ddf3940
[EuiIcon] Added `doubleArrowLeft` and `doubleArrowRight` while also u…
Nov 1, 2021
95875ef
Merge remote-tracking branch 'upstream/main' into feature/simple_pagi…
Nov 8, 2021
57ef10d
Added `first` and `last` buttons and refactored arrow button component
Nov 8, 2021
46476e3
Using negative index for `activePage` to indicate last page
Nov 8, 2021
cedef9c
Cleanup component
Nov 8, 2021
46bfd8d
Render first/last if `compressed` and remove clicks from numbers
Nov 8, 2021
c5d5ec3
Update examples and add one for `Indeterminate`
Nov 8, 2021
82fd090
Fix a11y
Nov 9, 2021
e7d23c6
Merge remote-tracking branch 'upstream/main' into feature/simple_pagi…
Nov 9, 2021
fc129ba
cl
Nov 9, 2021
ff3542f
Added `responsive` prop that renders the `compressed` display and is …
Nov 11, 2021
5227677
cl
Nov 11, 2021
8aa7e20
Merge remote-tracking branch 'upstream/main' into feature/simple_pagi…
Nov 11, 2021
02e59e1
Fix snippets
Nov 11, 2021
4b0194f
Merge branch 'elastic:main' into feature/simple_pagination
cchaos Nov 15, 2021
043654f
i18n updates
Nov 15, 2021
3a4cf61
update indeterminate page i18n tokens
thompsongl Nov 17, 2021
ced0a42
Merge branch 'main' into feature/simple_pagination
cchaos Nov 18, 2021
11b028c
Fixup a11y text by using simplified `Page # of #` syntax
Nov 22, 2021
d96e254
Wrapping with ScreenReaderOnly
Nov 23, 2021
fa17c54
Merge branch 'main' into feature/simple_pagination
cchaos Nov 23, 2021
83fe69f
Fix focus rings cutoff by `overflow: hidden`
Nov 23, 2021
12bc622
Remove `compressed` specific SR text
Dec 2, 2021
f8629dc
Merge remote-tracking branch 'upstream/main' into feature/simple_pagi…
Dec 2, 2021
52c9289
Added `arrowStart` and `arrowEnd` icons to replace the first/last pag…
Dec 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src-docs/src/views/icon/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ export const iconTypes = [
'cut',
'database',
'document',
'documentation',
'documentEdit',
'documents',
'documentEdit',
'documentation',
'dot',
'doubleArrowLeft',
'doubleArrowRight',
'download',
'email',
'empty',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import {

export default function () {
const [activePage, setActivePage] = useState(0);
const PAGE_COUNT = 10;

const goToPage = (pageNumber) => {
setActivePage(pageNumber);
};
const PAGE_COUNT = 15;

return (
<EuiFlexGroup justifyContent="spaceAround">
Expand All @@ -21,7 +17,7 @@ export default function () {
aria-label="Centered pagination example"
pageCount={PAGE_COUNT}
activePage={activePage}
onPageClick={(activePage) => goToPage(activePage)}
onPageClick={(activePage) => setActivePage(activePage)}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import { EuiPagination } from '../../../../src/components';

export default function () {
const [activePage, setActivePage] = useState(0);
const PAGE_COUNT = 4;

const goToPage = (pageNumber) => {
setActivePage(pageNumber);
};
const PAGE_COUNT = 24;

return (
<EuiPagination
pageCount={PAGE_COUNT}
activePage={activePage}
onPageClick={(activePage) => goToPage(activePage)}
onPageClick={(activePage) => setActivePage(activePage)}
compressed
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export default () => {
setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen);
const closePopover = () => setIsPopoverOpen(false);

const goToPage = (pageNumber) => setActivePage(pageNumber);
const goToPage = (pageNumber: number) => setActivePage(pageNumber);

const getIconType = (size) => {
const getIconType = (size: number) => {
return size === rowSize ? 'check' : 'empty';
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import React, { useState } from 'react';

import { EuiPagination } from '../../../../src/components';
import { EuiPagination } from '../../../../src';

export default function () {
const [activePage, setActivePage] = useState(0);
const PAGE_COUNT = 4;

const goToPage = (pageNumber) => {
setActivePage(pageNumber);
};

return (
<EuiPagination
aria-label="Few pages example"
pageCount={PAGE_COUNT}
activePage={activePage}
onPageClick={(activePage) => goToPage(activePage)}
onPageClick={(activePage) => setActivePage(activePage)}
/>
);
}
17 changes: 17 additions & 0 deletions src-docs/src/views/pagination/indeterminate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { useState } from 'react';

import { EuiPagination } from '../../../../src/components';

export default function () {
const [activePage, setActivePage] = useState(0);
const PAGE_COUNT = 0;

return (
<EuiPagination
pageCount={PAGE_COUNT}
activePage={activePage}
onPageClick={(activePage) => setActivePage(activePage)}
compressed
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ export default function () {
const [activePage, setActivePage] = useState(0);
const PAGE_COUNT = 22;

const goToPage = (pageNumber) => {
setActivePage(pageNumber);
};

return (
<EuiPagination
aria-label="Many pages example"
pageCount={PAGE_COUNT}
activePage={activePage}
onPageClick={(activePage) => goToPage(activePage)}
onPageClick={(activePage) => setActivePage(activePage)}
/>
);
}
38 changes: 35 additions & 3 deletions src-docs/src/views/pagination/pagination_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { GuideSectionTypes } from '../../components';
import {
EuiCode,
EuiPagination,
EuiPaginationButton,
EuiText,
EuiCallOut,
} from '../../../../src/components';
Expand Down Expand Up @@ -76,6 +75,16 @@ const compressedSnippet = `<EuiPagination
compressed
/>`;

import Indeterminate from './indeterminate';
const indeterminateSource = require('!!raw-loader!./indeterminate');
const indeterminateSnippet = `<EuiPagination
aria-label={paginationLabel}
pageCount={pageCount}
activePage={activePage}
onPageClick={(activePage) => goToPage(activePage)}
compressed
/>`;

export const PaginationExample = {
title: 'Pagination',
intro: (
Expand Down Expand Up @@ -122,7 +131,7 @@ export const PaginationExample = {
/>
</>
),
props: { EuiPagination, EuiPaginationButton },
props: { EuiPagination },
snippet: manyPagesSnippet,
demo: <ManyPages />,
playground: paginationConfig,
Expand Down Expand Up @@ -175,12 +184,35 @@ export const PaginationExample = {
text: (
<p>
Use the <EuiCode>compressed</EuiCode> prop to minimize the horizontal
footprint.
footprint. This will replace the numbered buttons with static numbers
and rely on the first, last, next and previous icon buttons to
navigate.
</p>
),
snippet: compressedSnippet,
demo: <Compressed />,
},
{
title: 'Indeterminate page count',
source: [
{
type: GuideSectionTypes.JS,
code: indeterminateSource,
},
],
text: (
<p>
If the total number of pages cannot be accurately determined, you can
pass <EuiCode>0</EuiCode> as the <EuiCode>pageCount</EuiCode>. This
will remove the button numbers and rely solely on the arrow icon
buttons for navigation. Without a total page count, the last page
button will pass back <EuiCode>-1</EuiCode> for the{' '}
<EuiCode>activePage</EuiCode>.
</p>
),
snippet: indeterminateSnippet,
demo: <Indeterminate />,
},
{
title: 'Customizable pagination',
source: [
Expand Down
3 changes: 2 additions & 1 deletion src-docs/src/views/tables/custom/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,15 @@ export default class extends Component {
<EuiSpacer size="m" />

<EuiTablePagination
tableCaption="Custom EuiTable demo"
aria-label="Custom EuiTable demo"
aria-controls={exampleId}
activePage={this.pager.getCurrentPageIndex()}
itemsPerPage={this.state.itemsPerPage}
itemsPerPageOptions={[5, 10, 20]}
pageCount={this.pager.getTotalPages()}
onChangeItemsPerPage={this.onChangeItemsPerPage}
onChangePage={this.onChangePage}
compressed
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,56 +485,52 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
aria-label="Pagination for table: "
className="euiPagination"
>
<EuiI18n
default="Previous page, {page}"
token="euiPagination.previousPage"
values={
Object {
"page": 1,
}
}
<EuiPaginationButtonArrow
activePage={1}
ariaControls="__table_generated-id"
disabled={false}
onClick={[Function]}
type="previous"
>
<EuiI18n
default="Previous page"
token="euiPagination.disabledPreviousPage"
<EuiButtonIcon
aria-controls="__table_generated-id"
aria-label="Previous page, 1"
color="text"
data-test-subj="pagination-button-previous"
href="#__table_generated-id"
iconType="arrowLeft"
isDisabled={false}
onClick={[Function]}
title="Previous page, 1"
>
<EuiButtonIcon
<a
aria-controls="__table_generated-id"
aria-label="Previous page, 1"
color="text"
className="euiButtonIcon euiButtonIcon--text euiButtonIcon--empty euiButtonIcon--xSmall"
data-test-subj="pagination-button-previous"
href="#__table_generated-id"
iconType="arrowLeft"
onClick={[Function]}
rel="noreferrer"
title="Previous page, 1"
>
<a
aria-controls="__table_generated-id"
aria-label="Previous page, 1"
className="euiButtonIcon euiButtonIcon--text euiButtonIcon--empty euiButtonIcon--xSmall"
data-test-subj="pagination-button-previous"
href="#__table_generated-id"
onClick={[Function]}
rel="noreferrer"
<EuiIcon
aria-hidden="true"
className="euiButtonIcon__icon"
color="inherit"
size="m"
type="arrowLeft"
>
<EuiIcon
<span
aria-hidden="true"
className="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="arrowLeft"
size="m"
type="arrowLeft"
>
<span
aria-hidden="true"
className="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="arrowLeft"
size="m"
/>
</EuiIcon>
</a>
</EuiButtonIcon>
</EuiI18n>
</EuiI18n>
/>
</EuiIcon>
</a>
</EuiButtonIcon>
</EuiPaginationButtonArrow>
<ul
aria-label="Pagination for table: "
className="euiPagination__list"
Expand Down Expand Up @@ -712,54 +708,47 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
</li>
</PaginationButtonWrapper>
</ul>
<EuiI18n
default="Next page, {page}"
token="euiPagination.nextPage"
values={
Object {
"page": 3,
}
}
<EuiPaginationButtonArrow
activePage={1}
ariaControls="__table_generated-id"
disabled={true}
onClick={[Function]}
type="next"
>
<EuiI18n
default="Next page"
token="euiPagination.disabledNextPage"
<EuiButtonIcon
aria-label="Next page, 3"
color="text"
data-test-subj="pagination-button-next"
iconType="arrowRight"
isDisabled={true}
onClick={[Function]}
>
<EuiButtonIcon
aria-label="Next page"
color="text"
<button
aria-label="Next page, 3"
className="euiButtonIcon euiButtonIcon-isDisabled euiButtonIcon--text euiButtonIcon--empty euiButtonIcon--xSmall"
data-test-subj="pagination-button-next"
disabled={true}
iconType="arrowRight"
onClick={[Function]}
type="button"
>
<button
aria-label="Next page"
className="euiButtonIcon euiButtonIcon-isDisabled euiButtonIcon--text euiButtonIcon--empty euiButtonIcon--xSmall"
data-test-subj="pagination-button-next"
disabled={true}
onClick={[Function]}
type="button"
<EuiIcon
aria-hidden="true"
className="euiButtonIcon__icon"
color="inherit"
size="m"
type="arrowRight"
>
<EuiIcon
<span
aria-hidden="true"
className="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="arrowRight"
size="m"
type="arrowRight"
>
<span
aria-hidden="true"
className="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="arrowRight"
size="m"
/>
</EuiIcon>
</button>
</EuiButtonIcon>
</EuiI18n>
</EuiI18n>
/>
</EuiIcon>
</button>
</EuiButtonIcon>
</EuiPaginationButtonArrow>
</nav>
</EuiPagination>
</div>
Expand Down
Loading