mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 14:16:28 +00:00
add change dynamic theme color
This commit is contained in:
1 parent
d81ed86920
commit
8a36bed032
1 file changed
+7
@@ -2,6 +2,8 @@
|
|||||||
dropdownOpen: false,
|
dropdownOpen: false,
|
||||||
search: '',
|
search: '',
|
||||||
allEntries: [],
|
allEntries: [],
|
||||||
|
darkColorContent: getComputedStyle($el).getPropertyValue('--color-base'),
|
||||||
|
whiteColorContent: getComputedStyle($el).getPropertyValue('--color-white'),
|
||||||
init() {
|
init() {
|
||||||
this.mounted();
|
this.mounted();
|
||||||
// Load all entries when component initializes
|
// Load all entries when component initializes
|
||||||
@@ -45,11 +47,16 @@
|
|||||||
const darkModePreference = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
const darkModePreference = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
const userSettings = localStorage.getItem('theme') || 'dark';
|
const userSettings = localStorage.getItem('theme') || 'dark';
|
||||||
localStorage.setItem('theme', userSettings);
|
localStorage.setItem('theme', userSettings);
|
||||||
|
|
||||||
|
const themeMetaTag = document.querySelector('meta[name=theme-color]');
|
||||||
|
|
||||||
if (userSettings === 'dark') {
|
if (userSettings === 'dark') {
|
||||||
document.documentElement.classList.add('dark');
|
document.documentElement.classList.add('dark');
|
||||||
|
themeMetaTag.setAttribute('content', this.darkColorContent);
|
||||||
this.theme = 'dark';
|
this.theme = 'dark';
|
||||||
} else if (userSettings === 'light') {
|
} else if (userSettings === 'light') {
|
||||||
document.documentElement.classList.remove('dark');
|
document.documentElement.classList.remove('dark');
|
||||||
|
themeMetaTag.setAttribute('content', this.whiteColorContent);
|
||||||
this.theme = 'light';
|
this.theme = 'light';
|
||||||
} else if (darkModePreference) {
|
} else if (darkModePreference) {
|
||||||
this.theme = 'system';
|
this.theme = 'system';
|
||||||
|
|||||||
Reference in new issue
Block a user