Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions solutions/dom_manipulation/3/3.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container{
display: flex;
width: 500px;
height: 30px;
background-color: red;
border-radius: 10px;
/* overflow: hidden; */
background-color: #f6f8fa;
}
.container input {
width: 90%;
border: none;
outline: none;
padding: 0 10px;
border: 2px solid rgb(206, 206, 206);
border-right: none;
border-radius: 10px 0 0 10px;
background-color: transparent;
}
.container .icon{
width: 10%;
border-radius: 0 10px 10px 0;
border: 2px solid rgb(206, 206, 206);
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}

.container .icon span{
position: absolute;
left: 50%;
top: -200%;
transform: translateX(-50%);
background-color: #303030;
color: #fff;
white-space: nowrap;
padding: 10px 15px;
border-radius: 10px;
display: none;
transition: all 0.3s;
}
.container .icon i{
transition: .3s;
}
.container .icon span::before{
content: "";
position: absolute;
left: 50%;
top: 100%;
transform: translateX(-50%);
border: 10px solid;
border-color: #303030 #0000 #0000 #0000;
}
30 changes: 30 additions & 0 deletions solutions/dom_manipulation/3/3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dom Manipulation 3rd challenge</title>
<link rel="stylesheet" href="3.css">

<!-- for the icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />

</head>

<body>
<div class="container">
<input type="text">
<div class="icon">
<i id="btn" class="fa-regular fa-copy"></i>
<!-- <i class="fa-solid fa-check"></i> -->
<span>Copied!</span>
</div>
</div>

<script src="3.js"></script>
</body>

</html>
27 changes: 27 additions & 0 deletions solutions/dom_manipulation/3/3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const text = document.querySelector("input");
const tooltip = document.querySelector("span");
const iconDiv = document.querySelector(".icon");
const copy = document.querySelector("#btn");

copy.addEventListener("click", () => {
text.select();

navigator.clipboard.writeText(text.value);
copy.classList.remove("fa-regular");
copy.classList.remove("fa-copy");
copy.classList.add("fa-solid");
copy.classList.add("fa-check");
tooltip.style.display = "block";
iconDiv.style.borderColor = "green";
copy.style.color = "green";

setTimeout(() => {
copy.classList.remove("fa-solid");
copy.classList.remove("fa-check");
copy.classList.add("fa-regular");
copy.classList.add("fa-copy");
tooltip.style.display = "none";
copy.style.color = "#000";
iconDiv.style.borderColor = "rgb(206, 206, 206)";
}, 3000);
});