3 import React from 'react';
5 import Icon from '../../../icons/Icon';
6 import iconEdit from '../../../../../../../../res/ecomp/asdc/sequencer/sprites/icon/edit.svg';
9 * A hover-over popup. It shows notes, but perhaps will be put to other uses.
10 * @param props React properties.
14 export default class Popup extends React.Component {
16 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19 * Construct react view.
20 * @param props element properties (of which there are none).
21 * @param context react context.
23 constructor(props, context) {
24 super(props, context);
33 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
41 // Build CSS + styles to position and configure popup.
43 let top = this.state.top;
44 let left = this.state.left;
46 const popupHeight = 200;
47 const popupWidth = 320;
49 let auxCssVertical = 'top';
50 let auxCssHorizontal = 'left';
52 if (this.state.top > (window.innerHeight - popupHeight)) {
53 top -= (popupHeight + 50);
54 auxCssVertical = 'bottom';
57 if (this.state.left > (window.innerWidth - popupWidth)) {
58 left -= (popupWidth - 80);
59 auxCssHorizontal = 'right';
62 const auxCss = `asdcs-diagram-popup-${auxCssVertical}${auxCssHorizontal}`;
66 display: (this.state.visible ? 'block' : 'none'),
71 let notes = this.state.notes || '';
72 if (notes.length > 255) {
73 notes = notes.substring(0, 255);
74 notes = `${notes} ...`;
78 <div className={`asdcs-diagram-popup ${auxCss}`} style={styles}>
79 <div className="asdcs-diagram-popup-header">Notes</div>
80 <div className="asdcs-diagram-popup-body">
81 <div className="asdcs-icon-popup">
82 <Icon glyph={iconEdit} />
84 <div className="asdcs-diagram-notes">
85 <div className="asdcs-diagram-note">
90 <div className="asdcs-diagram-popup-footer"></div>