From 4a73049df3f421ba8b087a76c24b5de31b42429c Mon Sep 17 00:00:00 2001 From: Mael Date: Mon, 30 Jul 2018 17:51:51 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20en=20valeur=20des=20tranches=20de=20bar?= =?UTF-8?q?=C3=A8me=20activ=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/components/rule/Algorithm.css | 29 --------------------- source/engine/mecanismViews/Barème.css | 35 ++++++++++++++++++++++---- source/engine/mecanismViews/Barème.js | 8 +++--- source/engine/mecanismViews/common.js | 2 +- source/engine/treat.js | 11 ++++++++ 5 files changed, 47 insertions(+), 38 deletions(-) diff --git a/source/components/rule/Algorithm.css b/source/components/rule/Algorithm.css index c11fb40e9..3196fb09e 100644 --- a/source/components/rule/Algorithm.css +++ b/source/components/rule/Algorithm.css @@ -44,7 +44,6 @@ margin: 1em 0; } - #rule-rules #ruleValue { font-weight: 400; text-align: center; @@ -159,7 +158,6 @@ white-space: nowrap; } - .percentage .name { font-weight: 500; } @@ -173,33 +171,6 @@ font-size: 60%; } -.barème > .nodeHead .name { - background: #1abc9c; -} - -.barème .key { - color: #1abc9c; -} -.mecanism.barème { - border-color: #1abc9c; -} - -.barème table { - margin-top: 1em; - width: 80%; - text-align: left; - font-weight: 400; -} -.barème table td { - padding: 0.1em 0.4em; -} -.barème table tr:first-child { - font-weight: 500; -} -.barème table tr:nth-child(2n) { - background: #f1f1f1; -} - .mecanism.inversion li { margin-top: 0.6em; } diff --git a/source/engine/mecanismViews/Barème.css b/source/engine/mecanismViews/Barème.css index 1c23cf87d..a01e4530f 100644 --- a/source/engine/mecanismViews/Barème.css +++ b/source/engine/mecanismViews/Barème.css @@ -1,7 +1,32 @@ -.tranche .activated { - background: yellow; +.barème > .nodeHead .name { + background: #1abc9c; } -.tranche .activated:last-child { - border: 1px dashed yellow; - background: none; + +.barème .key { + color: #1abc9c; +} +.mecanism.barème { + border-color: #1abc9c; +} + +.barème table { + margin-top: 1em; + width: 80%; + text-align: left; + font-weight: 400; +} +.barème table td { + padding: 0.1em 0.4em; +} +.barème table tr:first-child { + font-weight: 600; +} +.barème .tranche:nth-child(2n) { + background: #f1f1f1; +} +.barème .tranche.activated { + background: yellow !important ; +} +.barème .tranche.activated:last-of-type { + background: chartreuse; } diff --git a/source/engine/mecanismViews/Barème.js b/source/engine/mecanismViews/Barème.js index 077b5573b..0c5b8bdc9 100644 --- a/source/engine/mecanismViews/Barème.js +++ b/source/engine/mecanismViews/Barème.js @@ -3,7 +3,9 @@ import { Node } from './common' import { makeJsx } from '../evaluation' import { Trans } from 'react-i18next' import { trancheValue } from 'Engine/mecanisms/barème' +import { NodeValuePointer } from './common' import './Barème.css' +import classNames from 'classnames' export default function Barème(nodeValue, explanation) { return ( @@ -45,7 +47,7 @@ export default function Barème(nodeValue, explanation) { tranche={t} trancheValue={trancheValue( explanation['assiette'], - explanation['multiplicateur de tranches'] + explanation['multiplicateur des tranches'] )(t)} /> ))} @@ -68,7 +70,7 @@ function Tranche({ trancheValue }) { return ( - 0 ? 'activated' : ''}> + 0 })}> {maxOnly ? `En-dessous de ${maxOnly}` @@ -76,7 +78,7 @@ function Tranche({ ? `Au-dessus de ${minOnly}` : `De ${min} à ${max}`} - {makeJsx(taux)} + {makeJsx(taux)} ) } diff --git a/source/engine/mecanismViews/common.js b/source/engine/mecanismViews/common.js index 73032dd61..d55062142 100644 --- a/source/engine/mecanismViews/common.js +++ b/source/engine/mecanismViews/common.js @@ -23,7 +23,7 @@ export let NodeValue = withLanguage(({ data, language }) => ( {treatValue(data, language)} )) -let NodeValuePointer = ({ data }) => +export let NodeValuePointer = ({ data }) => data !== undefined && data !== null ? ( diff --git a/source/engine/treat.js b/source/engine/treat.js index dcacffb9b..d6ed57c39 100644 --- a/source/engine/treat.js +++ b/source/engine/treat.js @@ -153,6 +153,17 @@ export let treatString = (rules, rule) => rawNode => { // eslint-disable-next-line jsx: nodeValue => {nodeValue} }) + ], + [ + propEq('category', 'percentage'), + node => ({ + nodeValue: node.nodeValue, + // eslint-disable-next-line + jsx: nodeValue => ( + {nodeValue * 100}% + ) + //the best would be to display the original text before parsing, but nearley does'nt let us access it + }) ] ]) ),