Skip to content

Commit

Permalink
Load default theme from config.json, conditional dark attributes, lig…
Browse files Browse the repository at this point in the history
…ht theme adjustments, further theme mixin coverage of extant default dark styling, charts reactive to theme switch
  • Loading branch information
big boy committed Oct 15, 2023
1 parent 627ae4d commit 2e3affd
Show file tree
Hide file tree
Showing 27 changed files with 340 additions and 108 deletions.
1 change: 1 addition & 0 deletions public/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"defaultLocale": "en",
"defaultTheme": "dark",
"hostname": null,
"port": null,
"instancesDB": "moonraker",
Expand Down
206 changes: 206 additions & 0 deletions public/img/sidebar-background-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions remote/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"defaultLocale": "en",
"defaultTheme": "dark",
"hostname": null,
"port": null,
"instancesDB": "browser",
Expand Down
5 changes: 3 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-app :style="cssVars">
<v-app :dark="darkAttribute" :style="cssVars">
<template v-if="socketIsConnected && guiIsReady">
<the-sidebar />
<the-topbar />
Expand Down Expand Up @@ -27,6 +27,7 @@
import Component from 'vue-class-component'
import TheSidebar from '@/components/TheSidebar.vue'
import BaseMixin from '@/components/mixins/base'
import ThemeMixin from './components/mixins/theme'
import TheTopbar from '@/components/TheTopbar.vue'
import { Mixins, Watch } from 'vue-property-decorator'
import TheUpdateDialog from '@/components/TheUpdateDialog.vue'
Expand Down Expand Up @@ -59,7 +60,7 @@ Component.registerHooks(['metaInfo'])
TheScrewsTiltAdjustDialog,
},
})
export default class App extends Mixins(BaseMixin) {
export default class App extends Mixins(BaseMixin, ThemeMixin) {
public metaInfo(): any {
let title = this.$store.getters['getTitle']
Expand Down
8 changes: 5 additions & 3 deletions src/components/TheConnectingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<template>
<v-dialog v-model="showDialog" persistent :width="400">
<v-card>
<v-card :dark="darkAttribute">
<v-toolbar flat dense>
<v-toolbar-title>
<span class="subheading">
Expand All @@ -28,7 +28,7 @@
</div>
</v-card-text>
<v-card-text v-else class="pt-5">
<v-progress-linear indeterminate></v-progress-linear>
<v-progress-linear :color="progressBarColor" indeterminate></v-progress-linear>
</v-card-text>
</v-card>
</v-dialog>
Expand All @@ -38,6 +38,8 @@
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import ThemeMixin from '@/components/mixins/theme'
import ConnectionStatus from '@/components/ui/ConnectionStatus.vue'
import { mdiConnection } from '@mdi/js'
Expand All @@ -46,7 +48,7 @@ import { mdiConnection } from '@mdi/js'
ConnectionStatus,
},
})
export default class TheConnectingDialog extends Mixins(BaseMixin) {
export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) {
mdiConnection = mdiConnection
counter = 0
Expand Down
5 changes: 3 additions & 2 deletions src/components/TheEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</v-card-text>
</panel>
</v-dialog>
<v-snackbar v-model="loaderBool" :timeout="-1" :value="true" fixed right bottom>
<v-snackbar v-model="loaderBool" :timeout="-1" :value="true" fixed right bottom :dark="darkAttribute">
<div>
{{ snackbarHeadline }}
<br />
Expand Down Expand Up @@ -122,6 +122,7 @@
<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import ThemeMixin from '@/components/mixins/theme'
import { capitalize, formatFilesize, windowBeforeUnloadFunction } from '@/plugins/helpers'
import Panel from '@/components/ui/Panel.vue'
import { availableKlipperConfigReferenceTranslations } from '@/store/variables'
Expand All @@ -141,7 +142,7 @@ import type Codemirror from '@/components/inputs/Codemirror.vue'
@Component({
components: { Panel, CodemirrorAsync },
})
export default class TheEditor extends Mixins(BaseMixin) {
export default class TheEditor extends Mixins(BaseMixin, ThemeMixin) {
private dialogConfirmChange = false
formatFilesize = formatFilesize
Expand Down
23 changes: 10 additions & 13 deletions src/components/TheSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
app
:style="sidebarCssVars">
<template #img>
<v-img :src="sidebarBackground" height="100%" :style="backgroundImageStyle" />
<v-img :src="sidebarBackground" height="100%" />
</template>

<overlay-scrollbars class="nav-scrollbar">
Expand Down Expand Up @@ -56,7 +56,6 @@ import { navigationWidth, topbarHeight } from '@/store/variables'
import MainsailLogo from '@/components/ui/MainsailLogo.vue'
import SidebarItem from '@/components/ui/SidebarItem.vue'
import NavigationMixin from '@/components/mixins/navigation'
import { CSSProperties } from 'vue/types/jsx'
@Component({
components: {
Expand All @@ -83,7 +82,8 @@ export default class TheSidebar extends Mixins(NavigationMixin, BaseMixin) {
}
get sidebarBackground(): string {
return this.$store.getters['files/getSidebarBackground']
const defaultBg = this.$vuetify.theme.dark ? '/img/sidebar-background.svg' : '/img/sidebar-background-light.svg'
return this.$store.getters['files/getCustomSidebarBackground'] ?? defaultBg
}
get currentPage(): string {
Expand All @@ -94,17 +94,14 @@ export default class TheSidebar extends Mixins(NavigationMixin, BaseMixin) {
return !this.isMobile && this.$vuetify.breakpoint.mdAndDown
}
get sidebarCssVars(): CSSProperties {
let vars: CSSProperties = {
...(this.boolNaviTemp && { top: `${topbarHeight}px !important` }),
...(this.boolNaviTemp && { paddingBottom: `${topbarHeight}px` }),
get sidebarCssVars(): any {
if (this.boolNaviTemp) {
return {
top: `${topbarHeight}px !important`,
'padding-bottom': `${topbarHeight}px`,
}
}
return vars
}
get backgroundImageStyle(): CSSProperties {
return !this.$vuetify.theme.dark ? { filter: 'invert(1)' } : {}
return {}
}
get sidebarLogo(): string {
Expand Down
Loading

0 comments on commit 2e3affd

Please sign in to comment.