diff --git a/docs/styleguide.config.js b/docs/styleguide.config.js index ce1a595518..40d569df6c 100644 --- a/docs/styleguide.config.js +++ b/docs/styleguide.config.js @@ -29,6 +29,7 @@ module.exports = { '../react/Checkbox/index.jsx', '../react/Field/index.jsx', '../react/Input/index.jsx', + '../react/InputGroup/index.jsx', '../react/Label/index.jsx', '../react/Radio/index.jsx', '../react/SelectBox/SelectBox.jsx', diff --git a/react/InputGroup/Readme.md b/react/InputGroup/Readme.md new file mode 100644 index 0000000000..0e29b03ea8 --- /dev/null +++ b/react/InputGroup/Readme.md @@ -0,0 +1,89 @@ +### InputGroup with an appended text + +``` +const { Bold } = require('../Text'); +const Input = require('../Input').default; +
+``` + +### InputGroup with a prepended text + +``` +const { Bold } = require('../Text'); +const Input = require('../Input').default; + +``` + +### InputGroup with an appended input + +You will need to set a width to the side component, with a utility class for example. + +``` +const Input = require('../Input').default; + +``` + +### InputGroup with an appended select + +You will need to set a width to the side component, with a utility class for example. + +``` +const SelectBox = require('../SelectBox').default; +const options = [ + { value: 'cozy.io', label: '.cozy.io' }, + { value: 'cozycloud.cc', label: '.cozycloud.cc' } +]; + +``` + +### Full width InputGroup with an appended text + +``` +const { Bold } = require('../Text'); +const Input = require('../Input').default; + +``` + +### Errored InputGroup with an appended text + +``` +const { Bold } = require('../Text'); +const Input = require('../Input').default; + +``` diff --git a/react/InputGroup/index.jsx b/react/InputGroup/index.jsx new file mode 100644 index 0000000000..a4d144f082 --- /dev/null +++ b/react/InputGroup/index.jsx @@ -0,0 +1,57 @@ +import React, { Component } from 'react' +import cx from 'classnames' +import PropTypes from 'prop-types' +import styles from './styles.styl' + +class InputGroup extends Component { + constructor(props) { + super(props) + this.handleFocus = this.handleFocus.bind(this) + this.handleBlur = this.handleBlur.bind(this) + this.state = { + focused: false + } + } + + handleFocus() { + this.setState({ focused: true }) + } + + handleBlur() { + this.setState({ focused: false }) + } + + render() { + const { children, prepend, append, error, fullwidth } = this.props + const { focused } = this.state + return ( +