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

Add DOM homework #392

Merged

Conversation

misshatsker
Copy link
Contributor

DOM

Demo |
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

@github-actions
Copy link

github-actions bot commented Sep 1, 2022

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:

  • Give variables and functions meaningful names. Avoid generic names like item, element, key, object, array or their variations. Exception: helper functions that are specifically and intentionally designed to be multipurpose.
  • Function names should start with a verb as they denote actions; variables are normally nouns; boolean variables/functions start with is, does, has etc; variable containing multiple entities and functions returning lists contain entity name in plural form.
  • Have consistent code style and formatting. Employ Prettier to do all dirty work for you.
  • Use common sense or seek for an advice whenever requirements look ambiguous or unclear.

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,
Submissions Kottachecker 😺

@lysenko-sergey-developer

@misshatsker you should add a comment that you finish your self-check before a mentor starts to review your PR.

@misshatsker
Copy link
Contributor Author

@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.

@misshatsker
Copy link
Contributor Author

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:

  • Give variables and functions meaningful names. Avoid generic names like item, element, key, object, array or their variations. Exception: helper functions that are specifically and intentionally designed to be multipurpose.
  • Function names should start with a verb as they denote actions; variables are normally nouns; boolean variables/functions start with is, does, has etc; variable containing multiple entities and functions returning lists contain entity name in plural form.
  • Have consistent code style and formatting. Employ Prettier to do all dirty work for you.
  • Use common sense or seek for an advice whenever requirements look ambiguous or unclear.

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, Submissions Kottachecker 😺

I have finished self-check

@lysenko-sergey-developer
Copy link

lysenko-sergey-developer commented Sep 13, 2022

@misshatsker Great work! 💯

.header .menu-item .link:hover,
.header .menu-btn:hover,
.active-menu-item .link {
background-color: #f4f4f4;

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="">

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",

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" >

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];

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) {

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>';

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;

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();

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 = () => {

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

UI/UX Improvement:

  1. Main content should have left and right margins between 1080px and 768px
  2. Image squeezing at screen width 800px. Your images have different aspect ratios. Try to play with them.
    Screenshot 2022-09-14 at 00 59 07

@misshatsker
Copy link
Contributor Author

@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="">

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++) {

Choose a reason for hiding this comment

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

Change for to forEach

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]);

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

@lysenko-sergey-developer

@misshatsker Good job! We need one last push and we did it! 🥇

@misshatsker
Copy link
Contributor Author

@lysenko-sergey-developer Thanks! Could you re-review plz?)

Copy link

@lysenko-sergey-developer lysenko-sergey-developer left a comment

Choose a reason for hiding this comment

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

LGTM! 😃

@lysenko-sergey-developer lysenko-sergey-developer merged commit c8ddd38 into kottans:main Sep 16, 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