Skip to content

Commit

Permalink
Fixed skills section
Browse files Browse the repository at this point in the history
  • Loading branch information
aish2002 committed Sep 6, 2021
1 parent e54b2f6 commit a3ad002
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/components/Languages/Language.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import { Col, Row } from 'react-bootstrap'
import { Col, ProgressBar, Row } from 'react-bootstrap'
import { usePercent } from '../../hooks/usePercent'

const Language = ({ id }) => {
const {skills,total} = usePercent(id);
const {skills,total,max} = usePercent(id);

return (
<Col>
Expand All @@ -13,6 +13,9 @@ const Language = ({ id }) => {
<Col key={key}>
<div> {skills[key].lang} {total}</div>
{/* <img src={`/${skill}.svg`} alt="skill-badge"/> */}
<ProgressBar
now={Math.round(skills[key].percent*100/total) }
max={max*100/total}/>
</Col>
))}
</Row>
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/usePercent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import axios from 'axios'
export const usePercent = (id) => {
const [total, setTotal] = useState(0)
const [skills, setSkills] = useState([])
const [max,setMax] = useState(0)

useEffect(() => {
getRepos(id).then(repos => {
Expand All @@ -25,8 +26,9 @@ export const usePercent = (id) => {
}
});
setSkills(languages)
}).catch(err => console.log(err));
}, [id])
setMax(Math.max.apply(Math, skills.map(function(o) { return o.percent; })))

return {skills,total}
}).catch(err => console.log(err));
}, [id,skills])
return {skills,total,max}
}

0 comments on commit a3ad002

Please sign in to comment.