Skip to content

Commit

Permalink
feat(Pagination): Added wrapper arount menu toggle (patternfly#10662)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlabaj authored Jul 16, 2024
1 parent 640f3ad commit 6dbdcf4
Show file tree
Hide file tree
Showing 3 changed files with 931 additions and 844 deletions.
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

0 comments on commit 6dbdcf4

Please sign in to comment.