mon-entreprise/components/TagNavigation.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

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