From e2149ff4e68d5e190fb9e9195f38c3bc659aeb4f Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Thu, 4 Nov 2021 15:23:26 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Permet=20de=20passer=20un=20composa?= =?UTF-8?q?nt=20pour=20l'affichage=20des=20r=C3=A9f=C3=A9rences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notre logique d'affichage des référence était assez spécifique à mon-entreprise. D'autres sont possible comme l'affichage de “cartes” https://futur.eco/documentation/transport/avion/impact On passe maintenant par un “renderer” qui permet de personnalisé le composant affiché. --- .../source/components/conversation/Aide.tsx | 8 +- .../components/conversation/Question.tsx | 4 +- mon-entreprise/source/pages/Documentation.tsx | 114 +++++++++++++++--- publicodes/ui-react/source/contexts.tsx | 9 +- publicodes/ui-react/source/index.tsx | 2 - .../ui-react/source/rule/References.tsx | 111 ++++------------- publicodes/ui-react/source/rule/RulePage.tsx | 27 ++--- 7 files changed, 142 insertions(+), 133 deletions(-) diff --git a/mon-entreprise/source/components/conversation/Aide.tsx b/mon-entreprise/source/components/conversation/Aide.tsx index ee67c7d1b..b5af26106 100644 --- a/mon-entreprise/source/components/conversation/Aide.tsx +++ b/mon-entreprise/source/components/conversation/Aide.tsx @@ -1,13 +1,13 @@ import { explainVariable } from 'Actions/actions' import Overlay from 'Components/Overlay' +import { EngineContext } from 'Components/utils/EngineContext' import { Markdown } from 'Components/utils/markdown' import { useContext } from 'react' +import { Trans } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { RootState } from 'Reducers/rootReducer' -import { References } from 'publicodes-react' -import { Trans } from 'react-i18next' +import { References } from '../../pages/Documentation' import './Aide.css' -import { EngineContext } from 'Components/utils/EngineContext' export default function Aide() { const explained = useSelector((state: RootState) => state.explainedVariable) @@ -36,7 +36,7 @@ export default function Aide() {

En savoir plus

- + )} diff --git a/mon-entreprise/source/components/conversation/Question.tsx b/mon-entreprise/source/components/conversation/Question.tsx index 14363db2f..d0b723438 100644 --- a/mon-entreprise/source/components/conversation/Question.tsx +++ b/mon-entreprise/source/components/conversation/Question.tsx @@ -4,7 +4,6 @@ import Emoji from 'Components/utils/Emoji' import { Markdown } from 'Components/utils/markdown' import { DottedName } from 'modele-social' import { EvaluatedNode, Rule, RuleNode, serializeEvaluation } from 'publicodes' -import { References } from 'publicodes-react' import { createContext, useCallback, @@ -13,6 +12,7 @@ import { useState, } from 'react' import { Trans } from 'react-i18next' +import { References } from '../../pages/Documentation' import { Explicable } from './Explicable' import { binaryQuestion, InputProps } from './RuleInput' @@ -211,7 +211,7 @@ export const RadioLabel = (props: RadioLabelProps) => (

En savoir plus

- + )} diff --git a/mon-entreprise/source/pages/Documentation.tsx b/mon-entreprise/source/pages/Documentation.tsx index 3c634772a..88ad32152 100644 --- a/mon-entreprise/source/pages/Documentation.tsx +++ b/mon-entreprise/source/pages/Documentation.tsx @@ -2,20 +2,27 @@ import SearchRules from 'Components/search/SearchRules' import { FromBottom } from 'Components/ui/animate' import { ThemeColorsProvider } from 'Components/utils/colors' import { useEngine } from 'Components/utils/EngineContext' +import Meta from 'Components/utils/Meta' import { ScrollToTop } from 'Components/utils/Scroll' import { SitePathsContext } from 'Components/utils/SitePathsContext' -import { RulePage, getDocumentationSiteMap } from 'publicodes-react' +import rules, { DottedName } from 'modele-social' +import { getDocumentationSiteMap, RulePage } from 'publicodes-react' import { useCallback, useContext, useMemo } from 'react' +import { Helmet } from 'react-helmet-async' import { Trans, useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' -import { Redirect, useHistory, useLocation, Link } from 'react-router-dom' +import { + Link, + Redirect, + Route, + useHistory, + useLocation, +} from 'react-router-dom' import { RootState } from 'Reducers/rootReducer' +import styled from 'styled-components' import { TrackPage } from '../ATInternetTracking' -import rules, { DottedName } from 'modele-social' import RuleLink from '../components/RuleLink' -import Meta from 'Components/utils/Meta' -import { Route } from 'react-router-dom' -import { Helmet } from 'react-helmet-async' +import { capitalise0 } from '../utils' export default function MonEntrepriseRulePage() { const currentSimulation = useSelector( @@ -70,10 +77,10 @@ export default function MonEntrepriseRulePage() { rulePath={match.params.name} engine={engine} documentationPath={documentationPath} - referenceImages={referencesImages} renderers={{ Head: Helmet, Link, + References, }} /> )} @@ -88,7 +95,7 @@ function BackToSimulation() { const history = useHistory() const handleClick = useCallback(() => { url && history.push(url) - }, []) + }, [history, url]) return (