mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Detect dark theme via css variable (#17800)
* detect dark theme via css variable * minor refactor, add documentation If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`. This allows gitea to adjust the Monaco code editor's theme accordingly.
This commit is contained in:
		@@ -26,13 +26,8 @@ export function isObject(obj) {
 | 
			
		||||
 | 
			
		||||
// returns whether a dark theme is enabled
 | 
			
		||||
export function isDarkTheme() {
 | 
			
		||||
  if (document.documentElement.classList.contains('theme-auto')) {
 | 
			
		||||
    return window.matchMedia('(prefers-color-scheme: dark)').matches;
 | 
			
		||||
  }
 | 
			
		||||
  if (document.documentElement.classList.contains('theme-arc-green')) {
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
  return false;
 | 
			
		||||
  const style = window.getComputedStyle(document.documentElement);
 | 
			
		||||
  return style.getPropertyValue('--is-dark-theme').trim().toLowerCase() === 'true';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// removes duplicate elements in an array
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user