Merge branch 'themes-updates' into shigusegubu-themes3

This commit is contained in:
Henry Jameson 2024-12-30 21:03:55 +02:00
commit 9c952173f4
4 changed files with 18 additions and 12 deletions

View file

@ -6,10 +6,6 @@
color: var(--inputTopbarText, var(--inputText)); color: var(--inputTopbarText, var(--inputText));
} }
a {
color: var(--link);
}
.inner-nav { .inner-nav {
display: grid; display: grid;
grid-template-rows: var(--navbar-height); grid-template-rows: var(--navbar-height);
@ -91,10 +87,6 @@
width: 2em; width: 2em;
height: 100%; height: 100%;
text-align: center; text-align: center;
.svg-inline--fa {
color: var(--link);
}
} }
.sitename { .sitename {

View file

@ -32,6 +32,18 @@ export default {
directives: { directives: {
textColor: '--text' textColor: '--text'
} }
},
{
component: 'Icon',
parent: {
component: 'ButtonUnstyled',
parent: {
component: 'TopBar'
}
},
directives: {
textColor: '--parent--text'
}
} }
] ]
} }

View file

@ -225,7 +225,7 @@ export const getTextColor = function (bg, text, preserve) {
const originalColor = convert(text).hex const originalColor = convert(text).hex
const invertedColor = invertLightness(originalColor).hex const invertedColor = invertLightness(originalColor).hex
const invertedContrast = getContrastRatio(bg, invertedColor) const invertedContrast = getContrastRatio(bg, convert(invertedColor).rgb)
let workColor let workColor
if (invertedContrast > originalContrast) { if (invertedContrast > originalContrast) {
@ -238,13 +238,14 @@ export const getTextColor = function (bg, text, preserve) {
const result = convert(rgb2hex(workColor)).hsl const result = convert(rgb2hex(workColor)).hsl
const delta = result.l > 50 ? 1 : -1 const delta = result.l > 50 ? 1 : -1
const multiplier = 10 const multiplier = 10
while (contrast < 4.5) { while (contrast < 4.5 && result.l > 0 && result.l < 100) {
result.l += delta * multiplier result.l += delta * multiplier
contrast = getContrastRatio(bg, result) contrast = getContrastRatio(bg, convert(result).rgb)
console.log(convert(result).hex, result.l, contrast)
} }
const base = typeof text.a !== 'undefined' ? { a: text.a } : {} const base = typeof text.a !== 'undefined' ? { a: text.a } : {}
return Object.assign(base, result) return Object.assign(convert(result).rgb, base)
} }
/** /**

View file

@ -56,6 +56,7 @@
"bg": "#323337", "bg": "#323337",
"fg": "#1D1E21", "fg": "#1D1E21",
"link": "#18A0E3", "link": "#18A0E3",
"accent": "#6671E2",
"text": "#DBDDE0", "text": "#DBDDE0",
"cRed": "#E05053", "cRed": "#E05053",
"cBlue": "#6671E2", "cBlue": "#6671E2",