Open remarcmij opened 6 years ago
I fix it still media query remains (make it responsive)
You changes look good. I would advise you to use flexbox instead of floats to make the app responsive. Then, it is easy to switch the repo div and the contributor div from flex-direction: row;
(large screen) to flex-direction: column
(tablet/phone), using a media query.
Hi Aya, here is my feedback on your homework for week 3 (OOP version):
When I load your
index.html
file in the browser it looks good and functions as expected. However, your app is not responsive. On an (emulated) iPhone 6/7/8 it looks like this:On your code, I have little to comment. As last time it is a pleasure to read. Still, there are some minor improvements possible.
1. The sorting of the repository information could be simplified by using the standard string method
.localeCompare()
:The code that you used obviously works, however it does not take into account local language peculiarities. For instance, suppose you have an array with the following French words (listed in the correct dictionary order):
The result from sorting:
The
.localeCompare()
method might even be able to sort Arabic words (which I know to have no uppercase letters) in the correct dictionary order (perhaps you can try).2. In the assignment, it was suggested that you create a method
fetchContributors()
in theRepository
class. Because theRepository
class has all the information needed (in your case inthis._infoData
) to manage itself completely, it can fetch the contributors without an external caller needing to tell it what URL to use. So thisfetchContributors()
method could look like this:However, to make this work you would need to move the
fetchJSON()
function out of theView
class and make it a stand-alone function again, similar tocreateAndAppend()
.With this
fetchContributors()
method in theRepository
class yourrender()
method of theView
class could look like this:Now, your
View
class can remain completely unaware about the internal details of the repository information (that's a good thing).3. There is a problem with your use of
window.onload
. The way you coded it does not actually cause your code to be executed when the page is fully loaded. Instead it is executed immediately when the JavaScript engine loads the script file, which may be too early. If I move the<script src="app.js">
tag from<body>
to<header>
(which is a valid thing to do), you app no longer works. I get this error in the console:The
window.onload
property must be assigned a function. That function will be called when the page is completely loaded. For instance, you could do this (using an arrow function):Overall, you have done very well in JS3 class and I have no doubt you will do well in the rest of the HYF curriculum too.