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

chore(charts): readable tooltip value #331

Merged
merged 1 commit into from
Aug 20, 2024
Merged

chore(charts): readable tooltip value #331

merged 1 commit into from
Aug 20, 2024

Conversation

duyet
Copy link
Owner

@duyet duyet commented Aug 20, 2024

Summary by Sourcery

Enhance the readability of tooltips in bar and area charts by formatting values and adding visual indicators. Refactor the ActionItem and ActionMenu components to improve toast notification handling. Remove the Toaster component from the DataTable component.

Enhancements:

  • Improve tooltip readability in bar and area charts by formatting values with a more readable format and adding visual indicators for data points.
  • Refactor the ActionItem component to include toast and dismiss functions as props, enhancing the flexibility of action handling.
  • Refactor the ActionMenu component to pass toast and dismiss functions to ActionItem, improving the integration of toast notifications.

Chores:

  • Remove the Toaster component from the DataTable component, likely as part of a cleanup or refactoring effort.

Copy link

vercel bot commented Aug 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clickhouse-monitoring ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 20, 2024 6:23am

Copy link
Contributor

sourcery-ai bot commented Aug 20, 2024

Reviewer's Guide by Sourcery

This pull request focuses on improving the readability and functionality of chart tooltips in the generic-charts components, as well as refactoring the action menu in the data table component. The changes primarily affect the bar and area charts, introducing more detailed and customizable tooltip content. Additionally, there are modifications to the action menu structure to improve toast notifications handling.

File-Level Changes

Files Changes
components/generic-charts/bar.tsx Enhanced tooltip content for bar charts, including custom formatting and improved readability of values
components/generic-charts/area.tsx Similar enhancements to tooltip content for area charts, mirroring the changes made in the bar chart component
components/data-table/cells/actions/action-item.tsx Refactored action item component to receive toast and dismiss functions as props
components/data-table/cells/actions/action-menu.tsx Updated action menu component to provide toast and dismiss functions to action items
components/data-table/data-table.tsx Removed Toaster component from the DataTable component

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @duyet - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The <Toaster /> component has been removed from the DataTable. Please ensure it's been added higher up in the component tree to maintain toast functionality.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 3 issues found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

}: ActionButtonProps<TData, TValue>) {
const { toast, dismiss } = useToast()
toast,
dismiss,
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider reverting to using useToast directly within the function.

The recent changes to the ActionItem function have increased its complexity by adding toast and dismiss as parameters. This makes the function more tightly coupled with the useToast hook and increases the risk of errors if these props are not provided correctly. To simplify, consider reverting to the original approach where useToast is used directly within the function. This keeps the component self-contained and reduces redundancy, improving maintainability and readability.

<ChartTooltip
cursor
content={
<ChartTooltipContent
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider breaking down the JSX into smaller components.

The new code introduces increased complexity due to additional nesting, inline styles, and verbose logic. Consider breaking down the JSX and logic into smaller, reusable components to improve readability and maintainability. For example, extracting the tooltip content into a separate CustomTooltipContent component can help reduce complexity and enhance separation of concerns. This approach will make the code easier to read and maintain, while also improving reusability.

index,
payload: Array<Payload<ValueType, NameType>>
) => {
return (
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring the JSX logic into a helper function.

The new code introduces increased complexity due to additional nesting, verbose syntax, and some redundant logic. To improve readability and maintainability, consider refactoring by extracting the repeated JSX logic into a helper function, as shown in the renderContent function. This reduces redundancy and simplifies the code structure. Also, ensure consistent styling throughout the code to make it easier to follow. These changes should help in making the code more straightforward and easier to maintain.

@duyet duyet merged commit c2c4e1f into main Aug 20, 2024
21 checks passed
@duyet duyet deleted the feat/ui branch August 20, 2024 07:15
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.

1 participant