Likes
Likes
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Likes counter</title>
</head>
<body>
<h1>Likes counter</h1>
<div class="likes-wrapper" onclick="clickCounter()">
<div class="likes-header">
<p class="likes">Likes</p>
</div>
<div class="triangle-down"></div>
<p id="amount"></p>
<p class="likes">Likes</p>
</div>
</body>
</html>
.likes-wrapper {
position: absolute;
top: calc(50% - 50px);
left: calc(50% - 50px);
width: 100px;
height: 100px;
padding: 0;
background-color: #fff;
border:;
border-radius: 10px;
box-shadow: 0 5px #00a, 0 0 4px #000;
overflow: hidden;
cursor: pointer;
}
.likes-wrapper:active {
box-shadow: 0 1px #00a, 0 0 1px #000;
transform: translatey(+4px);
}
.likes-header {
position: relative;
top: -21px;
left: 0;
width: 100%;
height: 50%;
padding: 10px 0;
background-color: #07f;
}
.triangle-down {
position: absolute;
width: 0;
height: 0;
margin: -21px 45px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 10px solid #07f;
}
.likes {
margin-top: 20px;
color: #fff;
font-size: 20px;
font-weight: 700;
text-align: center;
}
#amount {
margin-top: -6px;
color: #00f;
font-size: 20px;
font-weight: 700;
text-align: center;
}
const amount = document.querySelector("#amount")
const clicks = document.querySelector(".likes-wrapper");
amount.innerHTML = localStorage.getItem('clicks') ? parseInt(localStorage.getItem('clicks')) : 0;
function clickCounter() {
var currentValue = localStorage.getItem('clicks') ? parseInt(localStorage.getItem('clicks')) : 0;
var newValue = currentValue + 1;
localStorage.setItem('clicks', newValue);
amount.innerHTML = newValue;
}