From fb119fff9aa271ce0f491e58a9cb389725fa85e7 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 31 Jul 2017 20:39:50 -0400 Subject: [PATCH] Add DomainInput component Signed-off-by: Mcat12 --- src/components/DomainInput/DomainInput.js | 37 +++++++++++++++++++++++ src/components/DomainInput/package.json | 6 ++++ 2 files changed, 43 insertions(+) create mode 100644 src/components/DomainInput/DomainInput.js create mode 100644 src/components/DomainInput/package.json diff --git a/src/components/DomainInput/DomainInput.js b/src/components/DomainInput/DomainInput.js new file mode 100644 index 0000000..5c9d00f --- /dev/null +++ b/src/components/DomainInput/DomainInput.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +export default class DomainInput extends Component { + constructor(props) { + super(props); + this.onAdd = this.onAdd.bind(this); + } + + onAdd() { + this.props.onAdd(this.refs.input.value); + } + + render() { + return ( +
+ e.charCode === 13 ? this.onAdd() : null} + placeholder="Add a domain (example.com or sub.example.com)" + /> + + + + +
+ ); + } +} + +DomainInput.propTypes = { + onAdd: PropTypes.func.isRequired, + onRefresh: PropTypes.func.isRequired +}; diff --git a/src/components/DomainInput/package.json b/src/components/DomainInput/package.json new file mode 100644 index 0000000..361d0d7 --- /dev/null +++ b/src/components/DomainInput/package.json @@ -0,0 +1,6 @@ +{ + "name": "DomainInput", + "version": "0.0.0", + "private": true, + "main": "./DomainInput.js" +}