Skip to content

Instantly share code, notes, and snippets.

@christianjuth
Created January 11, 2017 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianjuth/abf58ec9863992789cec9c6fbc8beebc to your computer and use it in GitHub Desktop.
Save christianjuth/abf58ec9863992789cec9c6fbc8beebc to your computer and use it in GitHub Desktop.
Todo
<html>
<head>
<title>Todo by Christian Juth</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Roboto:900" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel='stylesheet' href='style.css'/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src='script.js'></script>
</head>
<body>
<div class="banner">
<h1>Todo</h1>
<h3>by Christian Juth</h3>
</div>
<div class="todo-wrap">
<div class="todo">
<div class="todo-header">
<h1>Todo</h1>
<hr>
</div>
<div class="todo-body">
<ul class="todo-items"></ul>
</div>
<div class="todo-footer">
<hr>
<h3 class="add-todo">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
</h3>
</div>
</div>
</div>
<script type="text/html" id="todo-item">
<li class="todo-item">
<input type="text" placeholder="untitled">
<input type="checkbox">
<div class="clearfix"></div>
</li>
</script>
</body>
</html>
$(document).ready(function(){
$(".add-todo").click(function(){
$template = $("#todo-item").html();
$this = $($template).appendTo(".todo-items");
$this.find("input[type=checkbox]").change(function() {
if (this.checked) {
$this.addClass("completed");
} else {
$this.removeClass("completed");
}
});
});
});
html,
body{
background-color: #2ecc71;
height: 100%;
margin: 0;
padding: 0;
overflow: visible;
display: flex;
align-items: center;
justify-content: center;
font-family: 'Open Sans', sans-serif;
}
.banner{
display: none;
background-color: #fff;
border-radius: 2px;
padding: 20px;
}
.banner h1,
.banner h3{
margin: 0;
padding: 0;
}
.banner h1{
font-family: Roboto;
}
hr{
border: 1px solid #000;
margin: 0;
}
ul,
li{
list-style-type: none;
padding: 0;
margin: 0;
}
input{
padding: 5px;
margin: 0;
border: none;
font-size: 12px;
}
.clearfix{
clear: both;
}
.todo{
position: relative;
background-color: #fff;
width: 200px;
border-radius: 2px;
overflow: hidden;
}
.todo .todo-header,
.todo .todo-footer{
padding: 8px;
}
.todo .todo-body{
height: 200px;
padding: 0 8px;
overflow-y: scroll;
}
.todo .todo-header h1{
margin: 0;
font-family: Roboto;
text-align: center;
font-weight: bold;
}
.todo .todo-body ul li{
padding: 4px 0 4px 8px;
}
.todo .todo-body ul li input{
float: left;
display: inline-block;
padding: 0;
}
.todo .todo-body ul li input[type=text]{
width: calc(100% - 12px);
}
.todo .todo-body ul li input[type=checkbox]{
width: 12px;
}
.todo-item.completed input{
text-decoration: line-through;
}
.todo .todo-footer{
background-color: #fff;
}
.todo .todo-footer h3{
margin: 6px 0 0 0;
text-align: center;
cursor: pointer;
}
@media screen and (max-width: 300px){
.todo{
display: none;
}
.banner{
display: block;
}
}
@media screen and (min-height: 550px) and (min-width: 800px){
.todo{
width: 400px;
}
.todo .todo-body{
height: 400px;
}
.todo .todo-header,
.todo .todo-footer{
padding: 20px;
}
.todo .todo-body{
padding: 0 20px;
}
.todo .todo-header h1{
padding-bottom: 10px;
}
.todo .todo-footer h3{
padding-top: 10px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment