From 5313cd27deeb3f1ae612139904dd2d5e7744fe93 Mon Sep 17 00:00:00 2001 From: Mael Date: Wed, 20 Mar 2019 16:19:59 +0100 Subject: [PATCH] =?UTF-8?q?Les=20variations=20d=C3=A9sactiv=C3=A9es=20sont?= =?UTF-8?q?=20repli=C3=A9es=20par=20d=C3=A9faut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand une simulation est en cours --- source/engine/mecanismViews/Variations.js | 116 ++++++++++++++-------- 1 file changed, 77 insertions(+), 39 deletions(-) diff --git a/source/engine/mecanismViews/Variations.js b/source/engine/mecanismViews/Variations.js index e1da11cef..f97b270c6 100644 --- a/source/engine/mecanismViews/Variations.js +++ b/source/engine/mecanismViews/Variations.js @@ -6,52 +6,90 @@ import classNames from 'classnames' import writtenNumbers from '../../locales/writtenNumbers.yaml' import withLanguage from 'Components/utils/withLanguage' import { Trans } from 'react-i18next' +import { ShowValuesConsumer } from 'Components/rule/ShowValuesContext' +import emoji from 'react-easy-emoji' +import { useState } from 'react' let Comp = withLanguage(function Variations({ language, nodeValue, explanation }) { + let [expandedVariation, toggleVariation] = useState(null) + return ( - -

- Cette règle présente{' '} - {writtenNumbers[language][explanation.length]}{' '} - : -

- - - } - /> + + {showValues => ( + +

+ Cette règle présente{' '} + {writtenNumbers[language][explanation.length]}{' '} + : +

+
    + {explanation.map(({ condition, consequence, satisfied }, i) => ( +
  • + {showValues && + (!satisfied && !(expandedVariation === i)) ? ( +

    + non applicable{' '} + +

    + ) : ( + <> + {expandedVariation === i && ( + + )} +
    + {condition && ( + + Si {makeJsx(condition)} + + )} +
    + + {condition ? ( + Alors + ) : ( + Sinon + )}{' '} + : + + + {consequence && makeJsx(consequence)} + +
    +
    + + )} +
  • + ))} +
+ + } + /> + )} +
) }) // eslint-disable-next-line