Skip to content

Commit 639697d

Browse files
authored
Merge pull request Dezenix#100 from suyogkokaje/suyog
feat: added button with progress bar
2 parents 223c762 + 9bbc9c0 commit 639697d

File tree

4 files changed

+179
-0
lines changed

4 files changed

+179
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Music Player
2+
<h3> Tech Stack Used <img src = "https://media2.giphy.com/media/QssGEmpkyEOhBCb7e1/giphy.gif?cid=ecf05e47a0n3gi1bfqntqmob8g9aid1oyj2wr3ds3mg700bl&rid=giphy.gif" width = 32px> </h3>
3+
<p align="left"> <a href="https://www.w3.org/html/" target="_blank"> <img src="https://img.icons8.com/color/48/000000/html-5--v1.png"/> <a href="https://www.w3schools.com/css/" target="_blank"><img src="https://img.icons8.com/color/48/000000/css3.png"/></a>
4+
<img src="https://img.icons8.com/color/48/000000/javascript--v1.png"/></p>
5+
<hr>
6+
7+
### Preview
8+
![Button with Progressbar - Google Chrome 2022-01-18 22-23-31](https://user-images.githubusercontent.com/82764912/150049700-3749624c-f4c8-4c0b-96db-f9c21f24c757.gif)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="style.css">
8+
<title>Button with Progressbar</title>
9+
</head>
10+
<body>
11+
<section class="body">
12+
<button class="btn" data-btn>Submit</button>
13+
<div class="checkmark-container">
14+
<svg x="0px" y="0px" fill="none" class="checkmark-svg" viewBox="0 0 25 30">
15+
<path d="M2,19.2C5.9,23.6,9.4,28,9.4,28L23,2"/>
16+
</svg>
17+
</section>
18+
<script src="script.js"></script>
19+
</body>
20+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const btn = document.querySelector("[data-btn]");
2+
btn.addEventListener("click", () => {
3+
btn.classList.add("animating");
4+
});
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
*{
2+
margin: 0;
3+
padding: 0;
4+
}
5+
.body {
6+
background-color: black;
7+
min-height: 100vh;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
margin: 0;
12+
}
13+
14+
:root {
15+
--squish-animation-time: 500ms;
16+
--progress-animation-time: 1000ms;
17+
--circle-animation-time: 300ms;
18+
--checkmark-animation-time: 300ms;
19+
--btn-width: 125px;
20+
--btn-height: 40px;
21+
}
22+
23+
.btn {
24+
position: relative;
25+
background-color: #2b2d2f;
26+
color: #71dfbe;
27+
border: none;
28+
border-radius: 0.125em;
29+
width: var(--btn-width);
30+
height: var(--btn-height);
31+
font-weight: bold;
32+
cursor: pointer;
33+
padding: 0;
34+
}
35+
36+
.btn.animating {
37+
background-color: transparent;
38+
color: transparent;
39+
user-select: none;
40+
cursor: default;
41+
animation: hide 0ms
42+
calc(var(--squish-animation-time) + var(--progress-animation-time)) forwards;
43+
}
44+
45+
.btn::before {
46+
content: "";
47+
display: none;
48+
position: absolute;
49+
background-color: #2b2d2f;
50+
inset: 0;
51+
border-radius: 0.125em;
52+
animation: squish var(--squish-animation-time)
53+
cubic-bezier(0.26, 0.6, 0.46, 1.7);
54+
animation-fill-mode: forwards;
55+
}
56+
57+
.btn::after {
58+
content: "";
59+
display: none;
60+
position: absolute;
61+
background-color: #aaa;
62+
left: 51%;
63+
right: 51%;
64+
top: 45%;
65+
bottom: 45%;
66+
border-radius: 0.25em;
67+
animation: progress var(--progress-animation-time)
68+
var(--squish-animation-time);
69+
animation-fill-mode: forwards;
70+
}
71+
72+
.btn.animating::before,
73+
.btn.animating::after {
74+
display: block;
75+
}
76+
77+
.btn.animating + .checkmark-container {
78+
background-color: #2b2d2f;
79+
border-radius: 0.25em;
80+
width: 0;
81+
height: 0;
82+
animation: circle var(--circle-animation-time)
83+
calc(var(--squish-animation-time) + var(--progress-animation-time)) forwards
84+
cubic-bezier(0.26, 0.6, 0.46, 1.7);
85+
display: flex;
86+
justify-content: center;
87+
align-items: center;
88+
}
89+
90+
.btn.animating + .checkmark-container .checkmark-svg {
91+
stroke: white;
92+
width: 25px;
93+
stroke-dashoffset: 40.84104919433594;
94+
stroke-dasharray: 40.84104919433594;
95+
stroke-linecap: round;
96+
stroke-linejoin: round;
97+
stroke-width: 3px;
98+
animation: checkmark var(--circle-animation-time)
99+
calc(
100+
var(--squish-animation-time) + var(--progress-animation-time) +
101+
var(--circle-animation-time)
102+
)
103+
forwards;
104+
}
105+
106+
@keyframes squish {
107+
100% {
108+
left: -25%;
109+
right: -25%;
110+
top: 45%;
111+
bottom: 45%;
112+
border-radius: 0.25em;
113+
}
114+
}
115+
116+
@keyframes progress {
117+
100% {
118+
left: -25%;
119+
right: -25%;
120+
}
121+
}
122+
123+
@keyframes hide {
124+
100% {
125+
width: 0;
126+
height: 0;
127+
}
128+
}
129+
130+
@keyframes circle {
131+
0% {
132+
width: calc(var(--btn-width) * 1.5);
133+
height: calc(var(--btn-height) * 0.1);
134+
}
135+
100% {
136+
background-color: #71dfbe;
137+
width: 50px;
138+
height: 50px;
139+
border-radius: 100%;
140+
}
141+
}
142+
143+
@keyframes checkmark {
144+
100% {
145+
stroke-dashoffset: 0;
146+
}
147+
}

0 commit comments

Comments
 (0)