1
0

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

This commit is contained in:
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,57 +48,62 @@ export default class LocalSettingsPageItem extends React.PureComponent {
if (options && options.length > 0) {
const currentValue = settings.getIn(item);
const optionElems = options && options.length > 0 && options.map((opt) => (
<option
key={opt.value}
value={opt.value}
>
{opt.message}
</option>
));
return (
<label className='glitch local-settings__page__item' htmlFor={id}>
<p>{children}</p>
<p>
<select
id={id}
disabled={!enabled}
const optionElems = options && options.length > 0 && options.map((opt) => {
let optionId = `${id}--${opt.value}`;
return (
<label htmlFor={optionId}>
<input type='radio'
name={id}
id={optionId}
value={opt.value}
onBlur={handleChange}
onChange={handleChange}
value={currentValue}
>
{optionElems}
</select>
</p>
</label>
checked={ currentValue === opt.value }
disabled={!enabled}
/>
{opt.message}
</label>
);
});
return (
<div class='glitch local-settings__page__item radio_buttons'>
<fieldset>
<legend>{children}</legend>
{optionElems}
</fieldset>
</div>
);
} else if (placeholder) {
return (
<label className='glitch local-settings__page__item' htmlFor={id}>
<p>{children}</p>
<p>
<input
id={id}
type='text'
value={settings.getIn(item)}
placeholder={placeholder}
onChange={handleChange}
disabled={!enabled}
/>
</p>
</label>
<div className='glitch local-settings__page__item string'>
<label htmlFor={id}>
<p>{children}</p>
<p>
<input
id={id}
type='text'
value={settings.getIn(item)}
placeholder={placeholder}
onChange={handleChange}
disabled={!enabled}
/>
</p>
</label>
</div>
);
} else return (
<label className='glitch local-settings__page__item' htmlFor={id}>
<input
id={id}
type='checkbox'
checked={settings.getIn(item)}
onChange={handleChange}
disabled={!enabled}
/>
{children}
</label>
<div className='glitch local-settings__page__item boolean'>
<label htmlFor={id}>
<input
id={id}
type='checkbox'
checked={settings.getIn(item)}
onChange={handleChange}
disabled={!enabled}
/>
{children}
</label>
</div>
);
}

View File

@ -11,8 +11,21 @@
max-height: 450px;
overflow: hidden;
label {
label, legend {
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 {
@ -74,7 +87,11 @@
}
.glitch.local-settings__page__item {
select {
margin-bottom: 5px;
}
margin-bottom: 2px;
}
.glitch.local-settings__page__item.string,
.glitch.local-settings__page__item.radio_buttons {
margin-top: 10px;
margin-bottom: 10px;
}