🐛 répare le bouton d'aide cassé suite à la refacto du state

pull/262/head
Johan Girod 2018-06-20 14:08:49 +02:00
parent a07228204c
commit e16ef7e975
2 changed files with 17 additions and 29 deletions

View File

@ -1,29 +1,28 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import marked from 'Engine/marked'
import { findRuleByDottedName } from 'Engine/rules'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { flatRulesSelector } from 'Selectors/analyseSelectors'
import { EXPLAIN_VARIABLE } from '../actions'
import References from './rule/References'
import './Aide.css'
import References from './rule/References'
import withColours from './withColours'
@connect(
state => ({
explained: state.explainedVariable,
themeColours: state.themeColours,
flatRules: state.flatRules
flatRules: flatRulesSelector(state)
}),
dispatch => ({
stopExplaining: () => dispatch({ type: EXPLAIN_VARIABLE })
})
)
@withColours
export default class Aide extends Component {
renderExplanationMarkdown(explanation, term) {
return marked(`### ${term} \n\n${explanation}`)
}
render() {
let { flatRules, explained, stopExplaining, themeColours } = this.props
let { flatRules, explained, stopExplaining, colours } = this.props
if (!explained) return <section id="helpWrapper" />
@ -31,31 +30,19 @@ export default class Aide extends Component {
text = rule.description,
refs = rule.références
let possibilities = rule['choix exclusifs']
return (
<div id="helpWrapper" className="active">
<section id="help">
<i
className="fa fa-times-circle"
onClick={stopExplaining}
style={{ color: themeColours.colour }}
style={{ color: colours.colour }}
/>
<p
dangerouslySetInnerHTML={{
__html: this.renderExplanationMarkdown(text, rule.title)
}}
/>
{/* { possibilities &&
<p>
{possibilities.length} possibilités :
<ul>
{possibilities.map(p =>
<li key={p}>{p}</li>
)}
</ul>
</p>
} */}
{refs && (
<div>
<p>Pour en savoir plus: </p>

View File

@ -1,12 +1,11 @@
import React from 'react'
import classNames from 'classnames'
import './Explicable.css'
import { connect } from 'react-redux'
import { EXPLAIN_VARIABLE } from '../../actions'
import { findRuleByDottedName } from 'Engine/rules'
import React from 'react'
import { connect } from 'react-redux'
import { flatRulesSelector } from 'Selectors/analyseSelectors'
import ReactPiwik from '../Tracker'
import { EXPLAIN_VARIABLE } from '../../actions'
import withTracker from '../withTracker'
import './Explicable.css'
@connect(
state => ({
@ -18,6 +17,7 @@ import ReactPiwik from '../Tracker'
explain: variableName => dispatch({ type: EXPLAIN_VARIABLE, variableName })
})
)
@withTracker
export default class Explicable extends React.Component {
render() {
let {
@ -25,6 +25,7 @@ export default class Explicable extends React.Component {
dottedName,
explain,
explained,
tracker,
textColourOnWhite
} = this.props
@ -46,7 +47,7 @@ export default class Explicable extends React.Component {
<span
className="icon"
onClick={e => {
ReactPiwik.push(['trackEvent', 'help', dottedName])
tracker.push(['trackEvent', 'help', dottedName])
explain(dottedName)
e.preventDefault()
e.stopPropagation()