JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Jura" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.1/css/all.css" integrity="sha384-O8whS3fhG2OnA5Kas0Y9l3cfpmYjapjI0E4theH4iuMD+pLhbf6JI0jIMfYcK3yZ"
crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery-3.3.1.min.js"></script>
<title>To Do List</title>
</head>
<body>
<div class="container">
<div class="title">
<span>to-do list</span>
<span id="addSign">
<i class="fas fa-plus"></i>
</span>
</div>
<div class="list">
<ul>
<li id="addField">
<input type="text" placeholder="Add New Todo" id="inputField">
</li>
<!-- <li class="whBckg">
<div class='deleteSign' style="display: none"><i class="fas fa-trash-alt"></i></div>
<span class='list-item '>To jest test</span>
</li> -->
</ul>
</div>
</div>
<script src="js/index.js"></script>
</body>
</html>
CSS
body {
background: linear-gradient(to right, rgb(0, 217, 255), rgb(255, 238, 0)) no-repeat fixed;
font-family: 'Jura', sans-serif;
}
.container {
margin: 150px auto;
width: 25%;
min-width: 400px;
height: auto;
/* border: 2px solid black; */
}
.title {
width: 100%;
height: 100%;
padding-top: 10px;
padding-bottom: 10px;
/* border: 2px solid pink; */
background-color: rgb(48, 142, 250);
}
.title span {
font-size: 28px;
font-weight: bold;
color: white;
text-transform: uppercase;
padding-left: 5%;
}
#addSign {
font-size: 28px;
font-weight: bold;
color: white;
text-transform: uppercase;
float:right;
padding-right: 5%;
}
.list {
width: 100%;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
ul li {
background: rgb(235, 235, 235);
/* padding: 10px; */
}
ul li input{
display: block;
width: 100%;
padding: 10px;
border: 0;
margin: 0;
font-size: 16px;
background: none;
color: rgb(0, 119, 231);
}
ul li input:focus {
outline: none;
}
.whBckg {
background-color: white;
}
.grBckg {
background-color: rgb(235, 235, 235);
}
.fa-trash-alt {
color: white;
}
.deleteSign {
padding: 10px;
display: inline-flex;
background-color: red;
}
.list-item {
display: inline-block;
padding: 10px;
}
.marked {
text-decoration: line-through;
color: gray;
}
JavaScript
$('#addSign').on('click', function() {
$('#addField').slideToggle();
})
$('ul').on('click', 'li', function(){
$(this).children('.list-item').toggleClass('marked');
});
$('li').on('mouseenter', 'li', function() {
$(this).children('.deleteSign').animate({width:'toggle', paddingLeft: 'toggle', paddingRight: 'toggle'},350);
});
$('ul').on('mouseleave', 'li', function(){
$(this).children('.deleteSign').animate({width:'toggle', paddingLeft: 'toggle', paddingRight: 'toggle'},350);
})
$('ul').on('click', 'li', function() {
$(this).children('.deleteSign').closest('li').remove();
})
$('#inputField').on('keypress', function(e) {
if(e.charCode === 13) {
const value = ($(this).val());
$(this).val('');
const markup = `<li class="whBckg">
<div class='deleteSign' style="display: none"><i class="fas fa-trash-alt"></i></div>
<span class='list-item'>${value}</span>
</li>`;
$('ul').append(markup);
}
})