├── .gitignore
├── LICENSE
├── README.md
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
├── src
├── App.css
├── App.js
├── App.test.js
├── components
│ ├── Header.js
│ ├── Results.js
│ ├── SearchFilters.js
│ └── Topic.js
├── index.css
├── index.js
├── logo.svg
├── registerServiceWorker.js
└── theme.js
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 |
12 | # misc
13 | .DS_Store
14 | .env.local
15 | .env.development.local
16 | .env.test.local
17 | .env.production.local
18 |
19 | npm-debug.log*
20 | yarn-debug.log*
21 | yarn-error.log*
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 appbaseio-apps
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GitXplore app :octocat:
2 |
3 | A GitHub repo explorer app.
4 |
5 | Read how we built it in this [freecodecamp post here](https://medium.freecodecamp.org/building-a-github-repo-explorer-with-react-and-elasticsearch-8e1190e59c13).
6 |
7 | Built with
8 |
9 | - [React](https://reactjs.org/)
10 | - [ReactiveSearch](https://opensource.appbase.io/reactivesearch)
11 | - [Appbaseio](https://appbase.io)
12 | - ❤
13 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gitxplore-app",
3 | "version": "1.0.0",
4 | "private": false,
5 | "author": {
6 | "name": "Divyanshu Maithani",
7 | "email": "div.blackcat@gmail.com",
8 | "url": "https://github.com/divyanshu013"
9 | },
10 | "homepage": "https://appbaseio-apps.github.io/gitxplore-app",
11 | "dependencies": {
12 | "@appbaseio/reactivesearch": "^2.3.0",
13 | "react": "^16.2.0",
14 | "react-dom": "^16.2.0",
15 | "react-scripts": "1.0.17"
16 | },
17 | "scripts": {
18 | "start": "react-scripts start",
19 | "build": "react-scripts build",
20 | "predeploy": "npm run build",
21 | "deploy": "gh-pages -d build",
22 | "test": "react-scripts test --env=jsdom",
23 | "eject": "react-scripts eject"
24 | },
25 | "license": "MIT",
26 | "devDependencies": {
27 | "gh-pages": "^1.1.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-reactivesearch/gitxplore-app/e9216c65e00ff118d0de48ed8a553478fa49ef6b/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
23 | GitXplore App
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "GitXplore",
3 | "name": "GitXplore App",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | }
10 | ],
11 | "start_url": "./index.html",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | /* containers */
2 | .container {
3 | width: 100%;
4 | height: 100vh;
5 | }
6 |
7 | .data-search-container {
8 | position: fixed;
9 | z-index: 3;
10 | }
11 |
12 | .card-icon {
13 | margin-right: 4px;
14 | }
15 |
16 | .filters-container {
17 | max-height: calc(100vh - 100px);
18 | height: 100%;
19 | overflow-y: auto;
20 | }
21 |
22 | .results-container {
23 | width: calc(100% - 400px);
24 | }
25 |
26 | .result-list {
27 | margin-top: 60px;
28 | }
29 |
30 | .result-list-container {
31 | display: flex;
32 | flex-wrap: wrap;
33 | justify-content: center;
34 | }
35 |
36 | .result-list-info {
37 | margin: 1rem;
38 | justify-content: space-between;
39 | }
40 |
41 | .result-list-pagination {
42 | margin: 40px 0 50px;
43 | }
44 |
45 | .results-container .powered-by {
46 | display: none;
47 | }
48 |
49 | /* header styles */
50 | .navbar {
51 | background: mediumseagreen;
52 | left: 0;
53 | width: 400px;
54 | padding: 1rem;
55 | height: 100vh;
56 | position: fixed;
57 | z-index: 3;
58 | }
59 |
60 | .title {
61 | color: white;
62 | font-family: 'Monoton', cursive;
63 | font-size: 2rem;
64 | text-align: center;
65 | }
66 |
67 | /* components */
68 | .avatar {
69 | height: 50px;
70 | border-radius: 50%;
71 | }
72 |
73 | .btn {
74 | cursor: pointer;
75 | margin: 5px;
76 | padding: 5px;
77 | text-align: center;
78 | border-radius: 4px;
79 | }
80 |
81 | .card-btn {
82 | background: #eff3f6;
83 | min-width: 70px;
84 | }
85 |
86 | .card-btn:hover {
87 | background: #008000;
88 | color: white;
89 | }
90 |
91 | .link {
92 | cursor: pointer;
93 | color: mediumseagreen;
94 | text-decoration: none;
95 | font-weight: bold;
96 | margin-left: 20px;
97 | font-size: 1.2rem;
98 | }
99 |
100 | .topic {
101 | background: mediumseagreen;
102 | margin: 3px;
103 | padding: 4px;
104 | color: white;
105 | font-weight: bold;
106 | cursor: pointer;
107 | border-radius: 4px;
108 | }
109 |
110 | .topic:hover {
111 | background: #008000;
112 | }
113 |
114 | .topic.active {
115 | background: #008000;
116 | }
117 |
118 | .toggle-btn {
119 | color: white;
120 | border: 1px solid white;
121 | display: none;
122 | max-width: 200px;
123 | font-size: 1.3rem;
124 | align-self: center;
125 | padding: 10px;
126 | margin-top: 10px;
127 | }
128 |
129 | .toggle-btn:hover {
130 | background: white;
131 | color: mediumseagreen;
132 | }
133 |
134 | .range-label {
135 | color: white;
136 | }
137 |
138 | .result-item {
139 | padding: 20px 0;
140 | margin: 15px;
141 | padding: 25px;
142 | border: 1px solid #eee;
143 | flex-basis: 400px;
144 | max-width: 400px;
145 | min-height: 300px;
146 | box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
147 | transition: all 0.3s cubic-bezier(.25,.8,.25,1);
148 | font-size: 14px;
149 | display: flex;
150 | flex-direction: column;
151 | justify-content: space-between;
152 | align-items: center;
153 | }
154 |
155 | .result-item:hover {
156 | box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
157 | }
158 |
159 | .search-input {
160 | border: none;
161 | border-bottom: 1px solid #ccc;
162 | background: #fafafa;
163 | transition: all 0.3s cubic-bezier(.25,.8,.25,1);
164 | height: 50px;
165 | }
166 |
167 | .search-input:focus {
168 | border-color: #008000;
169 | box-shadow: 0 1px 0 0 #008000;
170 | }
171 |
172 | /* flex layouts */
173 | .flex {
174 | display: flex;
175 | }
176 |
177 | .column {
178 | flex-direction: column;
179 | }
180 |
181 | .row-reverse {
182 | flex-direction: row-reverse;
183 | }
184 |
185 | .align-center {
186 | align-items: center;
187 | }
188 |
189 | .justify-center {
190 | justify-content: center;
191 | }
192 |
193 | .justify-end {
194 | justify-content: flex-end;
195 | }
196 |
197 | .wrap {
198 | flex-wrap: wrap;
199 | }
200 |
201 | .m10 {
202 | margin: 10px;
203 | }
204 |
205 | .m10-0 {
206 | margin: 10px 0;
207 | }
208 |
209 | .m1,
210 | .result-list .m1 {
211 | margin: 1rem;
212 | }
213 |
214 | /* media queries */
215 | @media all and (max-width: 1280px) {
216 | .result-item {
217 | flex-basis: 350px;
218 | max-width: 350px;
219 | }
220 |
221 | .result-card-header {
222 | flex-direction: column;
223 | }
224 |
225 | .result-card-header > div {
226 | justify-content: center;
227 | margin-top: 5px;
228 | }
229 | }
230 |
231 | @media all and (max-width: 1200px) {
232 | .title {
233 | text-align: left;
234 | }
235 |
236 | .result-list {
237 | margin-top: 170px;
238 | }
239 |
240 | .navbar {
241 | width: 100%;
242 | height: auto;
243 | display: flex;
244 | flex-direction: column;
245 | }
246 |
247 | .navbar.active {
248 | height: 100vh;
249 | }
250 |
251 | .results-container {
252 | width: 100%;
253 | }
254 |
255 | .data-search-container {
256 | margin-top: 20px;
257 | width: calc(100% - 280px);
258 | right: 20px;
259 | }
260 |
261 | .toggle-btn {
262 | display: block;
263 | }
264 |
265 | .hidden {
266 | display: none;
267 | }
268 | }
269 |
270 | @media all and (max-width: 992px) {
271 | .app-container {
272 | flex-direction: column;
273 | }
274 |
275 | .result-list {
276 | margin-top: 220px;
277 | }
278 | }
279 |
280 | @media all and (max-width: 768px) {
281 | .data-search-container {
282 | width: 100%;
283 | right: auto;
284 | padding: 0 30px;
285 | margin-top: 65px;
286 | }
287 |
288 | .search-input {
289 | height: 42px;
290 | }
291 |
292 | .title {
293 | text-align: center;
294 | margin-bottom: 50px;
295 | }
296 | }
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { ReactiveBase, DataSearch } from '@appbaseio/reactivesearch';
3 |
4 | import Header from './components/Header';
5 | import Results from './components/Results';
6 |
7 | import theme from './theme';
8 | import './App.css';
9 |
10 | class App extends Component {
11 | constructor(props) {
12 | super(props);
13 | this.state = {
14 | currentTopics: [],
15 | };
16 | }
17 |
18 | setTopics = (currentTopics) => {
19 | this.setState({
20 | currentTopics: currentTopics || [],
21 | });
22 | }
23 |
24 | toggleTopic = (topic) => {
25 | const { currentTopics } = this.state;
26 | const nextState = currentTopics.includes(topic)
27 | ? currentTopics.filter(item => item !== topic)
28 | : currentTopics.concat(topic);
29 | this.setState({
30 | currentTopics: nextState,
31 | });
32 | }
33 |
34 | render() {
35 | return (
36 |
37 |
43 |
44 |
45 |
46 |
59 |
60 |
61 |
62 |
63 |
64 | );
65 | }
66 | }
67 |
68 | export default App;
69 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 |
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
7 | ReactDOM.render(, div);
8 | });
9 |
--------------------------------------------------------------------------------
/src/components/Header.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | import SearchFilters from './SearchFilters';
4 |
5 | class Header extends Component {
6 | constructor(props) {
7 | super(props);
8 | this.state = {
9 | visible: false,
10 | };
11 | }
12 |
13 | toggleVisibility = () => {
14 | const visible = !this.state.visible;
15 | this.setState({
16 | visible,
17 | });
18 | }
19 |
20 | render() {
21 | return (
22 |
27 | );
28 | }
29 | }
30 |
31 | export default Header;
32 |
--------------------------------------------------------------------------------
/src/components/Results.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { SelectedFilters, ReactiveList } from '@appbaseio/reactivesearch';
3 | import PropTypes from 'prop-types';
4 |
5 | import Topic from './Topic';
6 |
7 | const onResultStats = (results, time) => (
8 |
9 | {results} results found in {time}ms
10 |
11 | );
12 |
13 | const onData = (data, currentTopics, toggleTopic) => (
14 |
15 |
24 |
{data.description}
25 |
26 | {
27 | data.topics.slice(0, 7)
28 | .map(item => (
29 |
34 | {item}
35 |
36 | ))
37 | }
38 |
39 |
44 |
45 | );
46 |
47 | const Results = ({ toggleTopic, currentTopics }) => (
48 |
49 |
50 | onData(data, currentTopics, toggleTopic)}
54 | onResultStats={onResultStats}
55 | react={{
56 | and: ['language', 'topics', 'pushed', 'created', 'stars', 'forks', 'repo'],
57 | }}
58 | pagination
59 | innerClass={{
60 | list: 'result-list-container',
61 | pagination: 'result-list-pagination',
62 | resultsInfo: 'result-list-info',
63 | poweredBy: 'powered-by',
64 | }}
65 | size={6}
66 | sortOptions={[
67 | {
68 | label: 'Best Match',
69 | dataField: '_score',
70 | sortBy: 'desc',
71 | },
72 | {
73 | label: 'Most Stars',
74 | dataField: 'stars',
75 | sortBy: 'desc',
76 | },
77 | {
78 | label: 'Fewest Stars',
79 | dataField: 'stars',
80 | sortBy: 'asc',
81 | },
82 | {
83 | label: 'Most Forks',
84 | dataField: 'forks',
85 | sortBy: 'desc',
86 | },
87 | {
88 | label: 'Fewest Forks',
89 | dataField: 'forks',
90 | sortBy: 'asc',
91 | },
92 | {
93 | label: 'A to Z',
94 | dataField: 'owner.raw',
95 | sortBy: 'asc',
96 | },
97 | {
98 | label: 'Z to A',
99 | dataField: 'owner.raw',
100 | sortBy: 'desc',
101 | },
102 | {
103 | label: 'Recently Updated',
104 | dataField: 'pushed',
105 | sortBy: 'desc',
106 | },
107 | {
108 | label: 'Least Recently Updated',
109 | dataField: 'pushed',
110 | sortBy: 'asc',
111 | },
112 | ]}
113 | />
114 |
115 | );
116 |
117 | Results.propTypes = {
118 | toggleTopic: PropTypes.func,
119 | currentTopics: PropTypes.arrayOf(PropTypes.string),
120 | };
121 |
122 | export default Results;
123 |
--------------------------------------------------------------------------------
/src/components/SearchFilters.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import {
4 | MultiDropdownList,
5 | SingleDropdownRange,
6 | RangeSlider,
7 | } from '@appbaseio/reactivesearch';
8 |
9 | const SearchFilters = ({ currentTopics, setTopics, visible }) => (
10 |
11 |
12 |
19 |
20 |
21 |
32 |
33 |
34 |
46 |
47 |
48 |
112 |
113 |
114 |
128 |
129 |
130 |
144 |
145 |
146 | );
147 |
148 | SearchFilters.propTypes = {
149 | currentTopics: PropTypes.arrayOf(PropTypes.string),
150 | setTopics: PropTypes.func,
151 | visible: PropTypes.bool,
152 | };
153 |
154 | export default SearchFilters;
155 |
--------------------------------------------------------------------------------
/src/components/Topic.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | class Topic extends Component {
5 | handleClick = () => {
6 | this.props.toggleTopic(this.props.children);
7 | }
8 | render() {
9 | return (
10 |
11 | #{this.props.children}
12 |
13 | );
14 | }
15 | }
16 |
17 | Topic.propTypes = {
18 | children: PropTypes.string,
19 | active: PropTypes.bool,
20 | toggleTopic: PropTypes.func,
21 | };
22 |
23 | export default Topic;
24 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Monoton|Raleway');
2 |
3 | body {
4 | margin: 0;
5 | padding: 0;
6 | font-family: 'Raleway', 'Arial', sans-serif;
7 | }
8 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import registerServiceWorker from './registerServiceWorker';
6 |
7 | ReactDOM.render(, document.getElementById('root'));
8 | registerServiceWorker();
9 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/src/registerServiceWorker.js:
--------------------------------------------------------------------------------
1 | // In production, we register a service worker to serve assets from local cache.
2 |
3 | // This lets the app load faster on subsequent visits in production, and gives
4 | // it offline capabilities. However, it also means that developers (and users)
5 | // will only see deployed updates on the "N+1" visit to a page, since previously
6 | // cached resources are updated in the background.
7 |
8 | // To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
9 | // This link also includes instructions on opting out of this behavior.
10 |
11 | const isLocalhost = Boolean(
12 | window.location.hostname === 'localhost' ||
13 | // [::1] is the IPv6 localhost address.
14 | window.location.hostname === '[::1]' ||
15 | // 127.0.0.1/8 is considered localhost for IPv4.
16 | window.location.hostname.match(
17 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
18 | )
19 | );
20 |
21 | export default function register() {
22 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
23 | // The URL constructor is available in all browsers that support SW.
24 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
25 | if (publicUrl.origin !== window.location.origin) {
26 | // Our service worker won't work if PUBLIC_URL is on a different origin
27 | // from what our page is served on. This might happen if a CDN is used to
28 | // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
29 | return;
30 | }
31 |
32 | window.addEventListener('load', () => {
33 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
34 |
35 | if (isLocalhost) {
36 | // This is running on localhost. Lets check if a service worker still exists or not.
37 | checkValidServiceWorker(swUrl);
38 | } else {
39 | // Is not local host. Just register service worker
40 | registerValidSW(swUrl);
41 | }
42 | });
43 | }
44 | }
45 |
46 | function registerValidSW(swUrl) {
47 | navigator.serviceWorker
48 | .register(swUrl)
49 | .then(registration => {
50 | registration.onupdatefound = () => {
51 | const installingWorker = registration.installing;
52 | installingWorker.onstatechange = () => {
53 | if (installingWorker.state === 'installed') {
54 | if (navigator.serviceWorker.controller) {
55 | // At this point, the old content will have been purged and
56 | // the fresh content will have been added to the cache.
57 | // It's the perfect time to display a "New content is
58 | // available; please refresh." message in your web app.
59 | console.log('New content is available; please refresh.');
60 | } else {
61 | // At this point, everything has been precached.
62 | // It's the perfect time to display a
63 | // "Content is cached for offline use." message.
64 | console.log('Content is cached for offline use.');
65 | }
66 | }
67 | };
68 | };
69 | })
70 | .catch(error => {
71 | console.error('Error during service worker registration:', error);
72 | });
73 | }
74 |
75 | function checkValidServiceWorker(swUrl) {
76 | // Check if the service worker can be found. If it can't reload the page.
77 | fetch(swUrl)
78 | .then(response => {
79 | // Ensure service worker exists, and that we really are getting a JS file.
80 | if (
81 | response.status === 404 ||
82 | response.headers.get('content-type').indexOf('javascript') === -1
83 | ) {
84 | // No service worker found. Probably a different app. Reload the page.
85 | navigator.serviceWorker.ready.then(registration => {
86 | registration.unregister().then(() => {
87 | window.location.reload();
88 | });
89 | });
90 | } else {
91 | // Service worker found. Proceed as normal.
92 | registerValidSW(swUrl);
93 | }
94 | })
95 | .catch(() => {
96 | console.log(
97 | 'No internet connection found. App is running in offline mode.'
98 | );
99 | });
100 | }
101 |
102 | export function unregister() {
103 | if ('serviceWorker' in navigator) {
104 | navigator.serviceWorker.ready.then(registration => {
105 | registration.unregister();
106 | });
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/theme.js:
--------------------------------------------------------------------------------
1 | const theme = {
2 | typography: {
3 | fontFamily: 'Raleway, Helvetica, sans-serif',
4 | },
5 | colors: {
6 | primaryColor: '#008000',
7 | titleColor: 'white'
8 | },
9 | secondaryColor: 'mediumseagreen',
10 | };
11 |
12 | export default theme;
13 |
--------------------------------------------------------------------------------