-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Initial theme switching concept
- Loading branch information
1 parent
594afda
commit c30d211
Showing
25 changed files
with
270 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Enhancement: Darkmode theme switcher | ||
|
||
We've added a theme switcher and now initialize the user interface theme based on the user's browser preferences. | ||
|
||
https://github.com/owncloud/web/pull/6240 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<oc-button appearance="raw" variation="inverse" @click="changeTheme"> | ||
<span v-text="switchText" /> | ||
<oc-icon :name="switchIcon" fill-type="line" /> | ||
</oc-button> | ||
</template> | ||
<script> | ||
import { mapGetters, mapActions } from 'vuex' | ||
export default { | ||
data() { | ||
return { | ||
mode: 'light' | ||
} | ||
}, | ||
computed: { | ||
...mapGetters(['configuration']), | ||
switchIcon() { | ||
return this.mode === 'light' ? 'sun' : 'moon-clear' | ||
}, | ||
switchText() { | ||
return this.mode === 'light' ? this.$gettext('Light mode') : this.$gettext('Dark mode') | ||
} | ||
}, | ||
mounted() { | ||
if (window.matchMedia('(prefers-color-scheme: dark)').matches) { | ||
this.changeTheme() | ||
} | ||
}, | ||
methods: { | ||
...mapActions(['loadTheme']), | ||
changeTheme() { | ||
if (this.mode === 'light') { | ||
this.loadTheme({ theme: this.configuration.themes['default-dark'] }) | ||
this.applyChangedTheme() | ||
this.mode = 'dark' | ||
} else { | ||
this.loadTheme({ theme: this.configuration.themes.default }) | ||
this.applyChangedTheme() | ||
this.mode = 'light' | ||
} | ||
}, | ||
applyChangedTheme() { | ||
for (const param in this.configuration.currentTheme.designTokens.colorPalette) { | ||
document | ||
.querySelector(':root') | ||
.style.setProperty( | ||
'--oc-' + 'color-' + param, | ||
this.configuration.currentTheme.designTokens.colorPalette[param] | ||
) | ||
} | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.