forked from abhidg/skillboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
257 lines (243 loc) · 6.5 KB
/
index.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
<meta
name="description"
content="Single page HTML file to discover skills in a small group"
/>
<title>Skillboard</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif;
margin: auto;
max-width: 38rem;
padding: 2rem;
}
summary {
background-color: #f0f0f0;
padding: 5px;
margin: 0;
}
details {
padding: 5px 15px;
border: 1px solid gray;
background-color: #f0f0f0;
}
p {
line-height: 1.5;
}
p.skillset {
line-height: 2.5em;
}
ul {
columns: 3;
padding-left: 0;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-row-gap: 20px;
}
h1 {
margin-bottom: -10px;
}
header {
margin-bottom: 30px;
}
ul li {
list-style-type: none;
line-height: 2em;
}
pre {
padding: 15px;
background-color: #f0f0f0;
}
span.skill,
a.skill {
border: 1px solid silver;
border-radius: 10px;
padding: 4px;
margin-left: 5px;
background-color: azure;
cursor: pointer;
}
a.skill:hover {
background-color: cyan;
border: 1px solid #111;
cursor: pointer;
}
a.highlight,
span.highlight {
border: 1px solid violet;
box-shadow: violet 0px 0px 5px;
}
.highlight::before {
content: "✓ ";
}
span.wanted {
background-color: white;
}
footer {
margin-top: 30px !important;
border-top: 1px solid silver;
padding-top: 5px;
font-size: 14px;
}
@media (prefers-color-scheme: dark) {
body {
background-color: black;
color: #f0f0f0;
}
span.skill,
a.skill {
color: white;
background-color: darkblue;
}
span.wanted {
background-color: #444;
}
a.skill:hover {
background-color: purple;
}
details,
summary {
background-color: #353535;
color: white;
}
a.highlight,
span.highlight {
border: 1px solid #fff;
box-shadow: #fff 0px 0px 20px;
}
}
</style>
</head>
<body>
<header>
<h1>Skillboard</h1>
<p>Discover skills in a small group</p>
</header>
<div id="allskills"></div>
<p><button id="clear">Clear</button></p>
<p>
Click above to show people with particular skills. Click on a skill again
to toggle.<br />
Skills without stars are those that the person wants to learn.
</p>
<details>
<summary>How to add yourself</summary>
<p>
This is a single page HTML application which has the Javascript code bundled in
(use view source to see the code). The skill definitions are stored in an accompanying
<code>skills.json</code> file. To add yourself, edit the <code>skills.json</code> file
and create a key in the object, and list the skills, with + denoting the level of skill.
If there is a skill you want to learn but do not yet know, add the skill
without any + after it. Skills should be a single word without spaces,
hyphens are allowed.
</p>
<p>
Check that the file loads locally and commit to the Git repository, or
serve it on any webserver.
</p>
</details>
<div id="people"></div>
<footer>
source repository at
<a href="https://github.com/OxfordRSE/skillboard"
>https://github.com/OxfordRSE/skillboard</a
>
</footer>
<script type="text/javascript">
// state
const selectedSkills = new Set();
let SKILLS = null;
let allSkills = [];
// load skills.json
fetch("skills.json")
.then((r) => r.json())
.then((json) => SKILLS = json);
// functions
const collectSkills = (data) => {
const out = new Set();
Object.values(data).forEach((ss) => {
ss.map((s) => s.replaceAll("+", "")).forEach(out.add, out);
});
return Array.from(out).sort();
};
const clear = () => {
selectedSkills.clear();
allSkills.forEach((s) => {
document.getElementById(s).classList.remove("highlight");
});
render();
};
const skillOnClick = (s) => {
// toggle skill by clicking
if (selectedSkills.has(s)) {
selectedSkills.delete(s);
} else {
selectedSkills.add(s);
}
document.getElementById(s).classList.toggle("highlight");
render();
};
const render = (initial = false) => {
if (initial) {
if (!SKILLS) {
setTimeout(() => render(true), 100);
}
}
if (SKILLS) {
allSkills = collectSkills(SKILLS);
document.getElementById("allskills").innerHTML = skillHTML();
document.getElementById("people").innerHTML = Object.keys(SKILLS)
.map(personHighlightedSkills(selectedSkills))
.join("\n");
}
};
const skillHTML = () => {
const html = allSkills
.map((s) => {
const highlight = selectedSkills.has(s) ? "highlight" : "";
return `<li><a id="${s}" class="skill ${highlight}" onClick="skillOnClick('${s}')">${s}</a></li>`;
})
.join("\n");
return `<ul>${html}</ul>`;
};
const getSkills = (person) =>
SKILLS[person].map((s) => s.replaceAll("+", ""));
const peopleSkillHTML = (skills) => (skill) => {
const s = skill.replaceAll("+", "");
const stars = skill.replace(s, "").replaceAll("+", "★");
const highlight = skills.includes(skill.replaceAll("+", ""))
? "highlight"
: "";
const wanted = stars ? "" : "wanted";
return `<span class="skill ${highlight} ${wanted}" onClick="skillOnClick('${s}')">${s}${
stars ? " " + stars : ""
}</span>`;
};
const personHTML = (person) => {
const skillset = SKILLS[person];
return (
`<h2>${person}</h2><p class="skillset">` +
skillset.map(peopleSkillHTML([])).join(" ") +
"</p>\n"
);
};
const personHighlightedSkills = (skills) => (person) => {
if (skills.size === 0) return personHTML(person);
const skillset = getSkills(person);
const intersection = [...skills].filter((s) => skillset.includes(s));
return intersection.length > 0
? `<h2>${person}</h2><p class="skillset">` +
SKILLS[person].map(peopleSkillHTML(intersection)).join(" ") +
"</p>\n"
: "";
};
document.getElementById("clear").addEventListener("click", clear);
render(true);
</script>
</body>
</html>