8000 Fix CCJ-123: add "close" button to victory modal by nwinter · Pull Request #7764 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix CCJ-123: add "close" button to victory modal #7764

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

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

nwinter
Copy link
Contributor
@nwinter nwinter commented Oct 15, 2024
Screenshot 2024-10-15 at 10 50 02

Also makes it so that keyboard focus goes to "continue" button in victory modal, which lets you press escape to close the modal, instead of staying in the ace editor.

Fixes a random extra box shadow in CourseVictoryModal that was causing minor visual glitching.

Trivial refactor to some logging code that was decaffeinated poorly and logging in two cases instead of one.

Summary by CodeRabbit

  • New Features

    • Introduced a close button in the hero victory modal for improved user interaction.
    • Added keyframe animations for enhanced visual feedback.
  • Style Updates

    • Updated styles for the course and hero victory modals, including adjustments for responsiveness and layout.
  • Bug Fixes

    • Streamlined error handling and event management in the modal views for better performance.

Also makes it so that keyboard focus goes to "continue" button in
victory modal, which lets you press escape to close the modal, instead
of staying in the ace editor.

Fixes a random extra box shadow in CourseVictoryModal that was causing
minor visual glitching.

Trivial refactor to some logging code that was decaffeinated poorly
and logging in two cases instead of one.
Copy link
Contributor
coderabbitai bot commented Oct 15, 2024

Walkthrough

This pull request introduces modifications to the styling and functionality of victory modals in the application. Key changes include the addition of a close button in the hero victory modal, updates to SASS styles for both course and hero victory modals, and improvements to the ModalView and HeroVictoryModal classes for better event handling and rendering. These changes aim to enhance user interaction and streamline the modal experience.

Changes

File Path Change Summary
app/styles/play/level/modal/course-victory-modal.sass Updated SASS styles to remove box-shadow from .modal-content.
app/styles/play/level/modal/hero-victory-modal.sass Added .close-button class, adjusted margins and dimensions, introduced rewardPulse keyframes, and enhanced media queries.
app/templates/play/level/modal/hero-victory-modal.pug Added a close button element in the modal header for improved user interaction.
app/views/core/ModalView.js Modified ModalView class to streamline trapFocus method and improve logging and error handling.
app/views/play/level/modal/HeroVictoryModal.js Enhanced HeroVictoryModal class with modern JavaScript practices and improved rendering logic.

Assessment against linked issues

Objective Addressed Explanation
Add a way to replay levels (CCJ-123)

Possibly related PRs

  • ENG-1198 - fix modal scroll on small screens #7749: This PR addresses modal functionality, specifically improving responsiveness and scrolling on small screens, which is relevant to the changes made in the main PR regarding modal styles and user interaction enhancements.

Suggested reviewers

  • mrfinch

Poem

In the modal bright, a button to close,
With styles refined, the victory glows.
A pulse of reward, as joy takes flight,
Click away, dear player, into the night! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
app/styles/play/level/modal/course-victory-modal.sass (1)

Close Button Not Implemented

The shell scripts did not find any instances of id="close-modal" in the HTML or JavaScript files, nor were there recent commits related to close-modal. It appears that the close button referenced in the PR objectives has not been implemented. Please ensure that the close button is added to the HTML template and that appropriate JavaScript event listeners are in place.

🔗 Analysis chain

Line range hint 52-59: Verify the implementation of the close button.

I notice that there's an existing style for #close-modal in this file. Could you please confirm if this style is being used for the newly added close button mentioned in the PR objectives? If so, it might be worth reviewing if the positioning and styling (e.g., color, padding) are still appropriate for the new implementation.

To ensure the close button is properly implemented and styled, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of the close button in the victory modal.

# Test 1: Check for the presence of a close button in the HTML template
echo "Checking for close button in HTML template:"
rg --type html 'id="close-modal"' -A 5 -B 5

# Test 2: Verify if there are any JavaScript event listeners for the close button
echo "Checking for close button event listeners in JavaScript:"
rg --type js 'getElementById\("close-modal"\)' -A 5 -B 5

# Test 3: Look for any recent changes related to the close button
echo "Checking for recent changes related to the close button:"
git log -p -S "close-modal" --since="1 month ago"

Length of output: 497

app/views/core/ModalView.js (3)

54-54: Approved: Removal of return statement improves method flow.

The removal of the return statement from this.trapFocus() is a good change. It ensures that the render method completes its execution after trapping the focus, which is the expected behavior.

For improved clarity, consider adding a comment explaining the purpose of calling trapFocus here:

// Ensure keyboard focus is trapped within the modal
this.trapFocus()

86-93: Approved: Improved error handling and code readability.

The changes in the trapFocus method are well-implemented:

  1. Simplified condition for checking this.focusTrap.
  2. Improved error handling with optional chaining.
  3. Updated console logging with optional chaining.

These changes enhance code readability and reduce the risk of null pointer exceptions.

For consistency, consider using optional chaining for the console.log statement in the catch block as well:

console.log(this.constructor?.name, 'not trapping focus for modal with no focusable elements')

Line range hint 1-150: Overall: Good improvements to modal functionality and code quality.

The changes in this file contribute to better code maintainability, reduced risk of runtime errors, and improved accessibility through enhanced focus trapping. These modifications align well with the PR objectives of enhancing the modal functionality and user experience.

Consider adding JSDoc comments to the ModalView class and its methods to improve code documentation and maintainability. This will be particularly helpful for the trapFocus method, which plays a crucial role in accessibility.

app/styles/play/level/modal/hero-victory-modal.sass (2)

100-104: LGTM: Close button styling added.

The close button styling has been appropriately positioned. However, consider the following suggestions:

  1. Add a specific color to ensure visibility across different themes.
  2. Consider adding hover and focus states for better user interaction.
  3. Ensure the large font size (50px) doesn't cause any layout issues.

Would you like me to provide example styles for hover and focus states?


Line range hint 365-377: LGTM: Reward pulse animation added.

The rewardPulse keyframes and corresponding animations for XP and gems look good. They will create an engaging visual effect for the rewards.

Suggestion for optimization:
Consider using the will-change property to hint the browser about the animation:

.xp .pulse, .gems .pulse
  will-change: transform

This can potentially improve performance, especially on mobile devices.

Would you like me to provide more information about the will-change property and its benefits?

app/views/play/level/modal/HeroVictoryModal.js (1)

330-330: Inconsistent Use of Optional Chaining Operator ?.

The optional chaining operator ?. is used here but isn't consistently used elsewhere in the codebase. For consistency and readability, consider using standard jQuery chaining or consistently using optional chaining throughout the file.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e4ae776 and 21e4520.

📒 Files selected for processing (5)
  • app/styles/play/level/modal/course-victory-modal.sass (1 hunks)
  • app/styles/play/level/modal/hero-victory-modal.sass (1 hunks)
  • app/templates/play/level/modal/hero-victory-modal.pug (1 hunks)
  • app/views/core/ModalView.js (2 hunks)
  • app/views/play/level/modal/HeroVictoryModal.js (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
app/styles/play/level/modal/course-victory-modal.sass (1)

21-21: LGTM: Box shadow removal addresses the visual glitch.

This change aligns with the PR objectives by removing the extra box shadow from the CourseVictoryModal. It should resolve the visual glitch mentioned in the PR summary, improving the overall appearance of the modal.

app/templates/play/level/modal/hero-victory-modal.pug (1)

Line range hint 1-238: LGTM: Close button addition improves user experience

The addition of the close button to the hero victory modal aligns well with the PR objectives to enhance user experience. This change allows users to easily dismiss the modal, providing an alternative to the existing "Continue" button.

The rest of the file remains unchanged, preserving the existing functionality of the victory modal, including:

  • Display of victory text and course information
  • Level feedback and rating system
  • Achievement and reward displays
  • XP and gem totals
  • Sharing options
  • Navigation buttons for continuing or returning to other sections

These preserved elements ensure that the modal continues to provide valuable information and options to the user upon completing a level.

app/styles/play/level/modal/hero-victory-modal.sass (1)

Line range hint 1-377: Summary: Changes align with PR objectives and enhance user experience.

The modifications to this SASS file successfully implement the close button for the victory modal and improve the visual feedback for rewards. These changes align well with the PR objectives and should enhance the overall user experience.

Key points:

  1. The close button styling allows for easy modal dismissal.
  2. The reward pulse animations add engaging visual feedback.

These changes contribute to addressing the usability concern mentioned in the linked issue CCJ-123, providing users with more control over the victory modal interaction.

Comment on lines +13 to +14
button.close-button.btn.btn-illustrated.btn-lg.btn-warning(type="button", data-dismiss="modal", aria-hidden="true", tabindex=-1) &times;

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider relocating the close button to the modal header

The close button has been added to the modal body content, which is an unusual placement. Typically, close buttons are located in the modal header for consistency and user expectation.

  1. Consider moving this button to the modal-header-content block for better alignment with standard modal designs.
  2. The tabindex="-1" attribute may interfere with keyboard navigation. Consider removing it to allow natural tab order, or ensure it doesn't negatively impact accessibility.
  3. For better accessibility, consider adding an aria-label to the button, e.g., aria-label="Close".

Here's a suggested relocation of the close button to the modal header:

block modal-header-content
  button.close-button.btn.btn-illustrated.btn-lg.btn-warning(type="button", data-dismiss="modal", aria-hidden="true", aria-label="Close") &times;
  #victory-header.out
    // ... rest of the header content

This change would place the close button in a more standard location and improve its accessibility.

@mrfinch mrfinch merged commit 90b9fe2 into master Oct 16, 2024
2 checks passed
@mrfinch mrfinch deleted the nwinter/replay-from-victory-modal branch October 16, 2024 17:15
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
0