mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-09 04:05:01 +00:00
6545281f01
* Personnalise la configuration ESLint pour les scripts * 👽 Déplace la traduction de l'explication SEO sur le simulateur salarié * Ajout d'une fonction rule dans sitePaths Permet de type-checker le nom de la règle pour éviter les liens morts * 👽 Ajoute un test pour la traduction des unités * 👽 Traduction BNC * 👽 fix translations
36 lines
870 B
TypeScript
36 lines
870 B
TypeScript
import { ThemeColorsContext } from 'Components/utils/colors'
|
|
import { SitePathsContext } from 'Components/utils/withSitePaths'
|
|
import { nameLeaf } from 'Engine/rules'
|
|
import React, { useContext } from 'react'
|
|
import { Link } from 'react-router-dom'
|
|
import { Rule } from 'Types/rule'
|
|
import './RuleLink.css'
|
|
|
|
type RuleLinkProps = {
|
|
dottedName: Rule['dottedName']
|
|
title?: Rule['title']
|
|
style?: React.CSSProperties
|
|
children?: React.ReactNode
|
|
}
|
|
|
|
export default function RuleLink({
|
|
dottedName,
|
|
title,
|
|
style,
|
|
children
|
|
}: RuleLinkProps) {
|
|
const sitePaths = useContext(SitePathsContext)
|
|
const { color } = useContext(ThemeColorsContext)
|
|
const newPath = sitePaths.documentation.rule(dottedName)
|
|
|
|
return (
|
|
<Link
|
|
to={newPath}
|
|
className="rule-link"
|
|
title={title}
|
|
style={{ color, ...style }}
|
|
>
|
|
{children || title || nameLeaf(dottedName)}
|
|
</Link>
|
|
)
|
|
}
|