aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionLinear/CollectionLinearView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/collectionLinear/CollectionLinearView.tsx')
-rw-r--r--src/client/views/collections/collectionLinear/CollectionLinearView.tsx133
1 files changed, 60 insertions, 73 deletions
diff --git a/src/client/views/collections/collectionLinear/CollectionLinearView.tsx b/src/client/views/collections/collectionLinear/CollectionLinearView.tsx
index 92f6bbb64..9778fc4fe 100644
--- a/src/client/views/collections/collectionLinear/CollectionLinearView.tsx
+++ b/src/client/views/collections/collectionLinear/CollectionLinearView.tsx
@@ -1,12 +1,12 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { Tooltip } from '@material-ui/core';
+import { StylesProvider, Tooltip } from '@material-ui/core';
import { action, IReactionDisposer, observable, reaction, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { Doc, HeightSym, Opt, WidthSym } from '../../../../fields/Doc';
import { Id } from '../../../../fields/FieldSymbols';
-import { BoolCast, NumCast, ScriptCast, StrCast } from '../../../../fields/Types';
-import { emptyFunction, returnEmptyDoclist, returnTrue, Utils } from '../../../../Utils';
+import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from '../../../../fields/Types';
+import { emptyFunction, returnEmptyDoclist, returnTrue, StopEvent, Utils } from '../../../../Utils';
import { CollectionViewType } from '../../../documents/DocumentTypes';
import { DocumentManager } from '../../../util/DocumentManager';
import { DragManager } from '../../../util/DragManager';
@@ -119,7 +119,49 @@ export class CollectionLinearView extends CollectionSubView() {
e.preventDefault();
};
+ getLinkUI = () => {
+ return !DocumentLinksButton.StartLink ? null : (
+ <span className="bottomPopup-background" style={{ pointerEvents: 'all' }} onPointerDown={e => e.stopPropagation()}>
+ <span className="bottomPopup-text">
+ Creating link from:{' '}
+ <b>
+ {(DocumentLinksButton.AnnotationId ? 'Annotation in ' : ' ') +
+ (StrCast(DocumentLinksButton.StartLink.title).length < 51 ? DocumentLinksButton.StartLink.title : StrCast(DocumentLinksButton.StartLink.title).slice(0, 50) + '...')}
+ </b>
+ </span>
+
+ <Tooltip title={<div className="dash-tooltip">{'Toggle description pop-up'} </div>} placement="top">
+ <span className="bottomPopup-descriptions" onClick={this.changeDescriptionSetting}>
+ Labels: {LinkDescriptionPopup.showDescriptions ? LinkDescriptionPopup.showDescriptions : 'ON'}
+ </span>
+ </Tooltip>
+
+ <Tooltip title={<div className="dash-tooltip">Exit linking mode</div>} placement="top">
+ <span className="bottomPopup-exit" onClick={this.exitLongLinks}>
+ Stop
+ </span>
+ </Tooltip>
+ </span>
+ );
+ };
+ getCurrentlyPlayingUI = () => {
+ return !CollectionStackedTimeline.CurrentlyPlaying?.length ? null : (
+ <span className="bottomPopup-background">
+ <span className="bottomPopup-text">
+ Currently playing:
+ {CollectionStackedTimeline.CurrentlyPlaying.map((clip, i) => (
+ <span className="audio-title" onPointerDown={() => DocumentManager.Instance.jumpToDocument(clip, true, undefined, [])}>
+ {clip.title + (i === CollectionStackedTimeline.CurrentlyPlaying.length - 1 ? '' : ',')}
+ </span>
+ ))}
+ </span>
+ </span>
+ );
+ };
getDisplayDoc = (doc: Doc, preview: boolean = false) => {
+ if (doc.icon === 'linkui') return this.getLinkUI();
+ if (doc.icon === 'currentlyplayingui') return this.getCurrentlyPlayingUI();
+
const nested = doc._viewType === CollectionViewType.Linear;
const hidden = doc.hidden === true;
@@ -172,40 +214,32 @@ export class CollectionLinearView extends CollectionSubView() {
};
render() {
- const guid = Utils.GenerateGuid(); // Generate a unique ID to use as the label
- const flexDir: any = StrCast(this.Document.flexDirection); // Specify direction of linear view content
- const flexGap: number = NumCast(this.Document.flexGap); // Specify the gap between linear view content
- const expandable: boolean = BoolCast(this.props.Document.linearViewExpandable); // Specify whether it is expandable or not
- const floating: boolean = BoolCast(this.props.Document.linearViewFloating); // Specify whether it is expandable or not
+ const flexDir = StrCast(this.Document.flexDirection); // Specify direction of linear view content
+ const flexGap = NumCast(this.Document.flexGap); // Specify the gap between linear view content
+ const isExpanded = BoolCast(this.layoutDoc.linearViewIsExpanded);
- const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor);
- const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color);
- const icon: string = StrCast(this.props.Document.icon); // Menu opener toggle
const menuOpener = (
<label
- htmlFor={`${guid}`}
- style={{
- boxShadow: floating ? Shadows.STANDARD_SHADOW : undefined,
- color: BoolCast(this.layoutDoc.linearViewIsExpanded) ? undefined : Colors.BLACK,
- backgroundColor: backgroundColor === color ? 'black' : BoolCast(this.layoutDoc.linearViewIsExpanded) ? undefined : Colors.LIGHT_GRAY,
- }}
- onPointerDown={e => e.stopPropagation()}>
- <div className="collectionLinearView-menuOpener">{BoolCast(this.layoutDoc.linearViewIsExpanded) ? icon ? icon : <FontAwesomeIcon icon={'minus'} /> : icon ? icon : <FontAwesomeIcon icon={'plus'} />}</div>
+ className={`collectionlinearView-label${isExpanded ? '-expanded' : ''}`}
+ htmlFor={this.Document[Id] + '-input'}
+ style={{ boxShadow: this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BoxShadow) }}
+ onPointerDown={StopEvent}>
+ <div className="collectionLinearView-menuOpener">{Cast(this.props.Document.icon, 'string', null) ?? <FontAwesomeIcon icon={isExpanded ? 'minus' : 'plus'} />}</div>
</label>
);
return (
- <div className={`collectionLinearView-outer ${this.layoutDoc.linearViewSubMenu}`} style={{ backgroundColor: BoolCast(this.layoutDoc.linearViewIsExpanded) ? undefined : 'transparent' }}>
+ <div className={`collectionLinearView-outer ${this.layoutDoc.linearViewSubMenu}`} style={{ backgroundColor: this.layoutDoc.linearViewIsExpanded ? undefined : 'transparent' }}>
<div className="collectionLinearView" ref={this.createDashEventsTarget} onContextMenu={this.myContextMenu}>
- {!expandable ? null : (
- <Tooltip title={<div className="dash-tooltip">{BoolCast(this.props.Document.linearViewIsExpanded) ? 'Close' : 'Open'}</div>} placement="top">
+ {!this.props.Document.linearViewExpandable ? null : (
+ <Tooltip title={<div className="dash-tooltip">{isExpanded ? 'Close' : 'Open'}</div>} placement="top">
{menuOpener}
</Tooltip>
)}
<input
- id={`${guid}`}
+ id={this.Document[Id] + '-input'}
type="checkbox"
- checked={BoolCast(this.props.Document.linearViewIsExpanded)}
+ checked={isExpanded}
ref={this.addMenuToggle}
onChange={action(e => {
ScriptCast(this.Document.onClick)?.script.run({
@@ -216,7 +250,7 @@ export class CollectionLinearView extends CollectionSubView() {
thisContainer: this.props.ContainingCollectionDoc,
documentView: this.props.docViewPath().lastElement(),
});
- this.props.Document.linearViewIsExpanded = this.addMenuToggle.current!.checked;
+ this.layoutDoc.linearViewIsExpanded = this.addMenuToggle.current!.checked;
})}
/>
@@ -224,58 +258,11 @@ export class CollectionLinearView extends CollectionSubView() {
className="collectionLinearView-content"
style={{
height: this.dimension(),
- flexDirection: flexDir,
+ flexDirection: flexDir as any,
gap: flexGap,
}}>
{this.childLayoutPairs.map(pair => this.getDisplayDoc(pair.layout))}
</div>
- {!DocumentLinksButton.StartLink || this.layoutDoc !== Doc.MyDockedBtns ? null : (
- <span className="bottomPopup-background" style={{ pointerEvents: 'all' }} onPointerDown={e => e.stopPropagation()}>
- <span className="bottomPopup-text">
- Creating link from:{' '}
- <b>
- {(DocumentLinksButton.AnnotationId ? 'Annotation in ' : ' ') +
- (StrCast(DocumentLinksButton.StartLink.title).length < 51 ? DocumentLinksButton.StartLink.title : StrCast(DocumentLinksButton.StartLink.title).slice(0, 50) + '...')}
- </b>
- </span>
-
- <Tooltip
- title={
- <>
- <div className="dash-tooltip">{'Toggle description pop-up'} </div>
- </>
- }
- placement="top">
- <span className="bottomPopup-descriptions" onClick={this.changeDescriptionSetting}>
- Labels: {LinkDescriptionPopup.showDescriptions ? LinkDescriptionPopup.showDescriptions : 'ON'}
- </span>
- </Tooltip>
-
- <Tooltip
- title={
- <>
- <div className="dash-tooltip">Exit linking mode</div>
- </>
- }
- placement="top">
- <span className="bottomPopup-exit" onClick={this.exitLongLinks}>
- Stop
- </span>
- </Tooltip>
- </span>
- )}
- {!CollectionStackedTimeline.CurrentlyPlaying || !CollectionStackedTimeline.CurrentlyPlaying.length || this.layoutDoc !== Doc.MyDockedBtns ? null : (
- <span className="bottomPopup-background">
- <span className="bottomPopup-text">
- Currently playing:
- {CollectionStackedTimeline.CurrentlyPlaying.map((clip, i) => (
- <span className="audio-title" onPointerDown={() => DocumentManager.Instance.jumpToDocument(clip, true, undefined, [])}>
- {clip.title + (i === CollectionStackedTimeline.CurrentlyPlaying.length - 1 ? '' : ',')}
- </span>
- ))}
- </span>
- </span>
- )}
</div>
</div>
);