import React from "react"; import classNames from "classnames"; import { observer } from "mobx-react"; import { store } from "app/stores/store"; export interface SearchResultProps { search: any; } @observer export class SearchResult extends React.Component { constructor(props) { super(props); this.state = { search: store.search }; store.search.query(); } render() { return this.state.search.sections.map(section => { return ; }); } } export interface SectionProps { section: any; } @observer export class SearchResultSection extends React.Component { constructor(props) { super(props); } renderItem(item) { return (
{item.title}
); } toggleSection = () => { this.props.section.toggle(); }; render() { let collapseClassNames = classNames({ fa: true, "fa-plus": !this.props.section.expanded, "fa-minus": this.props.section.expanded, "search-section__header__toggle": true }); return (
{this.props.section.title}
{this.props.section.expanded && (
{this.props.section.items.map(this.renderItem)}
)}
); } }