This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Repository navigation
Create tabbed interface for GitHub features #461
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f57bfea
again
a8f1d09
Implement those tabs :sparkles:
a055aef
Only display github panel if `github.githubEnabled` config is true
60a4b77
:art: per @smashwilson
bb8642e
Style tabs
simurai 364b0f6
Allow TabPanel title to be a node
0bf5a03
Don't copy title prop onto Tab Panel DOM node
39995ed
Change Tab conditional rendering to fix linter format
8d7d094
Display tabs navigation as a segmented button group
99cc35a
Add contrast to labels
simurai 2dc7fb1
Show border also when active
simurai b978b9c
Use variable for corner radius
simurai 3073d62
Use variable for padding
simurai c8cb7a3
Add ellipsis
simurai 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
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 |
|---|---|---|
|
|
@@ -14,11 +14,12 @@ import FilePatchController from './controllers/file-patch-controller'; | |
| import GitController from './controllers/git-controller'; | ||
|
|
||
| export default class GithubPackage { | ||
| constructor(workspace, project, commandRegistry, notificationManager) { | ||
| constructor(workspace, project, commandRegistry, notificationManager, config) { | ||
| this.workspace = workspace; | ||
| this.project = project; | ||
| this.commandRegistry = commandRegistry; | ||
| this.notificationManager = notificationManager; | ||
| this.config = config; | ||
| this.repositoriesAndChangeObserversByProjectPath = new Map(); | ||
| this.activeRepository = null; | ||
| this.subscriptions = new CompositeDisposable(); | ||
|
|
@@ -33,6 +34,7 @@ export default class GithubPackage { | |
| this.subscriptions.add( | ||
| this.project.onDidChangePaths(this.didChangeProjectPaths), | ||
| this.workspace.onDidChangeActivePaneItem(this.didChangeActivePaneItem), | ||
| this.config.onDidChange('github.githubEnabled', this.rerender), | ||
| ); | ||
| if (state.activeRepositoryPath) { | ||
| const repository = await this.getRepositoryForWorkdirPath(state.activeRepositoryPath); | ||
|
|
@@ -51,6 +53,7 @@ export default class GithubPackage { | |
| }; | ||
| } | ||
|
|
||
| @autobind | ||
| rerender() { | ||
| if (!this.element) { | ||
| this.element = document.createElement('div'); | ||
|
|
@@ -69,6 +72,7 @@ export default class GithubPackage { | |
| repository={this.getActiveRepository()} | ||
| statusBar={this.statusBar} | ||
| savedState={this.savedState.gitController} | ||
| githubEnabled={this.config.get('github.githubEnabled')} | ||
|
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. Feature flags ftw ✨ |
||
| />, this.element, | ||
| ); | ||
| } | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import React from 'react'; | ||
| import cx from 'classnames'; | ||
| import {autobind} from 'core-decorators'; | ||
|
|
||
| function getClasses(staticClasses, active) { | ||
| return cx(...staticClasses, { | ||
| inactive: !active, | ||
| active, | ||
| }); | ||
| } | ||
|
|
||
| class TabsNavigationItem extends React.Component { | ||
| static propTypes = { | ||
| title: React.PropTypes.node, | ||
| tabIndex: React.PropTypes.number.isRequired, | ||
| active: React.PropTypes.bool, | ||
| onClick: React.PropTypes.func, | ||
| } | ||
|
|
||
| render() { | ||
| const classes = getClasses(['github-Tabs-NavigationItem'], this.props.active); | ||
| return ( | ||
| <div className={classes} onClick={this.handleClick}> | ||
| {this.props.title} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| @autobind | ||
| handleClick() { | ||
| this.props.onClick(this.props.tabIndex); | ||
| } | ||
| } | ||
|
|
||
| export default class Tabs extends React.Component { | ||
| static propTypes = { | ||
| className: React.PropTypes.string, | ||
| activeIndex: React.PropTypes.number.isRequired, | ||
| children: React.PropTypes.node, | ||
| onChange: React.PropTypes.func, | ||
| } | ||
|
|
||
| static defaultProps = { | ||
| className: '', | ||
| onChange: () => {}, | ||
| } | ||
|
|
||
| render() { | ||
| const children = React.Children.toArray(this.props.children).filter(v => !!v); | ||
| return ( | ||
| <div className={cx('github-Tabs', this.props.className)} data-tabs-count={children.length}> | ||
| <nav className="github-Tabs-NavigationContainer"> | ||
| {children.map((child, i) => child && ( | ||
| <TabsNavigationItem | ||
| key={i} | ||
| title={child.props.title} | ||
| active={this.props.activeIndex === i} | ||
| tabIndex={i} | ||
| onClick={this.props.onChange} | ||
| /> | ||
| ))} | ||
| </nav> | ||
| <section className="github-Tabs-PanelContainer"> | ||
| {children.map((child, i) => child && ( | ||
| React.cloneElement(child, {active: i === this.props.activeIndex}) | ||
| ))} | ||
| </section> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Tabs.Panel = class TabPanel extends React.Component { | ||
| static propTypes = { | ||
| className: React.PropTypes.string, | ||
| active: React.PropTypes.bool, | ||
| children: React.PropTypes.node, | ||
| title: React.PropTypes.node, | ||
| } | ||
|
|
||
| static defaultProps = { | ||
| className: '', | ||
| active: false, | ||
| } | ||
|
|
||
| render() { | ||
| // eslint-disable-next-line no-unused-vars | ||
| const {active, children, className, title, ...others} = this.props; | ||
| return ( | ||
| <div className={getClasses(['github-Tabs-Panel', className], this.props.active)} {...others}> | ||
| {this.props.children} | ||
| </div> | ||
| ); | ||
| } | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| @import "variables"; | ||
|
|
||
| // General Styles | ||
| .github-Tabs { | ||
| &-Panel { | ||
| &.active { | ||
| display: block; | ||
| } | ||
|
|
||
| &.inactive { | ||
| display: none; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // App-specific styles | ||
| .github-Tabs.sidebar-tabs { | ||
| height: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
|
|
||
| .github-Tabs-NavigationContainer { | ||
| display: flex; | ||
| flex-direction: row; | ||
| padding: @component-padding; | ||
|
|
||
| .github-Tabs-NavigationItem { | ||
| flex: 1; | ||
| text-align: center; | ||
| cursor: pointer; | ||
| background-color: @button-background-color; | ||
| color: contrast(@button-background-color, hsla(0,0%,0%,.6), hsla(0,0%,100%,.6)); | ||
| border: 1px solid @button-border-color; | ||
| padding: .25em .5em; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| white-space: nowrap; | ||
|
|
||
| & + .github-Tabs-NavigationItem { | ||
| border-left: none; | ||
| } | ||
|
|
||
| &.active { | ||
| background-color: @button-background-color-selected; | ||
| color: contrast(@button-background-color-selected, hsla(0,0%,0%,1), hsla(0,0%,100%,1)); | ||
| } | ||
|
|
||
| &:first-child { | ||
| border-top-left-radius: @component-border-radius; | ||
| border-bottom-left-radius: @component-border-radius; | ||
| } | ||
|
|
||
| &:last-child { | ||
| border-top-right-radius: @component-border-radius; | ||
| border-bottom-right-radius: @component-border-radius; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| &[data-tabs-count="1"] { | ||
| .github-Tabs-NavigationContainer { | ||
| display: none; | ||
| } | ||
| } | ||
|
|
||
| .github-Tabs-PanelContainer { | ||
| flex: 1; | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .github-Tabs-Panel { | ||
| flex: 1; | ||
|
|
||
| &.active { | ||
| } | ||
|
|
||
| &.inactive { | ||
| } | ||
| } | ||
| } |
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
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.
Hee hee, I still think that's great.
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.
Ya, let's leave it for a bit longer. 😂