2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
17 import React from 'react';
18 import Icon from '../../../icons/Icon';
19 import iconEdit from '../../../../../../../../res/ecomp/asdc/sequencer/sprites/icons/edit.svg';
22 * A hover-over popup. It shows notes, but perhaps will be put to other uses.
23 * @param props React properties.
27 class Popup extends React.Component {
29 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
32 * Construct react view.
33 * @param props element properties (of which there are none).
34 * @param context react context.
36 constructor(props, context) {
37 super(props, context);
46 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
54 // Build CSS + styles to position and configure popup.
56 let top = this.state.top;
57 let left = this.state.left;
59 const popupHeight = 200;
60 const popupWidth = 320;
62 let auxCssVertical = 'top';
63 let auxCssHorizontal = 'left';
65 if (this.state.top > (window.innerHeight - popupHeight)) {
66 top -= (popupHeight + 50);
67 auxCssVertical = 'bottom';
70 if (this.state.left > (window.innerWidth - popupWidth)) {
71 left -= (popupWidth - 80);
72 auxCssHorizontal = 'right';
75 const auxCss = `asdcs-diagram-popup-${auxCssVertical}${auxCssHorizontal}`;
79 display: (this.state.visible ? 'block' : 'none'),
84 let notes = this.state.notes || '';
85 if (notes.length > 255) {
86 notes = notes.substring(0, 255);
87 notes = `${notes} ...`;
91 <div className={`asdcs-diagram-popup ${auxCss}`} style={styles}>
92 <div className="asdcs-diagram-popup-header">Notes</div>
93 <div className="asdcs-diagram-popup-body">
94 <div className="asdcs-icon-popup">
95 <Icon glyph={iconEdit} />
97 <div className="asdcs-diagram-notes">
98 <div className="asdcs-diagram-note">
103 <div className="asdcs-diagram-popup-footer"></div>
109 export default Popup;