Skip to content

Commit

Permalink
Merge pull request #169 from betagouv/fix-fiches-plus
Browse files Browse the repository at this point in the history
Fix fiches plus
  • Loading branch information
laem authored Jan 25, 2021
2 parents b8b08c2 + f4be89b commit 0e47b31
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions source/components/publicodesUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { capitalise0 } from '../utils'

export const parentName = (dottedName, outputSeparator = ' . ') =>
splitName(dottedName).slice(0, -1).join(outputSeparator)

export const splitName = (dottedName) => dottedName.split(' . ')

export const title = (rule) =>
rule.titre ||
capitalise0(splitName(rule.dottedName)[splitName(rule.dottedName).length - 1])
9 changes: 8 additions & 1 deletion source/sites/publicodes/ActionPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ export default () => {
return (
<div css="padding: 0 .3rem 1rem; max-width: 600px; margin: 1rem auto;">
<ScrollToTop />
<div>
<Link to={'/actions/' + encodedName}>
<button className="ui__ button simple small ">
{emoji('◀')} Retour à la liste des fiches
</button>
</Link>
</div>
<Link to={'/actions/' + encodedName}>
<button className="ui__ button simple small ">
{emoji('')} Retour à la fiche
{emoji('🧮')} Voir le geste climat correspondant
</button>
</Link>
<div css="margin: 1.6rem 0">
Expand Down
18 changes: 9 additions & 9 deletions source/sites/publicodes/ListeActionPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { ScrollToTop } from 'Components/utils/Scroll'
import { utils } from 'publicodes'
import { useContext } from 'react'
import emoji from 'react-easy-emoji'
import { useSelector } from 'react-redux'
import { Link } from 'react-router-dom'
import { title } from '../../components/publicodesUtils'

export default () => {
const rules = useContext(EngineContext).getParsedRules()
const rules = useSelector((state) => state.rules)
const plusListe = Object.entries(rules)
.map(([dottedName, rule]) => ({ ...rule, dottedName }))
.filter((r) => r.plus)
Expand All @@ -19,9 +21,7 @@ export default () => {
<img src="https://img.shields.io/badge/-beta-purple" />
</h1>
<p>
<em>
Découvrez les enjeux qui se cachent derrière chaque action.
</em>
<em>Découvrez les enjeux qui se cachent derrière chaque action.</em>
</p>
<ul
css={`
Expand All @@ -37,9 +37,9 @@ export default () => {
}
`}
>
{plusListe.map(({ dottedName, icons, title }) => (
<li key={dottedName}>
<Link to={'/actions/plus/' + utils.encodeRuleName(dottedName)}>
{plusListe.map((rule) => (
<li key={rule.dottedName}>
<Link to={'/actions/plus/' + utils.encodeRuleName(rule.dottedName)}>
<div
className="ui__ card"
css={`
Expand All @@ -53,8 +53,8 @@ export default () => {
}
`}
>
<div>{emoji(icons || '🎯')}</div>
<div>{title}</div>
<div>{emoji(rule.icônes || '🎯')}</div>
<div>{title(rule)}</div>
</div>
</Link>
</li>
Expand Down

0 comments on commit 0e47b31

Please sign in to comment.