1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-23 22:51:42 +00:00

snippet note

This commit is contained in:
Dick Choi
2016-07-21 01:17:53 +09:00
parent 69d11b5cd0
commit b6d34472fe
13 changed files with 890 additions and 96 deletions

View File

@@ -0,0 +1,128 @@
import React, { PropTypes } from 'react'
import CSSModules from 'browser/lib/CSSModules'
import styles from './NewNoteModal.styl'
import dataApi from 'browser/main/lib/dataApi'
import { hashHistory } from 'react-router'
class NewNoteModal extends React.Component {
constructor (props) {
super(props)
this.state = {
}
}
componentDidMount () {
this.refs.markdownButton.focus()
}
handleCloseButtonClick (e) {
this.props.close()
}
handleMarkdownNoteButtonClick (e) {
let { storage, folder, dispatch, location } = this.props
dataApi
.createMarkdownNote(storage, folder, {
title: '',
content: ''
})
.then((note) => {
dispatch({
type: 'CREATE_NOTE',
note: note
})
hashHistory.push({
pathname: location.pathname,
query: {key: note.uniqueKey}
})
this.props.close()
})
}
handleMarkdownNoteButtonKeyDown (e) {
if (e.keyCode === 9) {
e.preventDefault()
this.refs.snippetButton.focus()
}
}
handleSnippetNoteButtonClick (e) {
let { storage, folder, dispatch, location } = this.props
dataApi
.createSnippetNote(storage, folder, {
title: '',
description: '',
snippets: [{
name: '',
mode: 'text',
content: ''
}]
})
.then((note) => {
dispatch({
type: 'CREATE_NOTE',
note: note
})
hashHistory.push({
pathname: location.pathname,
query: {key: note.uniqueKey}
})
this.props.close()
})
}
handleSnippetNoteButtonKeyDown (e) {
if (e.keyCode === 9) {
e.preventDefault()
this.refs.markdownButton.focus()
}
}
render () {
return (
<div styleName='root'>
<div styleName='header'>
<div styleName='title'>New Note</div>
</div>
<button styleName='closeButton'
onClick={(e) => this.handleCloseButtonClick(e)}
>Close</button>
<div styleName='control'>
<button styleName='control-button'
onClick={(e) => this.handleMarkdownNoteButtonClick(e)}
onKeyDown={(e) => this.handleMarkdownNoteButtonKeyDown(e)}
ref='markdownButton'
>
<i styleName='control-button-icon'
className='fa fa-file-text-o'
/><br/>
<span styleName='control-button-label'>Markdown Note</span><br/>
<span styleName='control-button-description'>It is good for any type of documents. Check List, Code block and Latex block are available.</span>
</button>
<button styleName='control-button'
onClick={(e) => this.handleSnippetNoteButtonClick(e)}
onKeyDown={(e) => this.handleSnippetNoteButtonKeyDown(e)}
ref='snippetButton'
>
<i styleName='control-button-icon'
className='fa fa-code'
/><br/>
<span styleName='control-button-label'>Snippet Note</span><br/>
<span styleName='control-button-description'>This format is specialized on managing snippets like Gist. Multiple snippets can be grouped as a note.
</span>
</button>
</div>
<div styleName='description'><i className='fa fa-arrows-h'/> Tab to switch format</div>
</div>
)
}
}
NewNoteModal.propTypes = {
}
export default CSSModules(NewNoteModal, styles)

View File

@@ -0,0 +1,56 @@
.root
modal()
max-width 540px
overflow hidden
position relative
.header
height 50px
font-size 18px
line-height 50px
padding 0 15px
background-color $ui-backgroundColor
border-bottom solid 1px $ui-borderColor
color $ui-text-color
.closeButton
position absolute
top 10px
right 10px
height 30px
width 0 25px
border $ui-border
border-radius 2px
color $ui-text-color
colorDefaultButton()
.control
padding 25px 15px 15px
text-align center
.control-button
width 220px
height 220px
margin 0 15px
border $ui-border
border-radius 5px
color $ui-text-color
colorDefaultButton()
padding 10px
&:focus
colorPrimaryButton()
.control-button-icon
font-size 50px
margin-bottom 15px
.control-button-label
font-size 18px
line-height 32px
.control-button-description
font-size 12px
.description
color $ui-inactive-text-color
text-align center
margin-bottom 25px