-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from HunterX18/main
Sorting repos on the basis of stars and forks
- Loading branch information
Showing
4 changed files
with
259 additions
and
166 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,30 +1,59 @@ | ||
import React,{ useContext, useState} from "react"; | ||
import React, { useContext, useState } from "react"; | ||
|
||
import './App.css'; | ||
import "./App.css"; | ||
|
||
import 'bootstrap/dist/css/bootstrap.min.css'; | ||
import "bootstrap/dist/css/bootstrap.min.css"; | ||
//Context | ||
import {ThemeContext} from './Context/themeContext' | ||
import { ThemeContext } from "./Context/themeContext"; | ||
//Components | ||
import Header from './components/Header'; | ||
import CardSet from './components/CardSet'; | ||
import Navigation from './components/Navigation'; | ||
import Header from "./components/Header"; | ||
import CardSet from "./components/CardSet"; | ||
import Navigation from "./components/Navigation"; | ||
|
||
function App() { | ||
const [language,setLanguage] = useState("Javascript"); | ||
const [pageNumber,setPageNumber] = useState(1); | ||
const [maxPageNumber,setMaxPageNumber] = useState(100); | ||
const [inputSearch, setInputSearch] = useState(""); | ||
const {theme} = useContext(ThemeContext) | ||
function App() { | ||
const [language, setLanguage] = useState("Javascript"); | ||
const [pageNumber, setPageNumber] = useState(1); | ||
const [maxPageNumber, setMaxPageNumber] = useState(100); | ||
const [inputSearch, setInputSearch] = useState(""); | ||
const [sortByForks, setSortByForks] = useState("desc"); | ||
const [sortByStars, setSortByStars] = useState("desc"); | ||
const { theme } = useContext(ThemeContext); | ||
|
||
return ( | ||
<div className="App" style={{ backgroundColor: theme.bg, color: theme.color}}> | ||
<Header setLanguage={setLanguage} setInputSearch={setInputSearch} inputSearch={inputSearch}/> | ||
<Navigation setPageNumber={setPageNumber} pageNumber={pageNumber} maxPageNumber={maxPageNumber} /> | ||
<CardSet pageNumber={pageNumber} language={language} key={language+pageNumber} setMaxPageNumber={setMaxPageNumber} inputSearch={inputSearch}/> | ||
<Navigation setPageNumber={setPageNumber} pageNumber={pageNumber} maxPageNumber={maxPageNumber} /> | ||
</div> | ||
); | ||
return ( | ||
<div | ||
className="App" | ||
style={{ backgroundColor: theme.bg, color: theme.color }} | ||
> | ||
<Header | ||
setLanguage={setLanguage} | ||
setInputSearch={setInputSearch} | ||
inputSearch={inputSearch} | ||
sortByStars={sortByStars} | ||
setSortByStars={setSortByStars} | ||
sortByForks={sortByForks} | ||
setSortByForks={setSortByForks} | ||
/> | ||
<Navigation | ||
setPageNumber={setPageNumber} | ||
pageNumber={pageNumber} | ||
maxPageNumber={maxPageNumber} | ||
/> | ||
<CardSet | ||
pageNumber={pageNumber} | ||
language={language} | ||
key={language + pageNumber} | ||
setMaxPageNumber={setMaxPageNumber} | ||
sortByForks={sortByForks} | ||
sortByStars={sortByStars} | ||
inputSearch={inputSearch} | ||
/> | ||
<Navigation | ||
setPageNumber={setPageNumber} | ||
pageNumber={pageNumber} | ||
maxPageNumber={maxPageNumber} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,66 +1,112 @@ | ||
import { Navbar, Nav, NavDropdown, Form, Button } from "react-bootstrap"; | ||
import { useContext, useState } from "react"; | ||
import langugagesData from "../data/languages.json"; | ||
import { useDebouncedCallback } from 'use-debounce'; | ||
import { useDebouncedCallback } from "use-debounce"; | ||
//Context | ||
import {ThemeContext} from '../Context/themeContext' | ||
import { ThemeContext } from "../Context/themeContext"; | ||
|
||
const Header = (props) => { | ||
const [language, setLanguage] = useState("javascript"); | ||
const {theme, changeTheme} = useContext(ThemeContext) | ||
const [inputSearch, setInputSearch] = useState(""); | ||
const [language, setLanguage] = useState("javascript"); | ||
const { theme, changeTheme } = useContext(ThemeContext); | ||
const [inputSearch, setInputSearch] = useState(""); | ||
|
||
const debouncedInput = useDebouncedCallback((value) => { | ||
props.setInputSearch(value); | ||
}, | ||
// delay in ms | ||
1000 | ||
); | ||
const debouncedInput = useDebouncedCallback( | ||
(value) => { | ||
props.setInputSearch(value); | ||
}, | ||
// delay in ms | ||
1000 | ||
); | ||
|
||
const handleInputSearch = (inputValue) => { | ||
setInputSearch(inputValue); | ||
debouncedInput(inputValue); | ||
} | ||
const handleInputSearch = (inputValue) => { | ||
setInputSearch(inputValue); | ||
debouncedInput(inputValue); | ||
}; | ||
|
||
return ( | ||
<div style={{color: theme.color}}> | ||
<Navbar bg={theme.mode} variant={theme.mode} expand="lg"> | ||
<Navbar.Brand href="#home">Find Me Issues</Navbar.Brand> | ||
{theme.mode === 'light' ? | ||
<Button onClick={changeTheme}><i className="fa fa-moon-o" aria-hidden="true"></i></Button> | ||
: | ||
<Button onClick={changeTheme}><i className="fa fa-sun-o" aria-hidden="true"></i></Button> | ||
} | ||
<Nav className="mr-auto"></Nav> | ||
<Form inline> | ||
<label className="mr-sm-3"> | ||
<span>Find specific content in the project description</span> | ||
<input type="text" value={inputSearch} onChange={(e) => handleInputSearch(e.target.value)} /> | ||
</label> | ||
<div id="outlined-basic" className="mr-sm-2">{language}</div> | ||
<NavDropdown title="Select Language" id="basic-nav-dropdown"> | ||
<div style={{height:"400px", overflowY:"auto"}}> | ||
{langugagesData.languages.map((lang, index) => { | ||
return ( | ||
<div key={index}> | ||
<NavDropdown.Item | ||
onClick={() => { | ||
setLanguage(lang); | ||
props.setLanguage(lang); | ||
}} | ||
> | ||
{lang} | ||
</NavDropdown.Item> | ||
<NavDropdown.Divider /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</NavDropdown> | ||
</Form> | ||
</Navbar> | ||
</div> | ||
); | ||
const handleSortByStars = () => { | ||
props.setSortByForks(""); | ||
if (props.sortByStars == "desc") props.setSortByStars("asc"); | ||
else props.setSortByStars("desc"); | ||
}; | ||
const handleSortByForks = () => { | ||
props.setSortByStars(""); | ||
if (props.sortByForks == "desc") props.setSortByForks("asc"); | ||
else props.setSortByForks("desc"); | ||
}; | ||
|
||
return ( | ||
<div style={{ color: theme.color }}> | ||
<Navbar bg={theme.mode} variant={theme.mode} expand="lg"> | ||
<Navbar.Brand href="#home">Find Me Issues</Navbar.Brand> | ||
{theme.mode === "light" ? ( | ||
<Button onClick={changeTheme}> | ||
<i className="fa fa-moon-o" aria-hidden="true"></i> | ||
</Button> | ||
) : ( | ||
<Button onClick={changeTheme}> | ||
<i className="fa fa-sun-o" aria-hidden="true"></i> | ||
</Button> | ||
)} | ||
<Nav className="mr-auto"></Nav> | ||
|
||
<button | ||
style={{ | ||
margin: "3px", | ||
borderRadius: "5px", | ||
backgroundColor: "blue", | ||
color: "white", | ||
}} | ||
onClick={handleSortByStars} | ||
> | ||
sort by stars | ||
</button> | ||
<button | ||
style={{ | ||
margin: "3px", | ||
borderRadius: "5px", | ||
backgroundColor: "blue", | ||
color: "white", | ||
}} | ||
onClick={handleSortByForks} | ||
> | ||
sort by forks | ||
</button> | ||
|
||
<Form inline> | ||
<label className="mr-sm-3"> | ||
<span>Find specific content in the project description</span> | ||
<input | ||
type="text" | ||
value={inputSearch} | ||
onChange={(e) => handleInputSearch(e.target.value)} | ||
/> | ||
</label> | ||
<div id="outlined-basic" className="mr-sm-2"> | ||
{language} | ||
</div> | ||
<NavDropdown title="Select Language" id="basic-nav-dropdown"> | ||
<div style={{ height: "400px", overflowY: "auto" }}> | ||
{langugagesData.languages.map((lang, index) => { | ||
return ( | ||
<div key={index}> | ||
<NavDropdown.Item | ||
onClick={() => { | ||
setLanguage(lang); | ||
props.setLanguage(lang); | ||
}} | ||
> | ||
{lang} | ||
</NavDropdown.Item> | ||
<NavDropdown.Divider /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</NavDropdown> | ||
</Form> | ||
</Navbar> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Header; |
Oops, something went wrong.