mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-12 00:19:48 +00:00
Chore: change dark mode to use Bootstrap's color modes (#4174)
* Change setting dark mode to use Bootstrap's data-bs-theme attribute * Update dark mode styling to use Bootstrap's color mode attribute * Update unit tests and lints * Fix not reflecting custom theme color * Remove commented-out code * fix inverted thumbnails in dark mode & card borders * prettier * Fix application of dark mode, tests --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
d1292c59ea
commit
78ae4c42f7
@@ -106,19 +106,19 @@ export class SettingsService {
|
||||
themeColor ??= this.get(SETTINGS_KEYS.THEME_COLOR)
|
||||
|
||||
if (darkModeUseSystem) {
|
||||
this._renderer.addClass(this.document.body, 'color-scheme-system')
|
||||
this._renderer.removeClass(this.document.body, 'color-scheme-dark')
|
||||
this._renderer.setAttribute(
|
||||
this.document.documentElement,
|
||||
'data-bs-theme',
|
||||
'auto'
|
||||
)
|
||||
} else {
|
||||
this._renderer.removeClass(this.document.body, 'color-scheme-system')
|
||||
darkModeEnabled
|
||||
? this._renderer.addClass(this.document.body, 'color-scheme-dark')
|
||||
: this._renderer.removeClass(this.document.body, 'color-scheme-dark')
|
||||
this._renderer.setAttribute(
|
||||
this.document.documentElement,
|
||||
'data-bs-theme',
|
||||
darkModeEnabled ? 'dark' : 'light'
|
||||
)
|
||||
}
|
||||
|
||||
// remove these in case they were there
|
||||
this._renderer.removeClass(this.document.body, 'primary-dark')
|
||||
this._renderer.removeClass(this.document.body, 'primary-light')
|
||||
|
||||
if (themeColor) {
|
||||
const hsl = hexToHsl(themeColor)
|
||||
const bgBrightnessEstimate = estimateBrightnessForColor(themeColor)
|
||||
@@ -142,6 +142,16 @@ export class SettingsService {
|
||||
`${hsl.l * 100}%`,
|
||||
RendererStyleFlags2.DashCase
|
||||
)
|
||||
|
||||
/**
|
||||
* Fix for not reflecting changed variables. (--bs-primary is at :root while here we set them to body)
|
||||
*/
|
||||
this._renderer.setStyle(
|
||||
document.body,
|
||||
'--bs-primary',
|
||||
'hsl(var(--pngx-primary), var(--pngx-primary-lightness))',
|
||||
RendererStyleFlags2.DashCase
|
||||
)
|
||||
} else {
|
||||
this._renderer.removeStyle(
|
||||
document.body,
|
||||
@@ -153,6 +163,11 @@ export class SettingsService {
|
||||
'--pngx-primary-lightness',
|
||||
RendererStyleFlags2.DashCase
|
||||
)
|
||||
this._renderer.removeStyle(
|
||||
document.body,
|
||||
'--bs-primary',
|
||||
RendererStyleFlags2.DashCase
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user