Skip to content
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
Expand Up @@ -14,7 +14,7 @@ export interface ActionListProps extends React.HTMLProps<HTMLDivElement> {
export const ActionList: React.FunctionComponent<ActionListProps> = ({
children,
isIconList,
className = '',
className,
...props
}: ActionListProps) => (
<div className={css(styles.actionList, isIconList && styles.modifiers.icons, className)} {...props}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ export interface ActionListGroupProps extends React.HTMLProps<HTMLDivElement> {
children?: React.ReactNode;
/** Additional classes added to the action list group */
className?: string;
/** Flag indicating the action list group contains multiple icons and item padding should be removed */
isIconGroup?: boolean;
}

export const ActionListGroup: React.FunctionComponent<ActionListGroupProps> = ({
children,
className = '',
className,
isIconGroup,
...props
}: ActionListGroupProps) => (
<div className={css(styles.actionListGroup, className)} {...props}>
<div className={css(styles.actionListGroup, isIconGroup && styles.modifiers.icons, className)} {...props}>
{children}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ActionListItemProps extends React.HTMLProps<HTMLDivElement> {

export const ActionListItem: React.FunctionComponent<ActionListItemProps> = ({
children,
className = '',
className,
...props
}: ActionListItemProps) => (
<div className={css(`${styles.actionList}__item`, className)} {...props}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ test('Renders children', () => {
expect(screen.getByText('Test')).toBeVisible();
});

test(`Renders with class ${styles.actionListGroup}`, () => {
test(`Renders with only class ${styles.actionListGroup} by default`, () => {
render(<ActionListGroup>Test</ActionListGroup>);

expect(screen.getByText('Test')).toHaveClass(styles.actionListGroup);
expect(screen.getByText('Test')).toHaveClass(styles.actionListGroup, { exact: true });
});

test(`Renders with class ${styles.modifiers.icons} when isIconGroup is true`, () => {
render(<ActionListGroup isIconGroup>Test</ActionListGroup>);

expect(screen.getByText('Test')).toHaveClass(styles.modifiers.icons);
});

test('Renders with custom class names provided via prop', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {
ActionList,
ActionListGroup,
ActionListItem,
Button,
Dropdown,
Expand Down Expand Up @@ -46,50 +47,54 @@ export const ActionListSingleGroup: React.FunctionComponent = () => {
return (
<React.Fragment>
<ActionList>
<ActionListItem>
<Button variant="primary" id="single-group-next-button">
Next
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="secondary" id="single-group-back-button">
Back
</Button>
</ActionListItem>
<ActionListGroup>
<ActionListItem>
<Button variant="primary" id="single-group-next-button">
Next
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="secondary" id="single-group-back-button">
Back
</Button>
</ActionListItem>
</ActionListGroup>
</ActionList>
<br />
With kebab
<ActionList>
<ActionListItem>
<Button variant="primary" id="single-group-next-button2">
Next
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="secondary" id="single-group-back-button2">
Back
</Button>
</ActionListItem>
<ActionListItem>
<Dropdown
onSelect={onSelect}
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle
ref={toggleRef}
onClick={onToggle}
variant="plain"
isExpanded={isOpen}
aria-label="Action list single group kebab"
>
<EllipsisVIcon />
</MenuToggle>
)}
isOpen={isOpen}
onOpenChange={(isOpen: boolean) => setIsOpen(isOpen)}
>
<DropdownList>{dropdownItems}</DropdownList>
</Dropdown>
</ActionListItem>
<ActionListGroup>
<ActionListItem>
<Button variant="primary" id="single-group-next-button2">
Next
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="secondary" id="single-group-back-button2">
Back
</Button>
</ActionListItem>
<ActionListItem>
<Dropdown
onSelect={onSelect}
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle
ref={toggleRef}
onClick={onToggle}
variant="plain"
isExpanded={isOpen}
aria-label="Action list single group kebab"
>
<EllipsisVIcon />
</MenuToggle>
)}
isOpen={isOpen}
onOpenChange={(isOpen: boolean) => setIsOpen(isOpen)}
>
<DropdownList>{dropdownItems}</DropdownList>
</Dropdown>
</ActionListItem>
</ActionListGroup>
</ActionList>
</React.Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ export const ActionListWithCancelButton: React.FunctionComponent = () => (
<React.Fragment>
In modals, forms, data lists
<ActionList>
<ActionListItem>
<Button variant="primary" id="with-cancel-save-button">
Save
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="link" id="with-cancel-cancel-button">
Cancel
</Button>
</ActionListItem>
<ActionListGroup>
<ActionListItem>
<Button variant="primary" id="with-cancel-save-button">
Save
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="link" id="with-cancel-cancel-button">
Cancel
</Button>
</ActionListItem>
</ActionListGroup>
</ActionList>
<br />
In wizards
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
import React from 'react';
import { ActionList, ActionListItem, Button } from '@patternfly/react-core';
import { ActionList, ActionListGroup, ActionListItem, Button } from '@patternfly/react-core';
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';

export const ActionListWithIcons: React.FunctionComponent = () => (
<ActionList isIconList>
<ActionListItem>
<Button variant="plain" id="with-icons-times-button" aria-label="times icon button">
<TimesIcon />
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="plain" id="with-icons-check-button" aria-label="check icon button">
<CheckIcon />
</Button>
</ActionListItem>
</ActionList>
<>
<h4>With list icons wrapper</h4>
<ActionList isIconList>
<ActionListItem>
<Button variant="plain" id="with-icons-times-button" aria-label="times icon button">
<TimesIcon />
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="plain" id="with-icons-check-button" aria-label="check icon button">
<CheckIcon />
</Button>
</ActionListItem>
</ActionList>
<br />
<h4>With group icons wrapper</h4>
<ActionList>
<ActionListGroup isIconGroup>
<ActionListItem>
<Button variant="plain" id="with-icons-list-times-button" aria-label="times icon button">
<TimesIcon />
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="plain" id="with-icons-list-check-button" aria-label="check icon button">
<CheckIcon />
</Button>
</ActionListItem>
</ActionListGroup>
<ActionListGroup isIconGroup>
<ActionListItem>
<Button variant="plain" id="with-icons-group-times-button" aria-label="times icon button">
<TimesIcon />
</Button>
</ActionListItem>
<ActionListItem>
<Button variant="plain" id="with-icons-group-check-button" aria-label="check icon button">
<CheckIcon />
</Button>
</ActionListItem>
</ActionListGroup>
</ActionList>
</>
);