Skip to content

add a draft of dark mode (#106, #285) #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions oioioi/base/static/js/darkreader.min.js

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions oioioi/base/static/scss/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,47 @@ body {
height: $oioioi-footer-height;
justify-content: center;
}

.footer-content {
position: absolute;
left: 50%;
transform: translateX(-50%);
}

#dark-mode-toggle {
margin-left: auto;
position: relative;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
width: 60px;
height: 30px;
border-radius: 30px;
background-color: #a8adad;
transition: all 0.5s ease-in;
cursor: pointer;
z-index: 1;
}

#dark-mode-toggle::before {
content: "";
width: 25px;
height: 25px;
border-radius: 50%;
background: #EEE;
position: absolute;
top: 50%;
left: 3px;
transform: translateY(-50%);
transition: all 0.5s ease-in;
}

#dark-mode-toggle:checked {
background: #a8adad;
}

#dark-mode-toggle:checked::before {
background: #333;
left: 32px;
}

22 changes: 22 additions & 0 deletions oioioi/base/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,27 @@
src="{{ mathjax_location }}MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
{% endblock %}

<script src="{{ STATIC_URL }}js/darkreader.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const toggleButton = document.getElementById("dark-mode-toggle");

if (localStorage.getItem("dark-mode") === "enabled") {
DarkReader.enable();
}

toggleButton.addEventListener("click", function () {
if (DarkReader.isEnabled()) {
DarkReader.disable();
localStorage.setItem("dark-mode", "disabled");
} else {
DarkReader.enable();
localStorage.setItem("dark-mode", "enabled");
}
});
});
</script>

</body>
</html>
19 changes: 12 additions & 7 deletions oioioi/base/templates/ingredients/footer.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{% load i18n all_with_prefix %}
<footer class="footer container-fluid">
<span class="text-muted">
<!--
<div class="footer-content">
<span class="text-muted">
<!--
Please make sure that the following text is visible. We are glad that
you are using SIO2 and we simply want the other people to learn about
this system, too. Thank you.
-->
{% blocktrans trimmed %}
Powered by <a href="https://www.github.com/sio2project/oioioi">OIOIOI</a>,
from the <a href="https://github.com/sio2project">SIO2 Project</a>.
{% endblocktrans %}
</span>
{% blocktrans trimmed %}
Powered by <a href="https://www.github.com/sio2project/oioioi">OIOIOI</a>,
from the <a href="https://github.com/sio2project">SIO2 Project</a>.
{% endblocktrans %}
</span>
</div>
<input type="checkbox" id="dark-mode-toggle">
{% all_with_prefix extra_footer_ %}
</footer>