Skip to content

feat: added close callout btn #933

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 3, 2024

Conversation

brokewhale
Copy link
Contributor

added callout close btn

Screen.Recording.2024-09-26.at.8.40.24.PM.mov

@brokewhale brokewhale requested a review from a team as a code owner September 26, 2024 19:44
Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes introduce a close button functionality to the WipCallout component, allowing users to hide the callout. A new state variable manages its visibility, and the component's styling is adjusted to accommodate the close button. Additionally, minor formatting adjustments are made to related callout components. The CSS updates include changes to the positioning of the callout and the introduction of a new class for the close button.

Changes

File Change Summary
components/WipCallout.tsx Added close button functionality with a new state variable to manage visibility of the callout.
styles/global.css Updated styling for div.custom-callouts (positioning, padding, z-index) and added .callout-close-btn class.

Possibly related PRs

  • feat: added wip callout feature #769: This PR introduces the WipCallout component, which is directly related to the changes made in the main PR, as both involve modifications to the same component in components/WipCallout.tsx.
  • Make callouts fixed instead of sticky #925: This PR modifies the CSS for callouts, specifically changing the position property from sticky to fixed, which is relevant to the styling changes made in the main PR's styles/global.css file.

Suggested reviewers

  • 0xmariniere
  • cpengilly

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.

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

netlify bot commented Sep 26, 2024

Deploy Preview for docs-optimism ready!

Name Link
🔨 Latest commit 1a85dee
🔍 Latest deploy log https://app.netlify.com/sites/docs-optimism/deploys/66f5b9a9020b7c00081bef24
😎 Deploy Preview https://deploy-preview-933--docs-optimism.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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: 0

🧹 Outside diff range and nitpick comments (2)
styles/global.css (1)

78-92: Close button implemented, consider improving mobile usability

The new .callout-close-btn class successfully implements the close button for callouts as per the PR objective:

  • Absolute positioning ensures consistent placement at the top-right corner.
  • The circular design and color scheme are appropriate for a close button.

However, the button's small size (25x25px) might be difficult to interact with on mobile devices. Consider the following improvements:

  1. Increase the button size for better touch targets on mobile:
-  width: 25px;
-  height: 25px;
+  width: 44px;
+  height: 44px;
  1. Add a media query to adjust the button size for larger screens:
@media (min-width: 768px) {
  .callout-close-btn {
    width: 25px;
    height: 25px;
  }
}
  1. Consider adding a hover effect for desktop users:
.callout-close-btn:hover {
  background-color: #ffdc00;
  cursor: pointer;
}
components/WipCallout.tsx (1)

44-49: Close button added, but consider improving accessibility

The close button is correctly implemented with the appropriate onClick event handler. However, to improve accessibility:

  1. Add an aria-label attribute to describe the button's function.
  2. Consider using a more descriptive text or an icon with alt text instead of just 'x'.

Here's a suggested improvement:

 <button
-  className="callout-close-btn"
+  className="callout-close-btn"
+  aria-label="Close callout"
   onClick={() => setCloseCallout(true)}
 >
-  x
+  Close
 </button>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1810438 and 1a85dee.

📒 Files selected for processing (2)
  • components/WipCallout.tsx (4 hunks)
  • styles/global.css (1 hunks)
🔇 Additional comments (7)
styles/global.css (2)

57-92: Overall implementation aligns with PR objective

The changes successfully implement the close button for callouts as described in the PR objective. The modifications to div.custom-callouts and the new .callout-close-btn class work together to create a functional and visually consistent feature.

To further enhance the implementation, consider:

  1. Addressing the potential mobile layout issues by re-introducing a media query for smaller screens.
  2. Improving the close button's usability on mobile devices by adjusting its size and adding touch-friendly interactions.

These refinements will ensure a better user experience across all devices while maintaining the intended functionality.


57-60: Improved callout visibility, but consider mobile layout

The changes to div.custom-callouts enhance the visibility and user experience:

  • Sticky positioning keeps the callout visible while scrolling.
  • Adjusted top value and padding improve spacing.
  • High z-index (9999) ensures the callout appears above other elements.

However, the removal of the media query for screens below 767px might affect the layout on smaller devices.

To ensure proper mobile layout, please run the following script:

Also applies to: 63-63

components/WipCallout.tsx (5)

13-13: LGTM: useState import added correctly

The addition of the useState import is appropriate for the new state management in the WipCallout component.


19-19: LGTM: State variable for close functionality added

The closeCallout state variable is correctly implemented using the useState hook. This will effectively manage the visibility of the callout.


21-25: LGTM: Conditional class for hiding callout implemented correctly

The conditional application of the 'nx-hidden' class based on the closeCallout state is well-implemented. This will effectively hide the callout when the close button is clicked.


62-67: LGTM: Text updates in InfoCallout and AltCallout

The text modifications in both InfoCallout and AltCallout components improve the clarity of the messages. These changes don't affect functionality and provide better information to users.

Also applies to: 84-89


Line range hint 1-93: Summary: Close button functionality added successfully

The implementation of the close button in the WipCallout component is well-done and aligns with the PR objectives. The state management and conditional rendering are implemented correctly.

To ensure the robustness of this new feature:

  1. Consider adding unit tests for the WipCallout component to verify the close functionality.
  2. Implement end-to-end tests to confirm the button works as expected in the actual UI.

To verify the implementation, you can run the following commands:

This will help identify any existing tests and determine where new tests should be added.

Copy link
Member

@bradleycamacho bradleycamacho left a comment

Choose a reason for hiding this comment

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

Looks great! As long as the button is actually clickable on mobile and you check out my small comment, this looks great to me! Thanks!!

@bradleycamacho
Copy link
Member

Looks great! As long as the button is actually clickable on mobile and you check out my small comment, this looks great to me! Thanks!!

Can confirm the button works on mobile btw

Copy link
Contributor Author

@brokewhale brokewhale left a comment

Choose a reason for hiding this comment

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

@krofax
Copy link
Collaborator

krofax commented Sep 27, 2024

@bradleycamacho please approval and merge.

@krofax krofax merged commit 5090547 into ethereum-optimism:main Oct 3, 2024
5 of 6 checks passed
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.

3 participants