import React from 'react'; import createClass from 'create-react-class'; import PropTypes from 'prop-types'; import Select from 'react-select-plus'; import Gravatar from 'react-gravatar'; const USERS = require('../data/users'); const GRAVATAR_SIZE = 15; const stringOrNode = PropTypes.oneOfType([ PropTypes.string, PropTypes.node, ]); const GravatarOption = createClass({ propTypes: { children: PropTypes.node, className: PropTypes.string, isDisabled: PropTypes.bool, isFocused: PropTypes.bool, isSelected: PropTypes.bool, onFocus: PropTypes.func, onSelect: PropTypes.func, option: PropTypes.object.isRequired, }, handleMouseDown (event) { event.preventDefault(); event.stopPropagation(); this.props.onSelect(this.props.option, event); }, handleMouseEnter (event) { this.props.onFocus(this.props.option, event); }, handleMouseMove (event) { if (this.props.isFocused) return; this.props.onFocus(this.props.option, event); }, render () { let gravatarStyle = { borderRadius: 3, display: 'inline-block', marginRight: 10, position: 'relative', top: -2, verticalAlign: 'middle', }; return (
{this.props.children}
); } }); const GravatarValue = createClass({ propTypes: { children: PropTypes.node, placeholder: stringOrNode, value: PropTypes.object }, render () { var gravatarStyle = { borderRadius: 3, display: 'inline-block', marginRight: 10, position: 'relative', top: -2, verticalAlign: 'middle', }; return (
{this.props.children}
); } }); const UsersField = createClass({ propTypes: { hint: PropTypes.string, label: PropTypes.string, }, getInitialState () { return {}; }, setValue (value) { this.setState({ value }); }, render () { var placeholder = ☺ Select User; return (

{this.props.label} (Source)