Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / composer / src / src / components / CatalogPanelTray.js
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19 'use strict';
20
21 import React from 'react';
22 import ClassNames from 'classnames'
23 import PureRenderMixin from 'react-addons-pure-render-mixin'
24 import CatalogPanelTrayActions from '../actions/CatalogPanelTrayActions'
25
26 import '../styles/CatalogPanelTray.scss'
27
28 const CatalogPanelTray = React.createClass({
29 mixins: [PureRenderMixin],
30 getInitialState() {
31 return {
32 isDragging: false
33 };
34 },
35 getDefaultProps() {
36 return {show: false};
37 },
38 preventResizeCursor(e) {
39 e.stopPropagation();
40 document.body.style.cursor = '';
41 },
42 componentWillMount() {
43 },
44 componentDidMount() {
45 },
46 componentDidUpdate() {
47 },
48 componentWillUnmount() {
49 },
50 onDragOver() {
51 this.setState({isDragging: true});
52 },
53 onDragLeave() {
54 this.setState({isDragging: false});
55 },
56 render() {
57 const classNames = ClassNames('CatalogPanelTray', {
58 '-close': !this.props.show,
59 '-is-dragging': this.state.isDragging
60 });
61 return (
62 <div className={classNames} onMouseMove={this.preventResizeCursor} onDragOver={this.onDragOver} onDragLeave={this.onDragLeave}>
63 <h1 data-open-close-icon={this.props.show ? 'open' : 'closed'} onClick={CatalogPanelTrayActions.toggleOpenClose}>Catalog Package Manager</h1>
64 <div className="tray-body">
65 {this.props.children}
66 </div>
67 </div>
68 );
69 }
70 });
71
72 export default CatalogPanelTray;