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

Fix formula text being janky #2618

Merged
merged 1 commit into from
Jan 25, 2025
Merged

Fix formula text being janky #2618

merged 1 commit into from
Jan 25, 2025

Conversation

nguyentvan7
Copy link
Collaborator

@nguyentvan7 nguyentvan7 commented Jan 25, 2025

Describe your changes

Fixed formula text being multiple lines

Issue or discord link

Testing/validation

Formulas are all normal now
image
Strikethrough still works
image

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

  • Style
    • Updated formula display rendering to use simpler JSX structure
    • Replaced Material-UI Typography component with native span elements
    • Maintained existing formula display logic and visual presentation

@nguyentvan7 nguyentvan7 requested a review from frzyc January 25, 2025 17:49
Copy link
Contributor

coderabbitai bot commented Jan 25, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

/usr/local/bin/yarn: 3: dirname: not found
/usr/local/bin/yarn: 7: dirname: not found
node:internal/modules/cjs/loader:1251
throw err;
^

Error: Cannot find module '/yarn.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
at Module._load (node:internal/modules/cjs/loader:1074:27)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:166:5)
at node:internal/main/run_main_module:30:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v22.9.0

Walkthrough

The pull request modifies the getCalcDisplay.tsx file in the UI library, specifically focusing on the computeFormulaDisplay function. The changes involve simplifying the rendering of formula displays by removing the Material-UI Typography component and instead using native fragment and span elements. The core logic for calculating and displaying formula components remains unchanged, with the primary difference being a more streamlined JSX structure.

Changes

File Change Summary
libs/gi/ui/src/util/getCalcDisplay.tsx Replaced Typography component with fragment and direct span styling for formula display rendering

Suggested Reviewers

  • frzyc

🐰 A Rabbit's Ode to UI Refinement

Fragments dance where Typography once stood,
Spans now carry style with rabbit-like mood,
Simplicity reigns in our code's sweet design,
Rendering formulas with elegance divine!
🎨✨


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (1)
libs/gi/ui/src/util/getCalcDisplay.tsx (1)

223-234: LGTM! The changes effectively fix the formula text display.

The removal of the Material-UI Typography component in favor of native spans is a good approach to prevent unwanted line breaks and fix the "janky" appearance of formula text.

Consider memoizing the style object.

Since the style object is recreated on every render, consider memoizing it or moving it outside the map function:

+ const strikethroughStyle = { textDecoration: 'line-through' }
  {components.map((x, i) => (
    <span
-     style={{
-       textDecoration: info.strikethrough ? 'line-through' : undefined,
-     }}
+     style={info.strikethrough ? strikethroughStyle : undefined}
      key={i}
    >
      {x}
    </span>
  ))}

Note: The Fragment is necessary here as we're mapping over components, so we can safely ignore the static analysis warning.

🧰 Tools
🪛 Biome (1.9.4)

[error] 223-234: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 234d0cd and c584309.

📒 Files selected for processing (1)
  • libs/gi/ui/src/util/getCalcDisplay.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
libs/gi/ui/src/util/getCalcDisplay.tsx

[error] 223-234: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint

@nguyentvan7 nguyentvan7 merged commit e3482dc into master Jan 25, 2025
7 checks passed
@nguyentvan7 nguyentvan7 deleted the van/go/fixFormula branch January 25, 2025 18:03
nguyentvan7 added a commit that referenced this pull request Jan 26, 2025
nguyentvan7 added a commit that referenced this pull request Jan 26, 2025
nguyentvan7 added a commit that referenced this pull request Jan 27, 2025
nguyentvan7 added a commit that referenced this pull request Jan 27, 2025
* Add nonstacking to all relevant buffs

* fix

* dumdum proof

* Reapply "Add non-stacking buff back to NO4 in a smarter way (#2592)" (#2629)

This reverts commit e8a420a.

* Reapply "Fix formula text being janky (#2618)" (#2627)

This reverts commit 72d89fb.

---------

Co-authored-by: lantua <[email protected]>
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