Skip to content

Commit ae0a3ef

Browse files
Merge pull request #37 from ankitjhagithub21/new_branch
added note-taking-app
2 parents f14b897 + 6ff34f1 commit ae0a3ef

5 files changed

Lines changed: 279 additions & 0 deletions

File tree

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<link rel="shortcut icon" href="/notes-icon.png" type="image/png">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<title>Note Taking App</title>
9+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet"
10+
integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
11+
<link rel="stylesheet" href="style.css">
12+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css">
13+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
14+
</head>
15+
16+
<body>
17+
<nav class="navbar navbar-dark bg-dark navbar-expand-lg ">
18+
<div class="container-fluid">
19+
<a class="navbar-brand" href="#">
20+
<img src="notes-icon.png" alt="logo" width="30px" class="mx-3">
21+
</a>
22+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
23+
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"
24+
onclick="toggleMenu()">
25+
<i class="fa-solid fa-bars" id="menu-icon"></i>
26+
</button>
27+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
28+
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
29+
<li class="nav-item">
30+
<button class="btn btn-dark" onclick="displayHome()">Home</button>
31+
</li>
32+
<li class="nav-item">
33+
<button class="btn btn-dark" onclick="displayNotes()">Your Notes</button>
34+
</li>
35+
36+
37+
</ul>
38+
<div class="d-flex align-items-center justify-content-center">
39+
<input class="form-control me-2" type="search" placeholder="Search Notes.." aria-label="Search" id="input">
40+
<i class="fa-solid fa-search text-light fs-5"></i>
41+
</div>
42+
</div>
43+
</div>
44+
</nav>
45+
46+
<div class="container mt-5">
47+
<div class="row">
48+
<div class="col-lg-8 mx-auto" id="form-container">
49+
<h2 class="text-center">Add a note</h2>
50+
<form id="my-form">
51+
<div class="mb-3">
52+
<label for="title" class="form-label fs-5">Title</label>
53+
<input type="text" class="form-control" id="title" name="title" placeholder="Enter Title" required
54+
autocomplete="off">
55+
</div>
56+
<div class="mb-3">
57+
<label for="description" class="form-label fs-5">Description</label>
58+
<textarea name="description" id="description" rows="5" class="form-control" required autocomplete="off"
59+
placeholder="Enter Description"></textarea>
60+
</div>
61+
<button class="btn btn-dark">Submit</button>
62+
</form>
63+
</div>
64+
<div class="col-lg-8 mx-auto" id="all-notes">
65+
<h2 class="text-center">Your Notes</h2>
66+
<div id="notes-container">
67+
68+
</div>
69+
</div>
70+
</div>
71+
</div>
72+
73+
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
74+
<div class="modal-dialog">
75+
<div class="modal-content">
76+
<div class="modal-header">
77+
<h1 class="modal-title fs-5" id="exampleModalLabel">Edit Note</h1>
78+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
79+
</div>
80+
<div class="modal-body">
81+
<form id="edit-form">
82+
83+
<input type="text" class="form-control mb-3" id="edit-title" placeholder="Edit Title" required
84+
autocomplete="off">
85+
86+
<textarea name="edit-description" id="edit-description" rows="5" class="form-control mb-3" required
87+
autocomplete="off" placeholder="Edit Description"></textarea>
88+
89+
<button class="btn btn-success">Save Changes</button>
90+
</form>
91+
</div>
92+
93+
</div>
94+
</div>
95+
</div>
96+
97+
98+
99+
<script src="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js"></script>
100+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"
101+
integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
102+
crossorigin="anonymous"></script>
103+
<script src="script.js"></script>
104+
</body>
105+
106+
</html>
2.36 KB
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# note-taking-app
2+
Welcome to the Note-Taking-App repository! This is a simple web-based note-taking application built using HTML, CSS, Bootstrap, and JavaScript. With this app, users can add, delete, edit, and search for notes easily.
3+
4+
![image](https://github.com/ankitjhagithub21/Web-Devlopment-Projects/assets/91364014/8ec7f459-766c-4ab6-9576-2a2d6378afb0)
5+
6+
7+
## Live On
8+
('''https://note-taking-app-23.netlify.app/''')
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
var notyf = new Notyf();
2+
3+
const formContainer = document.getElementById('form-container')
4+
const notesContainer = document.getElementById('notes-container')
5+
const myForm = document.getElementById('my-form')
6+
const editForm = document.getElementById('edit-form')
7+
const editTitle = document.getElementById('edit-title')
8+
const editDescription = document.getElementById('edit-description')
9+
const menuIcon = document.getElementById('menu-icon')
10+
const allNotes = document.getElementById('all-notes')
11+
const input = document.getElementById('input')
12+
const notes = JSON.parse(localStorage.getItem('notes')) || []
13+
14+
let editIndex;
15+
16+
const displayHome = () =>{
17+
formContainer.style.display="block"
18+
allNotes.style.display="none"
19+
}
20+
const displayNotes = () =>{
21+
formContainer.style.display="none"
22+
allNotes.style.display="block"
23+
}
24+
25+
myForm.addEventListener('submit',(e)=>{
26+
e.preventDefault()
27+
28+
let note = {
29+
30+
title:e.target.title.value,
31+
description:e.target.description.value
32+
}
33+
myForm.reset()
34+
addNote(note)
35+
36+
})
37+
38+
const addNote = (note) => {
39+
notes.push(note)
40+
notyf.success('Note Added!');
41+
updateLs()
42+
}
43+
44+
const editNote = (index) => {
45+
editTitle.value=notes[index].title
46+
editDescription.value=notes[index].description
47+
editIndex = index
48+
}
49+
50+
51+
const fetchNotes = () => {
52+
notesContainer.innerHTML = ""
53+
if(notes.length==0){
54+
notesContainer.innerHTML = `<p class="fs-5 text-center">Nothing to display !!</p>`
55+
return
56+
}
57+
notes.forEach((note,index)=>{
58+
let noteBox = document.createElement('div')
59+
noteBox.classList.add('card')
60+
noteBox.innerHTML = `
61+
<h2 class="card-title">${note.title}</h2>
62+
63+
<p>${note.description}</p>
64+
<div class="d-flex gap-2">
65+
<button class="btn btn-danger"><i class="fa-solid fa-trash"></i> </button>
66+
<button class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#exampleModal"><i class="fa-solid fa-edit"></i> </button>
67+
</div>
68+
69+
70+
`
71+
notesContainer.appendChild(noteBox)
72+
73+
noteBox.querySelector('.btn-danger').addEventListener('click',()=>{
74+
notes.splice(index,1)
75+
updateLs()
76+
notyf.success('Note deleted!');
77+
})
78+
noteBox.querySelector('.btn-warning').addEventListener('click',()=>{
79+
editNote(index)
80+
})
81+
})
82+
}
83+
84+
editForm.addEventListener('submit',(e)=>{
85+
e.preventDefault()
86+
notes[editIndex].title=editTitle.value
87+
notes[editIndex].description=editDescription.value
88+
editForm.reset()
89+
notyf.success('Note saved!');
90+
updateLs()
91+
92+
})
93+
94+
fetchNotes()
95+
96+
const toastTrigger = document.getElementById('liveToastBtn')
97+
const toastLiveExample = document.getElementById('liveToast')
98+
99+
if (toastTrigger) {
100+
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
101+
toastTrigger.addEventListener('click', () => {
102+
toastBootstrap.show()
103+
})
104+
}
105+
106+
function toggleMenu(){
107+
if(menuIcon.classList.contains('fa-bars')){
108+
menuIcon.classList.replace('fa-bars','fa-xmark')
109+
}else{
110+
menuIcon.classList.replace('fa-xmark','fa-bars')
111+
}
112+
}
113+
114+
function updateLs(){
115+
localStorage.setItem('notes',JSON.stringify(notes))
116+
fetchNotes()
117+
}
118+
119+
input.addEventListener('keyup',(e)=>{
120+
let searchTerm = e.target.value.toUpperCase()
121+
122+
notesContainer.querySelectorAll('.card-title').forEach((title)=>{
123+
if(title.textContent.toUpperCase().includes(searchTerm)){
124+
title.parentElement.style.display=""
125+
}else{
126+
title.parentElement.style.display="none"
127+
}
128+
})
129+
130+
})
131+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;600&display=swap');
2+
3+
body {
4+
background-color: whitesmoke;
5+
font-family: 'Noto Sans', sans-serif;
6+
}
7+
8+
::-webkit-scrollbar {
9+
display: none;
10+
}
11+
12+
#all-notes {
13+
display: none;
14+
}
15+
16+
.card {
17+
padding: 10px;
18+
margin: 20px 0px;
19+
}
20+
21+
.navbar-toggler,
22+
.navbar-toggler:focus,
23+
.navbar-toggler:active,
24+
.navbar-toggler-icon:focus {
25+
outline: none;
26+
border: none;
27+
box-shadow: none;
28+
}
29+
30+
31+
32+
.form-control {
33+
box-shadow: none !important;
34+
}

0 commit comments

Comments
 (0)