1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 02:55:01 +00:00
mon-entreprise/source/components/TagNavigation.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-07-04 18:34:18 +02:00
import React from 'react'
import TagMap from './TagMap'
2016-07-04 18:34:18 +02:00
export default class TagNavigation extends React.Component {
render(){
2016-07-28 16:01:25 +02:00
let {tagsToSelect, selectedTags, selectTag, resetTags} = this.props
2016-07-04 18:34:18 +02:00
return (
<section id="tag-navigation">
2016-07-28 16:01:25 +02:00
<h2> Explorez par catégorie</h2>
<div className="content">
{selectedTags.length > 0 &&
<div id="selected">
<TagMap data={selectedTags} />
2016-07-28 16:01:25 +02:00
<button onClick={resetTags}>Effacer ma sélection </button>
</div>
}
<ul id="to-select">
{tagsToSelect.map(tag =>
<Tag selectTag={selectTag} key={tag.name} tag={tag} />
)}
2016-07-20 18:13:42 +02:00
</ul>
2016-07-28 16:01:25 +02:00
</div>
2016-07-04 18:34:18 +02:00
</section>
)
}
}
class Tag extends React.Component {
render(){
let {tag: {name, choices, number}, selectTag} = this.props
return (<li>
2016-07-28 16:01:25 +02:00
<span className="name">
{name}
<span className="nb">
({number} variable{number > 1 ? 's' : ''})
2016-07-28 16:01:25 +02:00
</span>
</span>
2016-07-04 18:34:18 +02:00
<ul className="choices">
{[...choices].map(c =>
2016-07-28 16:01:25 +02:00
<li className="tag-value" key={c} onClick={() => selectTag(name, c)}>
2016-07-04 18:34:18 +02:00
{c}
</li>
)}
</ul>
</li>)
}
}