aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/selectedDoc/SelectedDocView.tsx
blob: 49cdc6bf8d9d4802d78fcadecfcd6acde30fe57e (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
42
43
44
45
46
47
48
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ListBox } from '@dash/components';
import { computed } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { emptyFunction } from '../../../Utils';
import { Doc } from '../../../fields/Doc';
import { StrCast } from '../../../fields/Types';
import { SnappingManager } from '../../util/SnappingManager';
import { DocumentView } from '../nodes/DocumentView';
import { FocusViewOptions } from '../nodes/FocusViewOptions';

export interface SelectedDocViewProps {
    selectedDocs: Doc[];
}

@observer
export class SelectedDocView extends React.Component<SelectedDocViewProps> {
    @computed get selectedDocs() {
        return this.props.selectedDocs;
    }

    render() {
        return (
            <div className="selectedDocView-container">
                <ListBox
                    items={this.selectedDocs.map(doc => {
                        const options: FocusViewOptions = {
                            playAudio: false,
                            playMedia: false,
                            willPan: true,
                        };
                        return {
                            text: StrCast(doc.title),
                            val: StrCast(doc._id),
                            color: SnappingManager.userColor,
                            background: SnappingManager.userBackgroundColor,
                            icon: <FontAwesomeIcon size="1x" icon={Doc.toIcon(doc)} />,
                            onClick: () => DocumentView.showDocument(doc, options, emptyFunction),
                        };
                    })}
                    color={SnappingManager.userColor}
                    background={SnappingManager.userBackgroundColor}
                />
            </div>
        );
    }
}