| Jeremy Mordkoff | e29efc3 | 2016-09-07 18:59:17 -0400 | [diff] [blame] | 1 | /* |
| Laurence Maultsby | dfe972f | 2016-09-12 12:14:43 -0400 | [diff] [blame] | 2 | * |
| Jeremy Mordkoff | e29efc3 | 2016-09-07 18:59:17 -0400 | [diff] [blame] | 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; |
| Laurence Maultsby | dfe972f | 2016-09-12 12:14:43 -0400 | [diff] [blame] | 28 | let classRoot = className ? ' ' + className : ' '; |
| 29 | let hasCorners = this.props['no-corners']; |
| Jeremy Mordkoff | e29efc3 | 2016-09-07 18:59:17 -0400 | [diff] [blame] | 30 | let titleTag = title ? <header className="skyquakePanel-title">{title}</header> : ''; |
| 31 | return ( |
| 32 | <section className={'skyquakePanel' + classRoot} style={props.style}> |
| Laurence Maultsby | dfe972f | 2016-09-12 12:14:43 -0400 | [diff] [blame] | 33 | { !hasCorners ? <i className="corner-accent top left"></i> : null } |
| 34 | { !hasCorners ? <i className="corner-accent top right"></i> : null } |
| Jeremy Mordkoff | e29efc3 | 2016-09-07 18:59:17 -0400 | [diff] [blame] | 35 | {titleTag} |
| 36 | <div className="skyquakePanel-wrapper"> |
| 37 | <div className={(classRoot ? 'skyquakePanel-body ' + decorateClassNames(classRoot, '-body') : 'skyquakePanel-body')}> |
| 38 | {children} |
| 39 | </div> |
| 40 | </div> |
| Laurence Maultsby | dfe972f | 2016-09-12 12:14:43 -0400 | [diff] [blame] | 41 | { !hasCorners ? <i className="corner-accent bottom left"></i> : null } |
| 42 | { !hasCorners ? <i className="corner-accent bottom right"></i> : null } |
| Jeremy Mordkoff | e29efc3 | 2016-09-07 18:59:17 -0400 | [diff] [blame] | 43 | </section> |
| 44 | ) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | Panel.defaultProps = { |
| 49 | |
| 50 | } |
| 51 | |
| 52 | export class PanelWrapper extends Component { |
| 53 | render() { |
| Laurence Maultsby | dfe972f | 2016-09-12 12:14:43 -0400 | [diff] [blame] | 54 | return ( |
| 55 | <div className={'skyquakePanelWrapper ' + this.props.className} style={this.props.style}> |
| Jeremy Mordkoff | e29efc3 | 2016-09-07 18:59:17 -0400 | [diff] [blame] | 56 | {this.props.children} |
| 57 | </div>) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | export default Panel; |
| 62 | |
| 63 | |
| 64 | function decorateClassNames(className, addendum) { |
| Laurence Maultsby | dfe972f | 2016-09-12 12:14:43 -0400 | [diff] [blame] | 65 | return className.trim().split(' ').map(function(c) { |
| Jeremy Mordkoff | e29efc3 | 2016-09-07 18:59:17 -0400 | [diff] [blame] | 66 | return c + addendum |
| 67 | }).join(' '); |
| 68 | } |