-
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
+50
−2
Merged
Changes from 3 commits
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
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
| 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="Site navigation with nav styling example" | ||
| > | ||
| <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.
532's logic is a little confusing to me, would this be equivalent and slightly cleaner?
const Component: any = component !== undefined ? component : defaultComponent;Because
defaultComponentis already set to "nav" for isNav and "div" otherwise, and if TabsComponent.nav is passed in that's should already be setting it to "nav".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.
Yep that's the part re "this could be cleaned up Im sure" 😆 Using the logic you mention does work the same so using that would be better