* -------------------------------------------------------------------------
* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* -------------------------------------------------------------------------
*/
import { useTheme } from '@emotion/react';
const COLOR = {
BRIGHT_BLUE: '#7df7ff',
Grey20: '#cacaca',
Grey40: '#989898',
Grey50: '#7b7a7a',
Band0: '#f82d18',
Band1: '#eac299',
Band2: '#c7eef5',
Band3: '#0177ff',
LIGHT_BLUE: '#1890ff',
};
export function useThemeColor(darkColor: string = '#D1D1D1', lightColor: string = '#595959'): string {
const curTheme = useTheme().mode;
if (curTheme === 'light') {
return lightColor;
} else {
return darkColor;
}
}
export function compareColors(color1: string, color2: string): boolean {
const toHex = (color: string): string => {
if (color.startsWith('#')) {
return color.slice(1).toUpperCase();
}
const rgbMatch = color.match(/\d+/g);
if (!rgbMatch) return '';
const r = parseInt(rgbMatch[0], 10);
const g = parseInt(rgbMatch[1], 10);
const b = parseInt(rgbMatch[2], 10);
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
return '';
}
return `${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`.toUpperCase();
};
const hex1 = toHex(color1);
const hex2 = toHex(color2);
if (!hex1 || !hex2) {
return false;
}
return hex1 === hex2;
}
export default COLOR;