New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Améliorations diverses des pages de doc des règles #354
base: master
Are you sure you want to change the base?
Changes from all commits
ee837d1
6d8ef01
c8dcbb7
04d8928
52bcd1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
import { capitalise0 } from 'publicodes' | ||
|
||
type ReferencesProps = { | ||
references: Record<string, string> | ||
references: Record<string, string> | undefined | ||
rawNode: Object | ||
} | ||
|
||
export default function References({ references }: ReferencesProps) { | ||
if (!references) return null | ||
return ( | ||
<ul> | ||
{Object.entries(references).map(([name, link]) => ( | ||
<li | ||
style={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
}} | ||
key={name} | ||
> | ||
<a | ||
href={link} | ||
target="_blank" | ||
<section> | ||
<h3>Références</h3> | ||
<ul> | ||
{Object.entries(references).map(([name, link]) => ( | ||
<li | ||
style={{ | ||
marginRight: '1rem', | ||
display: 'flex', | ||
alignItems: 'center', | ||
}} | ||
key={name} | ||
> | ||
{capitalise0(name)} | ||
</a> | ||
<span className="ui__ label">{link}</span> | ||
</li> | ||
))} | ||
</ul> | ||
<a | ||
href={link} | ||
target="_blank" | ||
style={{ | ||
marginRight: '1rem', | ||
}} | ||
> | ||
{capitalise0(name)} | ||
</a> | ||
<span className="ui__ label">{link}</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je crois que l'on peut supprimer les |
||
</li> | ||
))} | ||
</ul> | ||
</section> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,14 @@ type RulePageProps = { | |
mobileMenuPortalId?: string | ||
openNavButtonPortalId?: string | ||
showDevSection?: boolean | ||
contributionLink?: { | ||
repository: string | ||
// e.g. repository: 'datagir/nosgestesclimat', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cela peut passer en |
||
directory: string | ||
// e.g. directory: 'data', | ||
title?: string | ||
text?: string | ||
} | ||
} | ||
|
||
export default function RulePage({ | ||
|
@@ -50,6 +58,7 @@ export default function RulePage({ | |
mobileMenuPortalId, | ||
openNavButtonPortalId, | ||
showDevSection = true, | ||
contributionLink, | ||
}: RulePageProps) { | ||
const currentEngineId = new URLSearchParams(window.location.search).get( | ||
'currentEngineId' | ||
|
@@ -81,6 +90,7 @@ export default function RulePage({ | |
mobileMenuPortalId={mobileMenuPortalId} | ||
openNavButtonPortalId={openNavButtonPortalId} | ||
showDevSection={showDevSection} | ||
contributionLink={contributionLink} | ||
/> | ||
</RenderersContext.Provider> | ||
</BasepathContext.Provider> | ||
|
@@ -100,6 +110,7 @@ type RuleProps = { | |
| 'mobileMenuPortalId' | ||
| 'openNavButtonPortalId' | ||
| 'showDevSection' | ||
| 'contributionLink' | ||
> | ||
|
||
function Rule({ | ||
|
@@ -112,9 +123,10 @@ function Rule({ | |
mobileMenuPortalId, | ||
openNavButtonPortalId, | ||
showDevSection, | ||
contributionLink, | ||
}: RuleProps) { | ||
const baseEngine = useEngine() | ||
const { References, Text } = useContext(RenderersContext) | ||
const { References, Text, VisualisationBlock } = useContext(RenderersContext) | ||
|
||
const useSubEngine = | ||
subEngineId && baseEngine.subEngines.length >= subEngineId | ||
|
@@ -147,9 +159,15 @@ function Rule({ | |
<Article> | ||
<DottedNameContext.Provider value={dottedName}> | ||
<RuleHeader dottedName={dottedName} /> | ||
{question && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ce n'est pas bizarre d'afficher la question à chaque fois juste au-dessus de la description ? Cela ne donne-t-il pas l'impression que la description est une réponse à la question ? (c'est une vraie interrogation, peut-être que pas du tout) Ceci étant dit, sur le principe, je suis pour afficher la question dans la documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je me suis posé un peu la même question, pour la page https://pages-doc-rapides--nosgestesclimat.netlify.app/documentation/alimentation/plats j'ai eu du mal à comprendre la relation entre la description et la question 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En effet, suite à une remarque de @Clemog j'ai ajouté un label "aide à la saisie" quand il s'agit d'une question. |
||
<section id="documentation-rule-question"> | ||
<Text>{question}</Text> | ||
</section> | ||
)} | ||
<section> | ||
<Text>{description || question || ''}</Text> | ||
<Text>{description || ''}</Text> | ||
</section> | ||
{VisualisationBlock && <VisualisationBlock />} | ||
|
||
<p style={{ fontSize: '1.25rem', lineHeight: '2rem' }}> | ||
Valeur : {formatValue(rule, { language })} | ||
|
@@ -209,11 +227,25 @@ function Rule({ | |
</div> | ||
</> | ||
)} | ||
{rule.rawNode.références && References && ( | ||
<> | ||
<h3>Références</h3> | ||
<References references={rule.rawNode.références} /> | ||
</> | ||
<References | ||
references={rule.rawNode.références} | ||
rawNode={rule.rawNode} | ||
/> | ||
|
||
{contributionLink && ( // Feature only implemented for github for now, don't hesitate to implement Gitlab and others | ||
<div> | ||
<h3> | ||
{contributionLink.title || | ||
`Une erreur, une idée d'amélioration ?`} | ||
</h3> | ||
<a | ||
href={`https://github.com/search?q=${encodeURIComponent( | ||
`repo:${contributionLink.repository} "${dottedName}:"` | ||
)} path:${contributionLink.directory}&type=code`} | ||
> | ||
{contributionLink.text || `✏️ Contribuer à cette page`} | ||
</a> | ||
</div> | ||
)} | ||
<br /> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ajouterai un peu de
tsdoc
ici pour préciser à quoi sert VisualisationBlock. De ce que je comprends, il s'agit d'un composant custom à ajouter dans les pages règles entre la description et l'explication des calculs. Si c'est bien ça, je propose un tout petit ajout : passer enprop
ledottedName
de la règle courante, au cas où l'on souhaite avoir une logique d'affichage différente en fonction de la règle.