diff options
| author | bob <bcz@cs.brown.edu> | 2019-05-03 10:58:12 -0400 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2019-05-03 10:58:12 -0400 |
| commit | 26b0374d87ef1b14d947d5882f73e67b8607436e (patch) | |
| tree | 39047f4666b8d06a67b037219c7d620eba934a3f /src/client/views/nodes | |
| parent | ee6842b6509264f402217fcd214fa4dc167d985e (diff) | |
changes to icon box and decorations.
Diffstat (limited to 'src/client/views/nodes')
| -rw-r--r-- | src/client/views/nodes/CollectionFreeFormDocumentView.tsx | 8 | ||||
| -rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 1 | ||||
| -rw-r--r-- | src/client/views/nodes/IconBox.scss | 12 | ||||
| -rw-r--r-- | src/client/views/nodes/IconBox.tsx | 32 |
4 files changed, 45 insertions, 8 deletions
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx index 09f9c8516..53298fbdd 100644 --- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx +++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx @@ -112,10 +112,11 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF public toggleIcon = async (): Promise<void> => { SelectionManager.DeselectAll(); let isMinimized: boolean | undefined; - let minimizedDocSet = Cast(this.props.Document.linkTags, listSpec(Doc)); - if (!minimizedDocSet) return; + let minimizedDocSet = Cast(this.props.Document.linkedIconTags, listSpec(Doc), []); let docs = minimizedDocSet.map(d => d); - docs.push(this.props.Document); + let minimDoc = Cast(this.props.Document.minimizedDoc, Doc); + if (minimDoc instanceof Doc) docs.push(minimDoc); + else docs.push(this.props.Document); docs.map(async minimizedDoc => { this.props.addDocument && this.props.addDocument(minimizedDoc, false); let maximizedDoc = await Cast(minimizedDoc.maximizedDoc, Doc); @@ -125,6 +126,7 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF let maximizedDocMinimizedState = Cast(maximizedDoc.isMinimized, "boolean"); isMinimized = (maximizedDocMinimizedState) ? true : false; } + if (isMinimized) this.props.bringToFront(maximizedDoc); let minx = NumCast(minimizedDoc.x, undefined); let miny = NumCast(minimizedDoc.y, undefined); let maxx = NumCast(maximizedDoc.x, undefined); diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 8c245ab3a..892850a69 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -53,6 +53,7 @@ export interface DocumentViewProps { parentActive: () => boolean; whenActiveChanged: (isActive: boolean) => void; toggleMinimized: () => void; + bringToFront: (doc: Doc) => void; } const schema = createSchema({ diff --git a/src/client/views/nodes/IconBox.scss b/src/client/views/nodes/IconBox.scss index ce0ee2e09..85bbdeb59 100644 --- a/src/client/views/nodes/IconBox.scss +++ b/src/client/views/nodes/IconBox.scss @@ -4,9 +4,19 @@ position: absolute; left:0; top:0; + height: 100%; + width: max-content; + // overflow: hidden; + pointer-events: all; svg { - width: 100% !important; + width: $MINIMIZED_ICON_SIZE !important; height: 100%; background: white; } + .iconBox-label { + position: inherit; + width:max-content; + font-size: 14px; + margin-top: 3px; + } }
\ No newline at end of file diff --git a/src/client/views/nodes/IconBox.tsx b/src/client/views/nodes/IconBox.tsx index 7a0c49735..08301ae0d 100644 --- a/src/client/views/nodes/IconBox.tsx +++ b/src/client/views/nodes/IconBox.tsx @@ -2,14 +2,17 @@ import React = require("react"); import { library } from '@fortawesome/fontawesome-svg-core'; import { faCaretUp, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { action, computed } from "mobx"; +import { action, computed, observable, runInAction } from "mobx"; import { observer } from "mobx-react"; import { SelectionManager } from "../../util/SelectionManager"; import { FieldView, FieldViewProps } from './FieldView'; import "./IconBox.scss"; -import { Cast } from "../../../new_fields/Types"; -import { Doc } from "../../../new_fields/Doc"; +import { Cast, StrCast, BoolCast } from "../../../new_fields/Types"; +import { Doc, WidthSym, HeightSym } from "../../../new_fields/Doc"; import { IconField } from "../../../new_fields/IconField"; +import { ContextMenu } from "../ContextMenu"; +import Measure from "react-measure"; +import { MINIMIZED_ICON_SIZE } from "../../views/globalCssVariables.scss"; library.add(faCaretUp); @@ -36,10 +39,31 @@ export class IconBox extends React.Component<FieldViewProps> { return <FontAwesomeIcon icon={button} className="documentView-minimizedIcon" />; } + setLabelField = (e: React.MouseEvent): void => { + this.props.Document.hideLabel = !BoolCast(this.props.Document.hideLabel); + } + + specificContextMenu = (e: React.MouseEvent): void => { + ContextMenu.Instance.addItem({ + description: BoolCast(this.props.Document.hideLabel) ? "show label" : "hide label", + event: this.setLabelField + }); + } + @observable _panelWidth: number = 0; + @observable _panelHeight: number = 0; render() { + let labelField = StrCast(this.props.Document.labelField); + let hideLabel = BoolCast(this.props.Document.hideLabel); + let maxDoc = Cast(this.props.Document.maximizedDoc, Doc) as Doc; + let label = !hideLabel && maxDoc && labelField ? maxDoc[labelField] : ""; return ( - <div className="iconBox-container"> + <div className="iconBox-container" onContextMenu={this.specificContextMenu}> {this.minimizedIcon} + <Measure onResize={(r) => runInAction(() => { if (r.entry.width || BoolCast(this.props.Document.hideLabel)) this.props.Document.nativeWidth = this.props.Document.width = (r.entry.width + Number(MINIMIZED_ICON_SIZE)); })}> + {({ measureRef }) => + <span ref={measureRef} className="iconBox-label">{label}</span> + } + </Measure> </div>); } }
\ No newline at end of file |
