🎨 améliore l'affichage et corrige le debounce sur l'input du pourcentage

pull/525/head
Johan Girod 2019-05-20 12:45:26 +02:00
parent b6e76ec746
commit d8ee14a77d
No known key found for this signature in database
GPG Key ID: 9E27B57DA2E8AE12
5 changed files with 21 additions and 15 deletions

View File

@ -3,6 +3,7 @@
vertical-align: middle;
outline: none;
border: none;
cursor: pointer;
padding: 0;
background: none;
}

View File

@ -2,30 +2,32 @@ import React from 'react'
import { debounce } from '../utils'
import './PercentageField.css'
export default class extends React.Component {
onChange = this.props.debounce
export default class PercentageField extends React.Component {
debouncedOnChange = this.props.debounce
? debounce(this.props.debounce, this.props.input.onChange)
: this.props.input.onChange
state = {
value: this.props.input?.value
}
onChange(value) {
this.setState({ value })
this.debouncedOnChange(value)
}
render() {
let {
input: { value }
} = this.props
return (
<div>
<input
className="range"
onChange={e => this.onChange(e.target.value)}
value={value}
type="range"
value={this.state.value}
name="volume"
min="0"
step="0.1"
step="0.05"
max="1"
/>
<span style={{ display: 'inline-block', width: '3em' }}>
{value * 100} %
{Math.round(this.state.value * 100)} %
</span>
</div>
)

View File

@ -104,14 +104,16 @@ export default compose(
controls={analysis.controls}
/>
)}
<PeriodSwitch />
{(Array.isArray(objectifs)
? [[null, objectifs]]
: toPairs(objectifs)
).map(([groupName, groupTargets]) => (
).map(([groupName, groupTargets], index) => (
<>
{groupName && <h2>{emoji(groupName)}</h2>}
<div style={{ display: 'flex', alignItems: 'end' }}>
{groupName && <h2 style={{ flex: 1 }}>{emoji(groupName)}</h2>}
{index === 0 && <PeriodSwitch />}
</div>
<section
className="ui__ plain card"
style={{

View File

@ -19,6 +19,7 @@ questions:
blacklist:
- entreprise . charges
- contrat salarié . avantages en nature . montant
- entreprise . rémunération du dirigeant
situation:
auto entrepreneur: non
indépendant: non

View File

@ -17,7 +17,7 @@ type OwnProps = {|
type Props = OwnProps & {
tracker: Tracker,
location: Location,
location: Location
}
type State = {
opened: boolean,
@ -97,5 +97,5 @@ class SideBar extends React.Component<Props, State> {
export default (compose(
withTracker,
withRouter,
withRouter
)(SideBar): React$ComponentType<OwnProps>)