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

Feedback #1

Open
wants to merge 28 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 28 commits into from

Conversation

github-classroom[bot]
Copy link

@github-classroom github-classroom bot commented Mar 9, 2024

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to main since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to main since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @adeledsg

adeledsg and others added 2 commits April 15, 2024 18:23
user is not allowed to add more than one images to a div, adjsuted cs…
Copy link
Member

@joemull joemull left a comment

Choose a reason for hiding this comment

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

Really impressive! I've left a bunch of detailed comments here in GitHub, but a summary and mark will be sent out a bit later as well.

img3.src = "puzzle1/piece4.png";
img3.width = "199";
img3.height = "232";
img3.alt = "puzzle piece 4"
Copy link
Member

Choose a reason for hiding this comment

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

This is good for a simple puzzle, but as you say in the report, it would be good to make the code DRYer (referring to the principle of "don't repeat yourself"). Maybe the best way to do that is to store the data needed to construct the puzzle in a bit of JSON, and then iterate over it to populate the HTML.

By the way, I do like the style of short lines and good descriptive variables, as it is nice and readable.


Array.from(dropZone).forEach(function(zone){ //Iterating through elements with this class name as DOM returns the elements as an array
zone.style.border = "1px solid black"; //adding borders to div to indicate users where to put the pieces
});
Copy link
Member

Choose a reason for hiding this comment

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

Great use of Array.from and forEach

piece.style.left = `${leftPosition}%`;
piece.style.top = `${topPosition}%`
pieceContainer.appendChild(piece);
});
Copy link
Member

Choose a reason for hiding this comment

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

Great idea!

startButton.style.display = 'flex'; // Showing the start button
let element = e.target;
window.location.reload(); // https://www.freecodecamp.org/news/javascript-refresh-page-how-to-reload-a-page-in-js/#:~:text=The%20simplest%20way%20to%20refresh,and%20loading%20the%20latest%20content.
});
Copy link
Member

Choose a reason for hiding this comment

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

I like the start and reset buttons--they definitely put the user in control of the game and feel nice and intuitive.

e.stopPropagation(); // ensure that the click event is just on the image not its parent
if (e.type === 'dragstart') {
console.log(e);
e.dataTransfer.setData('text/plain', e.currentTarget.id); //Seeting the data to add id to my target element that is my div and retriving it in drop- source: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setData
Copy link
Member

Choose a reason for hiding this comment

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

Excellent. This is complicated stuff!

#puzzle-container{ /*All puzzles*/
display: flex;
flex-direction: row;
flex-wrap: wrap;
Copy link
Member

Choose a reason for hiding this comment

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

I think the best approach for this kind of layout is a CSS grid. It would provide more fine-grained control with less repetitive code.

Copy link
Member

Choose a reason for hiding this comment

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

This was a lot of work! I recognize that and also the difficulty of getting the display for something like a puzzle to work, with so many possible states that the game could be in. But I do think this CSS is too repetitive and should have been reduced by breaking down the display into elements that could each be coded once (or a few times for things like media queries).

flex-direction: row;
flex-wrap: wrap;
width: 70%; /*For all media queries, I toogled width and height each time until i was visually satisfied*/
height: calc(50% - 1vh); /*For all media queries, I toogled width and height each time until i was visually satisfied*/
Copy link
Member

Choose a reason for hiding this comment

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

There are two choices here that may be causing issues: 1) the choice to use percentages in width and height units, and 2) the choice to define both width and height, rather than just one. Together these seem to be causing skewing when the viewport is taller or wider than the width and height at which it was coded.

image

I suspect it is also making it more difficult to get the pieces to align without gaps.

Did you experiment with using rem or em units (with only x or y specified, not both)? It may be you'd have the same issues with that approach, but if not, it's worth a try.

flex-direction: row;
flex-wrap: wrap;
width: 50%;
height: 50%;
Copy link
Member

Choose a reason for hiding this comment

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

As with the container, I'm curious whether each piece's layout could be improved by defining just width OR height and using em or rem rather than percentages.


}

@media (max-width: 767px) and (orientation: landscape){
Copy link
Member

Choose a reason for hiding this comment

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

Great that you are considering portrait vs landscape! Helps with the responsiveness for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants