aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/MenuIconBox.tsx
blob: e1656fcbad10d4db08b754e926efd6b2ca2c6cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { observer } from 'mobx-react';
import * as React from 'react';
import { createSchema, makeInterface } from '../../../fields/Schema';
import { DocComponent } from '../DocComponent';
import './MenuIconBox.scss';
import { FieldView, FieldViewProps } from './FieldView';
import { StrCast, Cast, NumCast } from '../../../fields/Types';
import { Utils } from "../../../Utils";
import { runInAction, observable, reaction, IReactionDisposer } from 'mobx';
import { Doc } from '../../../fields/Doc';
import { ScriptField } from '../../../fields/ScriptField';
import { CurrentUserUtils } from '../../util/CurrentUserUtils';
const MenuIconSchema = createSchema({
    icon: "string"
});

type MenuIconDocument = makeInterface<[typeof MenuIconSchema]>;
const MenuIconDocument = makeInterface(MenuIconSchema);
@observer
export class MenuIconBox extends DocComponent<FieldViewProps, MenuIconDocument>(MenuIconDocument) {
    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(MenuIconBox, fieldKey); }
    _ref: React.RefObject<HTMLButtonElement> = React.createRef();

    render() {

        const menuBTN = <div className="menuButton" style={{ backgroundColor: CurrentUserUtils.panelContent === this.dataDoc.title ? "lightgrey" : "" }}>
            <div className="menuButton-wrap"
                style={{ backgroundColor: CurrentUserUtils.panelContent === this.dataDoc.title ? "lightgrey" : "" }}
            //onPointerDown={this.dataDoc.click}
            >
                <FontAwesomeIcon className="menuButton-icon" icon={StrCast(this.dataDoc.icon, "user") as any}
                    color={CurrentUserUtils.panelContent === this.dataDoc.title ? "black" : "white"} size="lg" />
                <div className="menuButton-label"
                    style={{ color: CurrentUserUtils.panelContent === this.dataDoc.title ? "black" : "white" }}> {this.dataDoc.title} </div>
            </div>
        </div>;

        return menuBTN;
    }
}