Skip to content

Commit a597efd

Browse files
committed
adding newsletter toast
1 parent 2bbc0f7 commit a597efd

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

_layouts/post.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ <h2>{{ page.description | escape }}</h2>
3737
<p>Sign up here to get updates on new posts:</p>
3838
<input type="email" name="email" id="email" placeholder="email"
3939
required style="font-family: Roboto; width: 45%;" />
40-
<input type="submit" value="Subscribe" onclick="validateSubmit()" style="font-family: Roboto;" />
40+
<input type="submit" value="Subscribe" style="font-family: Roboto;" />
41+
<div id="subscribeToast">Thanks for subscribing!</div>
4142
</form>
4243

4344
<iframe name="dummyframe" id="dummyframe" style="display: none;"></iframe>
@@ -47,6 +48,15 @@ <h2>{{ page.description | escape }}</h2>
4748
function clearEmail() {
4849
setTimeout(function() {
4950
document.querySelector('#email').value = '';
51+
showToast();
5052
}, 5);
5153
}
54+
55+
function showToast() {
56+
const toast = document.querySelector("#subscribeToast");
57+
toast.classList.add('show');
58+
setTimeout(function() {
59+
toast.classList.remove('show');
60+
}, 3000);
61+
}
5262
</script>

assets/css/extra.css

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,46 @@ figcaption {
8383
.spoiler p::selection {
8484
background: rgb(160, 140, 152);
8585
color: #fafafa;
86-
}
86+
}
87+
88+
#subscribeToast {
89+
visibility: hidden;
90+
min-width: 250px;
91+
margin-left: -125px;
92+
background-color: #334;
93+
color: #fff;
94+
text-align: center;
95+
border-radius: 2px;
96+
padding: 16px;
97+
position: fixed;
98+
z-index: 1;
99+
left: 50%;
100+
bottom: 30px;
101+
102+
&.show {
103+
visibility: visible;
104+
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
105+
animation: fadein 0.5s, fadeout 0.5s 2.5s;
106+
}
107+
}
108+
109+
@-webkit-keyframes fadein {
110+
from {bottom: 0; opacity: 0;}
111+
to {bottom: 30px; opacity: 1;}
112+
}
113+
114+
@keyframes fadein {
115+
from {bottom: 0; opacity: 0;}
116+
to {bottom: 30px; opacity: 1;}
117+
}
118+
119+
@-webkit-keyframes fadeout {
120+
from {bottom: 30px; opacity: 1;}
121+
to {bottom: 0; opacity: 0;}
122+
}
123+
124+
@keyframes fadeout {
125+
from {bottom: 30px; opacity: 1;}
126+
to {bottom: 0; opacity: 0;}
127+
}
128+

0 commit comments

Comments
 (0)