diff --git a/packages/react-core/src/components/Page/examples/Page.md b/packages/react-core/src/components/Page/examples/Page.md index 2cc85a40c00..531c61bebd3 100644 --- a/packages/react-core/src/components/Page/examples/Page.md +++ b/packages/react-core/src/components/Page/examples/Page.md @@ -16,10 +16,6 @@ propComponents: --- import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon'; -import { -PageHeader, -PageHeaderTools -} from '@patternfly/react-core/deprecated'; import './page.css'; ## Examples diff --git a/packages/react-core/src/components/Toolbar/ToolbarGroup.tsx b/packages/react-core/src/components/Toolbar/ToolbarGroup.tsx index 1c5bbcce61d..f2257a3b63f 100644 --- a/packages/react-core/src/components/Toolbar/ToolbarGroup.tsx +++ b/packages/react-core/src/components/Toolbar/ToolbarGroup.tsx @@ -53,6 +53,8 @@ export interface ToolbarGroupProps extends Omit, }; /** Content to be rendered inside the data toolbar group */ children?: React.ReactNode; + /** Flag that modifies the toolbar group to hide overflow and respond to available space. Used for horizontal navigation. */ + isOverflowContainer?: boolean; /** @hide Reference to pass to this group if it has .pf-m-chip-container modifier */ innerRef?: React.RefObject; } @@ -69,6 +71,7 @@ class ToolbarGroupWithRef extends React.Component { className, variant, children, + isOverflowContainer, innerRef, ...props } = this.props; @@ -88,6 +91,7 @@ class ToolbarGroupWithRef extends React.Component { alignItems === 'baseline' && styles.modifiers.alignItemsBaseline, alignSelf === 'center' && styles.modifiers.alignSelfCenter, alignSelf === 'baseline' && styles.modifiers.alignSelfBaseline, + isOverflowContainer && styles.modifiers.overflowContainer, className )} {...props} diff --git a/packages/react-core/src/components/Toolbar/ToolbarItem.tsx b/packages/react-core/src/components/Toolbar/ToolbarItem.tsx index bf46dc7ca1e..5f7c91d7240 100644 --- a/packages/react-core/src/components/Toolbar/ToolbarItem.tsx +++ b/packages/react-core/src/components/Toolbar/ToolbarItem.tsx @@ -70,6 +70,8 @@ export interface ToolbarItemProps extends React.HTMLProps { id?: string; /** Flag indicating if the expand-all variant is expanded or not */ isAllExpanded?: boolean; + /** Flag that modifies the toolbar item to hide overflow and respond to available space. Used for horizontal navigation. */ + isOverflowContainer?: boolean; /** Content to be rendered inside the data toolbar item */ children?: React.ReactNode; } @@ -85,6 +87,7 @@ export const ToolbarItem: React.FunctionComponent = ({ id, children, isAllExpanded, + isOverflowContainer, ...props }: ToolbarItemProps) => { if (variant === ToolbarItemVariant.separator) { @@ -116,6 +119,7 @@ export const ToolbarItem: React.FunctionComponent = ({ | 'chipGroup' ], isAllExpanded && styles.modifiers.expanded, + isOverflowContainer && styles.modifiers.overflowContainer, formatBreakpointMods(visibility, styles, '', getBreakpoint(width)), formatBreakpointMods(align, styles, '', getBreakpoint(width)), formatBreakpointMods(spacer, styles, '', getBreakpoint(width)), diff --git a/packages/react-core/src/components/Toolbar/__tests__/ToolbarGroup.test.tsx b/packages/react-core/src/components/Toolbar/__tests__/ToolbarGroup.test.tsx new file mode 100644 index 00000000000..9c34c0a99b2 --- /dev/null +++ b/packages/react-core/src/components/Toolbar/__tests__/ToolbarGroup.test.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import { ToolbarGroup } from '../ToolbarGroup'; + +describe('ToolbarItem', () => { + it('should render with pf-m-overflow-container when isOverflowContainer is set', () => { + render(Test); + expect(screen.getByTestId('toolbargroup')).toHaveClass('pf-m-overflow-container'); + }); +}); diff --git a/packages/react-core/src/components/Toolbar/__tests__/ToolbarItem.test.tsx b/packages/react-core/src/components/Toolbar/__tests__/ToolbarItem.test.tsx index 4d958bb81b6..af810124f1d 100644 --- a/packages/react-core/src/components/Toolbar/__tests__/ToolbarItem.test.tsx +++ b/packages/react-core/src/components/Toolbar/__tests__/ToolbarItem.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { ToolbarItem } from '../ToolbarItem'; describe('ToolbarItem', () => { @@ -16,4 +16,9 @@ describe('ToolbarItem', () => { const { asFragment } = render(Test); expect(asFragment()).toMatchSnapshot(); }); + + it('should render with pf-m-overflow-container when isOverflowContainer is set', () => { + render(Test); + expect(screen.getByTestId('toolbaritem')).toHaveClass('pf-m-overflow-container'); + }); }); diff --git a/packages/react-core/src/demos/Nav.md b/packages/react-core/src/demos/Nav.md index 543b34edcb1..6480dc67c23 100644 --- a/packages/react-core/src/demos/Nav.md +++ b/packages/react-core/src/demos/Nav.md @@ -3,20 +3,14 @@ id: Navigation section: components --- -import { -PageHeader, -PageHeaderTools, -PageHeaderToolsGroup, -PageHeaderToolsItem -} from '@patternfly/react-core/deprecated'; - import { DashboardBreadcrumb } from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; import DashboardHeader from '@patternfly/react-core/src/demos/examples/DashboardHeader'; import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; -import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg'; +import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; +import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg'; import imgColorBrand from '@patternfly/react-core/src/demos/examples/pfColorLogo.svg'; @@ -387,6 +381,10 @@ import { DropdownList, Gallery, GalleryItem, + Masthead, + MastheadMain, + MastheadBrand, + MastheadContent, MenuToggle, Nav, NavItem, @@ -396,21 +394,19 @@ import { PageSectionVariants, SkipToContent, TextContent, - Text + Text, + Toolbar, + ToolbarContent, + ToolbarGroup, + ToolbarItem } from '@patternfly/react-core'; - -import { - PageHeader, - PageHeaderTools, - PageHeaderToolsGroup, - PageHeaderToolsItem -} from '@patternfly/react-core/deprecated'; import { DashboardBreadcrumb } from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; -import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg'; +import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; +import imgColorBrand from '@patternfly/react-core/src/demos/examples/pfColorLogo.svg'; import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg'; class PageLayoutHorizontalNav extends React.Component { @@ -419,6 +415,7 @@ class PageLayoutHorizontalNav extends React.Component { this.state = { isDropdownOpen: false, isKebabDropdownOpen: false, + isFullKebabDropdownOpen: false, activeItem: 0 }; @@ -446,6 +443,12 @@ class PageLayoutHorizontalNav extends React.Component { }); }; + this.onFullKebabToggle = () => { + this.setState((prevState) => ({ + isFullKebabDropdownOpen: !prevState.isFullKebabDropdownOpen + })); + }; + this.onNavSelect = (_event, result) => { this.setState({ activeItem: result.itemId @@ -454,7 +457,7 @@ class PageLayoutHorizontalNav extends React.Component { } render() { - const { isDropdownOpen, isKebabDropdownOpen, activeItem } = this.state; + const { isDropdownOpen, isKebabDropdownOpen, isFullKebabDropdownOpen, activeItem } = this.state; const PageNav = (