aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/StyleProvider.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-04-09 14:55:28 -0400
committerbobzel <zzzman@gmail.com>2025-04-09 14:55:28 -0400
commit2d382a1dd28aa5aae22669988475e5721435b738 (patch)
treef432634a1d02959a2795f3a6d81f9a7ec54140e3 /src/client/views/StyleProvider.tsx
parent4f236271c39380f15409b8fb38b2f6e2bae8df9f (diff)
more color template fixes.
Diffstat (limited to 'src/client/views/StyleProvider.tsx')
-rw-r--r--src/client/views/StyleProvider.tsx20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx
index a1c6aa1a2..a3067907d 100644
--- a/src/client/views/StyleProvider.tsx
+++ b/src/client/views/StyleProvider.tsx
@@ -248,14 +248,18 @@ export function DefaultStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps &
: 0;
case StyleProp.BackgroundColor: {
if (SnappingManager.LastPressedBtn === doc?.[Id]) return SnappingManager.userColor; // hack to indicate active menu panel item
- const dataKey = doc ? Doc.LayoutFieldKey(doc) : "";
- const usePath = StrCast(doc?.[dataKey + "_usePath"]);
- const alternate = usePath.includes(":hover") ? ( isHovering?.() ? '_' + usePath.replace(":hover","") : "") : usePath ? "_" +usePath:usePath;
- let docColor:Opt<string> = StrCast(doc?._backgroundColor, // renderDoc === this.layoutDoc
- StrCast(doc?.[fieldKey+alternate], // doc === this.Document
- StrCast(doc?.['backgroundColor' +alternate],
- isCaption ? 'rgba(0,0,0,0.4)' : '')));
-
+ const dataKey = doc ? Doc.LayoutFieldKey(doc) : '';
+ const usePath = StrCast(doc?.[dataKey + '_usePath']);
+ const alternate = usePath.includes(':hover') ? ( isHovering?.() ? '_' + usePath.replace(':hover','') : '') : usePath ? "_" +usePath:usePath;
+ let docColor:Opt<string> = layoutDoc &&
+ StrCast(alternate ? layoutDoc['backgroundColor' + alternate]:undefined,
+ doc.rootDocument
+ ? StrCast(layoutDoc.backgroundColor, StrCast(DocCast(doc.rootDocument).backgroundColor)) // for nested templates: use template's color, then root doc's color
+ : layoutDoc === doc
+ ? StrCast(doc.backgroundColor)
+ : StrCast(StrCast(Doc.GetT(layoutDoc, 'backgroundColor', 'string', true), StrCast(doc.backgroundColor, StrCast(layoutDoc.backgroundColor)) // otherwise, use expanded template coloor, then root doc's color, then template's inherited color
+ )));
+
// prettier-ignore
switch (layoutDoc?.type) {
case DocumentType.PRESELEMENT: docColor = docColor || ""; break;