mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Backport https://github.com/go-gitea/gitea/pull/25780, clean cherry-pick. 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; | ||||
|  | ||||
| @@ -190,7 +191,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
	 silverwind
					silverwind