-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
903c14c
commit 49ce259
Showing
7 changed files
with
174 additions
and
23 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 |
---|---|---|
@@ -1,9 +1,55 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'admin-root', | ||
template: '<router-outlet></router-outlet>', | ||
}) | ||
export class AppComponent { | ||
title = 'Admin Cpanel'; | ||
export class AppComponent implements OnInit { | ||
mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); | ||
|
||
updateTheme(savedTheme: string | null = null): string { | ||
let theme = 'system' | ||
try { | ||
if (!savedTheme) { | ||
savedTheme = window.localStorage.getItem('theme') | ||
} | ||
if (savedTheme === 'dark') { | ||
theme = 'dark' | ||
document.documentElement.classList.add('dark') | ||
} else if (savedTheme === 'light') { | ||
theme = 'light' | ||
document.documentElement.classList.remove('dark') | ||
} else if (this.mediaQuery.matches) { | ||
document.documentElement.classList.add('dark') | ||
} else { | ||
document.documentElement.classList.remove('dark') | ||
} | ||
} catch { | ||
theme = 'light' | ||
document.documentElement.classList.remove('dark') | ||
} | ||
return theme | ||
} | ||
|
||
updateThemeWithoutTransitions(savedTheme: string | null = null): void { | ||
this.updateTheme(savedTheme) | ||
document.documentElement.classList.add('[&_*]:!transition-none') | ||
window.setTimeout(() => { | ||
document.documentElement.classList.remove('[&_*]:!transition-none') | ||
}, 0) | ||
} | ||
|
||
ngOnInit(): void { | ||
document.documentElement.setAttribute('data-theme', this.updateTheme()) | ||
|
||
new MutationObserver(([{ oldValue }]) => { | ||
let newValue = document.documentElement.getAttribute('data-theme')! | ||
if (newValue !== oldValue) { | ||
try { | ||
window.localStorage.setItem('theme', newValue) | ||
} catch {} | ||
this.updateThemeWithoutTransitions(newValue) | ||
} | ||
}).observe(document.documentElement, { attributeFilter: ['data-theme'], attributeOldValue: true }) | ||
} | ||
} |
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
12 changes: 6 additions & 6 deletions
12
src/app/shared/themes/components/sidebar/sidebar.component.html
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
12 changes: 5 additions & 7 deletions
12
src/app/shared/themes/components/sidebar/sidebar.component.scss
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
|
||
.menu { | ||
@apply flex items-center px-6 py-2 text-sm font-medium border-l-4 border-transparent text-slate-600 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white; | ||
|
||
svg { | ||
@apply text-slate-600 group-hover:text-slate-900 dark:text-slate-500 dark:group-hover:text-white; | ||
} | ||
@apply flex items-center px-6 py-2 text-sm font-medium border-l-4 border-transparent; | ||
|
||
&-current { | ||
@apply text-primary-600 border-primary-600 hover:text-primary-600; | ||
@apply border-primary-600 hover:text-primary-600; | ||
color: theme('colors.primary.600') !important; | ||
|
||
svg { | ||
@apply text-primary-600 group-hover:text-primary-600; | ||
@apply group-hover:text-primary-600; | ||
stroke: theme('colors.primary.600') !important; | ||
} | ||
} | ||
} |
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