Skip to content

Commit 97aa7b1

Browse files
committed
1 parent 7e6b9f3 commit 97aa7b1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/eez-studio-shared/color.ts

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ export function isDark(color: string) {
7272
return tinycolor(color).isDark();
7373
}
7474

75+
export function isLight(color: string) {
76+
return tinycolor(color).isLight();
77+
}
78+
7579
export function isValid(color: string) {
7680
return tinycolor(color).isValid();
7781
}

packages/project-editor/ui-components/PropertyGrid/ThemedColorInput.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ReactDOM from "react-dom";
33
import { observer } from "mobx-react";
44
import { SketchPicker } from "react-color";
55

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

88
import { getProperty } from "project-editor/core/object";
99
import { getEezStudioDataFromDragEvent } from "project-editor/store";
@@ -197,7 +197,11 @@ export const ThemedColorInput = observer(
197197
ref={this.props.inputRef}
198198
className="form-control"
199199
style={{
200-
color: isDark(tinycolor(color).toHexString())
200+
color: settingsController.isDarkTheme
201+
? isLight(tinycolor(color).toHexString())
202+
? "#000"
203+
: undefined
204+
: isDark(tinycolor(color).toHexString())
201205
? "#fff"
202206
: undefined,
203207
backgroundColor: tinycolor(color).toHexString()

0 commit comments

Comments
 (0)