Switch from selects to radio buttons for local settings, improve styling

pull/772/head
Thibaut Girka 2018-10-01 17:40:56 +02:00 committed by ThibG
parent a3677a828d
commit faecb35fe0
2 changed files with 70 additions and 48 deletions

View File

@ -48,33 +48,35 @@ export default class LocalSettingsPageItem extends React.PureComponent {
if (options && options.length > 0) { if (options && options.length > 0) {
const currentValue = settings.getIn(item); const currentValue = settings.getIn(item);
const optionElems = options && options.length > 0 && options.map((opt) => ( const optionElems = options && options.length > 0 && options.map((opt) => {
<option let optionId = `${id}--${opt.value}`;
key={opt.value}
value={opt.value}
>
{opt.message}
</option>
));
return ( return (
<label className='glitch local-settings__page__item' htmlFor={id}> <label htmlFor={optionId}>
<p>{children}</p> <input type='radio'
<p> name={id}
<select id={optionId}
id={id} value={opt.value}
disabled={!enabled}
onBlur={handleChange} onBlur={handleChange}
onChange={handleChange} onChange={handleChange}
value={currentValue} checked={ currentValue === opt.value }
> disabled={!enabled}
{optionElems} />
</select> {opt.message}
</p>
</label> </label>
); );
});
return (
<div class='glitch local-settings__page__item radio_buttons'>
<fieldset>
<legend>{children}</legend>
{optionElems}
</fieldset>
</div>
);
} else if (placeholder) { } else if (placeholder) {
return ( return (
<label className='glitch local-settings__page__item' htmlFor={id}> <div className='glitch local-settings__page__item string'>
<label htmlFor={id}>
<p>{children}</p> <p>{children}</p>
<p> <p>
<input <input
@ -87,9 +89,11 @@ export default class LocalSettingsPageItem extends React.PureComponent {
/> />
</p> </p>
</label> </label>
</div>
); );
} else return ( } else return (
<label className='glitch local-settings__page__item' htmlFor={id}> <div className='glitch local-settings__page__item boolean'>
<label htmlFor={id}>
<input <input
id={id} id={id}
type='checkbox' type='checkbox'
@ -99,6 +103,7 @@ export default class LocalSettingsPageItem extends React.PureComponent {
/> />
{children} {children}
</label> </label>
</div>
); );
} }

View File

@ -11,8 +11,21 @@
max-height: 450px; max-height: 450px;
overflow: hidden; overflow: hidden;
label { label, legend {
display: block; display: block;
font-size: 14px;
}
.boolean label, .radio_buttons label {
position: relative;
padding-left: 28px;
padding-top: 3px;
input {
position: absolute;
left: 0;
top: 0;
}
} }
h1 { h1 {
@ -74,7 +87,11 @@
} }
.glitch.local-settings__page__item { .glitch.local-settings__page__item {
select { margin-bottom: 2px;
margin-bottom: 5px; }
}
.glitch.local-settings__page__item.string,
.glitch.local-settings__page__item.radio_buttons {
margin-top: 10px;
margin-bottom: 10px;
} }