From bdf4ca9e31bd3000aff87d3a4c3db3fda1b47967 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 29 Apr 2021 12:30:24 -0400 Subject: fixed bug with color being out of bounds when fully opaque. fixed caption color defaults. --- src/client/views/StyleProvider.tsx | 3 +-- src/client/views/nodes/ColorBox.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx index 8cb8fea11..d7ee82f2c 100644 --- a/src/client/views/StyleProvider.tsx +++ b/src/client/views/StyleProvider.tsx @@ -96,10 +96,9 @@ export function DefaultStyleProvider(doc: Opt, props: Opt = StrCast(doc?.[fieldKey + "color"], StrCast(doc?._color)); if (docColor) return docColor; - if (isCaption) return "white"; const backColor = backgroundCol();// || (darkScheme() ? "black" : "white"); if (!backColor) return undefined; - const col = Color(backColor).rgb(); + const col = Color(backColor.startsWith("#") ? (backColor as string).substring(0, 7) : backColor).rgb(); const colsum = (col.red() + col.green() + col.blue()); if (colsum / col.alpha() > 400 || col.alpha() < 0.25) return "black"; return "white"; diff --git a/src/client/views/nodes/ColorBox.tsx b/src/client/views/nodes/ColorBox.tsx index 454fd5a0c..8da5cd1b1 100644 --- a/src/client/views/nodes/ColorBox.tsx +++ b/src/client/views/nodes/ColorBox.tsx @@ -41,7 +41,7 @@ export class ColorBox extends ViewBoxBaseComponent