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

new-log-viewer: In the menubar, show file name with a centered ellipsis when the name overflows (Fixes #97). #98

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

junhaoliao
Copy link
Member

@junhaoliao junhaoliao commented Oct 18, 2024

References

Fixes #97
new-log-viewer series: #45 #46 #48 #51 #52 #53 #54 #55 #56 #59 #60 #61 #62 #63 #66 #67 #68 #69 #70 #71 #72 #73 #74 #76 #77 #78 #79 #80 #81 #82 #83 #84 #89 #91 #93 #94 #96

Description

  1. Show file name with centered ellipsis in the menubar when the name overflows.

Validation performed

  1. Repeated the reproduction steps in the new-log-viewer: File name overflows the menubar when the name is too long. #97 issue report and observed now the menu bar is no longer getting overflowed.
  2. Resized the window in width and observed that the beginning and ending text of the file name was always visible, with the middle part showing more / less characters as the window was resizing. When the menu bar is not long enough to hold the full file name, an ellipsis showed in the middle; when the file name fully fits, the ellipsis is gone and all text was shown without any gap in between.
    image

Summary by CodeRabbit

  • New Features

    • Introduced a new CSS class for page number input to prevent content wrapping.
    • Added new classes for improved layout management of filename segments in the MenuBar component.
  • Improvements

    • Enhanced layout and styling of the MenuBar component for better responsiveness.
    • Updated file name display logic in the MenuBar for improved visual representation.
  • Bug Fixes

    • Adjusted overflow handling for filename segments to prevent visual overflow.

Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The changes introduced in this pull request involve modifications to the CSS and TypeScript files of the MenuBar component in the new-log-viewer project. A new CSS class .page-num-input has been added to prevent content wrapping, while several existing CSS classes have been updated for better layout and responsiveness. Additionally, the rendering logic of the MenuBar component has been altered to enhance the display of long file names by splitting them into two halves.

Changes

File Path Change Summary
new-log-viewer/src/components/MenuBar/PageNumInput.css New CSS class added: .page-num-input with white-space: nowrap;.
new-log-viewer/src/components/MenuBar/index.css Multiple updates: .menu-bar-logo-container changed to min-width: 48px; .menu-bar-filename renamed to .menu-bar-filename-container with new properties; two new classes .menu-bar-filename-left-split and .menu-bar-filename-right-split added.
new-log-viewer/src/components/MenuBar/index.tsx Modified MenuBar component: replaced Typography with Box for file name display, incorporating two Typography components for splitting the file name.

Assessment against linked issues

Objective Addressed Explanation
Prevent file name overflow in the menubar when the name is too long. (#[97])

Possibly related PRs

Suggested reviewers

  • kirkrodrigues

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e55a627 and 7667895.

📒 Files selected for processing (1)
  • new-log-viewer/src/components/MenuBar/index.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • new-log-viewer/src/components/MenuBar/index.tsx

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

@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 (3)
new-log-viewer/src/components/MenuBar/index.css (2)

25-30: Improved filename container styling and layout

The changes to the .menu-bar-filename-container class (renamed from .menu-bar-filename) effectively address the issue of long filenames overflowing. The addition of overflow-x: hidden; and display: flex; provides better control over the layout and prevents horizontal overflow.

The padding change to padding-inline: 0.75rem !important; ensures consistent padding on both sides. However, consider if the !important declaration is absolutely necessary, as it can make future style overrides more difficult.

If possible, try to avoid using !important by restructuring the CSS specificity instead.


37-40: Effective styling for right part of filename

The new .menu-bar-filename-right-split class effectively manages the right part of the filename display. The combination of overflow-x: hidden;, display: flex, and justify-content: flex-end; ensures that the right part of the filename is properly aligned and doesn't overflow.

However, consider if the !important declaration on display: flex is absolutely necessary. If possible, try to achieve the same result without using !important by restructuring the CSS specificity.

Evaluate if the !important declaration can be removed without affecting the desired layout.

new-log-viewer/src/components/MenuBar/index.tsx (1)

63-73: Excellent implementation of file name display

The new implementation effectively addresses the issue of long file names overflowing the menubar. Splitting the file name into two halves and using separate Typography components allows for displaying both the beginning and end of the file name, which is particularly useful for long names.

The title attribute on the Box component ensures that the full file name is accessible on hover, enhancing usability.

Suggestion for improvement:
Consider adding a visual indicator (like an ellipsis) between the two halves of the file name when it's truncated. This could be achieved by adding a third Typography component with a fixed width containing an ellipsis, placed between the two existing Typography components.

Would you like me to provide an example implementation of this suggestion?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ae24669 and e55a627.

📒 Files selected for processing (3)
  • new-log-viewer/src/components/MenuBar/PageNumInput.css (1 hunks)
  • new-log-viewer/src/components/MenuBar/index.css (1 hunks)
  • new-log-viewer/src/components/MenuBar/index.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • new-log-viewer/src/components/MenuBar/PageNumInput.css
🧰 Additional context used
🔇 Additional comments (5)
new-log-viewer/src/components/MenuBar/index.css (3)

17-17: Improved flexibility for logo container sizing

The change from width: 48px; to min-width: 48px; allows for more flexible sizing of the logo container while maintaining a minimum width. This adjustment aligns well with the PR objective of improving the layout for long filenames.


32-35: Effective styling for left part of filename

The new .menu-bar-filename-left-split class effectively manages the left part of the filename display. The combination of overflow-x: hidden; and text-overflow: ellipsis; ensures that long filenames are truncated with an ellipsis, preventing overflow and maintaining a clean layout. This implementation aligns perfectly with the PR objective of showing the filename with a centered ellipsis when it overflows.


17-40: Effective implementation of centered ellipsis for long filenames

The changes in this file successfully implement the solution for displaying long filenames with a centered ellipsis in the menubar. The combination of flexbox layout, overflow management, and the split of the filename into left and right parts effectively addresses the issue described in #97.

These changes align well with the PR objectives:

  1. They prevent filename overflow in the menubar.
  2. They ensure that both the beginning and end of long filenames remain visible.
  3. They allow for dynamic adjustment based on available space.

The implementation improves the user experience and maintains a clean, responsive layout. Great job on addressing this issue!

new-log-viewer/src/components/MenuBar/index.tsx (2)

4-4: LGTM: Import statement added for Box component

The addition of the Box import from @mui/joy is appropriate for the changes made in the component's rendering logic.


Line range hint 1-89: Overall impact: Effective solution for file name overflow

The changes implemented in this file successfully address the issue of long file names overflowing the menubar, as described in the linked issue #97. The new approach of splitting the file name display allows users to see both the beginning and end of long file names, improving usability.

The modifications are well-contained within the MenuBar component and don't appear to introduce any breaking changes or unintended side effects.

To ensure the changes work as expected across different scenarios:

Please run the following script to check for any potential regressions or unexpected behaviour:

This script will help identify any potential conflicts or areas that might need adjustment following these changes.

✅ Verification successful

Verification Successful: No Issues Found

The implemented changes to the MenuBar component do not introduce any regressions or conflicts. The component is only imported in Layout.tsx, and there are no hardcoded width values or other implementations affecting file name display.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of MenuBar component and potential impacts

# Test 1: Check if MenuBar is imported and used correctly in other components
echo "Checking MenuBar usage:"
rg --type typescript "import.*MenuBar" -g '!**/MenuBar/**'

# Test 2: Verify if there are any hardcoded width values for file name display that might conflict with the new implementation
echo "Checking for hardcoded file name widths:"
rg --type typescript --type css "width.*file.*name" -g '!**/MenuBar/**'

# Test 3: Look for any other components that might be handling file name display
echo "Checking for other file name display implementations:"
rg --type typescript "fileName.*display|display.*fileName" -g '!**/MenuBar/**'

Length of output: 585


Script:

#!/bin/bash
# Description: Verify the usage of MenuBar component and potential impacts

# Test 1: Check if MenuBar is imported and used correctly in other components
echo "Checking MenuBar usage:"
rg "import.*MenuBar" --glob '!**/MenuBar/**' --glob '*.ts' --glob '*.tsx'

# Test 2: Verify if there are any hardcoded width values for file name display that might conflict with the new implementation
echo "Checking for hardcoded file name widths:"
rg "width.*file.*name" --glob '!**/MenuBar/**' --glob '*.ts' --glob '*.tsx'
rg "width.*file.*name" --glob '!**/MenuBar/**' --glob '*.css'

# Test 3: Look for any other components that might be handling file name display
echo "Checking for other file name display implementations:"
rg "fileName.*display|display.*fileName" --glob '!**/MenuBar/**' --glob '*.ts' --glob '*.tsx'

Length of output: 652

@@ -14,15 +14,28 @@
.menu-bar-logo-container {
display: flex;
justify-content: center;
width: 48px;
min-width: 48px;
Copy link
Member Author

Choose a reason for hiding this comment

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

This avoids the YScope logo container from being squeezed when the other items in the menu bar try to take space.

Copy link
Contributor

@davemarco davemarco left a comment

Choose a reason for hiding this comment

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

LGTM

@junhaoliao junhaoliao changed the title new-log-viewer: Show file name with centered eclipse in the menubar when the name overflows (Fixes #97). new-log-viewer: Show file name with centered ellipsis in the menubar when the name overflows (Fixes #97). Oct 21, 2024
@junhaoliao junhaoliao changed the title new-log-viewer: Show file name with centered ellipsis in the menubar when the name overflows (Fixes #97). new-log-viewer: Show file name with a centered ellipsis in the menubar when the name overflows (Fixes #97). Oct 21, 2024
@junhaoliao junhaoliao changed the title new-log-viewer: Show file name with a centered ellipsis in the menubar when the name overflows (Fixes #97). new-log-viewer: In the menubar, show file name with a centered ellipsis when the name overflows (Fixes #97). Oct 21, 2024
@junhaoliao junhaoliao merged commit 02a80c8 into y-scope:main Oct 21, 2024
2 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.

new-log-viewer: File name overflows the menubar when the name is too long.
2 participants