aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ColorBox.tsx
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-11-16 12:28:12 -0500
committerab <abdullah_ahmed@brown.edu>2019-11-16 12:28:12 -0500
commitf7e101dfc7bc9e81ca03730865740360a831285a (patch)
tree8fd94d15bf573890882d746cbca065bfd5993cb9 /src/client/views/nodes/ColorBox.tsx
parentd26e058019d878d3058cb3806855281076b8d411 (diff)
parent22d1e65236bae11c508d5c34ebcbddd1a552bfd8 (diff)
merged
Diffstat (limited to 'src/client/views/nodes/ColorBox.tsx')
-rw-r--r--src/client/views/nodes/ColorBox.tsx29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/client/views/nodes/ColorBox.tsx b/src/client/views/nodes/ColorBox.tsx
index 30554ea36..fda6d64f4 100644
--- a/src/client/views/nodes/ColorBox.tsx
+++ b/src/client/views/nodes/ColorBox.tsx
@@ -4,23 +4,25 @@ import { SketchPicker } from 'react-color';
import { FieldView, FieldViewProps } from './FieldView';
import "./ColorBox.scss";
import { InkingControl } from "../InkingControl";
-import { DocStaticComponent } from "../DocComponent";
-import { documentSchema } from "./DocumentView";
+import { DocExtendableComponent } from "../DocComponent";
import { makeInterface } from "../../../new_fields/Schema";
-import { trace, reaction, observable, action, IReactionDisposer } from "mobx";
+import { reaction, observable, action, IReactionDisposer } from "mobx";
import { SelectionManager } from "../../util/SelectionManager";
import { StrCast } from "../../../new_fields/Types";
import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
-import { Doc } from "../../../new_fields/Doc";
+import { documentSchema } from "../../../new_fields/documentSchemas";
type ColorDocument = makeInterface<[typeof documentSchema]>;
const ColorDocument = makeInterface(documentSchema);
@observer
-export class ColorBox extends DocStaticComponent<FieldViewProps, ColorDocument>(ColorDocument) {
- public static LayoutString(fieldKey?: string) { return FieldView.LayoutString(ColorBox, fieldKey); }
+export class ColorBox extends DocExtendableComponent<FieldViewProps, ColorDocument>(ColorDocument) {
+ public static LayoutString(fieldKey: string) { return FieldView.LayoutString(ColorBox, fieldKey); }
+
_selectedDisposer: IReactionDisposer | undefined;
_penDisposer: IReactionDisposer | undefined;
+ @observable _startupColor = "black";
+
componentDidMount() {
this._selectedDisposer = reaction(() => SelectionManager.SelectedDocuments(),
action(() => this._startupColor = SelectionManager.SelectedDocuments().length ? StrCast(SelectionManager.SelectedDocuments()[0].Document.backgroundColor, "black") : "black"),
@@ -28,27 +30,12 @@ export class ColorBox extends DocStaticComponent<FieldViewProps, ColorDocument>(
this._penDisposer = reaction(() => CurrentUserUtils.ActivePen,
action(() => this._startupColor = CurrentUserUtils.ActivePen ? StrCast(CurrentUserUtils.ActivePen.backgroundColor, "black") : "black"),
{ fireImmediately: true });
-
- // compare to this reaction that used to be in Selection Manager
- // reaction(() => manager.SelectedDocuments, sel => {
- // let targetColor = "#FFFFFF";
- // if (sel.length > 0) {
- // let firstView = sel[0];
- // let doc = firstView.props.Document;
- // let targetDoc = doc.isTemplateField ? doc : Doc.GetProto(doc);
- // let stored = StrCast(targetDoc.backgroundColor);
- // stored.length > 0 && (targetColor = stored);
- // }
- // InkingControl.Instance.updateSelectedColor(targetColor);
- // }, { fireImmediately: true });
}
componentWillUnmount() {
this._penDisposer && this._penDisposer();
this._selectedDisposer && this._selectedDisposer();
}
- @observable _startupColor = "black";
-
render() {
return <div className={`colorBox-container${this.active() ? "-interactive" : ""}`}
onPointerDown={e => e.button === 0 && !e.ctrlKey && e.stopPropagation()}>