diff options
author | bobzel <zzzman@gmail.com> | 2020-12-11 19:05:07 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2020-12-11 19:05:07 -0500 |
commit | f923f3a3954b9e25a94970bc161cca8ec9800cef (patch) | |
tree | 040ab95f0f393c3a98562a3c017f30b4a9fb563c | |
parent | 58cd2a80fbd62fe31143922171a2448ac59f8bd8 (diff) |
trying out pushing MainView button into defaultStyleProvider -- I think it should be a parameterized default style provider instead of referencing MainView.
-rw-r--r-- | src/client/views/MainView.tsx | 16 | ||||
-rw-r--r-- | src/client/views/StyleProvider.tsx | 3 |
2 files changed, 6 insertions, 13 deletions
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<HTMLDivElement>(); private _mainViewRef = React.createRef<HTMLDivElement>(); - @observable private _lastButton: Doc | undefined; - + @observable public LastButton: Opt<Doc>; @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<DocumentViewProps>, 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 ? <div className={`mainView-libraryFlyout-out`}> {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<Doc>, props: Opt<DocumentViewProps case StyleProp.ItemBackgroundColor: let docColor: Opt<string> = 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"; |