Skip to content

Commit 3b7ed5f

Browse files
committed
foldable sidebar
1 parent ef866f9 commit 3b7ed5f

5 files changed

Lines changed: 85 additions & 26 deletions

File tree

browser/main/SideNav/SideNav.styl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,24 @@
100100
width 44px - 1
101101
text-align center
102102
&:hover .menu-button-label
103-
width 100px
103+
opacity 1
104104
// TODO: extract tooltip style to a mixin
105105
.menu-button-label
106106
position fixed
107107
display inline-block
108-
height 34px
108+
height 30px
109109
left 44px
110-
width 0
111-
padding-left 0
112-
margin-top -9px
110+
padding 0 10px
111+
margin-top -7px
113112
margin-left 0
114113
overflow ellipsis
115114
background-color $ui-tooltip-backgroundColor
116115
z-index 10
117116
color white
118117
line-height 34px
119-
border-top-right-radius 5px
120-
border-bottom-right-radius 5px
121-
transition width 0.15s
118+
border-top-right-radius 2px
119+
border-bottom-right-radius 2px
120+
transition opacity 0.15s
122121
pointer-events none
122+
opacity 0
123+
font-size 12px

browser/main/SideNav/StorageItem.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StorageItem extends React.Component {
3131
}
3232

3333
render () {
34-
let { storage, location } = this.props
34+
let { storage, location, isFolded } = this.props
3535
let folderList = storage.folders.map((folder) => {
3636
let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '\/folders\/' + folder.key))
3737
return <button styleName={isActive
@@ -44,15 +44,20 @@ class StorageItem extends React.Component {
4444
<span styleName='folderList-item-name'
4545
style={{borderColor: folder.color}}
4646
>
47-
{folder.name}
47+
{isFolded ? folder.name.substring(0, 1) : folder.name}
4848
</span>
49+
{isFolded &&
50+
<span styleName='folderList-item-tooltip'>
51+
{folder.name}
52+
</span>
53+
}
4954
</button>
5055
})
5156

5257
let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '$'))
5358

5459
return (
55-
<div styleName='root'
60+
<div styleName={isFolded ? 'root--folded' : 'root'}
5661
key={storage.key}
5762
>
5863
<div styleName={isActive
@@ -72,11 +77,19 @@ class StorageItem extends React.Component {
7277
onClick={(e) => this.handleHeaderInfoClick(e)}
7378
>
7479
<span styleName='header-info-name'>
75-
{storage.name}
80+
{isFolded ? storage.name.substring(0, 1) : storage.name}
7681
</span>
7782
<span styleName='header-info-path'>
7883
({storage.path})
7984
</span>
85+
{isFolded &&
86+
<span styleName='header-info--folded-tooltip'>
87+
{storage.name}
88+
<span styleName='header-info--folded-tooltip-path'>
89+
({storage.path})
90+
</span>
91+
</span>
92+
}
8093
</button>
8194
</div>
8295
{this.state.isOpen &&
@@ -90,6 +103,7 @@ class StorageItem extends React.Component {
90103
}
91104

92105
StorageItem.propTypes = {
106+
isFolded: PropTypes.bool
93107
}
94108

95109
export default CSSModules(StorageItem, styles)

browser/main/SideNav/StorageItem.styl

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
.header-info-path
5656
font-size 10px
5757
margin 0 5px
58-
5958
.folderList-item
6059
display block
6160
width 100%
@@ -67,6 +66,8 @@
6766
text-align left
6867
border none
6968
font-size 14px
69+
&:first-child
70+
margin-top 0
7071
&:hover
7172
background-color $ui-button--hover-backgroundColor
7273
&:active
@@ -84,6 +85,50 @@
8485
padding 0 10px
8586
height 30px
8687
line-height 30px
87-
border-width 0 0 0 4px
88+
border-width 0 0 0 6px
8889
border-style solid
8990
border-color transparent
91+
.folderList-item-tooltip
92+
tooltip()
93+
position fixed
94+
padding 0 10px
95+
left 44px
96+
z-index 10
97+
pointer-events none
98+
opacity 0
99+
border-top-right-radius 2px
100+
border-bottom-right-radius 2px
101+
height 30px
102+
margin-top -30px
103+
line-height 30px
104+
.root--folded
105+
@extend .root
106+
.header
107+
width 100%
108+
.header-info
109+
overflow ellipsis
110+
padding 0 0 0 18px
111+
&:hover .header-info--folded-tooltip
112+
opacity 1
113+
.header-info-path
114+
display none
115+
.header-toggleButton
116+
width 15px
117+
.header-info--folded-tooltip
118+
tooltip()
119+
position fixed
120+
padding 0 10px
121+
left 44px
122+
z-index 10
123+
pointer-events none
124+
opacity 0
125+
border-top-right-radius 2px
126+
border-bottom-right-radius 2px
127+
.header-info--folded-tooltip-path
128+
font-size 10px
129+
margin 0 5px
130+
.folderList-item:hover, .folderList-item--active:hover
131+
.folderList-item-tooltip
132+
opacity 1
133+
.folderList-item-name
134+
padding-left 14px

browser/main/SideNav/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SideNav extends React.Component {
4646
key={storage.key}
4747
storage={storage}
4848
location={location}
49+
isFolded={isFolded}
4950
/>
5051
})
5152

@@ -83,16 +84,14 @@ class SideNav extends React.Component {
8384
<div styleName='storageList-empty'>No storage mount.</div>
8485
)}
8586
</div>
86-
{false &&
87-
<button styleName='navToggle'
88-
onClick={(e) => this.handleToggleButtonClick(e)}
89-
>
90-
{isFolded
91-
? <i className='fa fa-angle-double-right'/>
92-
: <i className='fa fa-angle-double-left'/>
93-
}
94-
</button>
95-
}
87+
<button styleName='navToggle'
88+
onClick={(e) => this.handleToggleButtonClick(e)}
89+
>
90+
{isFolded
91+
? <i className='fa fa-angle-double-right'/>
92+
: <i className='fa fa-angle-double-left'/>
93+
}
94+
</button>
9695
</div>
9796
)
9897
}

browser/main/TopBar/TopBar.styl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.root
22
position relative
3-
width 100%
43
background-color $ui-backgroundColor
54
height $topBar-height - 1
6-
5+
.root--expanded
6+
@extend .root
77
$control-height = 34px
88

99
.control

0 commit comments

Comments
 (0)