diff --git a/publicodes-react/source/rule/références/URSSAF.png b/mon-entreprise/source/images/références/URSSAF.png
similarity index 100%
rename from publicodes-react/source/rule/références/URSSAF.png
rename to mon-entreprise/source/images/références/URSSAF.png
diff --git a/publicodes-react/source/rule/références/agirc-arrco.png b/mon-entreprise/source/images/références/agirc-arrco.png
similarity index 100%
rename from publicodes-react/source/rule/références/agirc-arrco.png
rename to mon-entreprise/source/images/références/agirc-arrco.png
diff --git a/publicodes-react/source/rule/références/ameli.png b/mon-entreprise/source/images/références/ameli.png
similarity index 100%
rename from publicodes-react/source/rule/références/ameli.png
rename to mon-entreprise/source/images/références/ameli.png
diff --git a/publicodes-react/source/rule/références/bpi-création.png b/mon-entreprise/source/images/références/bpi-création.png
similarity index 100%
rename from publicodes-react/source/rule/références/bpi-création.png
rename to mon-entreprise/source/images/références/bpi-création.png
diff --git a/publicodes-react/source/rule/références/ladocumentationfrançaise.png b/mon-entreprise/source/images/références/ladocumentationfrançaise.png
similarity index 100%
rename from publicodes-react/source/rule/références/ladocumentationfrançaise.png
rename to mon-entreprise/source/images/références/ladocumentationfrançaise.png
diff --git a/publicodes-react/source/rule/références/marianne.png b/mon-entreprise/source/images/références/marianne.png
similarity index 100%
rename from publicodes-react/source/rule/références/marianne.png
rename to mon-entreprise/source/images/références/marianne.png
diff --git a/publicodes-react/source/rule/références/pole-emploi.png b/mon-entreprise/source/images/références/pole-emploi.png
similarity index 100%
rename from publicodes-react/source/rule/références/pole-emploi.png
rename to mon-entreprise/source/images/références/pole-emploi.png
diff --git a/publicodes-react/source/rule/références/senat.png b/mon-entreprise/source/images/références/senat.png
similarity index 100%
rename from publicodes-react/source/rule/références/senat.png
rename to mon-entreprise/source/images/références/senat.png
diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Documentation.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Documentation.tsx
index d99f1d8b8..7e5bc5caa 100644
--- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Documentation.tsx
+++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Documentation.tsx
@@ -48,11 +48,13 @@ export default function RulePage() {
language={i18n.language as 'fr' | 'en'}
engine={engine}
documentationPath={documentationPath}
+ referenceImages={referencesImages}
/>
{/* */}
)
}
+
function BackToSimulation() {
const dispatch = useDispatch()
const handleClick = useCallback(() => {
@@ -79,3 +81,17 @@ function DocumentationLanding() {
>
)
}
+
+const referencesImages = {
+ 'service-public.fr': 'images/références/marianne.png',
+ 'urssaf.fr': 'images/références/URSSAF.png',
+ 'secu-independants.fr': 'images/références/URSSAF.png',
+ 'gouv.fr': 'images/références/marianne.png',
+ 'agirc-arrco.fr': 'images/références/agirc-arrco.png',
+ 'pole-emploi.fr': 'images/références/pole-emploi.png',
+ 'ladocumentationfrançaise.fr':
+ 'images/références/ladocumentationfrançaise.png',
+ 'senat.fr': 'images/références/senat.png',
+ 'ameli.fr': 'images/références/ameli.png',
+ 'bpifrance-creation': 'images/références/bpi-création.png',
+}
diff --git a/package.json b/package.json
index e50fa801b..7d3c1f059 100644
--- a/package.json
+++ b/package.json
@@ -115,7 +115,7 @@
"prepare": "if [ -z \"$NETLIFY\" ]; then yarn workspaces run prepare; fi",
"lint": "yarn lint:eslintrc && yarn lint:eslint && yarn lint:prettier",
"test": "yarn workspaces run test",
- "test:type": "yarn workspace publicodes run tsc && yarn workspace mon-entreprise run tsc",
+ "test:type": "yarn workspace publicodes run tsc && yarn workspace publicodes-react run tsc && yarn workspace mon-entreprise run tsc",
"test:regressions": "jest",
"clean": "yarn workspaces run clean",
"start": "yarn workspace publicodes build --watch & yarn workspace publicodes-react build --watch & yarn workspace mon-entreprise start",
diff --git a/publicodes-react/source/contexts.tsx b/publicodes-react/source/contexts.tsx
index 34c8b65b7..e81906340 100644
--- a/publicodes-react/source/contexts.tsx
+++ b/publicodes-react/source/contexts.tsx
@@ -3,3 +3,4 @@ import Engine from 'publicodes'
export const BasepathContext = createContext('/documentation')
export const EngineContext = createContext | null>(null)
+export const ReferencesImagesContext = createContext>({})
diff --git a/publicodes-react/source/index.tsx b/publicodes-react/source/index.tsx
index 741ef9af9..a5c4bce57 100644
--- a/publicodes-react/source/index.tsx
+++ b/publicodes-react/source/index.tsx
@@ -2,7 +2,11 @@ import React, { useEffect } from 'react'
import { Route } from 'react-router-dom'
import Engine, { utils } from 'publicodes'
import i18n from 'i18next'
-import { BasepathContext, EngineContext } from './contexts'
+import {
+ BasepathContext,
+ EngineContext,
+ ReferencesImagesContext,
+} from './contexts'
import RulePage from './rule/RulePage'
const { decodeRuleName, encodeRuleName } = utils
@@ -15,12 +19,14 @@ type DocumentationProps = {
documentationPath: string
engine: Engine
language: 'fr' | 'en'
+ referenceImages?: Record
}
export function Documentation({
documentationPath,
engine,
language = 'fr',
+ referenceImages = {},
}: DocumentationProps) {
useEffect(() => {
if (language !== i18n.language) {
@@ -31,18 +37,20 @@ export function Documentation({
return (
- {
- return (
-
- )
- }}
- />
+
+ {
+ return (
+
+ )
+ }}
+ />
+
)
diff --git a/publicodes-react/source/rule/References.tsx b/publicodes-react/source/rule/References.tsx
index cbc49c327..9edf24c0c 100644
--- a/publicodes-react/source/rule/References.tsx
+++ b/publicodes-react/source/rule/References.tsx
@@ -1,24 +1,8 @@
import { toPairs } from 'ramda'
import { capitalise0 } from 'publicodes'
import styled from 'styled-components'
-
-const references = {
- // 'service-public.fr': require('url-loader!./références/marianne.png').default,
- // 'urssaf.fr': require('url-loader!./références/URSSAF.png').default,
- // 'secu-independants.fr': require('url-loader!./références/URSSAF.png').default,
- // 'gouv.fr': require('url-loader!./références/marianne.png').default,
- // 'agirc-arrco.fr': require('url-loader!./références/agirc-arrco.png').default,
- // 'pole-emploi.fr': require('url-loader!./références/pole-emploi.png').default,
- // 'ladocumentationfrançaise.fr': require('url-loader!./références/ladocumentationfrançaise.png')
- // .default,
- // 'senat.fr': require('url-loader!./références/senat.png').default,
- // 'ameli.fr': require('url-loader!./références/ameli.png').default,
- // 'bpifrance-creation': require('url-loader!./références/bpi-création.png')
- // .default,
-}
-
-const findRefKey = (link: string) =>
- Object.keys(references).find((r) => link.includes(r))
+import { useContext } from 'react'
+import { ReferencesImagesContext } from '../contexts'
const cleanDomain = (link: string) =>
(link.includes('://') ? link.split('/')[2] : link.split('/')[0]).replace(
@@ -31,8 +15,15 @@ type RefProps = {
link: string
}
+// TODO: currently we only allow customizing the list of "references icons", but
+// this migth be limited for more advanced usages. For instance futur.eco uses a
+// different renderer for references:
+// https://futur.eco/documentation/transport/avion/impact We will probably want
+// to allow the user to provide its own components that can be inserted at
+// certains positions in the generated documentation ("hooks").
function Ref({ name, link }: RefProps) {
- const refKey = findRefKey(link)
+ const references = useContext(ReferencesImagesContext)
+ const refKey = Object.keys(references).find((r) => link.includes(r))
const domain = cleanDomain(link)
return (