Last active
March 2, 2018 14:49
-
-
Save divyanshu013/3298f431910cfd703cf6fc521170115d to your computer and use it in GitHub Desktop.
Main App container for GitXplore app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import { ReactiveBase, DataSearch } from '@appbaseio/reactivesearch'; | |
| import Header from './components/Header'; | |
| import Results from './components/Results'; | |
| import theme from './theme'; | |
| import './App.css'; | |
| class App extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| currentTopics: [], | |
| }; | |
| } | |
| setTopics = (currentTopics) => { | |
| this.setState({ | |
| currentTopics: currentTopics || [], | |
| }); | |
| } | |
| toggleTopic = (topic) => { | |
| const { currentTopics } = this.state; | |
| const nextState = currentTopics.includes(topic) | |
| ? currentTopics.filter(item => item !== topic) | |
| : currentTopics.concat(topic); | |
| this.setState({ | |
| currentTopics: nextState, | |
| }); | |
| } | |
| render() { | |
| return ( | |
| <section className="container"> | |
| <ReactiveBase | |
| app="gitxplore-app" | |
| credentials="4oaS4Srzi:f6966181-1eb4-443c-8e0e-b7f38e7bc316" | |
| type="gitxplore-latest" | |
| theme={theme} | |
| > | |
| <div className="flex row-reverse app-container"> | |
| <Header currentTopics={this.state.currentTopics} setTopics={this.setTopics} /> | |
| <div className="results-container"> | |
| <DataSearch | |
| componentId="repo" | |
| filterLabel="Search" | |
| dataField={['name', 'description', 'name.raw', 'fullname', 'owner', 'topics']} | |
| placeholder="Search Repos" | |
| iconPosition="left" | |
| autosuggest={false} | |
| URLParams | |
| className="data-search-container results-container" | |
| innerClass={{ | |
| input: 'search-input', | |
| }} | |
| /> | |
| <Results currentTopics={this.state.currentTopics} toggleTopic={this.toggleTopic} /> | |
| </div> | |
| </div> | |
| </ReactiveBase> | |
| </section> | |
| ); | |
| } | |
| } | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment