Skip to content
Merged
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
79 changes: 79 additions & 0 deletions backend/static/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.page {
background-color: #f4f6fc;
}

.page-dark [data-bs-toggle="tooltip"] {
color: white;
border: none !important;
}

.switch {
position: relative;
display: inline-block;
width: 30px;
height: 19px;
margin-right: 3px;
}

.switch input {
opacity: 0;
width: 0;
height: 0;
}

.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}

.slider:before {
position: absolute;
content: "";
height: 15px;
width: 15px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}

input:checked + .slider {
background-color: black;
}

input:focus + .slider {
box-shadow: 0 0 1px black;
}

input:checked + .slider:before {
-webkit-transform: translateX(10px);
-ms-transform: translateX(10px);
transform: translateX(10px);
}

/* Rounded sliders */
.slider.round {
border-radius: 15px;
}

.slider.round:before {
border-radius: 50%;
}

.toggle-btn {
margin-right: 10px;
width: 90px;
}

.toggle-btn i {
vertical-align: text-top;
margin-right: 2px;
}
67 changes: 61 additions & 6 deletions backend/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
<link rel="stylesheet" href="{% static 'css/app.css' %}" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
Expand All @@ -23,14 +24,11 @@
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/relativeTime.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
.page {
background-color: #f4f6fc;
}
</style>
{% block extra_css %}
{% endblock extra_css %}
</head>
<body class="page">
{% block content %}
<div id="theme-toggle-app">
<div class="banner">
<nav class="navbar navbar-expand-lg sticky-top border-bottom border-body mb-4"
data-bs-theme="light"
Expand All @@ -57,8 +55,65 @@
</div>
</div>
</div>
<div class="toggle-btn">
<theme-toggle></theme-toggle>
</div>
</nav>
</div>
</div>
{% block content %}
{% endblock content %}
<script>
const ThemeToggle = {
template: `
<i class="fa-regular fa-lightbulb"></i>
<label class="switch">
<input type="checkbox" v-model="isDarkTheme" @change="toggleTheme">
<span class="slider round"></span>
</label>
<i class="fa-solid fa-moon"></i>
`,
data() {
return {
isDarkTheme: false
}
},
mounted() {
const currentTheme = localStorage.getItem('theme')
if (currentTheme) {
this.isDarkTheme = currentTheme === 'dark'
this.applyTheme()
}
},
methods: {
toggleTheme() {
this.applyTheme()
localStorage.setItem('theme', this.isDarkTheme ? 'dark' : 'light')
},
applyTheme() {
document.documentElement.setAttribute('data-bs-theme', this.isDarkTheme ? 'dark' : 'light')
if (this.isDarkTheme) {
document.body.classList.remove("page");
document.body.classList.add("page-dark");

} else {
document.body.classList.remove("page-dark");
document.body.classList.add("page");
}

}
}
}

const themeToggleApp = Vue.createApp({
components: {
ThemeToggle
}
})

themeToggleApp.mount('#theme-toggle-app')
</script>
{% block extra_js %}
{% endblock extra_js %}
</body>
</html>