Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js-dom homework by LuckyDnepr #145

Merged
merged 2 commits into from
Aug 24, 2022
Merged

js-dom homework by LuckyDnepr #145

merged 2 commits into from
Aug 24, 2022

Conversation

LuckyDnepr
Copy link
Contributor

js-dom-task

Demo |
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

Copy link

@al0tak al0tak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outstanding work! Let's improve it a little, check the comments below.

@@ -0,0 +1,84 @@
"use strict";

import { readJSON } from "./readJSON.js";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to just store the data from the first call to the JSON somewhere and use it, instead of reaching out to this function every time someone changes a tab.


import { readJSON } from "./readJSON.js";

const dataBaseUrl = "./data-films.json";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you already have the same string in the main-script.js file. Maybe consider moving it to the readJSON.js file. Though, if you remove readJSON function usage here, maybe you don't need readJSON.js file at all and you can keep this function in the main-script.js.

const data = await readJSON(dataBaseUrl);
container.innerHTML = "";
const film = data.find((film) => film.ID === +id);
container.appendChild(makeTitle(film));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lot of reaching out to DOM just to switch content on one action. Consider wrapping all these elements with a document fragment and using only one appendChild.

asideMenuList.appendChild(makeAsideMenuItem(film.ID, film.title));
});
container.appendChild(asideMenuList);
return asideMenu;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a little confusing. The purpose of this function is to render an AsideMenu. When you name function makeAsideMenu it usually means that it should return some kind of element, and this function does do that, but you're not using this element in any way, because what it also does is render the element on line 23 right away. Either rename the function to something like renderAsideMenu and remove the return or keep the return, remove rendering here and render somewhere outside this function using the returned value.

@al0tak al0tak self-assigned this Aug 21, 2022
LuckyDnepr added a commit to LuckyDnepr-LearningStage/Kottans-DOM that referenced this pull request Aug 22, 2022
Add favicon. (^-^)

It would be better to just store the data from the first call
to the JSON somewhere and use it, instead of reaching out
to this function every time someone changes a tab.
kottans/frontend-2022-homeworks#145 (comment)
Resolved

Also, you already have the same string in the main-script.js file.
Maybe consider moving it to the readJSON.js file. Though,
if you remove readJSON function usage here, maybe you don't need
readJSON.js file at all and you can keep this function
in the main-script.js.
kottans/frontend-2022-homeworks#145 (comment)
Resolved

That's a lot of reaching out to DOM just to switch content on one action.
Consider wrapping all these elements with a document fragment and using only one appendChild.
kottans/frontend-2022-homeworks#145 (comment)
Resolved

This looks a little confusing. The purpose of this function is to render
an AsideMenu. When you name function makeAsideMenu it usually means that
it should return some kind of element, and this function does do that,
but you're not using this element in any way, because what it also does
is render the element on line 23 right away. Either rename the function
to something like renderAsideMenu and remove the return or keep the return,
remove rendering here and render somewhere outside this function using
the returned value.
kottans/frontend-2022-homeworks#145 (comment)
Resolved
Add favicon. (^-^)

It would be better to just store the data from the first call
to the JSON somewhere and use it, instead of reaching out
to this function every time someone changes a tab.
#145 (comment)
Resolved

Also, you already have the same string in the main-script.js file.
Maybe consider moving it to the readJSON.js file. Though,
if you remove readJSON function usage here, maybe you don't need
readJSON.js file at all and you can keep this function
in the main-script.js.
#145 (comment)
Resolved

That's a lot of reaching out to DOM just to switch content on one action.
Consider wrapping all these elements with a document fragment and using only one appendChild.
#145 (comment)
Resolved

This looks a little confusing. The purpose of this function is to render
an AsideMenu. When you name function makeAsideMenu it usually means that
it should return some kind of element, and this function does do that,
but you're not using this element in any way, because what it also does
is render the element on line 23 right away. Either rename the function
to something like renderAsideMenu and remove the return or keep the return,
remove rendering here and render somewhere outside this function using
the returned value.
#145 (comment)
Resolved
@LuckyDnepr
Copy link
Contributor Author

Thanks for review.
I solved the problems you pointed out.
Please, re-review.

@LuckyDnepr LuckyDnepr requested a review from al0tak August 22, 2022 12:29
@al0tak
Copy link

al0tak commented Aug 24, 2022

Good job!

@al0tak al0tak merged commit 30326ea into kottans:main Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants