From 365d7a1afd133c4479065860db38d0635b850d17 Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Thu, 12 May 2016 19:53:21 +0900 Subject: [PATCH] foldable SideNav --- browser/main/HomePage/SideNav/FolderItem.js | 42 +++++-- browser/main/HomePage/SideNav/FolderItem.styl | 69 ++++++++++- .../HomePage/SideNav/RepositorySection.js | 36 ++++-- .../HomePage/SideNav/RepositorySection.styl | 110 +++++++++++++++++- browser/main/HomePage/SideNav/SideNav.styl | 75 +++++++++--- browser/main/HomePage/SideNav/index.js | 55 ++++++--- browser/main/store.js | 14 +++ browser/styles/index.styl | 18 ++- 8 files changed, 361 insertions(+), 58 deletions(-) diff --git a/browser/main/HomePage/SideNav/FolderItem.js b/browser/main/HomePage/SideNav/FolderItem.js index b91f30d5..6331cf18 100644 --- a/browser/main/HomePage/SideNav/FolderItem.js +++ b/browser/main/HomePage/SideNav/FolderItem.js @@ -54,6 +54,7 @@ class FolderItem extends React.Component { } handleContextButtonClick (e) { + e.stopPropagation() if (this.state.isUpdating) { return } @@ -84,7 +85,7 @@ class FolderItem extends React.Component { click: () => this.handleDeleteButtonClick(e) })) - menu.popup(remote.getCurrentWindow()) + menu.popup(remote.getCurrentWindow(), e.clientX, e.clientY - 44) } handleRenameButtonClick (e) { @@ -124,16 +125,33 @@ class FolderItem extends React.Component { }) } + handleClick (e) { + let { folder, repository } = this.props + let { router } = this.context + + router.push('/repositories/' + repository.key + '/folders/' + folder.key) + } + renderIdle () { - let { folder } = this.props + let { folder, repository, isFolded } = this.props + let { router } = this.context + + let isActive = router.isActive('/repositories/' + repository.key + '/folders/' + folder.key) return ( -
this.handleClick(e)} onContextMenu={(e) => this.handleContextButtonClick(e)} >
- {folder.name} + + {folder.name}
}
} @@ -186,6 +201,10 @@ class RepositorySection extends React.Component { } } +RepositorySection.contextTypes = { + router: PropTypes.object +} + RepositorySection.propTypes = { repository: PropTypes.shape({ name: PropTypes.string, @@ -193,7 +212,8 @@ RepositorySection.propTypes = { name: PropTypes.string })) }), - dispatch: PropTypes.func + dispatch: PropTypes.func, + isFolded: PropTypes.bool } export default CSSModules(RepositorySection, styles) diff --git a/browser/main/HomePage/SideNav/RepositorySection.styl b/browser/main/HomePage/SideNav/RepositorySection.styl index 649bf322..5f50f5cb 100644 --- a/browser/main/HomePage/SideNav/RepositorySection.styl +++ b/browser/main/HomePage/SideNav/RepositorySection.styl @@ -8,10 +8,28 @@ cursor pointer color $nav-inactive-text-color transition 0.15s + border none + width 100% + text-align left + background-color transparent + font-size 14px &:hover background-color $nav-hover-background .header-control-button opacity 1 + &:active, &:active:hover + background-color $nav-active-background + color $nav-text-color + +.header--active + @extend .header + background-color $nav-active-background + color $nav-text-color + .header-control-button + opacity 1 + &:hover + background-color $nav-active-background + color $nav-text-color .header-name position absolute @@ -22,6 +40,9 @@ padding-left 10px line-height 33px +.header-name-label + margin-left 5px + .header-control position absolute top 0 @@ -39,7 +60,7 @@ background-color transparent color $nav-inactive-text-color opacity 0 - transition 0.15s + transition color background-color 0.15s &:hover background-color $nav-hover-background &:active @@ -75,9 +96,94 @@ text-align left color $nav-inactive-text-color background-color transparent - transition 0.15s + transition color background-color 0.15s &:hover background-color $nav-hover-background &:active background-color $nav-active-background color $nav-text-color + +.newFolderButton + height 34px + line-height 34px +.newFolderButton-label + margin-left 0 + +.root-folded + @extend .root + width 44px + .header, .header--active + width 44px + text-align center + overflow hidden + &:hover + .header-name-label + width 134px + padding-left 34px + .header-control + width 35px + padding-right 5px + .header-name + width 44px + padding-left 0 + .header-name-label + position fixed + display inline-block + height 34px + left 44px + width 0 + box-sizing border-box + margin-left 0 + overflow ellipsis + background-color $nav-tooltip-background-color + color white + line-height 34px + border-top-right-radius 5px + border-bottom-right-radius 5px + transition width 0.15s + pointer-events none + .header-control + position fixed + width 0 + height 33px + top inherit + bottom inherit + left 43px + box-sizing border-box + overflow hidden + .header-control-button + display none + .header-control-button--show + float right + background-color $nav-tooltip-button-background + &:hover + background-color $nav-tooltip-button-background--hover + .newFolderButton + width 44px + padding 0 + &:hover .newFolderButton-label + width 100px + .newFolderButton-icon + text-align center + width 44px + .newFolderButton-label + position fixed + display inline-block + height 34px + left 44px + width 0 + box-sizing border-box + margin-left 0 + overflow ellipsis + background-color $nav-tooltip-background-color + color white + line-height 34px + border-top-right-radius 5px + border-bottom-right-radius 5px + transition width 0.15s + pointer-events none + font-size 14px + text-align center + .newFolderForm-nameInput + position fixed + width 100px diff --git a/browser/main/HomePage/SideNav/SideNav.styl b/browser/main/HomePage/SideNav/SideNav.styl index 6b416d1f..c9bd6592 100644 --- a/browser/main/HomePage/SideNav/SideNav.styl +++ b/browser/main/HomePage/SideNav/SideNav.styl @@ -11,39 +11,26 @@ border-bottom solid 1px $nav-border-color .top-menu + navButtonColor() height 59px padding 0 10px font-size 14px width 100% text-align left - border none - color $nav-inactive-text-color - background-color transparent - transition 0.15s - &:hover - background-color $nav-hover-background - &:active - background-color $nav-active-background - color $nav-text-color + +.top-menu-label + margin-left 5px .menu margin-top 15px .menu-button + navButtonColor() height 44px padding 0 10px font-size 14px width 100% text-align left - border none - color $nav-inactive-text-color - background-color transparent - transition 0.15s - &:hover - background-color $nav-hover-background - &:active - background-color $nav-active-background - color $nav-text-color .menu-button--active @extend .menu-button @@ -52,6 +39,9 @@ &:hover background-color $nav-active-background +.menu-button-label + margin-left 5px + .repositoryList absolute left right bottom top 178px @@ -74,10 +64,57 @@ color $nav-inactive-text-color border none background-color transparent - transition 0.15s + transition color background-color 0.15s &:hover background-color $nav-hover-background color $nav-inactive-text-color &:active background-color $nav-active-background color $nav-text-color + +.root-folded + @extend .root + width 44px + .top-menu + width 44px + text-align center + &:hover .top-menu-label + width 100px + .top-menu-label + position fixed + display inline-block + height 34px + left 44px + width 0 + margin-top -5px + margin-left 0 + overflow hidden + background-color $nav-tooltip-background-color + color white + line-height 34px + border-top-right-radius 5px + border-bottom-right-radius 5px + transition width 0.15s + pointer-events none + .menu-button, .menu-button--active + width 44px + text-align center + &:hover .menu-button-label + width 100px + .menu-button-label + position fixed + display inline-block + height 34px + left 44px + width 0 + padding-left 0 + margin-top -9px + margin-left 0 + overflow ellipsis + background-color $nav-tooltip-background-color + color white + line-height 34px + border-top-right-radius 5px + border-bottom-right-radius 5px + transition width 0.15s + pointer-events none diff --git a/browser/main/HomePage/SideNav/index.js b/browser/main/HomePage/SideNav/index.js index 373c1677..dc21d019 100644 --- a/browser/main/HomePage/SideNav/index.js +++ b/browser/main/HomePage/SideNav/index.js @@ -24,7 +24,7 @@ class SideNav extends React.Component { label: 'Mount Repository', click: (e) => this.handleNewRepositoryButtonClick(e) })) - menu.popup(remote.getCurrentWindow()) + menu.popup(remote.getCurrentWindow(), e.clientX, e.clientY - 44) } handleNewRepositoryButtonClick (e) { @@ -45,29 +45,43 @@ class SideNav extends React.Component { router.push('/starred') } - render () { - let { repositories, dispatch, location } = this.props - let repositorieElements = repositories.map((repo) => { - return + handleToggleButtonClick (e) { + let { dispatch } = this.props + + dispatch({ + type: 'TOGGLE_SIDENAV' }) + } + + render () { + let { repositories, dispatch, location, status } = this.props + + let isFolded = !status.sideNavExpand let isHomeActive = location.pathname.match(/^\/home$/) let isStarredActive = location.pathname.match(/^\/starred$/) + let repositorieElements = repositories + .map((repo) => { + return + }) + return (
@@ -75,12 +89,18 @@ class SideNav extends React.Component {
@@ -90,8 +110,13 @@ class SideNav extends React.Component { )}
- ) diff --git a/browser/main/store.js b/browser/main/store.js index 70cb444c..4d16598c 100644 --- a/browser/main/store.js +++ b/browser/main/store.js @@ -110,8 +110,22 @@ function repositories (state = initialRepositories, action) { return state } +const defaultStatus = { + sideNavExpand: false +} + +function status (state = defaultStatus, action) { + switch (action.type) { + case 'TOGGLE_SIDENAV': + state.sideNavExpand = !state.sideNavExpand + return Object.assign({}, state) + } + return state +} + let reducer = combineReducers({ repositories, + status, routing: routerReducer }) diff --git a/browser/styles/index.styl b/browser/styles/index.styl index 24b39ab3..1533e32a 100644 --- a/browser/styles/index.styl +++ b/browser/styles/index.styl @@ -59,9 +59,23 @@ $disabled-input-background = #DDD $nav-text-color = #515151 $nav-inactive-text-color = #939395 $nav-hover-background = rgba(126, 127, 129, 0.08) -$nav-active-background = #E7E7E7 -$nav-border-color = #D1D1D2 +$nav-active-background = alpha(#E0E0E0, 90%) +$nav-border-color = #D1D1D1 $nav-background-color = #FAFAFA +$nav-tooltip-background-color = alpha(#444, 70%) +$nav-tooltip-button-background = #D1D1D1 +$nav-tooltip-button-background--hover = lighten(#D1D1D1, 30%) + +navButtonColor() + border none + color $nav-inactive-text-color + background-color transparent + transition color background-color 0.15s + &:hover + background-color $nav-hover-background + &:active + background-color $nav-active-background + color $nav-text-color /** * # Modal Stuff