mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +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:
		@@ -26,7 +26,8 @@
 | 
			
		||||
<script>
 | 
			
		||||
import $ from 'jquery';
 | 
			
		||||
import {SvgIcon} from '../svg.js';
 | 
			
		||||
import {useLightTextOnBackground, hexToRGBColor} from '../utils/color.js';
 | 
			
		||||
import {useLightTextOnBackground} from '../utils/color.js';
 | 
			
		||||
import tinycolor from 'tinycolor2';
 | 
			
		||||
 | 
			
		||||
const {appSubUrl, i18n} = window.config;
 | 
			
		||||
 | 
			
		||||
@@ -77,7 +78,7 @@ export default {
 | 
			
		||||
    labels() {
 | 
			
		||||
      return this.issue.labels.map((label) => {
 | 
			
		||||
        let textColor;
 | 
			
		||||
        const [r, g, b] = hexToRGBColor(label.color);
 | 
			
		||||
        const {r, g, b} = tinycolor(label.color).toRgb();
 | 
			
		||||
        if (useLightTextOnBackground(r, g, b)) {
 | 
			
		||||
          textColor = '#eeeeee';
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user