aboutsummaryrefslogtreecommitdiff
path: root/src/settings/components/form/PropertiesForm.tsx
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-04-13 20:37:36 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2020-04-13 20:37:36 +0900
commite1dac618a8b8929f601c7ec8aca3842c5ebf9d03 (patch)
tree6a914a8243c8c02e7752a83667a54d3fa832955c /src/settings/components/form/PropertiesForm.tsx
parent685f2b7b69218b06b5bb676069e35f79c5048c9b (diff)
Use plugin:prettier/recommended
Diffstat (limited to 'src/settings/components/form/PropertiesForm.tsx')
-rw-r--r--src/settings/components/form/PropertiesForm.tsx66
1 files changed, 35 insertions, 31 deletions
diff --git a/src/settings/components/form/PropertiesForm.tsx b/src/settings/components/form/PropertiesForm.tsx
index e648971..aebd9b1 100644
--- a/src/settings/components/form/PropertiesForm.tsx
+++ b/src/settings/components/form/PropertiesForm.tsx
@@ -1,9 +1,9 @@
-import './PropertiesForm.scss';
-import React from 'react';
+import "./PropertiesForm.scss";
+import React from "react";
interface Props {
- types: {[key: string]: string};
- value: {[key: string]: any};
+ types: { [key: string]: string };
+ value: { [key: string]: any };
onChange: (value: any) => void;
onBlur: () => void;
}
@@ -20,18 +20,18 @@ class PropertiesForm extends React.Component<Props> {
const types = this.props.types;
const values = this.props.value;
- return <div className='form-properties-form'>
- {
- Object.keys(types).map((name) => {
+ return (
+ <div className="form-properties-form">
+ {Object.keys(types).map((name) => {
const type = types[name];
- let inputType = '';
+ let inputType = "";
let onChange = this.bindValue.bind(this);
- if (type === 'string') {
- inputType = 'text';
- } else if (type === 'number') {
- inputType = 'number';
- } else if (type === 'boolean') {
- inputType = 'checkbox';
+ if (type === "string") {
+ inputType = "text";
+ } else if (type === "number") {
+ inputType = "number";
+ } else if (type === "boolean") {
+ inputType = "checkbox";
// Settings are saved onBlur, but checkbox does not fire it
onChange = (e) => {
@@ -41,29 +41,33 @@ class PropertiesForm extends React.Component<Props> {
} else {
return null;
}
- return <div key={name} className='form-properties-form-row'>
- <label>
- <span className='column-name'>{name}</span>
- <input type={inputType} name={name}
- className='column-input'
- value={values[name] ? values[name] : ''}
- onChange={onChange}
- onBlur={this.props.onBlur}
- checked={values[name]}
- />
- </label>
- </div>;
- })
- }
- </div>;
+ return (
+ <div key={name} className="form-properties-form-row">
+ <label>
+ <span className="column-name">{name}</span>
+ <input
+ type={inputType}
+ name={name}
+ className="column-input"
+ value={values[name] ? values[name] : ""}
+ onChange={onChange}
+ onBlur={this.props.onBlur}
+ checked={values[name]}
+ />
+ </label>
+ </div>
+ );
+ })}
+ </div>
+ );
}
bindValue(e: React.ChangeEvent<HTMLInputElement>) {
const name = e.target.name;
const next = { ...this.props.value };
- if (e.target.type.toLowerCase() === 'checkbox') {
+ if (e.target.type.toLowerCase() === "checkbox") {
next[name] = e.target.checked;
- } else if (e.target.type.toLowerCase() === 'number') {
+ } else if (e.target.type.toLowerCase() === "number") {
next[name] = Number(e.target.value);
} else {
next[name] = e.target.value;