import { action } from 'mobx';
import * as React from 'react';
import { Doc } from '../../../../fields/Doc';
import { InkTool } from '../../../../fields/InkField';
import { SnappingManager } from '../../../util/SnappingManager';
import { CollectionDockingView } from '../../collections/CollectionDockingView';
import { DocumentView } from '../../nodes/DocumentView';
import { OpenWhereMod } from '../../nodes/OpenWhere';
import { NewLightboxView } from '../NewLightboxView';
import './ButtonMenu.scss';

export function ButtonMenu() {
    return (
        <div className="newLightboxButtonMenu-container">
            <div
                className="newLightboxView-navBtn"
                title="toggle fit width"
                onClick={e => {
                    e.stopPropagation();
                    NewLightboxView.LightboxDoc!._fitWidth = !NewLightboxView.LightboxDoc!._fitWidth;
                }}
            />
            <div
                className="newLightboxView-tabBtn"
                title="open in tab"
                onClick={e => {
                    e.stopPropagation();
                    CollectionDockingView.AddSplit(NewLightboxView.LightboxDoc || NewLightboxView.LightboxDoc!, OpenWhereMod.none);
                    DocumentView.DeselectAll();
                    NewLightboxView.SetNewLightboxDoc(undefined);
                }}
            />
            <div
                className="newLightboxView-penBtn"
                title="toggle pen annotation"
                style={{ background: Doc.ActiveTool === InkTool.Ink ? 'white' : undefined }}
                onClick={e => {
                    e.stopPropagation();
                    Doc.ActiveTool = Doc.ActiveTool === InkTool.Ink ? InkTool.None : InkTool.Ink;
                }}
            />
            <div
                className="newLightboxView-exploreBtn"
                title="toggle explore mode to navigate among documents only"
                style={{ background: SnappingManager.ExploreMode ? 'white' : undefined }}
                onClick={action(e => {
                    e.stopPropagation();
                    SnappingManager.SetExploreMode(!SnappingManager.ExploreMode);
                })}
            />
        </div>
    );
}
