Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
	<div class='app'>
		<div class='header'>
			<img src="https://blog.sandiego.org/wp-content/uploads/2020/04/SDT_Zoom-Backgrounds_April-8_Windansea-1_1600x800.jpg"/>
			<div id="date">DATA</div>
			<div id="time"></div>
		</div>
		<div id='listTop'>
			<i class="fas fa-sync-alt" id="clear"></i>
			<p id='pClear'>Clear All</p>
		</div>
		<ul id='list'>

		</ul>
		<div class="footer">
			<i class="fas fa-plus-circle" aria-hidden="true" id='addButton'></i>
			<input type="text" id='itemInput' placeholder="Add a to-do" />
		</div>
	</div>
<script src="./app.js"></script>
<script src="https://kit.fontawesome.com/c6015819ca.js" crossorigin="anonymous"></script>
<script src='https://unpkg.com/uuid@latest/dist/umd/uuidv4.min.js'></script>  
</body>
              
            
!

CSS

              
                *{
	box-sizing: border-box;
	letter-spacing: 0.05em;
}


body{
	background-color: #1B2631;
	text-align: center;
	
}
  
.title {
	display: block;
	text-align: center;
	color: yellow;
	background-color: black;
	width: auto;
	margin-right: auto;
	margin-left: auto;
}
.app {
	width: 500px;
	height: 1000px;
	border: 2px solid lightblue;
	border-radius: 50%/ 10px 10px 10px 10px;
	background:	lightskyblue;
	margin: 0 auto;
	
}

.header {
	height: 200px;
}

.header img{
	margin: 0;
	padding: 0;
	position: relative;
	width: 24.5em;
	height: 10em;
	border-radius: 50%/ 10px 10px 10px 10px;
	border: 3px solid black;
}

#listTop {
	height: 50px;
	/* border: 2px solid black; */
}

#pClear {
	margin: 0;
	padding: 0 10 0 0;
	font-size: 25px;
	color: black;
	font-family: 'Roboto', sans-serif;
	font-weight: 800;
	float: right;

}
.fas.fa-sync-alt {
	font-size: 2em;
	margin: 0;
	z-index: 1;
	color: dodgerblue;
	float: right;
	-webkit-text-stroke: 1px black;
}
.fas.fa-sync-alt:hover {
	color: deepskyblue;
}

#date{
	z-index: 3;
	color: gold;
	font-family:  'Roboto', sans-serif;
	font-size: 25px;
	font-weight: 900;
	position: relative;
	top: -40px;
	left: -110px;
	-webkit-text-stroke: 1px black;
}

#time {
	font-size: 25px;
	font-weight: 800;
	z-index: 3;
	color:gold;
	font-family: 'Roboto', sans-serif;  /* Google font @import url('https://fonts.googleapis.com/css?family=Orbitron'); */ 				
	position: relative;
	top: -80px;
	right: -140px; 
	-webkit-text-stroke: 1px black;
}


#list {
	width: 100% !important;
	margin: 0 !important;
	padding: 0;
	height: 60%;
	margin-bottom: 10px;
	overflow: auto;
	align-items: center !important;
	background-color: whitesmoke;
}
.footer {
	height: 5em;
}

.item {
	width: 100%;
	height: auto;
	background-color:lightgray;
	margin: 5px 0px;
	display: flex;
}
.item:hover {
	background-color: silver;
	color: black;
}
i {
	padding: 0;
	margin: auto;
	color: black;
	cursor: pointer;
}
.fa-check-circle {
	color: green;
	font-size: 35px;
}
.fa-check-circle:hover{
	color: limegreen;
}
.fa-circle {
	color: rgba(0, 0, 0, 0.5);
	font-size: 35px;
}
.fa-circle:hover {
	color: rgba(0, 0, 0, 0.7);
}
.lineThrough {
	text-decoration: line-through;
	color: dimgray !important;
}
.fas.fa-trash-alt {
	margin: auto;
	font-size: 30px;
}
.fas.fas.fa-trash-alt:hover {
	color: red;
}
.description {
	padding: 0;
	margin: 5px;
	color: black;
	font-family:  'Roboto', sans-serif;
	font-size: 1.2em;
	font-weight: bold;
	width: 70%;
}
.wrap { 
	white-space: pre-wrap;      /* CSS3 */   
	white-space: -moz-pre-wrap; /* Firefox */    
	white-space: -pre-wrap;     /* Opera <7 */   
	white-space: -o-pre-wrap;   /* Opera 7 */    
	word-wrap: break-word;      /* IE */
 }

.fas.fa-plus-circle {
	margin: 5px 5px;
	font-size: 70px;
	color: dodgerblue;
	position: relative;
	-webkit-text-stroke: 1px black;
}
.fas.fa-plus-circle:hover {
	color: deepskyblue;
}
#itemInput {
	margin: 0;
	font-size: 30px;
	border: hidden;
	background-color: powderblue;
	position: relative;
}

#itemInput::-webkit-input-placeholder { /* Chrome/Opera/Safari */
	color: rgba(0, 0, 0, 0.8);
}
#itemInput::-moz-placeholder { /* Firefox 19+ */
	color: rgba(0, 0, 0, 0.8);
}
#itemInput:-ms-input-placeholder { /* IE 10+ */
	color: rgba(0, 0, 0, 0.8);
}
#itemInput:-moz-placeholder { /* Firefox 18- */
	color: rgba(0, 0, 0, 0.8);
}
              
            
!

JS

              
                const clear = document.querySelector("#clear");
const date = document.getElementById("date");
const list = document.getElementById("list");
const input = document.getElementById("itemInput");

const check = "fa-check-circle";
const uncheck = "fa-circle";
const lineThrough = "lineThrough";

//get the item from the local storage
let data = localStorage.getItem('TODO');

//check if data is not empty
if(data) {
	LIST = JSON.parse(data)
	loadList(LIST); // load all the items in the array to the UI 
} else {
	//if data is empty
	LIST = [];

}

function loadList(array) {
	array.forEach(item => {
		addToDo(item.name, item.id, item.done, item.trash);
	})
}

function currentTime () {
	// set clock
	let date = new Date;
	let hours = date.getHours();
	let min = date.getMinutes();
	let sec = date.getSeconds();
	let midday = "AM";
	midday = (hours >= 12) ? "PM" : "AM";
	hours = updateTimeAndDate(hours);
	min = updateTimeAndDate(min);
	sec = updateTimeAndDate(sec);
	hours = (hours == 0) ? 12 : ((hours > 12) ? (hours - 12): hours)
	document.getElementById('time').innerHTML = hours + ":" + min + ":" + sec + midday;
	setTimeout(currentTime, 1000);
	// set date
	let year = date.getFullYear();
	let month = date.getMonth()+1;
	let day = date.getDate();
	month = updateTimeAndDate(month);		// instead i could do:  let month = `${date.getMonth()+1}`.padStart(2, "0");
	day = updateTimeAndDate(day);	// instead i could do: let day = `${date.getDate()}`.padStart(2, "0");
	let dayOfTheWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
	let weekDay = dayOfTheWeek[date.getDay()];
	document.getElementById('date').innerHTML = year + "." + month + "." + day + " " + weekDay;
}

function updateTimeAndDate(k) {
	if(k < 10){
		return "0" + k;
	} else {
		return k;
	}
}

currentTime();

function addToDo(toDo, id, done, trash) {
	
	// if trash is true do not execute the code below
	if (trash) {return ;}
	const DONE = done ? check : uncheck;
	const LINE = done ? lineThrough : "";
	
	const text =`
	<li class="item">
		<i class="far ${DONE}"  id='${id}'></i>
			<div class="description ${LINE} wrap">${toDo}</div>
		<i class="fas fa-trash-alt"  id='${id}'></i>
	</li>`;
	const position = "beforeend";
	list.insertAdjacentHTML(position, text);		
}

// complete to-do
function jobComplete(element) {
	element.classList.toggle(check);
	element.classList.toggle(uncheck);
	element.parentNode.querySelector(".description").classList.toggle(lineThrough);
	LIST[element.id].done = LIST[element.id].done ? false : true;
}	

// remove to-do
function removeToDo(element, i) {	
	element.parentNode.remove();
	LIST = LIST.filter(element => element.id !== event.target.id);
	localStorage.setItem('TODO', JSON.stringify(LIST));
	console.log(LIST);
	return LIST;

}

// click listener for job complete and job delete
list.addEventListener('click', e => {
	const element = e.target;
	if(e.target.className == "fas fa-trash-alt" ){
		removeToDo(element);
	}else if(e.target.className == "far fa-circle") {
		jobComplete(element);
	}else if(e.target.className == "far fa-check-circle"){
	 	jobComplete(element);
	}
	}
)

//add a task with "enter" key
document.addEventListener("keyup", (event) => {
	if(event.keyCode == 13){
		const toDo = input.value;
			if(toDo) {
				//gen id
				const id = uuidv4();
				addToDo(toDo, id, false, false);
				LIST.push(
					{
						name: toDo,
						id: id,
						done: false,
						trash: false
					}
				);
				localStorage.setItem('TODO', JSON.stringify(LIST));
				input.value = '';
			}
		}
})
//clear all items
clear.addEventListener('click', () => {
	localStorage.clear()
	//location.reload();
	}
)

// add a task by clicking the plus icon
document.getElementById("addButton").addEventListener('click', (event) =>{
	const toDo = input.value;	
	if(toDo) {
		//gen id
		const id = uuidv4();
		addToDo(toDo, id, false, false);
		LIST.push(
			{
				name: toDo,
				id: id,
				done: false,
				trash: false
			}
			
		);
		localStorage.setItem('TODO', JSON.stringify(LIST));
		input.value = '';
		
	}
})

              
            
!
999px

Console