diff --git a/packages/react-core/src/components/Button/Button.tsx b/packages/react-core/src/components/Button/Button.tsx index 86b40f66826..7a4ec1d3daf 100644 --- a/packages/react-core/src/components/Button/Button.tsx +++ b/packages/react-core/src/components/Button/Button.tsx @@ -6,7 +6,7 @@ import { useOUIAProps, OUIAProps } from '../../helpers/OUIA/ouia'; import { Badge } from '../Badge'; import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon'; import OutlinedStarIcon from '@patternfly/react-icons/dist/esm/icons/outlined-star-icon'; -import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; +import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon'; import { hamburgerIcon } from './hamburgerIcon'; export enum ButtonVariant { @@ -109,6 +109,10 @@ export interface ButtonProps extends Omit, 'r hamburgerVariant?: 'expand' | 'collapse'; /** @beta Flag indicating the button is a circle button. Intended for buttons that only contain an icon.. */ isCircle?: boolean; + /** @beta Flag indicating the button is a dock variant button. For use in docked navigation. */ + isDock?: boolean; + /** @beta Flag indicating the dock button should display text. Only applies when isDock is true. */ + isTextExpanded?: boolean; /** @hide Forwarded ref */ innerRef?: React.Ref; /** Adds count number to button */ @@ -134,6 +138,8 @@ const ButtonBase: React.FunctionComponent = ({ isHamburger, hamburgerVariant, isCircle, + isDock = false, + isTextExpanded = false, spinnerAriaValueText, spinnerAriaLabelledBy, spinnerAriaLabel, @@ -215,7 +221,7 @@ const ButtonBase: React.FunctionComponent = ({ } if (isSettings) { - iconContent = ; + iconContent = ; } if (isHamburger) { iconContent = hamburgerIcon; @@ -265,6 +271,8 @@ const ButtonBase: React.FunctionComponent = ({ size === ButtonSize.sm && styles.modifiers.small, size === ButtonSize.lg && styles.modifiers.displayLg, isCircle && styles.modifiers.circle, + isDock && styles.modifiers.dock, + isTextExpanded && styles.modifiers.textExpanded, className )} disabled={isButtonElement ? isDisabled : null} diff --git a/packages/react-core/src/components/Button/__tests__/Button.test.tsx b/packages/react-core/src/components/Button/__tests__/Button.test.tsx index 2c6ec2bf4a6..d4425f53840 100644 --- a/packages/react-core/src/components/Button/__tests__/Button.test.tsx +++ b/packages/react-core/src/components/Button/__tests__/Button.test.tsx @@ -555,6 +555,28 @@ describe('Favorite button', () => { }); }); +describe('Dock variant', () => { + test(`Renders with class ${styles.modifiers.dock} when isDock = true`, () => { + render(); + expect(screen.getByRole('button')).toHaveClass(styles.modifiers.dock); + }); + + test(`Does not render with class ${styles.modifiers.dock} when isDock is not passed`, () => { + render(); + expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers.dock); + }); + + test(`Renders with class ${styles.modifiers.textExpanded} when isTextExpanded = true`, () => { + render(); + expect(screen.getByRole('button')).toHaveClass(styles.modifiers.textExpanded); + }); + + test(`Does not render with class ${styles.modifiers.textExpanded} when isTextExpanded is not passed`, () => { + render(); + expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers.textExpanded); + }); +}); + test(`Renders basic button`, () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); diff --git a/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap b/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap index d9ce0770e4a..4385859a719 100644 --- a/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +++ b/packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap @@ -5,7 +5,7 @@ exports[`Renders basic button 1`] = ` + ) : ( - - - + )} + + + {isDockTextExpanded ? ( + } + isDock + isTextExpanded={isDockTextExpanded} + aria-label="Help" + > + Help + + ) : ( -