import React, { PropTypes } from 'react'; import InlineSVG from 'react-inlinesvg'; import classNames from 'classnames'; const downArrowUrl = require('../../../images/down-arrow.svg'); class SidebarItem extends React.Component { constructor(props) { super(props); this.handleKeyPress = this.handleKeyPress.bind(this); this.handleFileNameChange = this.handleFileNameChange.bind(this); this.validateFileName = this.validateFileName.bind(this); } handleFileNameChange(event) { this.props.updateFileName(this.props.file.id, event.target.value); } handleKeyPress(event) { console.log(event.key); if (event.key === 'Enter') { this.props.hideEditFileName(this.props.file.id); } } validateFileName() { if (!this.props.file.name.match(/.*\.(js|css|html|json)$/)) { this.props.updateFileName(this.props.file.id, this.originalFileName); } } render() { let itemClass = classNames({ 'sidebar__file-item': true, 'sidebar__file-item--selected': this.props.file.isSelected, 'sidebar__file-item--open': this.props.file.isOptionsOpen, 'sidebar__file-item--editing': this.props.file.isEditingName }); return (