-
Notifications
You must be signed in to change notification settings - Fork 375
feat: Added Tab updates for site Navigation #12111
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
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0dadec6
feat: Added updates for site Navigation
dlabaj 142c8ba
Update packages/react-core/src/components/Tabs/examples/TabsSiteNav.tsx
dlabaj f788a6f
Updated with changes to allow a div to be set when using isNav.
dlabaj 58d388e
Updated the code with feedback from reviews.
dlabaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/react-core/src/components/Tabs/examples/TabsSiteNav.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { useState } from 'react'; | ||
| import { Tabs, Tab, TabTitleText } from '@patternfly/react-core'; | ||
|
|
||
| export const TabsSiteNav: React.FunctionComponent = () => { | ||
| const [activeTabKey, setActiveTabKey] = useState<string | number>(0); | ||
| // Toggle currently active tab | ||
| const handleTabClick = ( | ||
| event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent, | ||
| tabIndex: string | number | ||
| ) => { | ||
| setActiveTabKey(tabIndex); | ||
| }; | ||
| return ( | ||
| <Tabs activeKey={activeTabKey} onSelect={handleTabClick} isNav={true} aria-label="Tabs in the nav element example"> | ||
dlabaj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} href="#users" aria-label="Nav element content users"> | ||
| Users | ||
| </Tab> | ||
| <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>} href="#containers"> | ||
| Containers | ||
| </Tab> | ||
| <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>} href="#database"> | ||
| Database | ||
| </Tab> | ||
| <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled href="#disabled"> | ||
| Disabled | ||
| </Tab> | ||
| <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled href="#aria-disabled"> | ||
| ARIA Disabled | ||
| </Tab> | ||
| <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>} href="#network"> | ||
| Network | ||
| </Tab> | ||
| </Tabs> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@mcoker to get this to work as discussed - where you can override the wrapper element when isNav is true by passing component="div" - we'd have to remove the default value of the component prop from the
defaultPropsand replace it around here. This is because component is defaulted to a div, and if we say "make this element a nav when isNav is true, except when the component is passed div as a value" then that just happens by default so a consumer would also have to passcomponent="nav"Technically everything should remain the same - Tabs will default to a div wrapper as they currently do on Org examples - main thing is that the props table would no longer show the div being the default value in the table cell.
If we still want to allow isNav to dictate the nav modifier class being applied AND the wrapper element defaulting to a nav element, what I did locally was (all in Tabs.tsx file):
const defaultComponent = isNav && !component ? 'nav' : 'div';above theconst Componentline on ~532component === TabsComponent.nav || (isNav && component !== 'div') ? 'nav' : defaultComponent(all this could be cleaned up I'm sure)
Uh oh!
There was an error while loading. Please reload this page.
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.
+1 to let
componentoverride the wrapper even whenisNavis passed in. But can be done in a follow up if the above solution ends up complicated.