Apiweb3#5
Conversation
| for (let contributor of listOfContributors) { | ||
| Util.createAndAppend('img', contributors, { | ||
| src: this.contributor.avatar_url, | ||
| class: 'contri', |
There was a problem hiding this comment.
contri seems like a strange css class name. Can there be an alternative here?
| @@ -54,7 +55,7 @@ class App { | |||
| const repo = this.repos[index]; | |||
| const contributors = await repo.fetchContributors(); | |||
There was a problem hiding this comment.
Problem is here! Cant seem to go through this part
| function listenerSelect(listOfRepos) { | ||
| document.getElementById('dropdown-select').addEventListener('change', event => { | ||
| const selectedRepo = event.target.value; | ||
| const selectedData = listOfRepos.filter(repoData => repoData.name === selectedRepo)[0]; |
There was a problem hiding this comment.
This seems to be returning undefined every time. Think this is the source of the bug.
There was a problem hiding this comment.
The objects have a .repository field:
document.getElementById('dropdown-select').addEventListener('change', event => {
const selectedRepoName = event.target.value;
const selectedRepoData = this.repos.filter(
repoData => repoData.repository.name === selectedRepoName,
)[0];
const index = this.repos.indexOf(selectedRepoData);
this.fetchContributorsAndRender(index);
});
| render(container) { | ||
| // TODO: replace the next line with your code. | ||
| Util.createAndAppend('pre', container, { text: JSON.stringify(this.repository, null, 2) }); | ||
| Util.createAndAppend('option', container, { |
There was a problem hiding this comment.
You'll have to add more here. Think you can copy code over from the previous week? Also, can't read if not white colored.
| // TODO: replace the next line with your code. | ||
| Util.createAndAppend('pre', container, { text: JSON.stringify(this.contributor, null, 2) }); | ||
| const contributorsDiv = Util.createAndAppend('div', root, { id: 'contributors' }); | ||
| for (let contributor of listOfContributors) { |
There was a problem hiding this comment.
No need for loop here. One class, will be for one contributor. Can delete this line.
| const rightDiv = Util.createAndAppend('div', container); | ||
|
|
||
| const contributorList = Util.createAndAppend('ul', contributorContainer); | ||
| const contributorList = Util.createAndAppend('ul', rightDiv); |
There was a problem hiding this comment.
I would probably make this a normal div because it will not just be text, but images too.
| render(container) { | ||
| // TODO: replace the next line with your code. | ||
| Util.createAndAppend('pre', container, { text: JSON.stringify(this.contributor, null, 2) }); | ||
| const contributorsDiv = Util.createAndAppend('div', root, { id: 'contributors' }); |
| Util.createAndAppend('pre', container, { text: JSON.stringify(this.contributor, null, 2) }); | ||
| const contributorsDiv = Util.createAndAppend('div', root, { id: 'contributors' }); | ||
| for (let contributor of listOfContributors) { | ||
| Util.createAndAppend('img', contributors, { |
There was a problem hiding this comment.
you'll want to do:
Util.createAndAppend('img', contributorDiv, {
| class: 'contributors-detail', | ||
| }); | ||
| } | ||
| //Util.createAndAppend('pre', container, { text: JSON.stringify(this.contributor, null, 2) }); |
There was a problem hiding this comment.
You'll then want to do a normal append with what you created above. Something like:
container.appendChild(contributorDiv)
| Util.createAndAppend('p', contributorDiv, { | ||
| text: this.contributor.contributions, | ||
| class: 'contributors-detail', | ||
| }); |
There was a problem hiding this comment.
You want to use the container :)
render(container) {
Util.createAndAppend('img', container, {
src: this.contributor.avatar_url,
class: 'contributors-detail',
});
Util.createAndAppend('p', container, {
text: this.contributor.login,
class: 'contributors-detail',
});
Util.createAndAppend('p', container, {
text: this.contributor.contributions,
class: 'contributors-detail',
});
}
}
No description provided.