Toolkit.js (981B)
1 import React, { Component } from 'react' 2 3 class ToolKitItem extends Component { 4 render() { 5 let iconClass = this.props.tool.icon + " fa-2x" 6 let style = styles.toolkititem 7 if (this.props.selected) { 8 style = Object.assign({}, style, styles.selected) 9 } 10 return <div style={style} 11 onClick={() => this.props.onSelectTool(this.props.tool)}> 12 <i className={iconClass}></i> 13 </div> 14 } 15 } 16 17 export default class Toolkit extends Component { 18 render() { 19 let toolComponents = this.props.tools.map((tool) => { 20 return <ToolKitItem 21 tool={tool} 22 key={tool.name} 23 selected={tool === this.props.selectedTool} 24 onSelectTool={this.props.onSelectTool}/> 25 }) 26 return <div className="tools" 27 style={styles.toolkit}> 28 {toolComponents} 29 </div> 30 } 31 } 32 33 const styles = { 34 toolkit: { 35 background: "grey" 36 }, 37 toolkititem: { 38 padding: "5px", 39 }, 40 selected: { 41 background: "lightcoral" 42 } 43 }