-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Pivot: render headers only #1438
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
890b261
Pivot: new props headersOnly and getTabId.
a61b260
New example for separate render of pivot content.
587cff4
Describe change.
dc2f3b2
Merge branch 'master' into pivotHeadersOnly
cschleiden f7faae2
Fixed change description to be higher level.
pablonete cb7e9ea
Merge branch 'master' into pivotHeadersOnly
pablonete 94c79b2
Merge branch 'master' into pivotHeadersOnly
christiango ed66d14
Merge branch 'master' into pivotHeadersOnly
pablonete b7983b6
Merge branch 'master' into pivotHeadersOnly
christiango b6d223f
Update Pivot.Separate.Example.tsx
christiango 4c1b45c
Update Pivot.Separate.Example.tsx
christiango 95af888
Update Pivot.Separate.Example.tsx
christiango f480b67
Declare state public. Should fix TSLint error in CI.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "Pivot: Allow rendering PivotItem headers without content.", | ||
| "type": "minor" | ||
| }, | ||
| { | ||
| "comment": "", | ||
| "packageName": "@uifabric/utilities", | ||
| "type": "none" | ||
| }, | ||
| { | ||
| "comment": "", | ||
| "packageName": "@uifabric/example-app-base", | ||
| "type": "none" | ||
| } | ||
| ], | ||
| "email": "v-panu@microsoft.com" | ||
| } |
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
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
46 changes: 46 additions & 0 deletions
46
packages/office-ui-fabric-react/src/components/Pivot/examples/Pivot.Separate.Example.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,46 @@ | ||
| import * as React from 'react'; | ||
| import { Label } from 'office-ui-fabric-react/lib/Label'; | ||
| import { Button } from 'office-ui-fabric-react/lib/Button'; | ||
| import { Pivot, PivotItem } from 'office-ui-fabric-react/lib/Pivot'; | ||
| import { autobind } from 'office-ui-fabric-react/lib/Utilities'; | ||
|
|
||
| export class PivotSeparateExample extends React.Component<any, any> { | ||
| public state = { selectedKey: 'rectangleRed' }; | ||
|
|
||
| public render() { | ||
| return ( | ||
| <div> | ||
| <div | ||
| aria-labelledby={ this._getTabId(this.state.selectedKey) } | ||
| role='tabitem' | ||
| style={ { | ||
| float: 'left', | ||
| width: 100, | ||
| height: this.state.selectedKey === 'squareRed' ? 100 : 200, | ||
| background: this.state.selectedKey === 'rectangleGreen' ? 'green' : 'red' | ||
| } } /> | ||
| <Pivot | ||
| selectedKey={ this.state.selectedKey } | ||
| onLinkClick={ this._handleLinkClick } | ||
| headersOnly={ true } | ||
| getTabId={ this._getTabId }> | ||
| <PivotItem linkText='Rectangle red' itemKey='rectangleRed' /> | ||
| <PivotItem linkText='Square red' itemKey='squareRed' /> | ||
| <PivotItem linkText='Rectangle green' itemKey='rectangleGreen' /> | ||
| </Pivot> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| @autobind | ||
| private _handleLinkClick(item: PivotItem): void { | ||
| this.setState({ | ||
| selectedKey: item.props.itemKey | ||
| }); | ||
| } | ||
|
|
||
| @autobind | ||
| private _getTabId(itemKey: string): string { | ||
| return `ShapeColorPivot_${itemKey}`; | ||
| } | ||
| } |
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.
It feels like ideally we would split the component into a
PivotItemBarthat only rendersPivotItems and aPivotthat usesPivotItemBarto display the header and also shows the body content. Did you think about that?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, I started thinking like you, but then I realized that using the
Pivotwithout content was trivial and I did it with emptyPivotItems successfully.Next we realized we didn't complain with ARIA spec, and that's the goal of this PR.
So my opinion is that we don't need extra complexity, we can just demonstrate with the example how this can be easily achieved.
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.
Do we want to close this up and put a backlog item in for splitting these up? Or is there still work being done on this PR?
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.
This is ready from my side.