Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved UI #149

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.vscode/*
.vscode/*
.env
2 changes: 0 additions & 2 deletions config/.env

This file was deleted.

1 change: 1 addition & 0 deletions config/database.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const mongoose = require('mongoose')
console.log(process.env.PORT)

const connectDB = async () => {
try {
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"bcrypt": "^5.0.1",
"connect-mongo": "^3.2.0",
"dotenv": "^8.2.0",
"dotenv": "^8.6.0",
"ejs": "^3.1.6",
"express": "^4.17.1",
"express-flash": "^0.0.2",
Expand Down
62 changes: 59 additions & 3 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,66 @@
h1{
color: red;
}

.completed{
text-decoration: line-through;
color: gray;
}
.not{
text-decoration: underline;
}

.container {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}

.main {
display: flex;
flex-direction: column;
border: 1px solid rgb(64, 109, 12);
min-width: 50%;
border-radius: 20px;
padding: 50px;
margin: 10px;
box-shadow: 1px 1px 1px 1px black;
}

.button {
width: 120px;
height: 40px;
color: white;
background: rgba(64, 109, 12, 0.5);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
}

a{
text-decoration: none;
}

.btn-containers {
display: flex;
justify-content: center;
align-items: center;
gap: 20px;

}

.form {
display: flex;
flex-direction: column;
align-self: center;
gap: 10px;
margin: 0;
}

.form input {
width: 100%;
height: 10%;
}

.register {
padding: 20px;
}
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const logger = require('morgan')
const connectDB = require('./config/database')
const mainRoutes = require('./routes/main')
const todoRoutes = require('./routes/todos')
const path = require('path')

require('dotenv').config({path: './config/.env'})

Expand Down Expand Up @@ -40,7 +41,7 @@ app.use(flash())

app.use('/', mainRoutes)
app.use('/todos', todoRoutes)

app.listen(process.env.PORT, ()=>{
console.log('Server is running, you better catch it!')
})
16 changes: 13 additions & 3 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<title>Document</title>
</head>
<body>
<h1>Create Your VERY OWN Todolist!</h1>
<a href="/login"> Login</a>
<a href="/signup"> Signup</a>
<div class="container">
<div class="main">
<h1>Create Your VERY OWN Todolist!</h1>
<div class="btn-containers">
<a class="button" href="/login"> Login</a>
<a class="button" href="/signup"> Signup</a>
</div>

</div>

</div>

</body>
</html>
36 changes: 21 additions & 15 deletions views/login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<title>Document</title>
</head>
<body>
<% if (locals.messages.errors) { %>
<% messages.errors.forEach( el => { %>
<div class="alert alert-danger"><%= el.msg %></div>
<% }) %>
<% } %>
<% if (locals.messages.info) { %>
<% messages.info.forEach( el => { %>
<div class="alert alert-danger"><%= el.msg %></div>
<% }) %>
<% } %>
<form action="/login" method="POST">
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
<input type="submit">
</form>
<div class="container">
<div class="main">
<% if (locals.messages.errors) { %>
<% messages.errors.forEach( el => { %>
<div class="alert alert-danger"><%= el.msg %></div>
<% }) %>
<% } %>
<% if (locals.messages.info) { %>
<% messages.info.forEach( el => { %>
<div class="alert alert-danger"><%= el.msg %></div>
<% }) %>
<% } %>
<form action="/login" method="POST" class="form">
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
<input class="button" type="submit">
</form>
</div>
</div>

</body>
</html>
30 changes: 18 additions & 12 deletions views/signup.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<title>Document</title>
</head>
<body>
<% if (locals.messages.errors) { %>
<% messages.errors.forEach( el => { %>
<div class="alert alert-danger"><%= el.msg %></div>
<% }) %>
<% } %>
<form action="/signup" method="POST">
<input type="text" name="userName" placeholder="User Name">
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
<input type="password" name="confirmPassword" placeholder="Confirm Password">
<input type="submit">
</form>
<div class="container">
<div class="main register">
<% if (locals.messages.errors) { %>
<% messages.errors.forEach( el => { %>
<div class="alert alert-danger"><%= el.msg %></div>
<% }) %>
<% } %>
<form action="/signup" method="POST" class="form">
<input type="text" name="userName" placeholder="User Name">
<input type="email" name="email" placeholder="Email">
<input type="password" name="password" placeholder="Password">
<input type="password" name="confirmPassword" placeholder="Confirm Password">
<input class="button" type="submit">
</form>
</div>
</div>

</body>
</html>
41 changes: 23 additions & 18 deletions views/todos.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>Todos</h1>
<ul>
<% todos.forEach( el => { %>
<li class='todoItem' data-id='<%=el._id%>'>
<span class='<%= el.completed === true ? 'completed' : 'not'%>'><%= el.todo %></span>
<span class='del'> Delete </span>
</li>
<% }) %>
</ul>

<h2><%= user.userName %> has <%= left %> things left to do.</h2>

<form action="/todos/createTodo" method='POST'>
<input type="text" placeholder="Enter Todo Item" name='todoItem'>
<input type="submit">
</form>

<a href="/logout">Logout</a>
<div class="container">
<div class="main">
<h1>Todos</h1>
<ul>
<% todos.forEach( el => { %>
<li class='todoItem' data-id='<%=el._id%>'>
<span class='<%= el.completed === true ? 'completed' : 'not'%>'><%= el.todo %></span>
<span class='del'> Delete </span>
</li>
<% }) %>
</ul>

<h2><%= user.userName %> has <%= left %> things left to do.</h2>

<form action="/todos/createTodo" method='POST' class="form">
<input type="text" placeholder="Enter Todo Item" name='todoItem'>
<input class="button" type="submit">
</form>

<a class="button" href="/logout">Logout</a>
</div>
</div>


<script src="js/main.js"></script>
</body>
Expand Down