Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 1, 2024
1 parent 7e6b9f3 commit 97aa7b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/eez-studio-shared/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export function isDark(color: string) {
return tinycolor(color).isDark();
}

export function isLight(color: string) {
return tinycolor(color).isLight();
}

export function isValid(color: string) {
return tinycolor(color).isValid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from "react-dom";
import { observer } from "mobx-react";
import { SketchPicker } from "react-color";

import { isDark, isValid } from "eez-studio-shared/color";
import { isDark, isLight, isValid } from "eez-studio-shared/color";

import { getProperty } from "project-editor/core/object";
import { getEezStudioDataFromDragEvent } from "project-editor/store";
Expand Down Expand Up @@ -197,7 +197,11 @@ export const ThemedColorInput = observer(
ref={this.props.inputRef}
className="form-control"
style={{
color: isDark(tinycolor(color).toHexString())
color: settingsController.isDarkTheme
? isLight(tinycolor(color).toHexString())
? "#000"
: undefined
: isDark(tinycolor(color).toHexString())
? "#fff"
: undefined,
backgroundColor: tinycolor(color).toHexString()
Expand Down

0 comments on commit 97aa7b1

Please sign in to comment.