This repository was archived by the owner on Feb 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Added search-box && advance search options #1
Open
abdus
wants to merge
2
commits into
ResearchKernel:master
Choose a base branch
from
abdus:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import React from 'react'; | ||
| import './AdvanceSearchOptions.scss'; | ||
|
|
||
| export default class AdvanceSearchOptions extends React.Component { | ||
| render() { | ||
| return ( | ||
| <div className="adv-options"> | ||
| <section> | ||
| <div className="section-header">Lorem Ipsum</div> | ||
| <Radio | ||
| id="2017" | ||
| name="year" | ||
| value="2017" | ||
| label_text="this is a label text" | ||
| /> | ||
| <Radio | ||
| id="2018" | ||
| name="year" | ||
| value="2018" | ||
| label_text="this is a label text" | ||
| /> | ||
| </section> | ||
| <section> | ||
| <div className="section-header">Lorem Ipsum</div> | ||
| <Radio | ||
| id="2019" | ||
| name="year" | ||
| value="207" | ||
| label_text="this is a label text" | ||
| /> | ||
| <Radio | ||
| id="2020" | ||
| name="year" | ||
| value="2018" | ||
| label_text="this is a label text" | ||
| /> | ||
| </section> | ||
| <section> | ||
| <div className="section-header">Lorem Ipsum</div> | ||
| <Radio | ||
| id="2021" | ||
| name="year" | ||
| value="2017" | ||
| label_text="this is a label text" | ||
| /> | ||
| <Radio | ||
| id="2022" | ||
| name="year" | ||
| value="2018" | ||
| label_text="this is a label text" | ||
| /> | ||
| </section> | ||
| <section> | ||
| <div className="section-header">Lorem Ipsum</div> | ||
| <Radio | ||
| id="2023" | ||
| name="year" | ||
| value="2017" | ||
| label_text="this is a label text" | ||
| /> | ||
| <Radio | ||
| id="2024" | ||
| name="year" | ||
| value="2018" | ||
| label_text="this is a label text" | ||
| /> | ||
| </section> | ||
| <section> | ||
| <div className="section-header">Lorem Ipsum</div> | ||
| <Radio | ||
| id="2025" | ||
| name="year" | ||
| value="2017" | ||
| label_text="this is a label text" | ||
| /> | ||
| <Radio | ||
| id="2026" | ||
| name="year" | ||
| value="2018" | ||
| label_text="this is a label text" | ||
| /> | ||
| </section> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Radio | ||
| * @param {props} - accepts props from parent component | ||
| */ | ||
|
|
||
| const Radio = props => { | ||
| return( | ||
| <div className="form-check"> | ||
| <input className="form-check-input" type="radio" name={props.name} value={props.value} id={props.id} /> | ||
| <label className="form-check-label" htmlFor={props.id}> | ||
| {props.label_text} | ||
| </label> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| .adv-options { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| justify-content: space-between; | ||
| font-weight: 900; | ||
| border-top: 1px solid #c0c0c0a8; | ||
| border-bottom: 1px solid #c0c0c0a8; | ||
|
|
||
| & .form-check { | ||
| & .form-check-label { | ||
| font-weight: 300; | ||
| font-size: .9rem; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| &:hover { | ||
| color: #37a000; | ||
| } | ||
| } | ||
| & section { | ||
| width: auto; | ||
| min-width: 15%; | ||
| margin: 20px; | ||
|
|
||
| & .section-header { | ||
| margin: 4px 0; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| @media (max-width: 800px) { | ||
| .adv-options { | ||
|
|
||
|
|
||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from 'react'; | ||
| import './Search.scss'; | ||
| import AdvanceSearchOptions from './AdvanceSearchOptions'; | ||
| import SearchResult from './SearchResult'; | ||
|
|
||
| export default class SearchBox extends React.Component { | ||
|
|
||
| constructor() { | ||
| super(); | ||
|
|
||
| this.fetchData = this.fetchData.bind(this); | ||
| this.state = { | ||
| showAdvSearch: false, | ||
| searchResult: null | ||
| } | ||
| } | ||
|
|
||
| onFormSubmit(e) { | ||
| e.preventDefault(); | ||
| this.fetchData(); | ||
| } | ||
|
|
||
| toggleFilter(e) { | ||
| this.setState({ | ||
| showAdvSearch: !this.state.showAdvSearch | ||
| }) | ||
| } | ||
|
|
||
| fetchData() { | ||
| fetch('https://jsonplaceholder.typicode.com/posts') | ||
| .then(data => data.json()) | ||
| .then(data => this.setState({searchResult: data})); | ||
| } | ||
|
|
||
| render() { | ||
| return( | ||
| <> | ||
| <div className="search-wrapper"> | ||
| <form className="search-box" action="/" method="GET" onSubmit={this.onFormSubmit.bind(this)}> | ||
| <div className="basic-search"> | ||
| <input type="search" name="q" placeholder="Enter a Search Query"/> | ||
| <input type="submit" value="GO"/> | ||
| <input type="button" value="Filter" onClick={this.toggleFilter.bind(this)}/> | ||
| </div> | ||
| <div className={this.state.showAdvSearch === true ? 'adv-search' : 'adv-search hide-adv-search'}> | ||
| <AdvanceSearchOptions /> | ||
| </div> | ||
| </form> | ||
| <div className="search-result"> | ||
| {this.state.searchResult !== null ? this.state.searchResult.map((val, i) => <SearchResult header={val.title} description={val.body} key={i} />) : <NoDataFound/> } | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * No data found - search result | ||
| */ | ||
|
|
||
| const NoDataFound = () => { | ||
| return( | ||
| <div className="no-data-found">No Data Found... Press 'GO' to Load Dummy Data!</div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| .search-wrapper { | ||
| width: 80%; | ||
| margin: auto; | ||
| padding: 30px 0; | ||
| border-radius: 4px; | ||
| box-shadow: 0 0 10px 0 #c0c0c0a8; | ||
| // border: 1px solid #c4c4c467; | ||
| // border-bottom: 1px solid #c4c4c467; | ||
|
|
||
| & form.search-box, | ||
| & .search-result { | ||
| width: 90%; | ||
| margin: auto; | ||
|
|
||
| & .basic-search { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| justify-content: space-evenly; | ||
|
|
||
| & > * { | ||
| border: 1px solid #37a000; | ||
| padding: 10px; | ||
| background: transparent; | ||
| border-radius: 3px; | ||
| font-weight: 900; | ||
| } | ||
|
|
||
| & input[name="q"] { | ||
| width: 80%; | ||
|
|
||
| &::placeholder { | ||
| color: #37a000; | ||
| } | ||
| } | ||
|
|
||
| & input[type="submit"], | ||
| & input[type="button"] { | ||
| width: 9.5%; | ||
| color: #37a000; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| & input[type="submit"] { | ||
| background: #37a000; | ||
| color: #fff; | ||
| } | ||
| } | ||
|
|
||
| & .adv-search { | ||
| overflow: hidden; | ||
| max-height: 600px; | ||
| padding-top: 30px; | ||
| transition: .4s cubic-bezier(.65,.05,.36,1) all; | ||
| } | ||
|
|
||
| // & .show-adv-search { | ||
| // } | ||
|
|
||
| & .hide-adv-search { | ||
| max-height: 0; | ||
| padding-top: 0; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @media (max-width: 800px) { | ||
| .search-wrapper { | ||
| width: 95%; | ||
| & form.search-box { | ||
| & .basic-search { | ||
| & input[name="q"] { | ||
| width: 100%; | ||
| } | ||
|
|
||
| & input[type="submit"], | ||
| & input[type="button"] { | ||
| margin-top: 1px; | ||
| width: 49.5%; | ||
| } | ||
| } | ||
| & .adv-search { | ||
| max-height: 800px; | ||
| } | ||
|
|
||
| & .hide-adv-search { | ||
| max-height: 0; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // no data found | ||
| .no-data-found { | ||
| font-size: 1.2rem; | ||
| color: #9b9b9b; | ||
| margin: 2rem 0; | ||
| text-align: center; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import React from 'react'; | ||
| import './SearchResult.scss' | ||
|
|
||
| export default class SearchResult extends React.Component { | ||
| constructor(props) { | ||
| super(); | ||
| } | ||
| render() { | ||
| return( | ||
| <> | ||
| <div className="result-card"> | ||
| <div className="header">{this.props.header}</div> | ||
| <div className="description">{this.props.description}</div> | ||
| <div className="action"> | ||
| <button className="button download">Download</button> | ||
| <button className="button view">View</button> | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| .result-card { | ||
| padding: 40px 0; | ||
| border-bottom: 1px solid #c0c0c0a8; | ||
|
|
||
| & .header { | ||
| font-size: 1.2rem; | ||
| font-weight: bolder; | ||
| } | ||
|
|
||
| & .description { | ||
| color: #5a5a5a; | ||
| margin: 10px 0; | ||
| } | ||
|
|
||
| & .button { | ||
| background: unset; | ||
| font-size: inherit; | ||
| border: 1px solid #c0c0c0a8; | ||
| margin: 1px; | ||
| padding: 7px 10px; | ||
| border-radius: 2px; | ||
| cursor: pointer; | ||
| } | ||
| } |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
viewportmeta for responsiveness