From f923f3a3954b9e25a94970bc161cca8ec9800cef Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 11 Dec 2020 19:05:07 -0500 Subject: trying out pushing MainView button into defaultStyleProvider -- I think it should be a parameterized default style provider instead of referencing MainView. --- src/client/views/MainView.tsx | 16 ++++------------ src/client/views/StyleProvider.tsx | 3 ++- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 58cc1c0d2..5d26404ff 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -66,8 +66,7 @@ export class MainView extends React.Component { public static Instance: MainView; private _docBtnRef = React.createRef(); private _mainViewRef = React.createRef(); - @observable private _lastButton: Doc | undefined; - + @observable public LastButton: Opt; @observable private _panelWidth: number = 0; @observable private _panelHeight: number = 0; @observable private _panelContent: string = "none"; @@ -298,13 +297,6 @@ export class MainView extends React.Component { doc.dockingConfig ? CurrentUserUtils.openDashboard(Doc.UserDoc(), doc) : CollectionDockingView.AddSplit(doc, "right"); } - menuStyleProvider = (doc: Doc | undefined, props: Opt, property: string) => { - if (property === StyleProp.ItemBackgroundColor && this._lastButton === doc) { - return this.darkScheme ? "dimgrey" : "lightgrey"; - } - return DefaultStyleProvider(doc, props, property); - } - @computed get flyout() { return !this._flyoutWidth ?
{this.docButtons} @@ -359,7 +351,7 @@ export class MainView extends React.Component { PanelHeight={this.getContentsHeight} renderDepth={0} focus={emptyFunction} - styleProvider={this.menuStyleProvider} + styleProvider={DefaultStyleProvider} parentActive={returnTrue} whenActiveChanged={emptyFunction} bringToFront={emptyFunction} @@ -432,11 +424,11 @@ export class MainView extends React.Component { expandFlyout = action((button: Doc) => { this._flyoutWidth = (this._flyoutWidth || 250); this._sidebarContent.proto = button.target as any; - this._lastButton = button; + this.LastButton = button; }); closeFlyout = action(() => { - this._lastButton = undefined; + this.LastButton = undefined; this._panelContent = "none"; this._sidebarContent.proto = undefined; this._flyoutWidth = 0; diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx index adf47ec57..f51e94cfd 100644 --- a/src/client/views/StyleProvider.tsx +++ b/src/client/views/StyleProvider.tsx @@ -15,7 +15,7 @@ import "./StyleProvider.scss"; import React = require("react"); import Color = require('color'); import { listSpec } from '../../fields/Schema'; -import { Utils } from '../../Utils'; +import { MainView } from './MainView'; export enum StyleLayers { Background = "background" @@ -79,6 +79,7 @@ export function DefaultStyleProvider(doc: Opt, props: Opt = StrCast(doc?._backgroundColor, StrCast(doc?.backgroundColor)); if (docColor) return docColor; + if (MainView.Instance.LastButton === doc) return darkScheme() ? "dimgrey" : "lightgrey"; switch (doc?.type) { case DocumentType.FONTICON: return "black"; case DocumentType.LINK: return "lightblue"; -- cgit v1.2.3-70-g09d2