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

feat(Pagination): Added wrapper around menu toggle #10662

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/Pagination/pagination';
import { Menu, MenuContent, MenuList, MenuItem } from '../Menu';
import { MenuToggle } from '../MenuToggle';
import { Popper } from '../../helpers/Popper/Popper';
Expand Down Expand Up @@ -166,38 +167,40 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
));

const toggle = (
<MenuToggle
ref={toggleRef}
onClick={onToggle}
{...(optionsToggleAriaLabel && { 'aria-label': optionsToggleAriaLabel })}
isDisabled={isDisabled || (itemCount && itemCount <= 0)}
isExpanded={isOpen}
{...(widgetId && { id: `${widgetId}-toggle` })}
variant="plainText"
aria-haspopup="listbox"
>
{toggleTemplate &&
typeof toggleTemplate === 'string' &&
fillTemplate(toggleTemplate, { firstIndex, lastIndex, ofWord, itemCount, itemsTitle })}
{toggleTemplate &&
typeof toggleTemplate !== 'string' &&
(toggleTemplate as (props: PaginationToggleTemplateProps) => React.ReactElement)({
firstIndex,
lastIndex,
ofWord,
itemCount,
itemsTitle
})}
{!toggleTemplate && (
<ToggleTemplate
firstIndex={firstIndex}
lastIndex={lastIndex}
ofWord={ofWord}
itemCount={itemCount}
itemsTitle={itemsTitle}
/>
)}
</MenuToggle>
<div className={css(styles.paginationPageMenu)}>
<MenuToggle
ref={toggleRef}
onClick={onToggle}
{...(optionsToggleAriaLabel && { 'aria-label': optionsToggleAriaLabel })}
isDisabled={isDisabled || (itemCount && itemCount <= 0)}
isExpanded={isOpen}
{...(widgetId && { id: `${widgetId}-toggle` })}
variant="plainText"
aria-haspopup="listbox"
>
{toggleTemplate &&
typeof toggleTemplate === 'string' &&
fillTemplate(toggleTemplate, { firstIndex, lastIndex, ofWord, itemCount, itemsTitle })}
{toggleTemplate &&
typeof toggleTemplate !== 'string' &&
(toggleTemplate as (props: PaginationToggleTemplateProps) => React.ReactElement)({
firstIndex,
lastIndex,
ofWord,
itemCount,
itemsTitle
})}
{!toggleTemplate && (
<ToggleTemplate
firstIndex={firstIndex}
lastIndex={lastIndex}
ofWord={ofWord}
itemCount={itemCount}
itemsTitle={itemsTitle}
/>
)}
</MenuToggle>
</div>
);

const menu = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,53 @@

exports[`PaginationOptionsMenu should match snapshot (auto-generated) 1`] = `
<DocumentFragment>
<button
aria-expanded="false"
aria-haspopup="listbox"
class="pf-v6-c-menu-toggle pf-m-plain pf-m-text"
data-ouia-component-id="OUIA-Generated-MenuToggle-plainText-1"
data-ouia-component-type="PF6/MenuToggle"
data-ouia-safe="true"
id="''-toggle"
type="button"
<div
class="pf-v6-c-pagination__page-menu"
>
<span
class="pf-v6-c-menu-toggle__text"
>
<b>
0 - 0
</b>
Custom toggle template of
<b>
0
</b>
'items'
</span>
<span
class="pf-v6-c-menu-toggle__controls"
<button
aria-expanded="false"
aria-haspopup="listbox"
class="pf-v6-c-menu-toggle pf-m-plain pf-m-text"
data-ouia-component-id="OUIA-Generated-MenuToggle-plainText-1"
data-ouia-component-type="PF6/MenuToggle"
data-ouia-safe="true"
id="''-toggle"
type="button"
>
<span
class="pf-v6-c-menu-toggle__toggle-icon"
class="pf-v6-c-menu-toggle__text"
>
<b>
0 - 0
</b>
Custom toggle template of
<b>
0
</b>
'items'
</span>
<span
class="pf-v6-c-menu-toggle__controls"
>
<svg
aria-hidden="true"
class="pf-v6-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
<span
class="pf-v6-c-menu-toggle__toggle-icon"
>
<path
d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"
/>
</svg>
<svg
aria-hidden="true"
class="pf-v6-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"
/>
</svg>
</span>
</span>
</span>
</button>
</button>
</div>
</DocumentFragment>
`;
Loading
Loading