From be30d62f6fa48f365d37969610af834e7c1439eb Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 16 Jul 2018 18:29:14 +0200 Subject: [PATCH] Reduced the amount of duplicated code in CreateServer component --- src/servers/CreateServer.js | 47 ++++++++++++++--------------------- src/servers/CreateServer.scss | 1 + 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/servers/CreateServer.js b/src/servers/CreateServer.js index 7782d34f..1d290fcd 100644 --- a/src/servers/CreateServer.js +++ b/src/servers/CreateServer.js @@ -16,39 +16,28 @@ export class CreateServer extends React.Component { e.preventDefault(); this.props.createServer(this.state); }; - const renderInput = (id, placeholder, type = 'text') => - this.setState({ [id]: e.target.value })} - />; + const renderInputGroup = (id, placeholder, type = 'text') => +
+ +
+ this.setState({ [id]: e.target.value })} + required + /> +
+
; return (
-
- -
- {renderInput('name', 'Name')} -
-
- -
- -
- {renderInput('url', 'URL', 'url')} -
-
- -
- -
- {renderInput('apiKey', 'API key')} -
-
+ {renderInputGroup('name', 'Name')} + {renderInputGroup('url', 'URL', 'url')} + {renderInputGroup('apiKey', 'API key')}
diff --git a/src/servers/CreateServer.scss b/src/servers/CreateServer.scss index 73cbf36a..e4b760ad 100644 --- a/src/servers/CreateServer.scss +++ b/src/servers/CreateServer.scss @@ -6,6 +6,7 @@ .create-server__label { font-weight: bold; + cursor: pointer; @media (min-width: $mdMin) { text-align: right;