forked from forgejo/forgejo
Always pass 6-digit hex color to monaco (#25780)
Monaco can not deal with color formats other than 6-digit hex, so we convert the colors for it via new [`tinycolor2`](https://github.com/bgrins/TinyColor) dependency (5kB minzipped). Also, with the addition of the module, we can replace the existing `hexToRGBColor` usage, I verified it is compatible with the current tests before removing the function. Fixes: https://github.com/go-gitea/gitea/issues/25770
This commit is contained in:
parent
d58096ec31
commit
38844e0869
7 changed files with 33 additions and 55 deletions
|
@ -1,5 +1,6 @@
|
|||
import $ from 'jquery';
|
||||
import {useLightTextOnBackground, hexToRGBColor} from '../utils/color.js';
|
||||
import {useLightTextOnBackground} from '../utils/color.js';
|
||||
import tinycolor from 'tinycolor2';
|
||||
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
|
@ -210,7 +211,7 @@ export function initRepoProject() {
|
|||
}
|
||||
|
||||
function setLabelColor(label, color) {
|
||||
const [r, g, b] = hexToRGBColor(color);
|
||||
const {r, g, b} = tinycolor(color).toRgb();
|
||||
if (useLightTextOnBackground(r, g, b)) {
|
||||
label.removeClass('dark-label').addClass('light-label');
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue