mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix(theme): convert theme bg to hex for Electron backgroundColor (#7569)
* fix(theme): convert theme bg to hex for Electron backgroundColor * fix(theme): simplify background color conversion to hex in ThemeProvider
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Validator } from 'jsonschema';
|
||||
import toast from 'react-hot-toast';
|
||||
import { parseToRgb } from 'polished';
|
||||
import themes from 'themes/index';
|
||||
import themeSchema from 'themes/schema';
|
||||
import useLocalStorage from 'hooks/useLocalStorage/index';
|
||||
@@ -54,7 +55,10 @@ export const ThemeProvider = (props) => {
|
||||
if (window.ipcRenderer) {
|
||||
const isLight = effectiveTheme === 'light';
|
||||
const variantName = isLight ? themeVariantLight : themeVariantDark;
|
||||
const themeBg = themes[variantName]?.bg || (isLight ? '#ffffff' : '#1e1e1e');
|
||||
const rawBg = themes[variantName]?.bg || (isLight ? '#ffffff' : '#1e1e1e');
|
||||
// Convert to hex — Electron's backgroundColor only accepts hex colors
|
||||
const { red, green, blue } = parseToRgb(rawBg);
|
||||
const themeBg = `#${[red, green, blue].map((c) => c.toString(16).padStart(2, '0')).join('')}`;
|
||||
window.ipcRenderer.send('renderer:theme-change', storedTheme, themeBg);
|
||||
}
|
||||
}, [storedTheme, themeVariantLight, themeVariantDark]);
|
||||
|
||||
Reference in New Issue
Block a user