├── README.md ├── app.js ├── index.html ├── preview.png └── style.css /README.md: -------------------------------------------------------------------------------- 1 | # Note Taking App 2 | 3 | A minimal note application using Vanilla JavaScript. 4 | 5 | [View online demo](http://luciagm.net/note-app/) 6 | 7 | [![Preview](preview.png)](http://luciagm.net/note-app/) 8 | 9 | ### To be improved 10 | - Persistent notes saved in local storage 11 | - Form style 12 | - Form inside a note 13 | 14 | 15 | ## License 16 | MIT License 17 | 18 | Copyright (c) 2018 Lucia Gonzalez Moscoso 19 | 20 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | // Form reference 2 | const form = {} 3 | form.noteText = document.querySelector('#formNoteText'); 4 | form.addButton = document.querySelector('#formAddButton'); 5 | form.color = document.querySelector('#formColor'); 6 | 7 | const notes = document.querySelector('#notes'); 8 | 9 | form.noteText.focus(); 10 | 11 | // Functions 12 | function addNote() { 13 | let text = form.noteText.value; 14 | let note = document.createElement('div'); 15 | let deleteButton = document.createElement('span'); 16 | 17 | note.classList.add('note'); 18 | note.classList.add(form.color.value); 19 | note.innerHTML = `
${text}
`; 20 | deleteButton.classList.add('note-delete'); 21 | deleteButton.innerHTML = '×'; 22 | 23 | note.appendChild(deleteButton); 24 | notes.appendChild(note); 25 | 26 | form.noteText.value = ''; 27 | form.noteText.focus(); 28 | 29 | addListenerDeleteButton(deleteButton); 30 | } 31 | 32 | function addListenerDeleteButton(deleteButton) { 33 | deleteButton.addEventListener('click', function (e) { 34 | e.stopPropagation(); 35 | deleteNote(e); 36 | }); 37 | } 38 | 39 | function deleteNote(e) { 40 | let eventNote = e.target.parentNode; 41 | eventNote.parentNode.removeChild(eventNote); 42 | } 43 | 44 | 45 | 46 | // Event Listeners 47 | form.addButton.addEventListener('click', function (e) { 48 | e.preventDefault(); 49 | if (form.noteText.value != '') { 50 | addNote(); 51 | } 52 | }) 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Note Taking App 7 | 8 | 9 | 10 | 11 | 12 |

Note Taking App

13 |
14 | 15 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lucia-gm/note-app/4fbdb2c2e09c0ed95dec99d5ae0884ce1e3d8e39/preview.png -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | /* Global styles */ 2 | html, * { 3 | box-sizing: border-box; 4 | } 5 | 6 | html { 7 | font-size: 62.5%; 8 | } 9 | 10 | body { 11 | font: 1.8rem/1.56 sans-serif; 12 | color: #360066; 13 | margin: 0; 14 | padding: 0 3.2rem 2.4rem; 15 | background: #f5f5f5; 16 | } 17 | 18 | 19 | /* Form styles */ 20 | textarea { 21 | display: block; 22 | border-radius: 0.4rem; 23 | } 24 | 25 | textarea, 26 | form select { 27 | background: #fff; 28 | border: 1px solid #520099; 29 | } 30 | 31 | form select, 32 | form button { 33 | display: inline-block; 34 | margin: 2rem 1rem 0 0; 35 | height: 2rem; 36 | } 37 | 38 | #formAddButton { 39 | width: 7rem; 40 | background-color: #8902FF; 41 | color: #fff; 42 | border-radius: 0.4rem; 43 | border: 0; 44 | transition: background-color .2s ease-in-out; 45 | -webkit-transition: background-color .2s ease-in-out; 46 | } 47 | 48 | #formAddButton:hover { 49 | cursor: pointer; 50 | background-color: #e600e6; 51 | } 52 | 53 | 54 | /* Note Styles */ 55 | #notes { 56 | display: flex; 57 | flex-wrap: wrap; 58 | padding-top: 2rem; 59 | } 60 | 61 | .note { 62 | width: 24rem; 63 | height: 20rem; 64 | font-size: 1.4rem; 65 | background: #fff; 66 | border-radius: 0.4rem; 67 | padding: 1.2rem 1.6rem; 68 | margin: 2.4rem 2.4rem 0 0; 69 | box-shadow: 0 0.9rem 1.2rem rgba(0,0,0, 0.1); 70 | position: relative; 71 | } 72 | 73 | .note-text { 74 | height: 100%; 75 | overflow-y: auto; 76 | } 77 | 78 | .note::after { 79 | content: ''; 80 | position: absolute; 81 | bottom: 0; 82 | left: 0; 83 | right: 0; 84 | height: 0.8rem; 85 | border-radius: 0 0 0.4rem 0.4rem; 86 | } 87 | 88 | .note.red::after { 89 | background-color: lightcoral; 90 | } 91 | 92 | .note.blue::after { 93 | background-color: lightskyblue; 94 | } 95 | .note.green::after { 96 | background-color: lightgreen; 97 | } 98 | .note.yellow::after { 99 | background-color: gold; 100 | } 101 | 102 | .note span { 103 | position: absolute; 104 | width: 2rem; 105 | height: 2rem; 106 | top: 0.2rem; 107 | right: 0.2rem; 108 | border-radius: 0.4rem; 109 | color: #999; 110 | text-align: center; 111 | } 112 | 113 | .note span:hover { 114 | color: #333; 115 | background: #f5f5f5; 116 | cursor: pointer; 117 | } 118 | --------------------------------------------------------------------------------