mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-10 01:05:02 +00:00
Cela permet l'inférence de type à partir des fichiers js qui ne sont pas encore convertis en TypeScript. Par ailleurs suppression des dernières traces de Flow. Ajout d'options plus strictes pour dans la config tsconfig.js
37 lines
928 B
TypeScript
37 lines
928 B
TypeScript
import { ThemeColoursContext } from 'Components/utils/withColours'
|
|
import { SitePathsContext } from 'Components/utils/withSitePaths'
|
|
import { encodeRuleName, 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 { colour } = useContext(ThemeColoursContext)
|
|
const newPath =
|
|
sitePaths.documentation.index + '/' + encodeRuleName(dottedName)
|
|
|
|
return (
|
|
<Link
|
|
to={newPath}
|
|
className="rule-link"
|
|
title={title}
|
|
style={{ color: colour, ...style }}
|
|
>
|
|
{children || title || nameLeaf(dottedName)}
|
|
</Link>
|
|
)
|
|
}
|