mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Refactor contrast to use luminance function
This commit is contained in:
@@ -9,7 +9,11 @@ import {
|
||||
} from '@angular/core'
|
||||
import { Meta } from '@angular/platform-browser'
|
||||
import { CookieService } from 'ngx-cookie-service'
|
||||
import { hexToHsl } from 'src/app/utils/color'
|
||||
import {
|
||||
BRIGHTNESS,
|
||||
estimateBrightnessForColor,
|
||||
hexToHsl,
|
||||
} from 'src/app/utils/color'
|
||||
|
||||
export interface PaperlessSettings {
|
||||
key: string
|
||||
@@ -138,10 +142,9 @@ export class SettingsService {
|
||||
|
||||
if (themeColor) {
|
||||
const hsl = hexToHsl(themeColor)
|
||||
const useDarkTextColor =
|
||||
parseInt(themeColor.replace('#', ''), 16) > 0xffffff / 1.5
|
||||
const bgBrightnessEstimate = estimateBrightnessForColor(themeColor)
|
||||
|
||||
if (useDarkTextColor) {
|
||||
if (bgBrightnessEstimate == BRIGHTNESS.DARK) {
|
||||
this.renderer.addClass(this.document.body, 'text-bg-dark')
|
||||
this.renderer.removeClass(this.document.body, 'text-bg-light')
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user