Spaces:
Sleeping
Sleeping
Commit ·
b870f42
1
Parent(s): 302ef57
added notifications
Browse files
DjangoWeb/main/static/main/index.css
CHANGED
|
@@ -15,6 +15,41 @@ body{
|
|
| 15 |
left:0;
|
| 16 |
}
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
#main_container{
|
| 19 |
background-color: #ffffff4d;
|
| 20 |
box-shadow: 1px 1px 20px -10px #000;
|
|
@@ -120,3 +155,5 @@ input[type='button']:hover{
|
|
| 120 |
cursor: pointer;
|
| 121 |
}
|
| 122 |
}
|
|
|
|
|
|
|
|
|
| 15 |
left:0;
|
| 16 |
}
|
| 17 |
|
| 18 |
+
#toast_container{
|
| 19 |
+
position:fixed;
|
| 20 |
+
bottom:30px;
|
| 21 |
+
right:30px;
|
| 22 |
+
overflow: hidden;
|
| 23 |
+
/* height:70%;
|
| 24 |
+
display: flex;
|
| 25 |
+
flex-direction: column-reverse; */
|
| 26 |
+
|
| 27 |
+
}
|
| 28 |
+
.toast{
|
| 29 |
+
min-width:200px;
|
| 30 |
+
min-height:100px;
|
| 31 |
+
background-color: #fff;
|
| 32 |
+
margin:20px 0;
|
| 33 |
+
border-radius: 10px;
|
| 34 |
+
box-shadow: 1px 1px 20px -10px;
|
| 35 |
+
display: flex;
|
| 36 |
+
flex-direction: row;
|
| 37 |
+
align-items: center;
|
| 38 |
+
transform: translateX(100%);
|
| 39 |
+
animation: right-to-left 0.5s forwards linear;
|
| 40 |
+
}
|
| 41 |
+
@keyframes right-to-left {
|
| 42 |
+
100%{
|
| 43 |
+
transform: translateX(0%);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
.toast>i{
|
| 47 |
+
margin-inline: 20px;
|
| 48 |
+
background-color: #a9ff00;
|
| 49 |
+
padding:0.5rem;
|
| 50 |
+
border-radius: 50px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
#main_container{
|
| 54 |
background-color: #ffffff4d;
|
| 55 |
box-shadow: 1px 1px 20px -10px #000;
|
|
|
|
| 155 |
cursor: pointer;
|
| 156 |
}
|
| 157 |
}
|
| 158 |
+
|
| 159 |
+
|
DjangoWeb/main/static/main/index.js
CHANGED
|
@@ -15,7 +15,10 @@ function createColorCard(colorname,color){
|
|
| 15 |
card.dataset.color=color;
|
| 16 |
card.innerHTML=`
|
| 17 |
<div class="card-color" style='background:${color}'>
|
| 18 |
-
<i class="fa-solid fa-copy card-copy-btn"
|
|
|
|
|
|
|
|
|
|
| 19 |
<i class="fa-solid fa-heart card-like-btn"></i>
|
| 20 |
</div>
|
| 21 |
<div class="card-title">${colorname}</div>
|
|
@@ -62,4 +65,29 @@ function copyToClipboard(value){
|
|
| 62 |
function detectOnSubmit(e){
|
| 63 |
if(e.key==='Enter' || e.keyCode===13)
|
| 64 |
generateColor()
|
| 65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
card.dataset.color=color;
|
| 16 |
card.innerHTML=`
|
| 17 |
<div class="card-color" style='background:${color}'>
|
| 18 |
+
<i class="fa-solid fa-copy card-copy-btn"
|
| 19 |
+
onclick="copyToClipboard(this.closest('.card').dataset.color);addNotification('Copied !','success');"
|
| 20 |
+
|
| 21 |
+
></i>
|
| 22 |
<i class="fa-solid fa-heart card-like-btn"></i>
|
| 23 |
</div>
|
| 24 |
<div class="card-title">${colorname}</div>
|
|
|
|
| 65 |
function detectOnSubmit(e){
|
| 66 |
if(e.key==='Enter' || e.keyCode===13)
|
| 67 |
generateColor()
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
function addNotification(msg,type){
|
| 72 |
+
// <div class="toast">
|
| 73 |
+
// <i class="fa-solid fa-check"></i>
|
| 74 |
+
// <span>copied!</span>
|
| 75 |
+
// </div>
|
| 76 |
+
|
| 77 |
+
var toast = document.createElement("div");
|
| 78 |
+
toast.className = 'toast';
|
| 79 |
+
if(type=="success"){
|
| 80 |
+
toast.innerHTML=`<i class="fa-solid fa-check"></i>`;
|
| 81 |
+
}
|
| 82 |
+
else if(type=="error"){
|
| 83 |
+
toast.innerHTML=`<i class="fa-solid fa-cross"></i>`;
|
| 84 |
+
}
|
| 85 |
+
toast.innerHTML+=`<span>${msg}</span>`;
|
| 86 |
+
toast_container.append(toast);
|
| 87 |
+
|
| 88 |
+
setTimeout(()=>{
|
| 89 |
+
toast.remove();
|
| 90 |
+
},1000*2);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// addNotification('msg','success');
|
DjangoWeb/main/templates/main/index.html
CHANGED
|
@@ -20,6 +20,8 @@
|
|
| 20 |
|
| 21 |
<section id="colors_section"></section>
|
| 22 |
</div>
|
|
|
|
|
|
|
| 23 |
</body>
|
| 24 |
|
| 25 |
<script src="{% static 'main/index.js' %}"></script>
|
|
|
|
| 20 |
|
| 21 |
<section id="colors_section"></section>
|
| 22 |
</div>
|
| 23 |
+
<div id="toast_container">
|
| 24 |
+
</div>
|
| 25 |
</body>
|
| 26 |
|
| 27 |
<script src="{% static 'main/index.js' %}"></script>
|