1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

refactor: replace component with common component

This commit is contained in:
sota1235
2016-12-30 19:00:39 +09:00
parent e9a9e10c81
commit d65464401c
2 changed files with 15 additions and 85 deletions

View File

@@ -6,6 +6,7 @@ import modal from 'browser/main/lib/modal'
import CreateFolderModal from 'browser/main/modals/CreateFolderModal' import CreateFolderModal from 'browser/main/modals/CreateFolderModal'
import RenameFolderModal from 'browser/main/modals/RenameFolderModal' import RenameFolderModal from 'browser/main/modals/RenameFolderModal'
import dataApi from 'browser/main/lib/dataApi' import dataApi from 'browser/main/lib/dataApi'
import StorageItemChild from 'browser/components/StorageItem'
const { remote } = require('electron') const { remote } = require('electron')
const { Menu, MenuItem, dialog } = remote const { Menu, MenuItem, dialog } = remote
@@ -134,34 +135,24 @@ class StorageItem extends React.Component {
let { storage, location, isFolded, data } = this.props let { storage, location, isFolded, data } = this.props
let { folderNoteMap } = data let { folderNoteMap } = data
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)))
let noteSet = folderNoteMap.get(storage.key + '-' + folder.key) let noteSet = folderNoteMap.get(storage.key + '-' + folder.key)
let noteCount = noteSet != null let noteCount = noteSet != null
? noteSet.size ? noteSet.size
: 0 : 0
return <button styleName={isActive return (
? 'folderList-item--active' <StorageItemChild
: 'folderList-item' key={folder.key}
} isActive={isActive}
key={folder.key} handleButtonClick={(e) => this.handleFolderButtonClick(folder.key)(e)}
onClick={(e) => this.handleFolderButtonClick(folder.key)(e)} handleContextMenu={(e) => this.handleFolderButtonContextMenu(e, folder)}
onContextMenu={(e) => this.handleFolderButtonContextMenu(e, folder)} folderName={folder.name}
> folderColor={folder.color}
<span styleName='folderList-item-name' isFolded={isFolded}
style={{borderColor: folder.color}} noteCount={noteCount}
> />
{isFolded ? folder.name.substring(0, 1) : folder.name} )
</span>
{!isFolded &&
<span styleName='folderList-item-noteCount'>{noteCount}</span>
}
{isFolded &&
<span styleName='folderList-item-tooltip'>
{folder.name}
</span>
}
</button>
}) })
let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '$')) let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '$'))

View File

@@ -80,63 +80,6 @@
&:active &:active
color $ui-active-color color $ui-active-color
.folderList-item
display flex
width 100%
height 26px
background-color transparent
color $ui-inactive-text-color
padding 0
margin-bottom 5px
text-align left
border none
overflow ellipsis
font-size 14px
&:first-child
margin-top 0
&:hover
background-color $ui-button--hover-backgroundColor
&:active
color $ui-button--active-color
background-color $ui-button--active-backgroundColor
.folderList-item--active
@extend .folderList-item
color $ui-button--active-color
background-color $ui-button--active-backgroundColor
&:hover
color $ui-button--active-color
background-color $ui-button--active-backgroundColor
.folderList-item-name
display block
flex 1
padding 0 30px
height 26px
line-height 26px
border-width 0 0 0 3px
border-style solid
border-color transparent
.folderList-item-noteCount
float right
line-height 26px
padding-right 5px
font-size 12px
.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 26px
line-height 26px
.root--folded .root--folded
@extend .root @extend .root
.header .header
@@ -163,11 +106,7 @@
.header-info--folded-tooltip-path .header-info--folded-tooltip-path
font-size 10px font-size 10px
margin 0 5px margin 0 5px
.folderList-item:hover, .folderList-item--active:hover
.folderList-item-tooltip
opacity 1
.folderList-item-name
padding-left 14px
body[data-theme="dark"] body[data-theme="dark"]
.header-toggleButton .header-toggleButton
.header-addFolderButton .header-addFolderButton