Skip to content

Conversation

@MalusiS
Copy link

@MalusiS MalusiS commented Aug 13, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Summary
This PR implements the Image Carousel project with full Level 1 and Level 2 functionality as per the requirements. The carousel now supports both manual and automatic image navigation, with a clean and responsive layout.

Changes Made

HTML (index.html):

  • Updated title to "Image carousel".
  • Added auto-forward, auto-backward, and stop buttons for automatic navigation.
  • Grouped buttons into two neatly spaced rows for manual and auto controls.
  • Linked new style.css file for styling.

JavaScript (slideshow.js):

  • Implemented manual navigation (forward-btn, backward-btn) with wrap-around behavior.
  • Added automatic navigation (auto-forward and auto-backward) using setInterval.
  • Disabled auto buttons while slideshow is running and re-enabled on stop.
  • Stop button clears the interval without changing the current image.

CSS (style.css):

  • Centered carousel image with rounded corners and drop shadow.
  • Created evenly spaced, centered button rows with flex layout.
  • Added consistent button styling with hover effects and disabled states.
  • Ensured layout is presentation-ready and works across different screen sizes.

Testing

  • Passes all Level 1 & Level 2 tests from slideshow.test.js.
  • Verified wrap-around logic for both forward and backward navigation.
  • Confirmed timer interval is 2000ms and behaves correctly on stop.

Questions

Ask any questions you have for your reviewer.

@MalusiS MalusiS added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 13, 2025
@aedemarm aedemarm self-requested a review August 13, 2025 17:08
@aedemarm aedemarm added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 13, 2025
Copy link

@aedemarm aedemarm left a comment

Choose a reason for hiding this comment

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

This is a good PR:

  • good commit messages
  • great separation of concerns (dividing the functionality between functions)
  • good job with styling!

Looking at the Acceptance Criteria there is one that is failing:

Given the carousel is auto-advancing 
When either the forward or back button is clicked 
Then the auto-advance should stop

Please have a go at meeting this requirement.

There is no specific test for this. As an extra challenge you could try adding one or more tests for this functionality!

<button id="auto-backward">Auto Backwards</button>
<button id="auto-forward">Auto Forward</button>
<button id="stop">Stop</button>
</div>

Choose a reason for hiding this comment

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

The html updates are logical!
NTH (Nice to Have/ Not required for completion): semantic html
How might you refactor this to use semantic html to improve accessibility and maintainability? (https://www.freecodecamp.org/news/semantic-html5-elements/)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for great feedback! I have updated slideshow.js so that clicking the forward or back buttons while auto-advancing now stops the auto-advance as per the acceptance criteria. I also added a test to verify that manual navigation stops auto-advance mode.

Copy link
Author

@MalusiS MalusiS Aug 14, 2025

Choose a reason for hiding this comment

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

Thanks again for the suggestion. I have now wrapped all slideshow controls (manual and automatic) in a single semantic section with a heading. Manual and auto buttons are visually separated into rows, but screen readers and assistive technologies will now recognize all controls as part of one cohesive group. This improves accessibility, semantic clarity, and maintainability without changing the existing functionality.


autoForwardBtn.addEventListener("click", () => startAuto(nextImage));
autoBackwardBtn.addEventListener("click", () => startAuto(prevImage));
stopBtn.addEventListener("click", stopAuto);

Choose a reason for hiding this comment

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

Good job separating concerns! The individual functions make the code more readable.

Copy link
Author

Choose a reason for hiding this comment

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

I appreciate all the great feedback you have given.

@aedemarm aedemarm added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 13, 2025
@MalusiS MalusiS added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 14, 2025
Copy link

@aedemarm aedemarm left a comment

Choose a reason for hiding this comment

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

Well done making the changes: it's working well and your comments about the changes you made to the html make sense.

I have left a few additional comments on this PR to improve it but these are just suggestions and not required.

});
});

test("clicking forward or backward while auto-advancing stops auto mode", () => {

Choose a reason for hiding this comment

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

Good job adding this test!

NTH/Not necessary to fix: separate into two tests

This is testing a couple of pieces of functionality: (1) that when you hit the forward button while auto-advancing, the auto-advancing stops and the carousel moves to the next image and (2) that when you hit the back button while auto-advancing, the auto-advancing stops and the carousel moves to the previous image. In this scenario, it is cleaner to write 2 tests. That way if there are test failures, you can pinpoint more easily exactly why. It is also good practice for maintainability: just like with other code, when a test does too much and becomes too complicated, it becomes difficult to read, understand and maintain for future you and your team.

Copy link
Author

Choose a reason for hiding this comment

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

This is great feedback! I see how advantageous it would be to write two tests here, instead of having one test that does too much. I really appreciate your valuable and substantive feedback.

autoBackwardBtn.addEventListener("click", () => startAuto(() => {
currentIndex = (currentIndex - 1 + images.length) % images.length;
showImage(currentIndex);
}));

Choose a reason for hiding this comment

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

NTH/ Not necessary to do: remove duplication

This code is very similar to the prevImage/nextImage code. In your original PR you reused these methods for the auto functionality, which was good.

Suggestion: You have already seen how you can wrap a function around another to add to it (your startAuto function is a wrapper). Perhaps you could use the same idea for your manual navigation functionality.

@aedemarm aedemarm added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants