aboutsummaryrefslogtreecommitdiff
path: root/src/settings/components/ui
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-11-22 22:38:34 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-11-26 11:40:12 +0900
commit4e5ddc1d57ba4f42314eb49ae57a9b67950be596 (patch)
treec43db0b38d030446cbbde392d63cd7faf2d6f533 /src/settings/components/ui
parentd33b37cdb9d2956f5f2d23ab4e71e35db137b16e (diff)
Add keybindings form
Diffstat (limited to 'src/settings/components/ui')
-rw-r--r--src/settings/components/ui/input.jsx35
-rw-r--r--src/settings/components/ui/input.scss37
2 files changed, 44 insertions, 28 deletions
diff --git a/src/settings/components/ui/input.jsx b/src/settings/components/ui/input.jsx
index 9b6c229..5138411 100644
--- a/src/settings/components/ui/input.jsx
+++ b/src/settings/components/ui/input.jsx
@@ -3,32 +3,35 @@ import './input.scss';
class Input extends Component {
+ renderText(props) {
+ let inputClassName = props.error ? 'input-error' : '';
+ return <div className='settings-ui-input'>
+ <label
+ type='text'
+ htmlFor={props.id}
+ >{ props.label }</label>
+ <input type='text' className={inputClassName} {...props} />
+ </div>;
+ }
+
renderRadio(props) {
- let inputClasses = 'form-field-input';
- if (props.error) {
- inputClasses += ' input-error';
- }
- return <div>
+ let inputClassName = props.error ? 'input-error' : '';
+ return <div className='settings-ui-input'>
<label>
- <input className={ inputClasses } type='radio' {...props} />
+ <input type='radio' className={inputClassName} {...props} />
{ props.label }
</label>
</div>;
}
renderTextArea(props) {
- let inputClasses = 'form-field-input';
- if (props.error) {
- inputClasses += ' input-error';
- }
- return <div>
+ let inputClassName = props.error ? 'input-error' : '';
+ return <div className='settings-ui-input'>
<label
- className='form-field-label'
htmlFor={props.id}
>{ props.label }</label>
- <textarea className={inputClasses} {...props} />
-
- <p className='form-field-error'>{ this.props.error }</p>
+ <textarea className={inputClassName} {...props} />
+ <p className='settings-ui-input-error'>{ this.props.error }</p>
</div>;
}
@@ -36,6 +39,8 @@ class Input extends Component {
let { type } = this.props;
switch (this.props.type) {
+ case 'text':
+ return this.renderText(this.props);
case 'radio':
return this.renderRadio(this.props);
case 'textarea':
diff --git a/src/settings/components/ui/input.scss b/src/settings/components/ui/input.scss
index 6187138..92df712 100644
--- a/src/settings/components/ui/input.scss
+++ b/src/settings/components/ui/input.scss
@@ -1,17 +1,28 @@
-.form-field-label {
- font-weight: bold
-}
+.settings-ui-input {
+ page-break-inside: avoid;
-.form-field-error {
- font-weight: bold;
- color: red;
- min-height: 1.5em;
-}
+ * {
+ page-break-inside: avoid;
+ }
-.form-field-input {
- padding: 4px;
-}
+ label {
+ font-weight: bold;
+ min-width: 14rem;
+ display: inline-block;
+ }
+
+ input {
+ padding: 4px;
+ }
+
+ input.input-crror,
+ textarea.input-error {
+ box-shadow: 0 0 2px red;
+ }
-.form-field-input.input-error {
- box-shadow: 0 0 2px red;
+ &-error {
+ font-weight: bold;
+ color: red;
+ min-height: 1.5em;
+ }
}