Skip to content

Commit

Permalink
push 2
Browse files Browse the repository at this point in the history
  • Loading branch information
gregpr07 committed Oct 30, 2019
1 parent a6a5e05 commit b2f20f0
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 29 deletions.
8 changes: 4 additions & 4 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,
title: `X5GON site`,
description: `Awesome ML search`,
author: `IJS`,
},
plugins: [
`gatsby-plugin-react-helmet`,
Expand All @@ -24,7 +24,7 @@ module.exports = {
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
icon: `src/images/logo/x5gon_logo_dark.svg`, // This path is relative to the root of the site.
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "gatsby-starter-default",
"name": "search",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"description": "X5GON search engine powered by ML",
"version": "0.1.0",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"author": "IJS",
"dependencies": {
"@reach/router": "^1.2.1",
"gatsby": "^2.17.4",
Expand Down
3 changes: 2 additions & 1 deletion src/components/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Link } from "gatsby"
const Layout = props => {
return (
<div>
<Navbar light={"dark"}>{props.children}</Navbar>
<Navbar light={"dark"} />
{props.children}
</div>
)
}
Expand Down
43 changes: 41 additions & 2 deletions src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
import React from "react"
import React, { useState } from "react"
import "../css/main.css"
import "../css/bootstrap.css"
import { navigate } from "gatsby"

import Layout from "../components/layout"

const IndexPage = () => <Layout>homepage</Layout>
const IndexPage = () => {
const [searchKey, setSearchKey] = useState()

const onFormSubmit = e => {
e.preventDefault()
console.log("submitted")
navigate("/search?q=" + searchKey)
}

const ChangeSearchKey = value => {
setSearchKey(value)
}

const SearchBar = () => {
return (
<form onSubmit={onFormSubmit}>
<input
ref={input => input && input.focus()}
type="text"
value={searchKey}
onChange={e => ChangeSearchKey(e.target.value)}
placeholder="Search |"
className="form-control align-middle mb-3"
autoComplete="off"
/>
</form>
)
}

return (
<Layout>
<div className="text-center maxer-880 mx-auto">
<h3>X5GON Search</h3>
<h4>Find OER materials in the blink of an eye.</h4>
<SearchBar></SearchBar>
</div>
</Layout>
)
}

export default IndexPage
26 changes: 7 additions & 19 deletions src/pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import ReactPaginate from "react-paginate"
import { Link } from "gatsby"
import withLocation from "../components/withLocation"

import Layout from "../components/layout"

class Search extends React.Component {
constructor(props) {
super(props)
Expand Down Expand Up @@ -66,6 +68,7 @@ class Search extends React.Component {
)
.then(res => res.json())
.then(json => {
console.log(json)
this.setState({
isLoaded: true,
api_search: {
Expand Down Expand Up @@ -153,11 +156,8 @@ class Search extends React.Component {
if (this.state.IsSearching === true)
return (
<p className="mt-2">
Number of search results found:{" "}
{this.state.api_search.metadata.num_or_materials} for{" "}
<b>{this.state.api_search.query.text}</b> in{" "}
{this.state.api_search.metadata.max_pages} pages | currently on page{" "}
{this.state.current_page}
Found <b>{this.state.api_search.metadata.count}</b> Open Educational
Resources
</p>
)
else {
Expand Down Expand Up @@ -195,17 +195,6 @@ class Search extends React.Component {
</Link>
)
}
LogoIcon = () => {
return (
<Link to="/">
<img
src="https://www.x5gon.org/wp-content/themes/x5gon/dist/assets/img/logo.svg"
alt="X5GON"
className="my-5 img-fluid"
/>
</Link>
)
}
SearchItem = item => {
let sitem = item
if (sitem.description && sitem.description.length > 280) {
Expand Down Expand Up @@ -254,10 +243,9 @@ class Search extends React.Component {
// RENDER VIEW
render() {
return (
<React.Fragment>
<Layout>
<div className="container">
<div className="text-center" id="search">
<this.LogoIcon />
<this.SearchBar />
<this.SearchButton text={"Search"} />
<div />
Expand All @@ -268,7 +256,7 @@ class Search extends React.Component {
<this.SearchItemsUL />
<this.BottomPagination />
</div>
</React.Fragment>
</Layout>
)
}
}
Expand Down

0 comments on commit b2f20f0

Please sign in to comment.