Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made Algorithm component #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/Algorithms/Algorithm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Algorithm{
margin-top: 10px;
}
68 changes: 68 additions & 0 deletions src/components/Algorithms/Algorithm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { useEffect, useState } from 'react'
import axios from 'axios'

function Algorithm() {
const [data,setData] = useState([]);
const [algoList,setAlgoList] = useState([]);
const [pathForAPI,setpathForAPI] = useState("");
useEffect( ()=>{
axios
.get('https://api.github.com/repos/iiitv/algos/contents/')
.then( (res) => {
console.log(res.data);
setData(res.data);

})
.catch( (err) => {
console.error(err)
})

},[])

const humanize = (str) => {
var i, frags = str.split('_');
for (i=0; i<frags.length; i++){
frags[i] = frags[i].charAt(0).toUpperCase() + frags[i].slice(1);
}
return frags.join(' ');
}

useEffect(() => {
for(let i =0;i<data.length;i++){
if(data[i].name.includes(".") || data[i].name.includes("LICENSE") ){
}
else{
setAlgoList( old => [...old, data[i].name]);
}
}
}, [data])

// const handleAlgorithmClick = (FolderName) => {
// console.log("aaya ");
// console.log(FolderName);
// }
useEffect( ()=>{
axios
.get('https://api.github.com/repos/iiitv/algos/contents/'+pathForAPI)
.then( (res)=>{
console.log(res.data);

})
},[pathForAPI])
return (
<div>
<div className = "algoListContainer">
{algoList.map( (value,index) => (
<div className = "Algorithm" onClick={()=>{
setpathForAPI(value);
}}>
{value.includes("_") ? humanize(value) : value.charAt(0).toUpperCase()+value.slice(1)}
</div>
))}
</div>
</div>
)
}

export default Algorithm

3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
import { Route } from 'react-router';
import { BrowserRouter, Switch } from 'react-router-dom';
import { Provider } from 'react-redux';

import Algorithm from './components/Algorithms/Algorithm';
// import * as serviceWorker from './serviceWorker';
import store from './store';
import './index.css';
Expand All @@ -18,6 +18,7 @@ ReactDOM.render(
{/* <Route exact path="/" component={HomePage}></Route> */}
<Route exact path="/" component={HomeComponent}></Route>
<Route exact path="/home" component={HomePage}></Route>
<Route exact path="/algorithm" component={Algorithm}></Route>
</Switch>
</BrowserRouter>
</Provider>,
Expand Down
100 changes: 95 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=

[email protected]:
version "0.0.8"
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-0.0.8.tgz#a7ea79d0ccb0b40499091db930050fb304f62d7d"
integrity sha1-p+p50MywtASZCR25MAUPswT2LX0=

concat-stream@^1.5.0:
version "1.6.2"
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
Expand Down Expand Up @@ -3657,6 +3662,13 @@ [email protected]:
address "^1.0.1"
debug "^2.6.0"

"detective@git://github.com/shtylman/node-detective.git#06d5cb":
version "0.3.0-dz0"
resolved "git://github.com/shtylman/node-detective.git#06d5cb4534818860b5a7f8d0a321dc7ae86d8e74"
dependencies:
escodegen "0.0.15"
esprima "1.0.2"

diff-sequences@^24.9.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
Expand Down Expand Up @@ -4012,6 +4024,15 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=

[email protected]:
version "0.0.15"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-0.0.15.tgz#ffda9cb26b70b34f7cc19f1d88756539afb543bd"
integrity sha1-/9qcsmtws098wZ8diHVlOa+1Q70=
dependencies:
esprima ">= 1.0.0"
optionalDependencies:
source-map ">= 0.1.2"

escodegen@^1.11.0, escodegen@^1.9.1:
version "1.14.3"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503"
Expand Down Expand Up @@ -4215,7 +4236,12 @@ espree@^6.1.2:
acorn-jsx "^5.2.0"
eslint-visitor-keys "^1.1.0"

esprima@^4.0.0, esprima@^4.0.1:
[email protected]:
version "1.0.2"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.0.2.tgz#8039bf9ceac4d9d2c15f623264fb292b5502ceaf"
integrity sha1-gDm/nOrE2dLBX2IyZPspK1UCzq8=

"esprima@>= 1.0.0", esprima@^4.0.0, esprima@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
Expand Down Expand Up @@ -5201,6 +5227,13 @@ htmlparser2@^3.3.0:
inherits "^2.0.1"
readable-stream "^3.1.1"

[email protected]:
version "0.1.2"
resolved "https://registry.yarnpkg.com/http-browserify/-/http-browserify-0.1.2.tgz#85a4a0b0ae130bde96aeffc2fa408ded43848d67"
integrity sha1-haSgsK4TC96Wrv/C+kCN7UOEjWc=
dependencies:
concat-stream "0.0.8"

http-deceiver@^1.2.7:
version "1.2.7"
resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87"
Expand Down Expand Up @@ -6804,6 +6837,11 @@ merge2@^1.2.3:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/merge/-/merge-1.0.0.tgz#b443ab46d837c491e6222056ab0f7933ecb3568f"
integrity sha1-tEOrRtg3xJHmIiBWqw95M+yzVo8=

methods@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
Expand Down Expand Up @@ -7388,6 +7426,13 @@ opn@^5.5.0:
dependencies:
is-wsl "^1.1.0"

[email protected]:
version "0.3.4"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.3.4.tgz#4d6d0bd71ffad0da4ba4f6d876d5eeb04e07480b"
integrity sha1-TW0L1x/60NpLpPbYdtXusE4HSAs=
dependencies:
wordwrap "~0.0.2"

[email protected]:
version "5.0.3"
resolved "https://registry.yarnpkg.com/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-5.0.3.tgz#e2f1d4d94ad8c0af8967ebd7cf138dcb1ef14572"
Expand Down Expand Up @@ -8528,6 +8573,11 @@ process-nextick-args@~2.0.0:
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==

[email protected]:
version "0.5.0"
resolved "https://registry.yarnpkg.com/process/-/process-0.5.0.tgz#f82e05372efa5035715da6622d22f0a06b6f053e"
integrity sha1-+C4FNy76UDVxXaZiLSLwoGtvBT4=

process@^0.11.10:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
Expand Down Expand Up @@ -8774,6 +8824,13 @@ react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-particles-js@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/react-particles-js/-/react-particles-js-3.5.3.tgz#5fa8912cd3317061e4d31ed7743d331d9d7f2afe"
integrity sha512-e9GWBT51WDtPkcaSy0ZLUAT93lBzDvuqrfW81NOf6G69XSurgCtVy4+ZYpUCnLhZgkokzsjrhtVOSj1FxPVyEw==
dependencies:
lodash "^4.17.11"

react-redux@^7.2.1:
version "7.2.1"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.2.1.tgz#8dedf784901014db2feca1ab633864dee68ad985"
Expand Down Expand Up @@ -8881,10 +8938,10 @@ react-springy-parallax@^1.3.0:
dependencies:
animated "^0.2.2"

react@^16.13.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e"
integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==
react@^16.14.0:
version "16.14.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
Expand Down Expand Up @@ -9161,6 +9218,13 @@ require-main-filename@^2.0.0:
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==

[email protected]:
version "0.0.8"
resolved "https://registry.yarnpkg.com/required/-/required-0.0.8.tgz#1ac65062d40b64b222491947eb14b763083a0926"
integrity sha1-GsZQYtQLZLIiSRlH6xS3Ywg6CSY=
dependencies:
detective "git://github.com/shtylman/node-detective.git#06d5cb"

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
Expand Down Expand Up @@ -9406,6 +9470,17 @@ schema-utils@^2.5.0, schema-utils@^2.6.0, schema-utils@^2.6.1, schema-utils@^2.6
ajv "^6.12.4"
ajv-keywords "^3.5.2"

script@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/script/-/script-0.1.4.tgz#4f5d9dff0c60b05387efa70f8ca8bfe53b810fba"
integrity sha1-T12d/wxgsFOH76cPjKi/5TuBD7o=
dependencies:
http-browserify "0.1.2"
merge "1.0.0"
optimist "0.3.4"
process "0.5.0"
required "0.0.8"

select-hose@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca"
Expand Down Expand Up @@ -9727,6 +9802,11 @@ [email protected], source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, sourc
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

"source-map@>= 0.1.2":
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==

source-map@^0.5.0, source-map@^0.5.6:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
Expand Down Expand Up @@ -10328,6 +10408,11 @@ tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==

tsparticles@^1.35.2:
version "1.35.4"
resolved "https://registry.yarnpkg.com/tsparticles/-/tsparticles-1.35.4.tgz#1748a5a7821211c72cd7aeed79a2b673a031841b"
integrity sha512-usrQNLXoQKwBz3oOvtrwQCwCFWEX6mb4kPeJG+o9Zse119Sl/zWnPPLu9owQ3iD4hyQqGlXUjUWRwxvUBY+hPA==

tsutils@^3.17.1:
version "3.17.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"
Expand Down Expand Up @@ -10861,6 +10946,11 @@ word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==

wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc=

workbox-background-sync@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/workbox-background-sync/-/workbox-background-sync-4.3.1.tgz#26821b9bf16e9e37fd1d640289edddc08afd1950"
Expand Down