forked from HackYourFuture/JavaScript3
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathContributor.js
More file actions
39 lines (34 loc) · 1.1 KB
/
Contributor.js
File metadata and controls
39 lines (34 loc) · 1.1 KB
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
'use strict';
/* global Util */
// eslint-disable-next-line no-unused-vars
class Contributor {
constructor(contributor) {
this.contributor = contributor;
}
/**
* Render the contributor info to the DOM.
* @param {HTMLElement} container The container element in which to render the contributor.
*/
render(container) {
/** TODO: replace the next line with your code.
Util.createAndAppend('pre', container, JSON.stringify(this.contributor, null, 2));*/
const link = Util.createAndAppend('a', container, {
href: this.contributor.html_url,
target: '_blank',
class: 'contributor-item',
});
Util.createAndAppend('img', link, {
src: this.contributor.avatar_url,
alt: this.contributor.login,
class: 'image',
});
const contributorDetails = Util.createAndAppend('div', link, {
class: 'contributor-data',
});
Util.createAndAppend('div', contributorDetails, { text: this.contributor.login });
Util.createAndAppend('div', contributorDetails, {
text: this.contributor.contributions,
class: 'contributor-badge',
});
}
}