mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user