Skip to content

Commit 7f1b06e

Browse files
committed
Provide the full implementation of the HeaderView
1 parent 3849288 commit 7f1b06e

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Week3/MAKEME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Object Oriented Programming is a vast topic and in this homework we can only scr
9191
| ErrorView.js | Renders an error, of present. |
9292
| Util.js | Provides utility functions. |
9393

94-
>For this part of the homework you should modify the **xxxView.js** files, by adding and adapting code from your non-OOP version of the homework to these files. You should also copy the styling from your non-OOP version. Other files should not be modified.
94+
>For this part of the homework you should modify the **RepoView.js**, **ContributorsView.js** and the **ErrorView.js** files, by adding and adapting code from your non-OOP version of the homework to these files. You should also copy the styling from your non-OOP version. Other files should not be modified.
9595
9696
_Read:_
9797

homework-classes/HeaderView.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,22 @@
2323
* @param {Object[]} repos An array of repository objects.
2424
*/
2525
render(repos) {
26-
this.select = createAndAppend('select', this.header);
27-
// TODO: replace this comment and the console.log with your own code
28-
console.log('renderSelect', repos);
26+
createAndAppend('p', this.header, { text: this.account.name });
27+
this.select = createAndAppend('select', this.header, {
28+
class: 'repo-select',
29+
autofocus: 'autofocus',
30+
});
31+
32+
repos.forEach((repo, index) =>
33+
createAndAppend('option', this.select, {
34+
text: repo.name,
35+
value: index,
36+
}),
37+
);
38+
39+
this.select.addEventListener('change', () =>
40+
this.model.fetchData(this.select.value),
41+
);
2942
}
3043
}
3144

0 commit comments

Comments
 (0)