-
Notifications
You must be signed in to change notification settings - Fork 381
feat(Page): added responsive docked nav #12327
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
base: main
Are you sure you want to change the base?
Changes from all commits
10b8bcd
ac33466
bf172d0
83597fb
0b95e21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -555,6 +555,28 @@ describe('Favorite button', () => { | |
| }); | ||
| }); | ||
|
|
||
| describe('Dock variant', () => { | ||
| test(`Renders with class ${styles.modifiers.dock} when isDock = true`, () => { | ||
| render(<Button isDock>Dock Button</Button>); | ||
| expect(screen.getByRole('button')).toHaveClass(styles.modifiers.dock); | ||
| }); | ||
|
|
||
| test(`Does not render with class ${styles.modifiers.dock} when isDock is not passed`, () => { | ||
| render(<Button>Button</Button>); | ||
| expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers.dock); | ||
| }); | ||
|
|
||
| test(`Renders with class ${styles.modifiers.textExpanded} when isTextExpanded = true`, () => { | ||
| render(<Button isTextExpanded>Text Expanded Button</Button>); | ||
| expect(screen.getByRole('button')).toHaveClass(styles.modifiers.textExpanded); | ||
| }); | ||
|
|
||
| test(`Does not render with class ${styles.modifiers.textExpanded} when isTextExpanded is not passed`, () => { | ||
| render(<Button>Button</Button>); | ||
| expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers.textExpanded); | ||
| }); | ||
|
Comment on lines
+569
to
+577
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align This case currently verifies Suggested test adjustment- test(`Renders with class ${styles.modifiers.textExpanded} when isTextExpanded = true`, () => {
- render(<Button isTextExpanded>Text Expanded Button</Button>);
+ test(`Renders with class ${styles.modifiers.textExpanded} when isDock and isTextExpanded are true`, () => {
+ render(<Button isDock isTextExpanded>Text Expanded Button</Button>);
expect(screen.getByRole('button')).toHaveClass(styles.modifiers.textExpanded);
});
- test(`Does not render with class ${styles.modifiers.textExpanded} when isTextExpanded is not passed`, () => {
- render(<Button>Button</Button>);
+ test(`Does not render with class ${styles.modifiers.textExpanded} when isDock is true and isTextExpanded is not passed`, () => {
+ render(<Button isDock>Button</Button>);
expect(screen.getByRole('button')).not.toHaveClass(styles.modifiers.textExpanded);
});🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mcoker is the expectation that we only allow consumers to render the pf-m-text-expanded class only for dock variant buttons/nav/etc? Right now the various components that have both a pf-m-dock and pf-m-text-expanded class, either modifier can be applied independently (you don't need isDock in order to render the class from isTextExpanded) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }); | ||
|
|
||
| test(`Renders basic button`, () => { | ||
| const { asFragment } = render(<Button aria-label="basic button">Basic Button</Button>); | ||
| expect(asFragment()).toMatchSnapshot(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,10 @@ export interface MenuToggleProps | |
| isCircle?: boolean; | ||
| /** Flag indicating whether the toggle is a settings toggle. This will override the icon property */ | ||
| isSettings?: boolean; | ||
| /** @beta Flag indicating the toggle is a dock variant. For use in docked navigation. */ | ||
| isDock?: boolean; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here with |
||
| /** @beta Flag indicating the dock toggle should display text. Only applies when isDock is true. */ | ||
| isTextExpanded?: boolean; | ||
| /** Elements to display before the toggle button. When included, renders the menu toggle as a split button. */ | ||
| splitButtonItems?: React.ReactNode[]; | ||
| /** Variant styles of the menu toggle */ | ||
|
|
@@ -85,6 +89,8 @@ class MenuToggleBase extends Component<MenuToggleProps> { | |
| isFullHeight: false, | ||
| isPlaceholder: false, | ||
| isCircle: false, | ||
| isDock: false, | ||
| isTextExpanded: false, | ||
| size: 'default', | ||
| ouiaSafe: true | ||
| }; | ||
|
|
@@ -102,6 +108,8 @@ class MenuToggleBase extends Component<MenuToggleProps> { | |
| isPlaceholder, | ||
| isCircle, | ||
| isSettings, | ||
| isDock, | ||
| isTextExpanded, | ||
| splitButtonItems, | ||
| variant, | ||
| status, | ||
|
|
@@ -185,6 +193,8 @@ class MenuToggleBase extends Component<MenuToggleProps> { | |
| isDisabled && styles.modifiers.disabled, | ||
| isPlaceholder && styles.modifiers.placeholder, | ||
| isSettings && styles.modifiers.settings, | ||
| isDock && styles.modifiers.dock, | ||
| isTextExpanded && styles.modifiers.textExpanded, | ||
| size === MenuToggleSize.sm && styles.modifiers.small, | ||
| className | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -274,4 +274,34 @@ describe('Nav', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByTestId('docked-nav')).toHaveClass(styles.modifiers.docked); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test(`Renders with ${styles.modifiers.textExpanded} class when isTextExpanded is true`, () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| renderNav( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Nav isTextExpanded data-testid="text-expanded-nav"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NavList> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {props.items.map((item) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NavItem to={item.to} key={item.to}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {item.label} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </NavItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </NavList> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Nav> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByTestId('text-expanded-nav')).toHaveClass(styles.modifiers.textExpanded); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test(`Does not render with ${styles.modifiers.textExpanded} class when isTextExpanded is not passed`, () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| renderNav( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Nav data-testid="nav"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NavList> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {props.items.map((item) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NavItem to={item.to} key={item.to}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {item.label} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </NavItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </NavList> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Nav> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByTestId('nav')).not.toHaveClass(styles.modifiers.textExpanded); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+278
to
+306
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These tests currently validate Suggested test correction- test(`Renders with ${styles.modifiers.textExpanded} class when isTextExpanded is true`, () => {
+ test(`Renders with ${styles.modifiers.textExpanded} class when variant is docked and isTextExpanded is true`, () => {
renderNav(
- <Nav isTextExpanded data-testid="text-expanded-nav">
+ <Nav variant="docked" isTextExpanded data-testid="text-expanded-nav">
<NavList>
{props.items.map((item) => (
<NavItem to={item.to} key={item.to}>
{item.label}
</NavItem>
))}
</NavList>
</Nav>
);
expect(screen.getByTestId('text-expanded-nav')).toHaveClass(styles.modifiers.textExpanded);
});
- test(`Does not render with ${styles.modifiers.textExpanded} class when isTextExpanded is not passed`, () => {
+ test(`Does not render with ${styles.modifiers.textExpanded} class when variant is docked and isTextExpanded is not passed`, () => {
renderNav(
- <Nav data-testid="nav">
+ <Nav variant="docked" data-testid="nav">
<NavList>
{props.items.map((item) => (
<NavItem to={item.to} key={item.to}>
{item.label}
</NavItem>
))}
</NavList>
</Nav>
);
expect(screen.getByTestId('nav')).not.toHaveClass(styles.modifiers.textExpanded);
});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
isDockedorisInDockmaybe?