import React from 'react'; import { connect } from 'react-redux' import * as selectors from '../selectors' import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; import Search from './Search.jsx'; import TagListPanel from './TagListPanel.jsx'; import Icon from './Icon.jsx'; import copy from '../js/data/copy.json'; // NB: i think this entire component can actually be part of a future feature... class Toolbar extends React.Component { constructor(props) { super(props); this.state = { tab: -1 }; } toggleTab(tabIndex) { if ( this.state.tab === tabIndex ) { this.setState({ tab: -1 }); } else { this.setState({ tab: tabIndex }); } } resetAllFilters() { this.props.actions.resetAllFilters(); } toggleInfoPopup() { this.props.actions.toggleInfoPopup(); } toggleLanguage() { this.props.actions.toggleLanguage(); } toggleMapViews(layer) { const isLayerInView = !this.props.viewFilters[layer]; const newViews = {}; newViews[layer] = isLayerInView; const views = Object.assign({}, this.props.viewFilters, newViews); this.props.actions.updateFilters({ views }); } renderMapActions() { const isViewLayer = this.props.viewFilters; const routeClass = (isViewLayer.routes) ? 'action-button active disabled' : 'action-button disabled' const sitesClass = (isViewLayer.sites) ? 'action-button active disabled' : 'action-button disabled'; const coeventsClass = (isViewLayer.coevents) ? 'action-button active disabled' : 'action-button disabled'; return (
); } renderBottomActions() { return (
{this.renderMapActions()}
); } renderPanelHeader() { return (
this.toggleTab(-1)}>
); } renderToolbarTab(tabNum, key) { const isActive = (tabNum === this.state.tab); //let caption_lang = copy[this.props.language].toolbar.tabs[tabNum]; let classes = (isActive) ? 'toolbar-tab active' : 'toolbar-tab'; return (
{ this.toggleTab(tabNum); }}> {/**/}
{key}
); } renderToolbarTagRoot() { if (this.props.features.USE_TAGS && this.props.tags.children) { const roots = Object.values(this.props.tags.children); return roots.map((root, idx) => { return this.renderToolbarTab(idx, root.key); }) } return ''; } renderToolbarTabs() { const title = copy[this.props.language].toolbar.title; return (

{title}

{/*this.renderToolbarTab(0, 'search')*/} {this.renderToolbarTagRoot()}
{/* {this.renderBottomActions()} */}
) } renderTagListPanel(tagType) { const panels_lang = copy[this.props.language].toolbar.panels; const title = (panels_lang[tagType]) ? panels_lang[tagType].title : tagType; const overview = (panels_lang[tagType]) ? panels_lang[tagType].overview : ''; return ( ); } renderSearch() { if (this.props.features.USE_SEARCH) { return ( ) } } renderToolbarTagList() { if (this.props.features.USE_TAGS && this.props.tags.children) { const roots = Object.values(this.props.tags.children); return roots.map((root, idx) => { return ( {this.renderTagListPanel(root.key)} ) }) } return ''; } render() { let classes = (this.state.tab !== -1) ? 'toolbar-panels' : 'toolbar-panels folded'; return (
{this.renderToolbarTabs()}
{this.renderPanelHeader()} {this.renderToolbarTagList()}
); } } function mapStateToProps(state) { return { tags: selectors.getTagTree(state), categories: selectors.selectCategories(state), language: state.app.language, tagFilters: selectors.selectTagList(state), categoryFilter: state.app.filters.categories, viewFilters: state.app.filters.views, features: state.app.features } } export default connect(mapStateToProps)(Toolbar)