3 * Copyright 2016 RIFT.IO Inc
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 import React from 'react';
24 // Generalized component classes
27 class DropList extends React.Component {
29 handleOnChange = (e) => {
30 this.props.onChange(e.target.value);
34 const {className, selectedOption, options, ...props} = this.props;
36 <select className={className} onChange={this.handleOnChange}
37 value={selectedOption}>
39 options.map(function(op, i) {
41 <option key={i} value={op}>{op}</option>
49 DropList.defaultProps = {
51 onChange: function(e) {
52 console.log("DropList defaultProps onChange called, e=", e);
56 class RadioButtonGroup extends React.Component {
60 * TODO: Enable option to swap order of radio button and label
63 const {className, items, selectedItem, radioGroupName, onChange, ...props} = this.props;
65 <div className={className}>
67 items.map(function(item, index) {
69 <div key={index} className="radioItem">
70 <input type="radio" name={radioGroupName}
72 checked={selectedItem.value == item.value}
73 onChange={onChange} />
74 <label>{item.label}</label>
87 // TODO: support externally defined className(s)
88 class CardSection extends React.Component {
91 const {title, children, ...props} = this.props;
93 <div className="cardSection">
94 <div className="cardSectionHeader">{title}</div>
103 RadioButtonGroup: RadioButtonGroup,
104 CardSection: CardSection