mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-06-28 04:45:36 -04:00
feat: modal added
This commit is contained in:
parent
ba35554e0e
commit
104849154f
3 changed files with 66 additions and 27 deletions
|
@ -1,16 +1,22 @@
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--background-color: #000000;
|
--background-color: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 100px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar ul {
|
.navbar ul {
|
||||||
|
@ -18,16 +24,22 @@
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
min-height: 1000px;
|
||||||
|
min-width: 1000px;
|
||||||
|
}
|
||||||
|
|
||||||
.book-cards {
|
.book-cards {
|
||||||
display: flex;
|
display: grid;
|
||||||
justify-content: center;
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||||
flex-direction: column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<title>Anonymous Library</title>
|
<title>Anonymous Library</title>
|
||||||
</head>
|
</head>
|
||||||
|
@ -12,29 +14,31 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<nav class="navbar">
|
<nav class="navbar">
|
||||||
<h1 class="header">Anonymous BookClub</h1>
|
<h1 class="header">Anonymous BookClub</h1>
|
||||||
<ul>
|
<button class="show-modal btn">Add Book</button>
|
||||||
<li>Add Book</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
</nav>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="form">
|
<div class="book-cards">
|
||||||
<form action="" >
|
|
||||||
<input type="text" name="title" id="title">
|
|
||||||
<input type="text" name="author" id="author">
|
|
||||||
<button type="submit" id="btn">Submit</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="book-cards">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<div class="contact"></div>
|
<div class="contact"></div>
|
||||||
<div class="icons"></div>
|
<div class="icons"></div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
<dialog class="modal">
|
||||||
|
<main>
|
||||||
|
<div class="form">
|
||||||
|
<form action="" >
|
||||||
|
<input type="text" name="title" id="title">
|
||||||
|
<input type="text" name="author" id="author">
|
||||||
|
<button type="submit" id="submit-btn" class="btn">Submit</button>
|
||||||
|
</form>
|
||||||
|
<button class="btn close-btn">
|
||||||
|
<span class="material-symbols-outlined">close</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</dialog>
|
||||||
<script src="js/script.js"></script>
|
<script src="js/script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
const myLibrary = [];
|
const myLibrary = [];
|
||||||
|
const submitButton = document.querySelector('#submit-btn');
|
||||||
|
|
||||||
const booksDiv = document.querySelector('.book-cards');
|
const booksDiv = document.querySelector('.book-cards');
|
||||||
const defaultData = new Book('James Clear', 'Atomic Habits', true);
|
const dialog = document.querySelector("dialog");
|
||||||
|
const addBookButton = document.querySelector(".show-modal");
|
||||||
|
const closeDialogButton = document.querySelector(".close-btn");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const defaultData = new Book('Atomic Habits', 'James Clear', false);
|
||||||
|
|
||||||
|
|
||||||
function Book(title, author, read) {
|
function Book(title, author, read) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -40,9 +49,8 @@ function displayBooks(books) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const button = document.querySelector('#btn');
|
|
||||||
|
|
||||||
button.addEventListener('click', event => {
|
submitButton.addEventListener('click', event => {
|
||||||
const author = document.querySelector('#author').value;
|
const author = document.querySelector('#author').value;
|
||||||
const title = document.querySelector('#title').value;
|
const title = document.querySelector('#title').value;
|
||||||
const newBook = new Book(title, author, false);
|
const newBook = new Book(title, author, false);
|
||||||
|
@ -50,7 +58,22 @@ button.addEventListener('click', event => {
|
||||||
addBookToLibrary(newBook);
|
addBookToLibrary(newBook);
|
||||||
displayBooks(myLibrary);
|
displayBooks(myLibrary);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
})
|
});
|
||||||
|
|
||||||
|
addBookButton.addEventListener('click', () => {
|
||||||
|
dialog.showModal();
|
||||||
|
});
|
||||||
|
|
||||||
|
closeDialogButton.addEventListener('click', () => {
|
||||||
|
dialog.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
// document.addEventListener('click', e => {
|
||||||
|
// if (!e.target.closest("dialog")) {
|
||||||
|
// dialog.showModal();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
// default data
|
// default data
|
||||||
myLibrary.push(defaultData)
|
myLibrary.push(defaultData)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue