Provide multiple shades of on-primary color
This commit is contained in:
parent
949e05fb29
commit
f743705b4d
|
@ -188,10 +188,11 @@ export class ThemeService {
|
||||||
|
|
||||||
this.oldInjectedProperties = []
|
this.oldInjectedProperties = []
|
||||||
|
|
||||||
const toProcess: { prefix: string, invertIfDark: boolean, fallbacks?: Record<string, string> }[] = [
|
const toProcess: { prefix: string, invertIfDark: boolean, step: number, fallbacks?: Record<string, string> }[] = [
|
||||||
{ prefix: 'primary', invertIfDark: true },
|
{ prefix: 'primary', invertIfDark: true, step: 5 },
|
||||||
{ prefix: 'bg-secondary', invertIfDark: true },
|
{ prefix: 'on-primary', invertIfDark: true, step: 0 },
|
||||||
{ prefix: 'fg', invertIfDark: true, fallbacks: { '--fg-300': '--greyForegroundColor' } }
|
{ prefix: 'bg-secondary', invertIfDark: true, step: 5 },
|
||||||
|
{ prefix: 'fg', invertIfDark: true, fallbacks: { '--fg-300': '--greyForegroundColor' }, step: 5 }
|
||||||
]
|
]
|
||||||
|
|
||||||
const darkTheme = this.isDarkTheme(computedStyle)
|
const darkTheme = this.isDarkTheme(computedStyle)
|
||||||
|
@ -199,7 +200,7 @@ export class ThemeService {
|
||||||
debugLogger('Detected dark theme')
|
debugLogger('Detected dark theme')
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const { prefix, invertIfDark, fallbacks = {} } of toProcess) {
|
for (const { prefix, invertIfDark, step, fallbacks = {} } of toProcess) {
|
||||||
const mainColor = computedStyle.getPropertyValue('--' + prefix)
|
const mainColor = computedStyle.getPropertyValue('--' + prefix)
|
||||||
|
|
||||||
const darkInverter = invertIfDark && darkTheme
|
const darkInverter = invertIfDark && darkTheme
|
||||||
|
@ -227,7 +228,7 @@ export class ThemeService {
|
||||||
|
|
||||||
const existingValue = computedStyle.getPropertyValue(key)
|
const existingValue = computedStyle.getPropertyValue(key)
|
||||||
if (!existingValue || existingValue === '0') {
|
if (!existingValue || existingValue === '0') {
|
||||||
const newLuminance = this.buildNewLuminance(lastColorHSL, j, darkInverter)
|
const newLuminance = this.buildNewLuminance(lastColorHSL, j * step, darkInverter)
|
||||||
const newColorHSL = { ...lastColorHSL, l: newLuminance }
|
const newColorHSL = { ...lastColorHSL, l: newLuminance }
|
||||||
|
|
||||||
const newColorStr = this.toHSLStr(newColorHSL)
|
const newColorStr = this.toHSLStr(newColorHSL)
|
||||||
|
@ -259,7 +260,7 @@ export class ThemeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildNewLuminance (base: { l: number }, factor: number, darkInverter: number) {
|
private buildNewLuminance (base: { l: number }, factor: number, darkInverter: number) {
|
||||||
return Math.max(Math.min(100, Math.round(base.l + (factor * 5 * -1 * darkInverter))), 0)
|
return Math.max(Math.min(100, Math.round(base.l + (factor * -1 * darkInverter))), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private toHSLStr (c: { h: number, s: number, l: number, a: number }) {
|
private toHSLStr (c: { h: number, s: number, l: number, a: number }) {
|
||||||
|
|
|
@ -168,11 +168,11 @@
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus-visible {
|
&:focus-visible {
|
||||||
background-color: pvar-fallback(--menu-fg, --bg-secondary-450);
|
background-color: pvar-fallback(--menu-bg, --bg-secondary-450);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background-color: pvar-fallback(--menu-fg, --bg-secondary-500);
|
background-color: pvar-fallback(--menu-bg, --bg-secondary-500);
|
||||||
}
|
}
|
||||||
|
|
||||||
my-global-icon {
|
my-global-icon {
|
||||||
|
@ -195,10 +195,14 @@
|
||||||
.about {
|
.about {
|
||||||
.description {
|
.description {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: pvar-fallback(--menu-fg, --fg-200)
|
color: pvar-fallback(--menu-fg, --fg-200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my-button[theme=secondary] {
|
||||||
|
color: pvar-fallback(--menu-fg, --fg-400);
|
||||||
|
}
|
||||||
|
|
||||||
my-button[theme=secondary] ::ng-deep my-global-icon,
|
my-button[theme=secondary] ::ng-deep my-global-icon,
|
||||||
.menu-link my-global-icon {
|
.menu-link my-global-icon {
|
||||||
color: pvar(--secondary-icon-color) !important;
|
color: pvar(--secondary-icon-color) !important;
|
||||||
|
@ -207,7 +211,7 @@ my-button[theme=secondary] ::ng-deep my-global-icon,
|
||||||
.collapsed {
|
.collapsed {
|
||||||
my-button[theme=secondary] ::ng-deep my-global-icon,
|
my-button[theme=secondary] ::ng-deep my-global-icon,
|
||||||
.menu-link my-global-icon {
|
.menu-link my-global-icon {
|
||||||
color: pvar(--fg-200) !important;
|
color: pvar-fallback(--menu-fg, --fg-200) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,11 @@ textarea {
|
||||||
&.by-me {
|
&.by-me {
|
||||||
|
|
||||||
.bubble {
|
.bubble {
|
||||||
color: pvar(--on-primary);
|
color: pvar(--on-primary-400);
|
||||||
background-color: pvar(--primary-400);
|
background-color: pvar(--primary-400);
|
||||||
|
|
||||||
.date {
|
.date {
|
||||||
color: pvar(--on-primary);
|
color: pvar(--on-primary-400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ h1 {
|
||||||
|
|
||||||
&.active,
|
&.active,
|
||||||
&.child-active {
|
&.child-active {
|
||||||
color: pvar(--on-primary) !important;
|
color: pvar(--on-primary-450) !important;
|
||||||
background-color: pvar(--primary-450);
|
background-color: pvar(--primary-450);
|
||||||
opacity: .9;
|
opacity: .9;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ body {
|
||||||
|
|
||||||
--border-primary: #{pvar(--primary)};
|
--border-primary: #{pvar(--primary)};
|
||||||
|
|
||||||
--alert-primary-fg: #{pvar(--on-primary)};
|
--alert-primary-fg: #{pvar(--on-primary-200)};
|
||||||
--alert-primary-bg: #{pvar(--primary-200)};
|
--alert-primary-bg: #{pvar(--primary-200)};
|
||||||
--alert-primary-border-color: #{pvar(--primary-300)};
|
--alert-primary-border-color: #{pvar(--primary-300)};
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ body {
|
||||||
--input-check-active-fg: #{pvar(--bg)};
|
--input-check-active-fg: #{pvar(--bg)};
|
||||||
--input-check-active-bg: #{pvar(--fg-250)};
|
--input-check-active-bg: #{pvar(--fg-250)};
|
||||||
|
|
||||||
--alert-primary-fg: #{pvar(--on-primary)};
|
--alert-primary-fg: #{pvar(--on-primary-200)};
|
||||||
--alert-primary-bg: #{pvar(--primary-200)};
|
--alert-primary-bg: #{pvar(--primary-200)};
|
||||||
--alert-primary-border-color: #{pvar(--primary-300)};
|
--alert-primary-border-color: #{pvar(--primary-300)};
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
color: pvar(--on-primary);
|
color: pvar(--on-primary-450);
|
||||||
background-color: pvar(--primary-450);
|
background-color: pvar(--primary-450);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
@use '_mixins' as *;
|
@use '_mixins' as *;
|
||||||
|
|
||||||
@mixin secondary-button (
|
@mixin secondary-button (
|
||||||
$fg: pvar(--fg),
|
$fg: inherit,
|
||||||
$active-bg: pvar(--bg-secondary-500),
|
$active-bg: pvar(--bg-secondary-500),
|
||||||
$hover-bg: pvar(--bg-secondary-450),
|
$hover-bg: pvar(--bg-secondary-450),
|
||||||
$border-color: pvar(--bg-secondary-500)
|
$border-color: pvar(--bg-secondary-500)
|
||||||
|
|
|
@ -141,6 +141,20 @@ $variables: (
|
||||||
--bg-secondary-200: var(--bg-secondary-200),
|
--bg-secondary-200: var(--bg-secondary-200),
|
||||||
|
|
||||||
--on-primary: var(--on-primary),
|
--on-primary: var(--on-primary),
|
||||||
|
--on-primary-700: var(--on-primary-700),
|
||||||
|
--on-primary-650: var(--on-primary-650),
|
||||||
|
--on-primary-600: var(--on-primary-600),
|
||||||
|
--on-primary-550: var(--on-primary-550),
|
||||||
|
--on-primary-500: var(--on-primary-500),
|
||||||
|
--on-primary-450: var(--on-primary-450),
|
||||||
|
--on-primary-400: var(--on-primary-400),
|
||||||
|
--on-primary-350: var(--on-primary-350),
|
||||||
|
--on-primary-300: var(--on-primary-300),
|
||||||
|
--on-primary-250: var(--on-primary-250),
|
||||||
|
--on-primary-200: var(--on-primary-200),
|
||||||
|
--on-primary-150: var(--on-primary-150),
|
||||||
|
--on-primary-100: var(--on-primary-100),
|
||||||
|
--on-primary-50: var(--on-primary-50),
|
||||||
|
|
||||||
--primary: var(--primary),
|
--primary: var(--primary),
|
||||||
--primary-700: var(--primary-700),
|
--primary-700: var(--primary-700),
|
||||||
|
|
Loading…
Reference in New Issue