From cfeb438af2f0250d88236d9dffeb3a1c0579f328 Mon Sep 17 00:00:00 2001 From: Joey Payne Date: Wed, 2 Mar 2016 08:10:49 -0700 Subject: [PATCH] Add styling changes and beginnings of adding notes Zoom set to 85% since components can't be resized. Added start of functionality to add notes. --- app/components/EntrySelector.jsx | 31 ++++++++++++- app/components/LibraryNav.jsx | 75 +++++++++++++++++--------------- app/utils.jsx | 46 +++++++++++++++++++- main.js | 6 +-- style.css | 3 +- 5 files changed, 118 insertions(+), 43 deletions(-) diff --git a/app/components/EntrySelector.jsx b/app/components/EntrySelector.jsx index 2693688..35c20b7 100644 --- a/app/components/EntrySelector.jsx +++ b/app/components/EntrySelector.jsx @@ -12,6 +12,17 @@ import SelectableList from 'SelectableList' import Item from 'Item' +import uuid from 'node-uuid' +import path from 'path-extra' + +import * as utils from 'utils' +import glob from 'glob' + +import fs from 'fs' +import mkdirp from 'mkdirp' +import jsfile from 'jsonfile' +import rmdir from 'rimraf' + const {AppBar, AppCanvas, FontIcon, @@ -55,6 +66,17 @@ export default class EntrySelector extends React.Component { blank(){ } + + addNoteTapped = () => { + this.createNewNote((note) => { + var notes = this.state.notes + notes.splice(0, 0, note) + this.setState({notes: notes}, () => { + //this.refs['textField0'].focus() + }) + }) + + }; render(){ return ( @@ -65,11 +87,16 @@ export default class EntrySelector extends React.Component { active={false} selected={false} leftIcon={} - rightIconButton={ + rightIconButton={ }> {}} onEnterKeyDown={()=>{}} /> @@ -80,7 +107,7 @@ export default class EntrySelector extends React.Component { ref="entryList" selectedItemStyle={{backgroundColor: colors.grey300}}> } + leftIcon={} primaryText="Today's Notes" secondaryText={

diff --git a/app/components/LibraryNav.jsx b/app/components/LibraryNav.jsx index f89b7d7..2234fc2 100644 --- a/app/components/LibraryNav.jsx +++ b/app/components/LibraryNav.jsx @@ -30,15 +30,6 @@ import rmdir from 'rimraf' const colors = styles.Colors -function eventFire(el, etype){ - if (el.fireEvent) { - el.fireEvent('on' + etype); - } else { - var evObj = document.createEvent('Events'); - evObj.initEvent(etype, true, false); - el.dispatchEvent(evObj); - } -} String.prototype.trunc = String.prototype.trunc || function(n){ return (this.length > n) ? this.substr(0, n-1)+'...' : this; }; @@ -108,7 +99,6 @@ export default class LibraryNav extends React.Component { notebooks: [ ] } - this.sortNotebooks(true) this.getNotebooks() } @@ -134,8 +124,8 @@ export default class LibraryNav extends React.Component { } this.state.notebooks.push(nb) - this.sortNotebooks(true) } + this.sortNotebooks(true) }; compareNotebooks = (a, b) => { @@ -210,17 +200,27 @@ export default class LibraryNav extends React.Component { }; - createNewNotebook = (notebook, callback) => { - var notePath = utils.getNotebookPath(notebook) - mkdirp(notePath, (err) => { + createNewNotebook = (callback) => { + var nbUuid = uuid.v4().toUpperCase() + var nbPath = utils.getNotebookPathFromUUID(nbUuid) + + var nb = { + 'state': 'editing', + 'title': '', + 'uuid': nbUuid, + 'path': nbPath, + 'notes': 0 + } + + mkdirp(nbPath, (err) => { + if (callback){ + callback(nb, err) + } if(err){ console.log('There was an error creating the directory '+notePath) console.log(err) } else{ - if (callback){ - callback() - } this.createNotebookMeta(notebook) } }) @@ -242,7 +242,6 @@ export default class LibraryNav extends React.Component { }; newNotebookUnfocus = (i) => { - var nb = this.state.notebooks[i] var tf = this.refs["textField"+i] @@ -263,23 +262,13 @@ export default class LibraryNav extends React.Component { }; addNotebookTapped = () => { - var nb_uuid = uuid.v4().toUpperCase() - - var nb = { - 'state': 'editing', - 'title': '', - 'uuid': nb_uuid, - 'notes': 0 - } - - this.createNewNotebook(nb, () => { + this.createNewNotebook((nb, err) => { var nbs = this.state.notebooks nbs.splice(0, 0, nb) this.setState({notebooks: nbs}, () => { this.refs['textField0'].focus() }) }) - }; newNotebookTyped = (i) => { @@ -347,6 +336,10 @@ export default class LibraryNav extends React.Component { this.refs.mainList.setIndex(-1) }; + preventEventProp = (ev) => { + ev.stopPropagation(); + }; + notebookList = () => { return (

@@ -359,13 +352,16 @@ export default class LibraryNav extends React.Component { value={i} innerDivStyle={{'paddingBottom': 0, 'paddingTop': 0}} + onTouchTap={this.noteBookTapped.bind(this, i)} leftIcon={} rightIcon={}> + } + style={{padding: 0}} + > + + + } rightIcon={} @@ -397,6 +400,7 @@ export default class LibraryNav extends React.Component { }; notebookIconTapped = (i, ev) => { + ev.stopPropagation() }; render(){ @@ -406,7 +410,7 @@ export default class LibraryNav extends React.Component { ref='mainList' className="list" id="main-nav" - selectedItemStyle={{backgroundColor: "#C8C8C8"}} + selectedItemStyle={{backgroundColor: colors.lightBlue100}} subheader="Library"> {this.state.navItems.map((item, i) => { return
NoteBooks