|
1 | | -# Small notes application using Plain Js |
| 1 | +# Notes app using plain javascript |
2 | 2 |
|
3 | | -## Installation |
| 3 | +### Install in your project |
| 4 | +``` |
| 5 | +npm install @thecodeholic/plainjs-notes |
| 6 | +``` |
| 7 | + |
| 8 | +### Usage |
| 9 | +```javascript 1.8 |
| 10 | +const noteManager = new NoteManager({ |
| 11 | + el: document.getElementById('your_wrapper_element_id'), |
| 12 | + notes: [ |
| 13 | + { |
| 14 | + title: 'sunt aut facere repellat', |
| 15 | + body: 'uia et suscipit suscipit recusandae consequuntur expedita et cum reprehenderit molestiae ut ut quas totam nostrum rerum est autem sunt rem eveniet architecto' |
| 16 | + }, |
| 17 | + // ... |
| 18 | + ] |
| 19 | +}); |
| 20 | +``` |
| 21 | + |
| 22 | +### Methods |
| 23 | + |
| 24 | +```javascript 1.8 |
| 25 | +// Add the note at the bottom |
| 26 | +noteManager.addNote({ |
| 27 | + title: '', |
| 28 | + body: '' |
| 29 | +}); |
| 30 | + |
| 31 | +// Add the note at the top |
| 32 | +noteManager.prependNote({ |
| 33 | + title: '', |
| 34 | + body: '' |
| 35 | +}); |
| 36 | + |
| 37 | +// Remove the first note |
| 38 | +noteManager.removeNote(noteManager.notes[0]); |
| 39 | + |
| 40 | +// Update all notes and rerender |
| 41 | +noteManager.notes = [...]; |
| 42 | +noteManager.renderNotes(); |
| 43 | +``` |
| 44 | + |
| 45 | +### Events |
| 46 | + |
| 47 | +```javascript 1.8 |
| 48 | +noteManager.onNoteAdd = (note) => { |
| 49 | + console.log("Note added ", note); |
| 50 | +}; |
| 51 | +noteManager.onNoteChange = (note) => { |
| 52 | + console.log("Note changed ", note); |
| 53 | +}; |
| 54 | +noteManager.onNoteRemove = (note) => { |
| 55 | + console.log("Note removed ", note); |
| 56 | +}; |
| 57 | +``` |
| 58 | + |
| 59 | +------------------------------------------------- |
| 60 | + |
| 61 | + |
| 62 | +### Installation and view demo |
4 | 63 | 1. Clone the project |
5 | 64 | 2. Go to the project root directory |
6 | 65 | 3. Run `npm install` |
7 | 66 |
|
8 | | -## Running on development using [dev server](https://github.com/webpack/webpack-dev-server) |
| 67 | +### Running on development using [dev server](https://github.com/webpack/webpack-dev-server) |
9 | 68 |
|
10 | 69 | Run `npm run start` to start to webpack dev server with HMR ready |
11 | 70 |
|
12 | | -## For production |
| 71 | +### Build For production |
13 | 72 |
|
14 | 73 | Run `npm run build` to build project's all assets in `dist` folder. |
0 commit comments