Skip to content

Instantly share code, notes, and snippets.

@divyanshu013
Last active March 2, 2018 14:49
Show Gist options
  • Select an option

  • Save divyanshu013/3298f431910cfd703cf6fc521170115d to your computer and use it in GitHub Desktop.

Select an option

Save divyanshu013/3298f431910cfd703cf6fc521170115d to your computer and use it in GitHub Desktop.
Main App container for GitXplore app
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