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

update(tooltip): ajust tooltip color #187

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Brick-2012
Copy link
Contributor

@Brick-2012 Brick-2012 commented Mar 3, 2025

Summary by CodeRabbit

  • New Features

    • Introduced dynamic, token-based styling for tooltips across multiple chart types, ensuring a consistent and customizable appearance.
  • Style

    • Updated tooltip designs with refined element dimensions and border radii.
    • Applied dynamic color configurations to improve visual clarity and readability.

Copy link

coderabbitai bot commented Mar 3, 2025

Walkthrough

This pull request updates the tooltip formatting for various chart components. The modifications involve importing a new chartToken module and destructuring color variables (such as tipSeriesNameColor, tipNameColor, and tipValueColor) to dynamically style tooltip elements. Changes include adjustments to dimensions and border radii in the tooltip HTML. These updates are applied to the BubbleChart, PolarBarChart, ScatterChart, and TreeMapChart components, alongside the introduction of a dedicated chartToken file for the TreeMapChart.

Changes

File(s) Change Summary
src/.../BubbleChart/handleOptipn.js
src/.../ScatterChart/handleOptipn.js
src/.../TreeMapChart/handleOptipn.js
Added import of chartToken and destructured tipSeriesNameColor, tipNameColor, and tipValueColor. Updated tooltip HTML to apply dynamic colors and adjusted indicator dimensions (10px → 8px, border radius: 5px → 4px).
src/.../PolarBarChart/handleOption.js Extracted tipNameColor and tipValueColor from chartToken; modified tooltip structure including reduced indicator size, margin adjustments, and updated styling for series name and value elements.
src/.../TreeMapChart/chartToken.js Introduced a new module that imports the Theme module and CHART_TYPE constant. Retrieves the token for the TreeMapChart by invoking Theme.getTokenByName(CHART_TYPE.TREE_MAP) and exports chartToken.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant CC as Chart Component
    participant TF as tooltipFormatter
    participant CT as chartToken
    participant DS as defendXSS

    CC->>TF: Call tooltipFormatter()
    TF->>CT: Import & extract color tokens
    TF->>DS: Sanitize values via defendXSS
    DS-->>TF: Return sanitized content
    TF->>CC: Return formatted HTML tooltip

Possibly related PRs

Poem

In the code garden I hop with delight,
Colors now dance in the tooltip's light.
Tokens whisper hues in every span,
Sizes and curves crafted as planned.
I'm a rabbit coder, leaping day and night!
🐇✨

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.

src/components/BubbleChart/handleOptipn.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///eslint.config.js?mtime=1740995666756:1:15
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:483:26)
at async loadFlatConfigFile (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:299:21)
at async calculateConfigArray (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:378:28)
at async FlatESLint.lintFiles (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:741:25)
at async Object.execute (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/cli.js:421:23)
at async main (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/bin/eslint.js:152:22)

src/components/TreeMapChart/chartToken.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///eslint.config.js?mtime=1740995666756:1:15
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:483:26)
at async loadFlatConfigFile (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:299:21)
at async calculateConfigArray (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:378:28)
at async FlatESLint.lintFiles (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:741:25)
at async Object.execute (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/cli.js:421:23)
at async main (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/bin/eslint.js:152:22)

src/components/ScatterChart/handleOptipn.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///eslint.config.js?mtime=1740995666756:1:15
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:483:26)
at async loadFlatConfigFile (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:299:21)
at async calculateConfigArray (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:378:28)
at async FlatESLint.lintFiles (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/eslint/flat-eslint.js:741:25)
at async Object.execute (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/cli.js:421:23)
at async main (/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/bin/eslint.js:152:22)

  • 2 others
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

Sorry, something went wrong.

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

🧹 Nitpick comments (1)
src/components/BubbleChart/handleOptipn.js (1)

12-12: Consider centralizing the chartToken implementation

Currently, you're importing chartToken from local files in each chart component directory, which could lead to code duplication and maintenance issues. Consider creating a centralized token system that can be imported by all chart components.

For example, create a single token file at src/tokens/chartToken.js that all components can import:

// Example implementation
// src/tokens/chartToken.js
export default {
  tipSeriesNameColor: '#333333',
  tipNameColor: '#666666',
  tipValueColor: '#000000',
  // other token values...
};

And then update imports in all chart components:

-import chartToken from './chartToken';
+import chartToken from '../../tokens/chartToken';

Also applies to: 13-13, 16-16

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a7f4945 and 45d8628.

📒 Files selected for processing (5)
  • src/components/BubbleChart/handleOptipn.js (1 hunks)
  • src/components/PolarBarChart/handleOption.js (1 hunks)
  • src/components/ScatterChart/handleOptipn.js (2 hunks)
  • src/components/TreeMapChart/chartToken.js (1 hunks)
  • src/components/TreeMapChart/handleOptipn.js (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/TreeMapChart/chartToken.js
🔇 Additional comments (15)
src/components/TreeMapChart/handleOptipn.js (4)

12-12: Consistent token import added for styling

The import of chartToken aligns with the PR objective to adjust tooltip colors across chart components.


22-22: Proper token destructuring for color values

Destructuring the color variables from chartToken follows modern JavaScript practices and improves code readability.


25-32: Tooltip styling uses token-based colors for consistency

The implementation correctly applies the token-based color system to the tooltip elements, creating a more consistent UI.


25-27:

✅ Verification successful

Verify chartToken file exists in the directory

The implementation references a ./chartToken module which is being imported, but I don't see the actual file in the PR. Make sure this file exists and contains the expected color token values.

Also applies to: 30-31


🏁 Script executed:

#!/bin/bash
# Check if the chartToken.js file exists in the TreeMapChart directory
ls -la src/components/TreeMapChart/chartToken.js 2>/dev/null || echo "chartToken.js file is missing in TreeMapChart directory"

# Check the contents of the file to verify it contains the required color tokens
if [ -f src/components/TreeMapChart/chartToken.js ]; then
  echo "Content of chartToken.js:"
  cat src/components/TreeMapChart/chartToken.js
fi

Length of output: 965


Chart token file verified and appears as expected.

  • The file src/components/TreeMapChart/chartToken.js exists and includes the required references to color tokens.
  • Both code locations (lines 25-27 and 30-31) correctly leverage the token from the verified file.
src/components/ScatterChart/handleOptipn.js (4)

12-12: Consistent token import added for styling

The import of chartToken aligns with the PR objective to adjust tooltip colors across chart components.


24-24: Proper token destructuring for color values

Destructuring the color variables from chartToken follows modern JavaScript practices and improves code readability.


27-29: Tooltip styling uses token-based colors for consistency

The implementation correctly applies the token-based color system to the tooltip elements, creating a more consistent UI.

Also applies to: 32-33, 37-38


12-12:

✅ Verification successful

Verify chartToken file exists in the directory

The implementation references a ./chartToken module which is being imported, but I don't see the actual file in the PR. Make sure this file exists and contains the expected color token values.


🏁 Script executed:

#!/bin/bash
# Check if the chartToken.js file exists in the ScatterChart directory
ls -la src/components/ScatterChart/chartToken.js 2>/dev/null || echo "chartToken.js file is missing in ScatterChart directory"

# Check the contents of the file to verify it contains the required color tokens
if [ -f src/components/ScatterChart/chartToken.js ]; then
  echo "Content of chartToken.js:"
  cat src/components/ScatterChart/chartToken.js
fi

Length of output: 964


ChartToken file verified and correct

The chartToken.js file in the src/components/ScatterChart directory exists and its content correctly exports the tokens using Theme.getTokenByName(CHART_TYPE.SCATTER). No further changes are needed here.

src/components/PolarBarChart/handleOption.js (3)

68-68: Proper token destructuring for color values

Destructuring the color variables from chartToken follows modern JavaScript practices and improves code readability.


73-76: Tooltip styling dimensions and colors updated for consistency

The changes to the tooltip appearance (smaller dimensions, adjusted border radius, and token-based colors) create a more refined and consistent UI across chart components.


13-13:

✅ Verification successful

Verify chartToken file exists in the directory

The implementation references a chartToken module which is already imported, but I don't see the actual file in the PR. Make sure this file exists and contains the expected color token values.


🏁 Script executed:

#!/bin/bash
# Check if the chartToken.js file exists in the PolarBarChart directory
ls -la src/components/PolarBarChart/chartToken.js 2>/dev/null || echo "chartToken.js file is missing in PolarBarChart directory"

# Check the contents of the file to verify it contains the required color tokens
if [ -f src/components/PolarBarChart/chartToken.js ]; then
  echo "Content of chartToken.js:"
  cat src/components/PolarBarChart/chartToken.js
fi

Length of output: 970


Verification Complete: chartToken File Valid

The file src/components/PolarBarChart/chartToken.js has been confirmed to exist and contains the expected implementation that imports the required token configuration and exports it correctly. No further action is required for this review comment.

src/components/BubbleChart/handleOptipn.js (4)

12-12: Consistent token import added for styling

The import of chartToken aligns with the PR objective to adjust tooltip colors across chart components.


16-16: Proper token destructuring for color values

Destructuring the color variables from chartToken follows modern JavaScript practices and improves code readability.


21-23: Tooltip styling uses token-based colors for consistency with other components

The implementation applies the token-based color system to the tooltip elements, which aligns with the changes in other chart components. The dimensions have also been adjusted for consistency (8px × 8px with 4px border radius).

Also applies to: 25-31


12-12:

✅ Verification successful

Verify chartToken file exists in the directory

The implementation references a ./chartToken module which is being imported, but I don't see the actual file in the PR. Make sure this file exists and contains the expected color token values.


🏁 Script executed:

#!/bin/bash
# Check if the chartToken.js file exists in the BubbleChart directory
ls -la src/components/BubbleChart/chartToken.js 2>/dev/null || echo "chartToken.js file is missing in BubbleChart directory"

# Check the contents of the file to verify it contains the required color tokens
if [ -f src/components/BubbleChart/chartToken.js ]; then
  echo "Content of chartToken.js:"
  cat src/components/BubbleChart/chartToken.js
fi

Length of output: 959


Chart token file verified in BubbleChart directory.

The file src/components/BubbleChart/chartToken.js exists and its content confirms that it correctly imports and retrieves the Bubble Chart token values. No further changes are required.

Comment on lines +25 to +26
<span style="display:inline-block;width:8px;height:8px;
margin-right:8px;border-radius:4px;border-style: solid;border-width:1px;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix missing closing quotes in style attributes

There are syntax errors in multiple places where the closing quotes are missing after the interpolated color values, which will cause the styles to not apply correctly.

Apply these fixes:

-                            <span style="color:${tipValueColor};>${defendXSS(name)}</span>
+                            <span style="color:${tipValueColor};">${defendXSS(name)}</span>
-                <span style="color:${tipValueColor};>${defendXSS(x)}</span>
+                <span style="color:${tipValueColor};">${defendXSS(x)}</span>
-                <span style="color:${tipValueColor};>${defendXSS(y)}</span>
+                <span style="color:${tipValueColor};">${defendXSS(y)}</span>
-                <span style="color:${tipValueColor};>${defendXSS(radius)}</span>
+                <span style="color:${tipValueColor};">${defendXSS(radius)}</span>

Also applies to: 30-30, 34-35, 40-41, 46-47

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.

None yet

1 participant