Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / framework / widgets / panel / panel.jsx
1 /*
2  * 
3  *   Copyright 2016 RIFT.IO Inc
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  *
17  */
18 import React, {Component} from 'react';
19 import 'style/core.css';
20 import './panel.scss';
21 export class Panel extends Component {
22     constructor(props) {
23         super(props)
24     }
25     render() {
26         let self = this;
27         let {children, className, title, ...props} = self.props;
28         let classRoot = className ? ' ' + className : ' '
29         let titleTag = title ? <header className="skyquakePanel-title">{title}</header> : '';
30         return (
31             <section className={'skyquakePanel' + classRoot} style={props.style}>
32                 <i className="corner-accent top left"></i>
33                 <i className="corner-accent top right"></i>
34                 {titleTag}
35                 <div className="skyquakePanel-wrapper">
36                     <div className={(classRoot ? 'skyquakePanel-body ' + decorateClassNames(classRoot, '-body') : 'skyquakePanel-body')}>
37                             {children}
38                     </div>
39                 </div>
40                 <i className="corner-accent bottom left"></i>
41                 <i className="corner-accent bottom right"></i>
42             </section>
43         )
44     }
45 }
46
47 Panel.defaultProps = {
48
49 }
50
51 export class PanelWrapper extends Component {
52     render() {
53         return (<div className={'skyquakePanelWrapper'}>
54             {this.props.children}
55         </div>)
56     }
57 }
58
59 export default Panel;
60
61
62 function decorateClassNames(className, addendum) {
63     return className.split(' ').map(function(c) {
64         return c + addendum
65     }).join(' ');
66 }