Skip to content

Commit fdf94a9

Browse files
committed
Update readme
1 parent 721d58b commit fdf94a9

File tree

4 files changed

+81
-37
lines changed

4 files changed

+81
-37
lines changed

README.md

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,73 @@
1-
# Small notes application using Plain Js
1+
# Notes app using plain javascript
22

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
463
1. Clone the project
564
2. Go to the project root directory
665
3. Run `npm install`
766

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)
968

1069
Run `npm run start` to start to webpack dev server with HMR ready
1170

12-
## For production
71+
### Build For production
1372

1473
Run `npm run build` to build project's all assets in `dist` folder.

demo/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ const noteManager = new NoteManager({
2828
});
2929

3030
noteManager.onNoteAdd = (note) => {
31-
console.log("Note added", note);
31+
console.log("Note added ", note);
3232
};
3333
noteManager.onNoteChange = (note) => {
34-
console.log("Note changed", note);
34+
console.log("Note changed ", note);
3535
};
3636
noteManager.onNoteRemove = (note) => {
3737
console.log("Note removed ", note);

package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "webpack-babel-demo",
2+
"name": "@thecodeholic/plainjs-notes",
33
"version": "1.0.0",
4-
"description": "",
4+
"description": "Notes app using vanilla javascript",
55
"main": "index.js",
66
"scripts": {
77
"build": "npx webpack --config webpack.config.prod.js --mode=production",
88
"watch": "npx webpack --watch",
99
"start": "webpack-dev-server"
1010
},
11-
"author": "",
12-
"license": "ISC",
11+
"author": "Zura Sekhniashvili <zurasekhniashvili@gmail.com>",
12+
"license": "MIT",
1313
"devDependencies": {
1414
"@babel/core": "^7.2.2",
1515
"@babel/preset-env": "^7.2.3",
@@ -28,5 +28,14 @@
2828
"webpack-cli": "^3.2.0",
2929
"webpack-dev-server": "^3.1.14",
3030
"tar": ">=2.2.2"
31-
}
31+
},
32+
"dependencies": {},
33+
"repository": {
34+
"type": "git",
35+
"url": "git+https://github.com/thecodeholic/VanillaJsNotes.git"
36+
},
37+
"bugs": {
38+
"url": "https://github.com/thecodeholic/VanillaJsNotes/issues"
39+
},
40+
"homepage": "https://github.com/thecodeholic/VanillaJsNotes#readme"
3241
}

webpack.config.prod.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function (env, argv) {
99
return {
1010
mode: 'production',
1111
entry: [
12-
'./src/app.js'
12+
'./src/NoteManager.js'
1313
],
1414
optimization: {
1515
minimizer: [
@@ -19,9 +19,6 @@ module.exports = function (env, argv) {
1919
,
2020
plugins: [
2121
new CleanWebpackPlugin(['dist']),
22-
new HtmlWebpackPlugin({
23-
template: path.resolve('./src/index.html')
24-
}),
2522
new MiniCssExtractPlugin({
2623
filename: "[name].css",
2724
chunkFilename: "[id].css"
@@ -47,28 +44,7 @@ module.exports = function (env, argv) {
4744
presets: ['@babel/preset-env']
4845
}
4946
}
50-
},
51-
{
52-
test: /\.(woff(2)?|ttf|otf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
53-
use: [
54-
{
55-
loader: 'file-loader',
56-
options: {
57-
name: '[name].[ext]',
58-
outputPath: 'fonts/'
59-
}
60-
}
61-
]
62-
},
63-
{
64-
test: /\.html$/,
65-
use: {
66-
loader: 'html-loader',
67-
options: {
68-
attrs: [':src', ':href']
69-
}
70-
}
71-
},
47+
}
7248
]
7349
}
7450
};

0 commit comments

Comments
 (0)