-
-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add DOM homework #392
Add DOM homework #392
Conversation
Hey! Congratulations on your PR! 😎😎😎 Let's do some self-checks to fix most common issues and to make some improvements to the code before reviewers put their hands on the code. Go through the requirements/most common mistakes listed/linked below and fix the code as appropriate. If you have any questions to requirements/common mistakes feel free asking them here or in Students' chat. When you genuinely believe you are done put a comment stating that you have completed self-checks and fixed code accordingly. Also, be aware, that if you would silently ignore this recommendation, a mentor can think that you are still working on fixes. And your PR will not be reviewed. 😒 Please, make sure you haven't made common mistakes Universal recommendations:
Also take a note of the requirements above and follow them in all your future projects. By the way, you may proceed to the next task before this one is reviewed and merged. Sincerely yours, |
@misshatsker you should add a comment that you finish your self-check before a mentor starts to review your PR. |
@lysenko-sergey-developer thank you for informing!) I will do it immediately. |
I have finished self-check |
@misshatsker Great work! 💯 |
.header .menu-item .link:hover, | ||
.header .menu-btn:hover, | ||
.active-menu-item .link { | ||
background-color: #f4f4f4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this colour also to :root
</header> | ||
<main> | ||
<div class="full-main-page"> | ||
<img class="media-animal" alt=""> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to fill an alt attribute with an image description. That increases your code accessibility.
title: "Cats", | ||
media: "./media/cat.jpg", | ||
description: "Domestic cats are natural hunters able to stalk prey and pounce with sharp claws and teeth. They are particularly effective at night, when their light-reflecting eyes allow them to see better than much of their prey. Cats also enjoy acute hearing. All cats are nimble and agile, and their long tails aid their outstanding balance.", | ||
propertyLifespan: "Up to 18 years", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property
prefix is redundant
<div class="animal-main-info"> | ||
<h1 class="animal-category-title"></h1> | ||
<p class="animal-category-description"></p> | ||
<ul class="animal-property-list" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant space. Configure your code editor to see redundant spaces/tabs.
} | ||
]; | ||
|
||
const menuIcon = document.getElementsByClassName("menu-icon")[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using document.querySelector
will be more readable.
|
||
let isOpened = false; | ||
menuIcon.onclick = () => { | ||
if (isOpened) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can skip additional var isOpened
if you will use menuIcon.classList.contains
activeLi = li; | ||
} | ||
|
||
li.innerHTML = '<a class="link" href="#'+ animalTitle + '">' + animalTitle + '</a>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use template string over concatenations by +
|
||
changeMainPageInfo(animals[0]); | ||
|
||
let activeLi = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to wrap this part of the code in function with meaning name. Also will be cool if you will store activeLi
in closure.
li.innerHTML = '<a class="link" href="#'+ animalTitle + '">' + animalTitle + '</a>'; | ||
|
||
li.onclick = () => { | ||
closeMenu(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It closes menu each time, and even menu is not displayed.
|
||
li.innerHTML = '<a class="link" href="#'+ animalTitle + '">' + animalTitle + '</a>'; | ||
|
||
li.onclick = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use event bubbling technique to avoid adding a listener on each list item.
https://blog.logrocket.com/deep-dive-into-event-bubbling-and-capturing/
@lysenko-sergey-developer Thanks a lot for your review, Could you please check the changes? |
<p class="animal-category-description"></p> | ||
<ul class="animal-property-list"> | ||
<li class="property"> | ||
<img class="property-icon" src="./icons/heart.png" alt=""> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fill all empty alts
.
function appendMenuItems() { | ||
let previousLiEl = null; | ||
|
||
for (let i = 0; i < animals.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change for
to forEach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And move to function with a name something like fill Menu
weight.textContent = animal.weight; | ||
} | ||
|
||
changeMainPageInfo(animals[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move initial app state calls to file bottom
@misshatsker Good job! We need one last push and we did it! 🥇 |
@lysenko-sergey-developer Thanks! Could you re-review plz?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 😃
DOM
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.