1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 10:46:32 +00:00

foldable sidebar

This commit is contained in:
Dick Choi
2016-07-30 19:17:09 +09:00
parent ef866f957a
commit 3b7ed5ffd7
5 changed files with 85 additions and 26 deletions

View File

@@ -100,23 +100,24 @@
width 44px - 1 width 44px - 1
text-align center text-align center
&:hover .menu-button-label &:hover .menu-button-label
width 100px opacity 1
// TODO: extract tooltip style to a mixin // TODO: extract tooltip style to a mixin
.menu-button-label .menu-button-label
position fixed position fixed
display inline-block display inline-block
height 34px height 30px
left 44px left 44px
width 0 padding 0 10px
padding-left 0 margin-top -7px
margin-top -9px
margin-left 0 margin-left 0
overflow ellipsis overflow ellipsis
background-color $ui-tooltip-backgroundColor background-color $ui-tooltip-backgroundColor
z-index 10 z-index 10
color white color white
line-height 34px line-height 34px
border-top-right-radius 5px border-top-right-radius 2px
border-bottom-right-radius 5px border-bottom-right-radius 2px
transition width 0.15s transition opacity 0.15s
pointer-events none pointer-events none
opacity 0
font-size 12px

View File

@@ -31,7 +31,7 @@ class StorageItem extends React.Component {
} }
render () { render () {
let { storage, location } = this.props let { storage, location, isFolded } = this.props
let folderList = storage.folders.map((folder) => { let folderList = storage.folders.map((folder) => {
let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '\/folders\/' + folder.key)) let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '\/folders\/' + folder.key))
return <button styleName={isActive return <button styleName={isActive
@@ -44,15 +44,20 @@ class StorageItem extends React.Component {
<span styleName='folderList-item-name' <span styleName='folderList-item-name'
style={{borderColor: folder.color}} style={{borderColor: folder.color}}
> >
{folder.name} {isFolded ? folder.name.substring(0, 1) : folder.name}
</span> </span>
{isFolded &&
<span styleName='folderList-item-tooltip'>
{folder.name}
</span>
}
</button> </button>
}) })
let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '$')) let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '$'))
return ( return (
<div styleName='root' <div styleName={isFolded ? 'root--folded' : 'root'}
key={storage.key} key={storage.key}
> >
<div styleName={isActive <div styleName={isActive
@@ -72,11 +77,19 @@ class StorageItem extends React.Component {
onClick={(e) => this.handleHeaderInfoClick(e)} onClick={(e) => this.handleHeaderInfoClick(e)}
> >
<span styleName='header-info-name'> <span styleName='header-info-name'>
{storage.name} {isFolded ? storage.name.substring(0, 1) : storage.name}
</span> </span>
<span styleName='header-info-path'> <span styleName='header-info-path'>
({storage.path}) ({storage.path})
</span> </span>
{isFolded &&
<span styleName='header-info--folded-tooltip'>
{storage.name}
<span styleName='header-info--folded-tooltip-path'>
({storage.path})
</span>
</span>
}
</button> </button>
</div> </div>
{this.state.isOpen && {this.state.isOpen &&
@@ -90,6 +103,7 @@ class StorageItem extends React.Component {
} }
StorageItem.propTypes = { StorageItem.propTypes = {
isFolded: PropTypes.bool
} }
export default CSSModules(StorageItem, styles) export default CSSModules(StorageItem, styles)

View File

@@ -55,7 +55,6 @@
.header-info-path .header-info-path
font-size 10px font-size 10px
margin 0 5px margin 0 5px
.folderList-item .folderList-item
display block display block
width 100% width 100%
@@ -67,6 +66,8 @@
text-align left text-align left
border none border none
font-size 14px font-size 14px
&:first-child
margin-top 0
&:hover &:hover
background-color $ui-button--hover-backgroundColor background-color $ui-button--hover-backgroundColor
&:active &:active
@@ -84,6 +85,50 @@
padding 0 10px padding 0 10px
height 30px height 30px
line-height 30px line-height 30px
border-width 0 0 0 4px border-width 0 0 0 6px
border-style solid border-style solid
border-color transparent border-color transparent
.folderList-item-tooltip
tooltip()
position fixed
padding 0 10px
left 44px
z-index 10
pointer-events none
opacity 0
border-top-right-radius 2px
border-bottom-right-radius 2px
height 30px
margin-top -30px
line-height 30px
.root--folded
@extend .root
.header
width 100%
.header-info
overflow ellipsis
padding 0 0 0 18px
&:hover .header-info--folded-tooltip
opacity 1
.header-info-path
display none
.header-toggleButton
width 15px
.header-info--folded-tooltip
tooltip()
position fixed
padding 0 10px
left 44px
z-index 10
pointer-events none
opacity 0
border-top-right-radius 2px
border-bottom-right-radius 2px
.header-info--folded-tooltip-path
font-size 10px
margin 0 5px
.folderList-item:hover, .folderList-item--active:hover
.folderList-item-tooltip
opacity 1
.folderList-item-name
padding-left 14px

View File

@@ -46,6 +46,7 @@ class SideNav extends React.Component {
key={storage.key} key={storage.key}
storage={storage} storage={storage}
location={location} location={location}
isFolded={isFolded}
/> />
}) })
@@ -83,16 +84,14 @@ class SideNav extends React.Component {
<div styleName='storageList-empty'>No storage mount.</div> <div styleName='storageList-empty'>No storage mount.</div>
)} )}
</div> </div>
{false && <button styleName='navToggle'
<button styleName='navToggle' onClick={(e) => this.handleToggleButtonClick(e)}
onClick={(e) => this.handleToggleButtonClick(e)} >
> {isFolded
{isFolded ? <i className='fa fa-angle-double-right'/>
? <i className='fa fa-angle-double-right'/> : <i className='fa fa-angle-double-left'/>
: <i className='fa fa-angle-double-left'/> }
} </button>
</button>
}
</div> </div>
) )
} }

View File

@@ -1,9 +1,9 @@
.root .root
position relative position relative
width 100%
background-color $ui-backgroundColor background-color $ui-backgroundColor
height $topBar-height - 1 height $topBar-height - 1
.root--expanded
@extend .root
$control-height = 34px $control-height = 34px
.control .control