forked from barryclark/jekyll-now
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skills.js
56 lines (49 loc) · 1.19 KB
/
skills.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
const e = React.createElement;
const randomNumber = min => Math.floor(Math.random() * 100);
const skillsList = [
'JavaScript',
'C#',
'SQL',
'Communication',
'Public Speaking',
'Private Speaking',
'MS Paint',
];
const initialSkills = {};
skillsList.forEach(skill => {
initialSkills[skill] = { count: randomNumber(), hasBeenEndorsed: false };
});
const Skills = () => {
const [skills, setSkills] = React.useState(initialSkills);
return Object.keys(skills).map(key => {
const skill = skills[key];
const isComplete = skill.count === 100;
return (
<div className="flex align-items-center">
<div className="box-container flex-grow">
<div className="box" style={{ width: `${skill.count}%` }}>
{isComplete && <i class="fas fa-check mr-s"></i>}
{key}
</div>
</div>
{!isComplete && (
<button
className="ml-s"
onClick={() => {
setSkills(
Object.assign({}, skills, {
[key]: { count: skill.count + 1, hasBeenEndorsed: true },
})
);
}}
>
Endorse
</button>
)}
</div>
);
});
};
const container = document.querySelector('#skills');
ReactDOM.render(e(Skills), container);