mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-11 17:19:34 +00:00
de9a7a87fd
* refactor(project structure): UI * refactor(project structure): extract utilities * refactor(project structure): remove unused * refactor(project structure): electron * refactor(project structure): server refactor: migrate to vitest refactor: monorepo config * refactor: extract application menu * refactor: exit process * refactor: extract tray menu * chore: electron build * Added Seconds in studio clock #282 --------- Co-authored-by: Fabian Posenau <fabian@fphome.de> --------- Co-authored-by: Fabian Posenau <fabian.p99@gmx.de> Co-authored-by: Fabian Posenau <fabian@fphome.de>
30 lines
845 B
TypeScript
30 lines
845 B
TypeScript
import Color from 'color';
|
|
|
|
type ColourCombination = {
|
|
backgroundColor: string;
|
|
color: string;
|
|
}
|
|
|
|
/**
|
|
* @description Selects text colour to maintain accessible contrast
|
|
* @param bgColour
|
|
* @return {{backgroundColor, color: string}}
|
|
*/
|
|
export const getAccessibleColour = (bgColour: string): ColourCombination => {
|
|
if (bgColour) {
|
|
try {
|
|
const textColor = Color(bgColour).isLight() ? 'black' : '#fffffa';
|
|
return { backgroundColor: bgColour, color: textColor };
|
|
} catch (error) {
|
|
console.log(`Unable to parse colour: ${bgColour}`);
|
|
}
|
|
}
|
|
return { backgroundColor: '#000', color: "#fffffa" };
|
|
};
|
|
|
|
/**
|
|
* @description Creates a list of classnames from array of css module conditions
|
|
* @param classNames - css modules objects
|
|
*/
|
|
export const cx = (classNames: any[]) => classNames.filter(Boolean).join(" ");
|