wip, split dark theme style by .dark and store light theme to normal

This commit is contained in:
LouisLam 2021-08-07 01:21:41 +08:00
parent 8d60568fd0
commit f345a8f33a
11 changed files with 235 additions and 155 deletions

View file

@ -1,46 +1,16 @@
@import "vars.scss"; @import "vars.scss";
@import "node_modules/bootstrap/scss/bootstrap"; @import "node_modules/bootstrap/scss/bootstrap";
html,
body,
input,
.modal-content {
background: var(--page-background);
color: var(--main-font-color);
}
a,
.table,
.nav-link {
color: var(--main-font-color);
}
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
color: #0a0a0a;
}
.nav-link:hover,
.nav-link:focus {
color: #5cdd8b;
}
.form-control,
.form-control:focus,
.form-select,
.form-select:focus {
color: var(--main-font-color);
background-color: var(--background-4);
}
#app { #app {
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, font-family: ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,segoe ui,Roboto,helvetica neue,Arial,noto sans,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol,noto color emoji;
segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif,
apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji;
} }
.shadow-box { .shadow-box {
overflow: hidden; overflow: hidden;
box-shadow: 0 15px 70px rgba(0, 0, 0, 0.1); box-shadow: 0 15px 70px rgba(0, 0, 0, .1);
padding: 10px; padding: 10px;
border-radius: 10px;
&.big-padding { &.big-padding {
padding: 20px; padding: 20px;
} }
@ -52,13 +22,10 @@ a,
} }
.btn-primary { .btn-primary {
color: #0a0a0a; color: white;
&:hover, &:hover, &:active, &:focus, &.active {
&:active, color: white;
&:focus,
&.active {
color: #0a0a0a;
background-color: $highlight; background-color: $highlight;
border-color: $highlight; border-color: $highlight;
} }
@ -69,8 +36,49 @@ a,
backdrop-filter: blur(3px); backdrop-filter: blur(3px);
} }
@media (prefers-color-scheme: dark) { // Dark Theme override here
.dark {
a:hover { a:hover {
color: #7ce8a4; color: #7ce8a4;
} }
.btn-primary {
color: #0a0a0a;
&:hover, &:active, &:focus, &.active {
color: #0a0a0a;
background-color: $highlight;
border-color: $highlight;
}
}
html,
body,
input,
.modal-content {
background: var(--page-background);
color: var(--main-font-color);
}
a,
.table,
.nav-link {
color: var(--main-font-color);
}
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
color: #0a0a0a;
}
.nav-link:hover,
.nav-link:focus {
color: #5cdd8b;
}
.form-control,
.form-control:focus,
.form-select,
.form-select:focus {
color: var(--main-font-color);
background-color: var(--background-4);
}
} }

View file

@ -1,24 +1,17 @@
$primary: #5cdd8b; $primary: #5CDD8B;
$danger: #dc3545; $danger: #DC3545;
$warning: #dca235; $warning: #f8a306;
$link-color: #111; $link-color: #111;
$border-radius: .25rem; $border-radius: 50rem;
$highlight: #7ce8a4; $highlight: #7ce8a4;
$highlight-white: #e7faec; $highlight-white: #e7faec;
:root { .dark {
color-scheme: light dark; $primary: #5cdd8b;
--page-background: #fafafa; $danger: #dc3545;
--background-secondary: #d0d3d5; $warning: #dca235;
--background-4: #d0d3d5;
--background-ternary: #8e8e8e;
--background-sidebar-active: #e4e4e4;
--background-navbar: #FFF;
--main-font-color: #212529;
}
@media (prefers-color-scheme: dark) {
:root { :root {
--page-background: #0a0a0a; --page-background: #0a0a0a;
--background-secondary: #656565; --background-secondary: #656565;

View file

@ -133,7 +133,7 @@ export default {
} }
</script> </script>
<style scoped lang="scss"> <style lang="scss" scoped>
@import "../assets/vars.scss"; @import "../assets/vars.scss";
.wrap { .wrap {
@ -149,7 +149,11 @@ export default {
border-radius: 50rem; border-radius: 50rem;
&.empty { &.empty {
background-color: #d0d3d5; background-color: aliceblue;
.dark & {
background-color: #d0d3d5;
}
} }
&.down { &.down {
@ -168,8 +172,10 @@ export default {
} }
} }
.hp-bar-big .beat.empty{ .dark {
background-color: #848484; .hp-bar-big .beat.empty{
background-color: #848484;
}
} }
</style> </style>

View file

@ -233,17 +233,17 @@
<template v-if="notification.type === 'pushy'"> <template v-if="notification.type === 'pushy'">
<div class="mb-3"> <div class="mb-3">
<label for="pushy-app-token" class="form-label">API_KEY</label> <label for="pushy-app-token" class="form-label">API_KEY</label>
<input type="text" class="form-control" id="pushy-app-token" required v-model="notification.pushyAPIKey"> <input id="pushy-app-token" v-model="notification.pushyAPIKey" type="text" class="form-control" required>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="pushy-user-key" class="form-label">USER_TOKEN</label> <label for="pushy-user-key" class="form-label">USER_TOKEN</label>
<div class="input-group mb-3"> <div class="input-group mb-3">
<input type="text" class="form-control" id="pushy-user-key" required v-model="notification.pushyToken"> <input id="pushy-user-key" v-model="notification.pushyToken" type="text" class="form-control" required>
</div> </div>
</div> </div>
<p style="margin-top: 8px;"> <p style="margin-top: 8px;">
More info on: <a href="https://pushy.me/docs/api/send-notifications" target="_blank">https://pushy.me/docs/api/send-notifications</a> More info on: <a href="https://pushy.me/docs/api/send-notifications" target="_blank">https://pushy.me/docs/api/send-notifications</a>
</p> </p>
</template> </template>
@ -334,7 +334,6 @@
</div> </div>
</div> </div>
</template> </template>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button v-if="id" type="button" class="btn btn-danger" :disabled="processing" @click="deleteConfirm"> <button v-if="id" type="button" class="btn btn-danger" :disabled="processing" @click="deleteConfirm">
@ -509,17 +508,19 @@ export default {
} }
</script> </script>
<style> <style lang="scss" scoped>
.modal-dialog .form-text, .modal-dialog p{ .dark {
color: var(--main-font-color); .modal-dialog .form-text, .modal-dialog p{
} color: var(--main-font-color);
.modal-content{ }
border: 1px solid var(--main-font-color);
} .modal-content{
@media (prefers-color-scheme: dark) { border: 1px solid var(--main-font-color);
}
.btn-close{ .btn-close{
background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23FFF'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat; background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23FFF'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
opacity: 1; opacity: 1;
} }
} }
</style> </style>

View file

@ -1,76 +1,78 @@
<template> <template>
<div v-if="! $root.socket.connected && ! $root.socket.firstConnect" class="lost-connection"> <div :class="$root.theme">
<div class="container-fluid"> <div v-if="! $root.socket.connected && ! $root.socket.firstConnect" class="lost-connection">
{{ $root.connectionErrorMsg }} <div class="container-fluid">
{{ $root.connectionErrorMsg }}
</div>
</div> </div>
<!-- Desktop header -->
<header v-if="! $root.isMobile" class="d-flex flex-wrap justify-content-center py-3 mb-3 border-bottom">
<router-link to="/dashboard" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
<object class="bi me-2 ms-4" width="40" height="40" data="/icon.svg" alt="Logo" />
<span class="fs-4 title">Uptime Kuma</span>
</router-link>
<ul class="nav nav-pills">
<li class="nav-item">
<router-link to="/dashboard" class="nav-link">
<font-awesome-icon icon="tachometer-alt" /> Dashboard
</router-link>
</li>
<li class="nav-item">
<router-link to="/settings" class="nav-link">
<font-awesome-icon icon="cog" /> Settings
</router-link>
</li>
</ul>
</header>
<!-- Mobile header -->
<header v-else class="d-flex flex-wrap justify-content-center mt-3 mb-3">
<router-link to="/dashboard" class="d-flex align-items-center text-dark text-decoration-none">
<object class="bi" width="40" height="40" data="/icon.svg" />
<span class="fs-4 title ms-2">Uptime Kuma</span>
</router-link>
</header>
<main>
<!-- Add :key to disable vue router re-use the same component -->
<router-view v-if="$root.loggedIn" :key="$route.fullPath" />
<Login v-if="! $root.loggedIn && $root.allowLoginDialog" />
</main>
<footer>
<div class="container-fluid">
Uptime Kuma -
Version: {{ $root.info.version }} -
<a href="https://github.com/louislam/uptime-kuma/releases" target="_blank" rel="noopener">Check Update On GitHub</a>
</div>
</footer>
<!-- Mobile Only -->
<div v-if="$root.isMobile" style="width: 100%;height: 60px;" />
<nav v-if="$root.isMobile" class="bottom-nav">
<router-link to="/dashboard" class="nav-link" @click="$root.cancelActiveList">
<div><font-awesome-icon icon="tachometer-alt" /></div>
Dashboard
</router-link>
<a href="#" :class=" { 'router-link-exact-active' : $root.showListMobile } " @click="$root.showListMobile = ! $root.showListMobile">
<div><font-awesome-icon icon="list" /></div>
List
</a>
<router-link to="/add" class="nav-link" @click="$root.cancelActiveList">
<div><font-awesome-icon icon="plus" /></div>
Add
</router-link>
<router-link to="/settings" class="nav-link" @click="$root.cancelActiveList">
<div><font-awesome-icon icon="cog" /></div>
Settings
</router-link>
</nav>
</div> </div>
<!-- Desktop header -->
<header v-if="! $root.isMobile" class="d-flex flex-wrap justify-content-center py-3 mb-3 border-bottom">
<router-link to="/dashboard" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-decoration-none">
<object class="bi me-2 ms-4" width="40" height="40" data="/icon.svg" alt="Logo" />
<span class="fs-4 title">Uptime Kuma</span>
</router-link>
<ul class="nav nav-pills">
<li class="nav-item">
<router-link to="/dashboard" class="nav-link">
<font-awesome-icon icon="tachometer-alt" /> Dashboard
</router-link>
</li>
<li class="nav-item">
<router-link to="/settings" class="nav-link">
<font-awesome-icon icon="cog" /> Settings
</router-link>
</li>
</ul>
</header>
<!-- Mobile header -->
<header v-else class="d-flex flex-wrap justify-content-center mt-3 mb-3">
<router-link to="/dashboard" class="d-flex align-items-center text-decoration-none">
<object class="bi" width="40" height="40" data="/icon.svg" />
<span class="fs-4 title ms-2">Uptime Kuma</span>
</router-link>
</header>
<main>
<!-- Add :key to disable vue router re-use the same component -->
<router-view v-if="$root.loggedIn" :key="$route.fullPath" />
<Login v-if="! $root.loggedIn && $root.allowLoginDialog" />
</main>
<footer>
<div class="container-fluid">
Uptime Kuma -
Version: {{ $root.info.version }} -
<a href="https://github.com/louislam/uptime-kuma/releases" target="_blank" rel="noopener">Check Update On GitHub</a>
</div>
</footer>
<!-- Mobile Only -->
<div v-if="$root.isMobile" style="width: 100%;height: 60px;" />
<nav v-if="$root.isMobile" class="bottom-nav">
<router-link to="/dashboard" class="nav-link" @click="$root.cancelActiveList">
<div><font-awesome-icon icon="tachometer-alt" /></div>
Dashboard
</router-link>
<a href="#" :class=" { 'router-link-exact-active' : $root.showListMobile } " @click="$root.showListMobile = ! $root.showListMobile">
<div><font-awesome-icon icon="list" /></div>
List
</a>
<router-link to="/add" class="nav-link" @click="$root.cancelActiveList">
<div><font-awesome-icon icon="plus" /></div>
Add
</router-link>
<router-link to="/settings" class="nav-link" @click="$root.cancelActiveList">
<div><font-awesome-icon icon="cog" /></div>
Settings
</router-link>
</nav>
</template> </template>
<script> <script>
@ -103,7 +105,7 @@ export default {
} }
</script> </script>
<style scoped lang="scss"> <style lang="scss" scoped>
@import "../assets/vars.scss"; @import "../assets/vars.scss";
.bottom-nav { .bottom-nav {
@ -113,7 +115,6 @@ export default {
height: 60px; height: 60px;
width: 100%; width: 100%;
left: 0; left: 0;
background-color: var(--background-navbar);
box-shadow: 0 15px 47px 0 rgba(0, 0, 0, 0.05), 0 5px 14px 0 rgba(0, 0, 0, 0.05); box-shadow: 0 15px 47px 0 rgba(0, 0, 0, 0.05), 0 5px 14px 0 rgba(0, 0, 0, 0.05);
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
@ -141,6 +142,12 @@ export default {
} }
} }
.dark {
.bottom-nav {
background-color: var(--background-navbar);
}
}
.title { .title {
font-weight: bold; font-weight: bold;
} }

View file

@ -9,6 +9,7 @@ import { FontAwesomeIcon } from "./icon.js";
import EmptyLayout from "./layouts/EmptyLayout.vue"; import EmptyLayout from "./layouts/EmptyLayout.vue";
import Layout from "./layouts/Layout.vue"; import Layout from "./layouts/Layout.vue";
import socket from "./mixins/socket"; import socket from "./mixins/socket";
import theme from "./mixins/theme";
import Dashboard from "./pages/Dashboard.vue"; import Dashboard from "./pages/Dashboard.vue";
import DashboardHome from "./pages/DashboardHome.vue"; import DashboardHome from "./pages/DashboardHome.vue";
import Details from "./pages/Details.vue"; import Details from "./pages/Details.vue";
@ -76,6 +77,7 @@ const router = createRouter({
const app = createApp({ const app = createApp({
mixins: [ mixins: [
socket, socket,
theme
], ],
render: () => h(App), render: () => h(App),
}) })

View file

@ -29,7 +29,7 @@ export default {
notificationList: [], notificationList: [],
windowWidth: window.innerWidth, windowWidth: window.innerWidth,
showListMobile: false, showListMobile: false,
connectionErrorMsg: "Cannot connect to the socket server. Reconnecting..." connectionErrorMsg: "Cannot connect to the socket server. Reconnecting...",
} }
}, },

33
src/mixins/theme.js Normal file
View file

@ -0,0 +1,33 @@
export default {
data() {
return {
system: (window.matchMedia("(prefers-color-scheme: dark)")) ? "dark" : "light",
userTheme: localStorage.theme,
};
},
mounted() {
// Default Light
if (! this.userTheme) {
this.userTheme = "light";
}
},
computed: {
theme() {
if (this.userTheme === "auto") {
return this.system;
}
return this.userTheme;
}
},
methods: {
changeTheme(name) {
localStorage.theme = name;
this.userTheme = name;
}
}
}

View file

@ -89,7 +89,7 @@ export default {
} }
</script> </script>
<style scoped lang="scss"> <style lang="scss" scoped>
@import "../assets/vars.scss"; @import "../assets/vars.scss";
.container-fluid { .container-fluid {
@ -119,11 +119,11 @@ export default {
} }
&:hover { &:hover {
background-color: var(--background-4); background-color: $highlight-white;
} }
&.active { &.active {
background-color: var(--background-4); background-color: #cdf8f4;
} }
} }
} }
@ -133,4 +133,18 @@ export default {
padding-right: 5px !important; padding-right: 5px !important;
} }
.dark {
.list {
.item {
&:hover {
background-color: var(--background-4);
}
&.active {
background-color: var(--background-4);
}
}
}
}
</style> </style>

View file

@ -169,11 +169,11 @@ export default {
} }
</script> </script>
<style scoped lang="scss"> <style lang="scss" scoped>
@import "../assets/vars"; @import "../assets/vars";
.num { .num {
font-size: 1rem; font-size: 30px;
color: $primary; color: $primary;
font-weight: bold; font-weight: bold;
display: block; display: block;

View file

@ -20,6 +20,19 @@
</select> </select>
</div> </div>
<div class="mb-3">
<div class="btn-group" role="group" aria-label="Basic checkbox toggle button group">
<input id="btncheck1" type="radio" class="btn-check" name="theme" autocomplete="off">
<label class="btn btn-outline-primary" for="btncheck1">Light</label>
<input id="btncheck2" type="radio" class="btn-check" name="theme" autocomplete="off">
<label class="btn btn-outline-primary" for="btncheck2">Dark</label>
<input id="btncheck3" type="radio" class="btn-check" name="theme" autocomplete="off">
<label class="btn btn-outline-primary" for="btncheck3">Auto</label>
</div>
</div>
<div> <div>
<button class="btn btn-primary" type="submit"> <button class="btn btn-primary" type="submit">
Save Save
@ -201,12 +214,15 @@ export default {
} }
</script> </script>
<style scoped> <style lang="scss" scoped>
.shadow-box { .shadow-box {
padding: 20px; padding: 20px;
} }
.list-group-item{
background-color: var(--background-4); .dark {
color: var(--main-font-color); .list-group-item {
background-color: var(--background-4);
color: var(--main-font-color);
}
} }
</style> </style>