-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
261 lines (248 loc) · 7.2 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
258
259
260
261
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
// add yourself by changing this object, + denotes skill level
// absence of + indicates a skill you want to learn
const SKILLS = {
"Arya Stark": [
"fencing+++",
"sword-fighting+++",
"wit++",
"diplomacy+",
],
"Cersei Lannister": [
"politics++",
"diplomacy",
"military+",
"leadership+",
],
"Jaime Lannister": ["politics+", "diplomacy++", "sword-fighting+++"],
"Tyrion Lannister": ["politics+++", "diplomacy+++", "language+++"],
"Petyr Baelish": ["politics++", "manipulation+++"],
"Jon Snow": ["sword-fighting++", "leadership+++"],
"Daenerys Targaryen": ["leadership++", "dragons+++", "diplomacy+"],
};
</script>
<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: 70rem;
padding: 2rem;
font-size: 0.95rem;
}
summary {
padding: 5px;
margin: 0;
}
details {
padding: 5px 15px;
border-left: 2px solid gray;
}
p {
line-height: 1.5;
}
p.skillset {
line-height: 2;
}
ul {
columns: auto;
list-style: none;
margin-left: -3rem;
}
h1 {
margin-bottom: -10px;
}
header {
margin-bottom: 30px;
}
ul li {
margin-bottom: 20px;
list-style-type: none;
display: inline-block;
}
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;
}
a.skill:hover {
background-color: cyan;
border: 1px solid #111;
cursor: pointer;
}
a.highlight,
span.highlight,
span.highlightwanted {
background-color: turquoise;
}
a.highlight::before {
content: "✓ ";
}
span.wanted {
background-color: white;
}
footer {
margin-top: 30px !important;
border-top: 1px solid silver;
padding-top: 5px;
font-size: 0.8rem;
}
@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 {
color: white;
}
a.highlight,
span.highlight,
span.highlightwanted {
background-color: blueviolet;
}
}
</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 file which has the Javascript code bundled in
(use view source to see the code). To add yourself, edit the
<code>SKILLS</code> object in the Javascript code. 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/abhidg/skillboard"
>https://github.com/abhidg/skillboard</a
>
</footer>
<script type="text/javascript">
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);
};
// state
const selectedSkills = new Set();
const allSkills = collectSkills(SKILLS);
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 = () => {
document.getElementById("people").innerHTML = Object.keys(SKILLS)
.map(personHighlightedSkills(selectedSkills))
.join("\n");
};
const skillHTML = () => {
const html = allSkills
.map(
(s) =>
`<li><a id="${s}" class="skill" 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}">${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("allskills").innerHTML = skillHTML();
document.getElementById("clear").addEventListener("click", clear);
render();
</script>
</body>
</html>