Client: replace select with radio buttons on statistics

This commit is contained in:
Sam 2019-07-07 12:56:09 +02:00
parent d59454ba26
commit c9f0405ee6
2 changed files with 47 additions and 14 deletions

View File

@ -329,6 +329,36 @@ label {
max-height: 45px; max-height: 45px;
} }
.time-frames {
align-items: center;
display: inline-flex;
}
.time-frame label {
float: left;
padding: 0 5px;
width: 4em;
}
.time-frame label input {
display: none;
}
.time-frame label span {
border: #a9a9a9 solid 1px;
border-radius: 9%;
color: #7b7b7b;
display: block;
font-size: 0.9em;
padding: 2px 0;
text-align: center;
}
.time-frame input:checked + span {
background-color: #a9a9a9;
color: #ffffff;
}
.timezone-custom-height { .timezone-custom-height {
height: calc(2.25rem + 14px); height: calc(2.25rem + 14px);
} }

View File

@ -48,7 +48,8 @@ class Statistics extends React.Component {
} }
handleOnChangeDuration(e) { handleOnChangeDuration(e) {
const duration = e.target.value const duration = e.target.name
const date = new Date() const date = new Date()
const start = duration === 'year' const start = duration === 'year'
? startOfYear(subYears(date, 9)) ? startOfYear(subYears(date, 9))
@ -131,19 +132,21 @@ class Statistics extends React.Component {
/> />
</p> </p>
</div> </div>
<div className="col-md-3"> <div className="col-md-3 time-frames justify-content-around">
<select {durations.map(d => (
className="form-control input-lg" <div className="time-frame" key={d}>
name="duration" <label >
defaultValue={statsParams.duration} <input
onChange={e => this.handleOnChangeDuration(e)} type="radio"
> id={d}
{durations.map(d => ( name={d}
<option key={d} value={d}> checked={d === statsParams.duration}
{d} onChange={e => this.handleOnChangeDuration(e)}
</option> />
))} <span>{ d }</span>
</select> </label>
</div>
))}
</div> </div>
<div className="col chart-arrows"> <div className="col chart-arrows">
<p className="text-center"> <p className="text-center">