🐛 Répare la page /documentation

pull/1059/head
Johan Girod 2020-05-28 11:41:45 +02:00
parent 3a00ab11e7
commit 3e68f5bd82
2 changed files with 29 additions and 7 deletions

View File

@ -119,7 +119,7 @@ export default function SearchBar({ rules, showDefaultList }: SearchBarProps) {
setInput(input)
}}
/>
{!!input.length && !showDefaultList && !results.length ? (
{!!input.length && !results.length ? (
<p
className="ui__ notice light-bg"
css={`
@ -140,16 +140,22 @@ export default function SearchBar({ rules, showDefaultList }: SearchBarProps) {
list-style: none;
`}
>
{(showDefaultList && !results.length
? searchIndex.map(item => ({ item, matches: [] }))
{(showDefaultList && !results.length && !input.length
? searchIndex
.filter(item => item.espace.length === 2)
.map(item => ({ item, matches: [] }))
: results
)
.slice(0, 6)
.slice(0, showDefaultList ? 100 : 6)
.map(({ item, matches }) => (
<li key={item.dottedName}>
<RuleLink
dottedName={item.dottedName}
style={{ width: '100%', textDecoration: 'none' }}
style={{
width: '100%',
textDecoration: 'none',
lineHeight: '1.5rem'
}}
>
<small>
{item.espace
@ -166,8 +172,8 @@ export default function SearchBar({ rules, showDefaultList }: SearchBarProps) {
{' '}
</span>
))}
</small>{' '}
<br />
<br />
</small>
{highlightMatches(
item.title,
matches.filter(m => m.key === 'title')

View File

@ -10,6 +10,7 @@ import { Trans, useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { Redirect, useLocation } from 'react-router-dom'
import { RootState } from 'Reducers/rootReducer'
import SearchBar from 'Components/SearchBar'
export default function RulePage() {
const currentSimulation = useSelector(
@ -24,6 +25,9 @@ export default function RulePage() {
)
const { i18n } = useTranslation()
if (pathname === '/documentation') {
return <DocumentationLanding rules={engine.getParsedRules()} />
}
if (!documentationSitePaths[pathname]) {
return <Redirect to="/404" />
}
@ -63,3 +67,15 @@ function BackToSimulation() {
</button>
)
}
function DocumentationLanding({ rules }) {
return (
<>
<h1>
<Trans i18nKey="page.documentation.title">Documentation</Trans>
</h1>
<p>Explorez toutes les règles de la documentation</p>
<SearchBar rules={rules} showDefaultList={true} />
</>
)
}