2018-06-12 10:21:36 +00:00
|
|
|
/* @flow */
|
2018-07-12 08:09:41 +00:00
|
|
|
import withColours from 'Components/utils/withColours'
|
2019-01-11 10:46:02 +00:00
|
|
|
import withSitePaths from 'Components/utils/withSitePaths'
|
2018-07-25 14:07:53 +00:00
|
|
|
import { compose } from 'ramda'
|
2018-06-12 10:21:36 +00:00
|
|
|
import React from 'react'
|
|
|
|
import { Link } from 'react-router-dom'
|
|
|
|
import './RuleLink.css'
|
2018-07-25 14:07:53 +00:00
|
|
|
import type { Règle } from 'Types/RegleTypes'
|
2019-02-01 12:31:57 +00:00
|
|
|
import type { ThemeColours } from 'Components/utils/withColours'
|
2019-03-06 14:00:44 +00:00
|
|
|
import { encodeRuleName } from 'Engine/rules'
|
2019-01-11 10:46:02 +00:00
|
|
|
|
2018-07-25 14:07:53 +00:00
|
|
|
type Props = Règle & {
|
2019-01-11 10:46:02 +00:00
|
|
|
sitePaths: Object,
|
2018-07-25 14:07:53 +00:00
|
|
|
style: CSSStyleDeclaration,
|
2019-02-01 12:31:57 +00:00
|
|
|
colours: ThemeColours
|
2018-07-25 14:07:53 +00:00
|
|
|
}
|
2019-01-11 10:46:02 +00:00
|
|
|
const RuleLink = ({
|
2019-03-06 14:00:44 +00:00
|
|
|
dottedName,
|
2019-07-01 15:59:57 +00:00
|
|
|
title,
|
2019-01-11 10:46:02 +00:00
|
|
|
colours: { colour },
|
|
|
|
style,
|
|
|
|
sitePaths
|
|
|
|
}: Props) => {
|
2019-03-06 14:00:44 +00:00
|
|
|
const newPath =
|
|
|
|
sitePaths.documentation.index + '/' + encodeRuleName(dottedName)
|
2019-07-01 15:59:57 +00:00
|
|
|
|
2018-10-04 13:20:57 +00:00
|
|
|
return (
|
|
|
|
<Link
|
|
|
|
to={newPath}
|
|
|
|
className="rule-link"
|
|
|
|
style={{ color: colour, ...style }}>
|
2019-07-01 15:59:57 +00:00
|
|
|
{title}
|
2018-10-04 13:20:57 +00:00
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|
2018-06-12 10:21:36 +00:00
|
|
|
|
2018-07-25 14:07:53 +00:00
|
|
|
export default compose(
|
2019-01-11 10:46:02 +00:00
|
|
|
withSitePaths,
|
2018-07-25 14:07:53 +00:00
|
|
|
withColours
|
|
|
|
)(RuleLink)
|