mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
modify: cut down the component from SideNav component
This commit is contained in:
57
browser/components/StorageItem.js
Normal file
57
browser/components/StorageItem.js
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @fileoverview Micro component for showing storage.
|
||||
*/
|
||||
import React, { PropTypes } from 'react'
|
||||
import styles from './StorageItem.styl'
|
||||
import CSSModules from 'browser/lib/CSSModules'
|
||||
|
||||
/**
|
||||
* @param {boolean} isActive
|
||||
* @param {Function} handleButtonClick
|
||||
* @param {Function} handleContextMenu
|
||||
* @param {string} folderName
|
||||
* @param {string} folderColor
|
||||
* @param {boolean} isFolded
|
||||
* @param {number} noteCount
|
||||
* @return {React.Component}
|
||||
*/
|
||||
const StorageItem = ({
|
||||
isActive, handleButtonClick, handleContextMenu, folderName,
|
||||
folderColor, isFolded, noteCount
|
||||
}) => (
|
||||
<button styleName={isActive
|
||||
? 'folderList-item--active'
|
||||
: 'folderList-item'
|
||||
}
|
||||
onClick={handleButtonClick}
|
||||
onContextMenu={handleContextMenu}
|
||||
>
|
||||
<span styleName={isFolded ?
|
||||
'folderList-item-name--folded' : 'folderList-item-name'
|
||||
}
|
||||
style={{borderColor: folderColor}}
|
||||
>
|
||||
{isFolded ? folderName.substring(0, 1) : folderName}
|
||||
</span>
|
||||
{!isFolded &&
|
||||
<span styleName='folderList-item-noteCount'>{noteCount}</span>
|
||||
}
|
||||
{isFolded &&
|
||||
<span styleName='folderList-item-tooltip'>
|
||||
{folderName}
|
||||
</span>
|
||||
}
|
||||
</button>
|
||||
)
|
||||
|
||||
StorageItem.propTypes = {
|
||||
isActive: PropTypes.bool.isRequired,
|
||||
handleButtonClick: PropTypes.func,
|
||||
handleContextMenu: PropTypes.func,
|
||||
folderName: PropTypes.string.isRequired,
|
||||
folderColor: PropTypes.string,
|
||||
isFolded: PropTypes.bool.isRequired,
|
||||
noteCount: PropTypes.number.isRequired,
|
||||
}
|
||||
|
||||
export default CSSModules(StorageItem, styles)
|
||||
Reference in New Issue
Block a user