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

[XS][1648] Add noWrap to team name display in TeamCharacterSelector #2518

Merged
merged 5 commits into from
Oct 27, 2024

Conversation

BaruYogesh
Copy link
Contributor

@BaruYogesh BaruYogesh commented Oct 24, 2024

Describe your changes

My first PR in this repo. Not familiar with mUI so bear with me. I just added a noWrap to a typography element, then added a nested typography element (is this ok?). i needed a nested element in order to keep using flex on the parent element, as ellipses wrap only works for inline display

willing to add more to other relevant areas when i hear that this is an acceptable pattern for approach.

Issue or discord link

Resolves #1648

Testing/validation

Screen.Recording.2024-10-23.at.10.20.22.PM.mov

Checklist before requesting a review (leave this PR as draft if any part of this list is not done.)

  • I have commented my code in hard-to understand areas.
  • I have made corresponding changes to README or wiki.
  • For front-end changes, I have updated the corresponding English translations.
  • I have run yarn run mini-ci locally to validate format and lint.
  • If I have added a new library or app, I have updated the deployment scripts to ignore changes as needed

Summary by CodeRabbit

  • New Features

    • Enhanced styling and readability of the TeamCharacterSelector component.
    • Improved text wrapping for the team name display to prevent overflow.
    • Added a new Typography component to display the active build name alongside the character's name.
    • Updated dropdown button styling to handle long text with ellipsis.
  • Bug Fixes

    • Adjusted properties to ensure the team name is displayed correctly without layout issues.
  • Refactor

    • Streamlined the JSX structure for better clarity and maintainability.
    • Refined layout and styling of the LoadoutDropdown component for improved text handling.
    • Enhanced the BuildCard component's title styling for better presentation.

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes made to the TeamCharacterSelector component in libs/gi/page-team/src/TeamCharacterSelector.tsx involve modifications to the JSX structure and styling. Enhancements include a reformatted Box component for better styling readability, updates to the Typography elements for improved text wrapping and overflow management, and minor structural refinements for clarity. The function signature has been updated to include specific parameters. Similar adjustments have been made to the Content.tsx and LoadoutDropdown.tsx files, focusing on layout and styling improvements while preserving core functionality.

Changes

File Path Change Summary
libs/gi/page-team/src/TeamCharacterSelector.tsx - JSX structure and styling modifications.
- Reformatted Box component for styling clarity.
- Updated Typography components for better text wrapping and added noWrap property.
- Minor structural refinements for clarity.
- Function signature updated to include specific parameters.
libs/gi/page-team/src/CharacterDisplay/Content.tsx - Enhancements to CharacterPanel and TabNav components.
- Added noWrap property to Typography for character name.
- New Typography for active build name.
- Corrected parameter name in handleDesc function.
- Minor layout and styling adjustments.
libs/gi/page-team/src/LoadoutDropdown.tsx - Layout and styling modifications to dropdown button's title.
- Added CSS properties for text handling in the dropdown.
libs/gi/ui/src/components/build/BuildCard.tsx - Updated BuildCard title rendering to use Typography with noWrap and gutterBottom properties for improved styling.

Possibly related PRs

  • add typecheck to SRO #2515: The changes in the main PR focus on enhancing the TeamCharacterSelector component, which includes updates to the Typography component with the noWrap property. This is similar to the updates in the Content.tsx file from the retrieved PRs, where the Typography component also received a noWrap property to prevent text overflow.

Suggested reviewers

  • nguyentvan7

Poem

In the code where rabbits play,
We’ve tidied up and brightened the way.
Typography dances, no text will overflow,
With boxes aligned, watch the styling glow!
So hop along, let’s celebrate this cheer,
For clearer code brings us all near! 🐇✨


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

github-actions bot commented Oct 24, 2024

[frontend] [Thu Oct 24 02:25:51 UTC 2024] - Deployed 8cd2bbe to https://genshin-optimizer-prs.github.io/pr/2518/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Thu Oct 24 21:56:16 UTC 2024] - Deployed 28fd2c6 to https://genshin-optimizer-prs.github.io/pr/2518/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Sat Oct 26 23:33:41 UTC 2024] - Deployed 00a5605 to https://genshin-optimizer-prs.github.io/pr/2518/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Sun Oct 27 01:18:43 UTC 2024] - Deployed 4001c29 to https://genshin-optimizer-prs.github.io/pr/2518/frontend (Takes 3-5 minutes after this completes to be available)

[Sun Oct 27 19:18:44 UTC 2024] - Deleted deployment

Copy link
Owner

@frzyc frzyc left a comment

Choose a reason for hiding this comment

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

I think there is another location to apply this change, according to the issue:
https://github.com/frzyc/genshin-optimizer/blob/master/libs/gi/page-team/src/CharacterDisplay/Content.tsx#L168

@@ -146,17 +152,19 @@ export default function TeamCharacterSelector({
}}
>
<Typography
Copy link
Owner

@frzyc frzyc Oct 24, 2024

Choose a reason for hiding this comment

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

I think we can simplify the hierarchy:

  • CardContent (flex, gap, align+justify:center, hover)
    • TeamIcon
    • Typography ( nowrap, h5, textshadow)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this worked 👍

@BaruYogesh
Copy link
Contributor Author

I think there is another location to apply this change, according to the issue: https://github.com/frzyc/genshin-optimizer/blob/master/libs/gi/page-team/src/CharacterDisplay/Content.tsx#L168

Screenshot 2024-10-24 at 10 09 14 AM

absolutely, i wanted to verify the approach before adding to other spots. let me know if this all looks right or if there are other spots you are thinking of (new to this app)

@frzyc
Copy link
Owner

frzyc commented Oct 24, 2024

I think there is another location to apply this change, according to the issue: https://github.com/frzyc/genshin-optimizer/blob/master/libs/gi/page-team/src/CharacterDisplay/Content.tsx#L168

Screenshot 2024-10-24 at 10 09 14 AM absolutely, i wanted to verify the approach before adding to other spots. let me know if this all looks right or if there are other spots you are thinking of (new to this app)

I wonder what happens when you have both a long loadout name and a long build name?

@frzyc
Copy link
Owner

frzyc commented Oct 24, 2024

I think there is another location to apply this change, according to the issue: https://github.com/frzyc/genshin-optimizer/blob/master/libs/gi/page-team/src/CharacterDisplay/Content.tsx#L168

Screenshot 2024-10-24 at 10 09 14 AM absolutely, i wanted to verify the approach before adding to other spots. let me know if this all looks right or if there are other spots you are thinking of (new to this app)

I wonder what happens when you have both a long loadout name and a long build name?
Looks like need to nowrap the build name as well
image

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bfd232a and f2ec382.

📒 Files selected for processing (2)
  • libs/gi/page-team/src/CharacterDisplay/Content.tsx (1 hunks)
  • libs/gi/page-team/src/LoadoutDropdown.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • libs/gi/page-team/src/LoadoutDropdown.tsx
🔇 Additional comments (1)
libs/gi/page-team/src/CharacterDisplay/Content.tsx (1)

176-176: LGTM: Proper vertical alignment added

The addition of alignItems: 'center' ensures proper vertical alignment of content within the card.

Comment on lines +194 to +203
<Typography
variant="h6"
noWrap
sx={{
gap: 1,
alignItems: 'center',
justifyContent: 'center',
textShadow: '#000 0 0 10px !important',
}}
>
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 flexible width distribution for long names

While the noWrap property prevents text wrapping as intended, consider adding flexible width distribution between character name and build name to handle cases where both are long.

Consider applying this improvement:

 <Typography
   variant="h6"
   noWrap
   sx={{
     gap: 1,
     alignItems: 'center',
     justifyContent: 'center',
     textShadow: '#000 0 0 10px !important',
+    flexShrink: 1,
+    minWidth: 0,
+    overflow: 'hidden',
+    textOverflow: 'ellipsis'
   }}
 >

This change would:

  1. Allow the Typography to shrink when space is limited
  2. Ensure text truncation with ellipsis when content overflows
  3. Maintain the desired single-line display
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Typography
variant="h6"
noWrap
sx={{
gap: 1,
alignItems: 'center',
justifyContent: 'center',
textShadow: '#000 0 0 10px !important',
}}
>
<Typography
variant="h6"
noWrap
sx={{
gap: 1,
alignItems: 'center',
justifyContent: 'center',
textShadow: '#000 0 0 10px !important',
flexShrink: 1,
minWidth: 0,
overflow: 'hidden',
textOverflow: 'ellipsis'
}}
>

Comment on lines +179 to +191
<PersonIcon />
<Typography
variant="h6"
noWrap
sx={{
display: 'flex',
gap: 1,
alignItems: 'center',
justifyContent: 'center',
textShadow: '#000 0 0 10px !important',
}}
>
<PersonIcon />
<strong>{teamChar.name}</strong>
<Divider orientation="vertical" variant="middle" flexItem />
<CheckroomIcon />
</Typography>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add maxWidth and text overflow handling for character names

The Typography component with noWrap lacks maxWidth constraints and text overflow handling, which could lead to layout issues with long character names. Add the following properties to the Typography's sx prop:

  • maxWidth
  • textOverflow: 'ellipsis'
  • overflow: 'hidden'
🔗 Analysis chain

Verify text overflow handling for long character names

The addition of noWrap prevents text wrapping as intended. However, we should ensure proper text truncation for long character names.

Let's verify the text overflow behavior:


Let me check the surrounding context of the Typography component to better understand the layout constraints.


Let me try a different approach to check the component's structure and styling.


Let me check the parent container's styling to understand the width constraints.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any maxWidth constraints or text overflow handling in the codebase
rg -g '*.tsx' -g '*.ts' 'textOverflow|maxWidth.*Typography' ./libs/gi/page-team/

Length of output: 166


Script:

#!/bin/bash
# Check the parent container's styling and width constraints
rg -g '*.tsx' -A 10 -B 10 '<Typography.*variant="h6".*noWrap' ./libs/gi/page-team/src/

Length of output: 88


Script:

#!/bin/bash
# Get the full content of CharacterDisplay/Content.tsx to understand the layout context
rg -g 'Content.tsx' -A 5 -B 5 'PersonIcon' ./libs/gi/page-team/src/CharacterDisplay/

Length of output: 2880


Script:

#!/bin/bash
# Get more context around the Typography component to see the parent container
rg -g 'Content.tsx' -A 20 -B 20 'variant="h6".*noWrap' ./libs/gi/page-team/src/CharacterDisplay/

Length of output: 96

@BaruYogesh
Copy link
Contributor Author

Screenshot 2024-10-26 at 6 35 16 PM fixed! new to this app thanks for informing. Screenshot 2024-10-26 at 6 35 10 PM i tried to use typography nowrap for the buildcard, didnt quite turn out how i like lol

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f2ec382 and be4568f.

📒 Files selected for processing (1)
  • libs/gi/ui/src/components/build/BuildCard.tsx (1 hunks)
🔇 Additional comments (1)
libs/gi/ui/src/components/build/BuildCard.tsx (1)

49-53: Verify text overflow behavior with long build names.

The addition of noWrap aligns with the PR objectives. However, ensure that the text overflow behavior works as expected with extremely long build names.

Let's verify the maximum build name length in the codebase:

✅ Verification successful

Text overflow handling is appropriate for the component's usage

Based on the codebase analysis:

  • The BuildCard component is used in simplified build views where names are passed directly as props
  • The component is used in a controlled context within character editors
  • The noWrap with ellipsis is an appropriate solution as:
    • It maintains consistent card heights in the layout
    • It prevents layout shifts from multi-line names
    • It preserves the visual hierarchy in the card header
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find the longest build names in the codebase to verify overflow behavior
# Look for build name assignments or definitions
rg -U "name['\"]?\s*[:=]\s*['\"]([^'\"]*)['\"" --multiline

Length of output: 195


Script:

#!/bin/bash
# Let's try a different approach to find build name patterns
# Search for name prop usage in BuildCard components
rg -U "name.*=.*" "BuildCard" -A 2 -B 2

# Also search for test files that might contain build name examples
fd "build.*test|test.*build" -e ts -e tsx -e js -e jsx --exec rg -l "name.*=.*"

# Look for mock data or fixtures related to builds
fd "mock|fixture" --exec rg -l "build.*name|name.*build"

Length of output: 230


Script:

#!/bin/bash
# Search for BuildCard component usage in the codebase
rg -U "BuildCard.*name.*=.*" -A 2 -B 2

# Look for the actual BuildCard component file
fd "BuildCard.tsx"

# Search for test files containing BuildCard
rg "BuildCard" -t test

Length of output: 1056

Comment on lines +49 to +53
title={
<Typography noWrap gutterBottom variant="h6">
{name}
</Typography>
}
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 adding a title attribute for accessibility.

When text is truncated with noWrap, the full text should be accessible via tooltip for users who need to see the complete build name.

 <Typography noWrap gutterBottom variant="h6"
+           title={typeof name === 'string' ? name : undefined}
 >
   {name}
 </Typography>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
title={
<Typography noWrap gutterBottom variant="h6">
{name}
</Typography>
}
title={
<Typography noWrap gutterBottom variant="h6"
title={typeof name === 'string' ? name : undefined}
>
{name}
</Typography>
}

Copy link
Owner

@frzyc frzyc left a comment

Choose a reason for hiding this comment

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

LGTM. thanks for your contribution!

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.

Add character limit to Team/Loadout/Build names
2 participants