mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
refactor: cut down the component from SideNav component
This commit is contained in:
41
browser/components/SideNavFilter.js
Normal file
41
browser/components/SideNavFilter.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* @fileoverview Filter for all notes.
|
||||||
|
*/
|
||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import styles from './SideNavFilter.styl'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} isHomeActive
|
||||||
|
* @param {Function} handleAllNotesButtonClick
|
||||||
|
* @param {boolean} isStarredActive
|
||||||
|
* @param {Function} handleStarredButtonClick
|
||||||
|
* @return {React.Component}
|
||||||
|
*/
|
||||||
|
const SideNavFilter = ({
|
||||||
|
isHomeActive, handleAllNotesButtonClick, isStarredActive, handleStarredButtonClick
|
||||||
|
}) => (
|
||||||
|
<div styleName='menu'>
|
||||||
|
<button styleName={isHomeActive ? 'menu-button--active' : 'menu-button'}
|
||||||
|
onClick={handleAllNotesButtonClick}
|
||||||
|
>
|
||||||
|
<i className='fa fa-book fa-fw'/>
|
||||||
|
<span styleName='menu-button-label'>All Notes</span>
|
||||||
|
</button>
|
||||||
|
<button styleName={isStarredActive ? 'menu-button--active' : 'menu-button'}
|
||||||
|
onClick={handleStarredButtonClick}
|
||||||
|
>
|
||||||
|
<i className='fa fa-star fa-fw'/>
|
||||||
|
<span styleName='menu-button-label'>Starred</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
SideNavFilter.propTypes = {
|
||||||
|
isHomeActive: PropTypes.bool.isRequired,
|
||||||
|
handleAllNotesButtonClick: PropTypes.func.isRequired,
|
||||||
|
isStarredActive: PropTypes.bool.isRequired,
|
||||||
|
handleStarredButtonClick: PropTypes.func.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(SideNavFilter, styles)
|
||||||
32
browser/components/SideNavFilter.styl
Normal file
32
browser/components/SideNavFilter.styl
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
.menu
|
||||||
|
margin-bottom 30px
|
||||||
|
|
||||||
|
.menu-button
|
||||||
|
navButtonColor()
|
||||||
|
height 32px
|
||||||
|
padding 0 15px
|
||||||
|
font-size 14px
|
||||||
|
width 100%
|
||||||
|
text-align left
|
||||||
|
overflow ellipsis
|
||||||
|
|
||||||
|
.menu-button--active
|
||||||
|
@extend .menu-button
|
||||||
|
background-color $ui-button--active-backgroundColor
|
||||||
|
color $ui-button--active-color
|
||||||
|
&:hover
|
||||||
|
background-color $ui-button--active-backgroundColor
|
||||||
|
|
||||||
|
.menu-button-label
|
||||||
|
margin-left 5px
|
||||||
|
|
||||||
|
body[data-theme="dark"]
|
||||||
|
.menu-button
|
||||||
|
navDarkButtonColor()
|
||||||
|
|
||||||
|
.menu-button--active
|
||||||
|
@extend .menu-button
|
||||||
|
background-color $ui-dark-button--active-backgroundColor
|
||||||
|
color $ui-dark-button--active-color
|
||||||
|
&:hover
|
||||||
|
background-color $ui-dark-button--active-backgroundColor
|
||||||
@@ -20,28 +20,6 @@
|
|||||||
margin-left 5px
|
margin-left 5px
|
||||||
overflow ellipsis
|
overflow ellipsis
|
||||||
|
|
||||||
.menu
|
|
||||||
margin-bottom 30px
|
|
||||||
|
|
||||||
.menu-button
|
|
||||||
navButtonColor()
|
|
||||||
height 32px
|
|
||||||
padding 0 15px
|
|
||||||
font-size 14px
|
|
||||||
width 100%
|
|
||||||
text-align left
|
|
||||||
overflow ellipsis
|
|
||||||
|
|
||||||
.menu-button--active
|
|
||||||
@extend .menu-button
|
|
||||||
background-color $ui-button--active-backgroundColor
|
|
||||||
color $ui-button--active-color
|
|
||||||
&:hover
|
|
||||||
background-color $ui-button--active-backgroundColor
|
|
||||||
|
|
||||||
.menu-button-label
|
|
||||||
margin-left 5px
|
|
||||||
|
|
||||||
.storageList
|
.storageList
|
||||||
absolute left right
|
absolute left right
|
||||||
overflow-y auto
|
overflow-y auto
|
||||||
@@ -131,16 +109,6 @@ body[data-theme="dark"]
|
|||||||
.top-menu
|
.top-menu
|
||||||
navDarkButtonColor()
|
navDarkButtonColor()
|
||||||
|
|
||||||
.menu-button
|
|
||||||
navDarkButtonColor()
|
|
||||||
|
|
||||||
.menu-button--active
|
|
||||||
@extend .menu-button
|
|
||||||
background-color $ui-dark-button--active-backgroundColor
|
|
||||||
color $ui-dark-button--active-color
|
|
||||||
&:hover
|
|
||||||
background-color $ui-dark-button--active-backgroundColor
|
|
||||||
|
|
||||||
.storageList-empty
|
.storageList-empty
|
||||||
color $ui-dark-inactive-text-color
|
color $ui-dark-inactive-text-color
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { openModal } from 'browser/main/lib/modal'
|
|||||||
import PreferencesModal from '../modals/PreferencesModal'
|
import PreferencesModal from '../modals/PreferencesModal'
|
||||||
import ConfigManager from 'browser/main/lib/ConfigManager'
|
import ConfigManager from 'browser/main/lib/ConfigManager'
|
||||||
import StorageItem from './StorageItem'
|
import StorageItem from './StorageItem'
|
||||||
|
import SideNavFilter from 'browser/components/SideNavFilter'
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { remote } = electron
|
const { remote } = electron
|
||||||
@@ -39,8 +40,8 @@ class SideNav extends React.Component {
|
|||||||
let { data, location, config, dispatch } = this.props
|
let { data, location, config, dispatch } = this.props
|
||||||
|
|
||||||
let isFolded = config.isSideNavFolded
|
let isFolded = config.isSideNavFolded
|
||||||
let isHomeActive = location.pathname.match(/^\/home$/)
|
let isHomeActive = !!location.pathname.match(/^\/home$/)
|
||||||
let isStarredActive = location.pathname.match(/^\/starred$/)
|
let isStarredActive = !!location.pathname.match(/^\/starred$/)
|
||||||
|
|
||||||
let storageList = data.storageMap.map((storage, key) => {
|
let storageList = data.storageMap.map((storage, key) => {
|
||||||
return <StorageItem
|
return <StorageItem
|
||||||
@@ -69,20 +70,12 @@ class SideNav extends React.Component {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div styleName='menu'>
|
<SideNavFilter
|
||||||
<button styleName={isHomeActive ? 'menu-button--active' : 'menu-button'}
|
isHomeActive={isHomeActive}
|
||||||
onClick={(e) => this.handleHomeButtonClick(e)}
|
handleAllNotesButtonClick={(e) => this.handleHomeButtonClick(e)}
|
||||||
>
|
isStarredActive={isStarredActive}
|
||||||
<i className='fa fa-book fa-fw'/>
|
handleStarredButtonClick={(e) => this.handleStarredButtonClick(e)}
|
||||||
<span styleName='menu-button-label'>All Notes</span>
|
/>
|
||||||
</button>
|
|
||||||
<button styleName={isStarredActive ? 'menu-button--active' : 'menu-button'}
|
|
||||||
onClick={(e) => this.handleStarredButtonClick(e)}
|
|
||||||
>
|
|
||||||
<i className='fa fa-star fa-fw'/>
|
|
||||||
<span styleName='menu-button-label'>Starred</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div styleName='storageList'>
|
<div styleName='storageList'>
|
||||||
{storageList.length > 0 ? storageList : (
|
{storageList.length > 0 ? storageList : (
|
||||||
|
|||||||
Reference in New Issue
Block a user