Make changelog banner dismissable (#1113)

This commit is contained in:
Manuel Díez 2021-04-23 15:17:42 -04:00 committed by GitHub
parent 31d9b8b471
commit 120bb346db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -62,15 +62,18 @@ table.docutils {
z-index: 9999;
display: none
}
#upgrade-footer-changelog {
.footer-button-container {
margin: 0 60px 0 10px;
float: right;
}
.footer-button {
background-color: #b3b3b3;
color: #4e4e4e;
display: inline-block;
border-radius: 5px;
padding: 0 20px;
margin-left: 10px;
cursor: pointer;
float: right;
margin: 0 60px 0 10px;
text-decoration: none;
}
.not-hidden {

View File

@ -30,15 +30,20 @@
{% block footer %}
<div id="upgrade-footer">
A new version has been release since you last visited this page: {{ release }} 🎉
<a id="upgrade-footer-changelog" href="/changelog/v{{ version }}.0.html">View Changelog</a>
<div class="footer-button-container">
<div role="button" id="upgrade-footer-dismiss" class="footer-button">Dismiss</div>
<a id="upgrade-footer-changelog" class="footer-button" href="/changelog/v{{ version }}.0.html">View Changelog</a>
</div>
</div>
<script>
var old = window.localStorage.getItem("version");
if (old === null) { window.localStorage.setItem("version", "{{ version }}");
} else if (old !== "{{ version }}") {
document.getElementById("upgrade-footer").classList.add("not-hidden");
document.getElementById("upgrade-footer-changelog").addEventListener('click', function () {
const footerEl = document.getElementById("upgrade-footer");
footerEl.classList.add("not-hidden");
footerEl.addEventListener('click', function () {
window.localStorage.setItem("version", "{{ version }}");
footerEl.classList.remove("not-hidden");
});
}
</script>