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

[WEB-4041] 14.6.8 - pricing card title tooltips, support for multiple tooltip orientations #507

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Oct 10, 2024

Jira Ticket Link / Motivation

https://ably.atlassian.net/jira/software/projects/WEB/boards/172?selectedIssue=WEB-4041

Motivated by this request here: https://ably-real-time.slack.com/archives/C019XP5SYB0/p1728566555191379?thread_ts=1728019882.765889&cid=C019XP5SYB0

Summary of changes

  • adds the ability to have tooltips in pricing card titles
  • adds relevant ones into the default dataset for consumption cards
  • adds support for interactive tooltips with multiple orientations

How do you manually test this?

https://ably.github.io/ably-ui/?path=/story/features-pricing-cards--consumption

Reviewer Tasks (optional)

Merge/Deploy Checklist

  • Written automated tests for implemented features/fixed bugs
  • Rebased and squashed commits
  • Commits have clear descriptions of their changes
  • Checked for any performance regressions

Frontend Checklist

  • No frontend changes in this PR
  • Added before/after screenshots for changes
  • Tested on different platforms/browsers with Browserstack
  • Compared with the initial design / our brand guidelines
  • Checked the code for accessibility issues (VoiceOver User Guide)?

Summary by CodeRabbit

  • New Features

    • Introduced tooltip functionality for titles in the Pricing Cards, enhancing user interaction with additional contextual information.
    • Added detailed tooltips for "Channels" and "Connections" in pricing data, linking to further documentation.
  • Improvements

    • Enhanced positioning logic for tooltips, allowing for better responsiveness and interaction based on cursor movements.
  • Version Update

    • Updated project version from 14.6.7 to 14.6.8.

Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

Walkthrough

The pull request introduces several updates across multiple files in the @ably/ui project. The package.json file reflects a version increment from 14.6.7 to 14.6.8. The PricingCards component has been modified to include a Tooltip feature, enhancing the user interface. Additionally, the data.tsx file has added tooltip information to specific entries, while the types.ts file now includes a new optional tooltip property in the PricingDataHeader type. The Tooltip component itself has been updated to improve its positioning and interaction behavior.

Changes

File Change Summary
package.json Version updated from 14.6.7 to 14.6.8.
src/core/Pricing/PricingCards.tsx Added Tooltip import, modified layout to include tooltip functionality for the title.
src/core/Pricing/data.tsx Added tooltip properties to title objects of "Channels" and "Connections" in consumptionData.
src/core/Pricing/types.ts Added optional tooltip property to PricingDataHeader type.
src/core/Tooltip.tsx Enhanced tooltip functionality with orientation management and improved cursor interaction logic.

Possibly related PRs

Suggested reviewers

  • aralovelace
  • kennethkalmer

🐇 In the garden where tooltips bloom,
A new version springs from code's loom.
With hints and guidance, they now appear,
Enhancing the cards, bringing cheer!
So hop along, let the changes unfold,
In the world of pricing, new tales to be told! 🌼


🪧 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

@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

🧹 Outside diff range and nitpick comments (4)
src/core/Pricing/data.tsx (2)

230-239: LGTM! Consider adding an aria-label for accessibility.

The addition of the tooltip for the "Channels" entry is informative and well-implemented. The content is concise and the link to further documentation is appropriate.

To improve accessibility, consider adding an aria-label to the link:

 <a href="/docs/channels" className="ui-link">
+  aria-label="Learn more about Ably channels"
   Find out more.
 </a>

268-276: LGTM! Consider adding an aria-label for accessibility.

The addition of the tooltip for the "Connections" entry is well-implemented and consistent with the "Channels" entry. The content is informative and the link to further documentation is appropriate.

To improve accessibility, consider adding an aria-label to the link:

 <a href="/docs/connect" className="ui-link">
+  aria-label="Learn more about Ably connections"
   Find out more.
 </a>
src/core/Pricing/PricingCards.tsx (2)

109-124: LGTM: Tooltip integration looks good.

The new structure for rendering the title with an optional tooltip is well-implemented. The conditional rendering and proper configuration of the Tooltip component are commendable.

Consider adding an aria-label to the tooltip container for improved accessibility:

 <div className="flex items-center mb-12">
+  <div aria-label={`${title.content} information`}>
     <p
       className={`${title.className ?? ""} ${t(title.color ?? "text-neutral-000")}`}
     >
       {title.content}
     </p>
     {title.tooltip ? (
       <Tooltip
         className="-mt-4"
         theme={theme}
         interactive={typeof title.tooltip !== "string"}
       >
         {title.tooltip}
       </Tooltip>
     ) : null}
+  </div>
 </div>

Line range hint 1-124: Overall implementation looks solid with room for minor optimization.

The addition of tooltips to the pricing card titles is well-implemented and aligns with the PR objectives. The changes are localized and maintain consistency with the existing code structure.

Consider memoizing the tooltip content to optimize performance, especially if the content is complex or the component re-renders frequently:

const memoizedTooltip = React.useMemo(() => (
  title.tooltip ? (
    <Tooltip
      className="-mt-4"
      theme={theme}
      interactive={typeof title.tooltip !== "string"}
    >
      {title.tooltip}
    </Tooltip>
  ) : null
), [title.tooltip, theme]);

// Then use memoizedTooltip in your JSX

This optimization can help reduce unnecessary re-renders of the tooltip content.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 028abfd and 8ff30a8.

📒 Files selected for processing (5)
  • package.json (1 hunks)
  • src/core/Pricing/PricingCards.tsx (2 hunks)
  • src/core/Pricing/data.tsx (2 hunks)
  • src/core/Pricing/types.ts (1 hunks)
  • src/core/Tooltip.tsx (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🧰 Additional context used
🔇 Additional comments (7)
src/core/Pricing/types.ts (1)

8-8: LGTM: Addition of tooltip property to PricingDataHeader

The new tooltip property is a good addition to the PricingDataHeader type. It allows for more flexibility in displaying additional information for pricing card headers. The use of string | ReactNode as the type is appropriate, allowing for both simple text tooltips and more complex React components.

A few points to consider:

  1. This change aligns well with the PR objectives of adding tooltip functionality to pricing card titles.
  2. The optional nature of the property (tooltip?) ensures backward compatibility with existing code using PricingDataHeader.
  3. The flexibility of using either string or ReactNode provides good extensibility for future use cases.

To ensure this change is properly utilized, let's verify its usage in the codebase:

✅ Verification successful

Verified: tooltip property is used correctly

The tooltip property in PricingDataHeader is consistently utilized as a ReactNode across the codebase, aligning with its type definition tooltip?: string | ReactNode. No type inconsistencies or issues were found.

  • tooltip is assigned JSX elements in src/core/Pricing/data.tsx, ensuring flexibility for complex React components.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of the new tooltip property in PricingDataHeader

# Test 1: Search for PricingDataHeader usage with tooltip
echo "Searching for PricingDataHeader usage with tooltip:"
rg --type typescript 'PricingDataHeader.*tooltip'

# Test 2: Search for any hardcoded tooltip strings in pricing-related files
echo "Searching for hardcoded tooltip strings in pricing-related files:"
rg --type typescript 'tooltip:' src/core/Pricing

Length of output: 424


Script:

#!/bin/bash
# Description: Check for usage of the new tooltip property in PricingDataHeader with corrected file type

# Test 1: Search for PricingDataHeader usage with tooltip
echo "Searching for PricingDataHeader usage with tooltip:"
rg --type ts 'PricingDataHeader.*tooltip'

# Test 2: Search for any hardcoded tooltip strings in pricing-related files
echo "Searching for hardcoded tooltip strings in pricing-related files:"
rg --type ts 'tooltip:' src/core/Pricing

Length of output: 424


Script:

#!/bin/bash
# Description: Extract lines with the tooltip property in src/core/Pricing/data.tsx to verify usage

echo "Extracting tooltip property usages in src/core/Pricing/data.tsx:"
rg 'tooltip:\s*' src/core/Pricing/data.tsx -A 2

Length of output: 402

src/core/Pricing/data.tsx (1)

Line range hint 230-276: Summary: Tooltips successfully added to pricing data

The changes in this file successfully implement tooltips for the "Channels" and "Connections" entries in the consumptionData array. These additions enhance the user experience by providing concise explanations and links to further documentation directly within the pricing interface.

The implementation is consistent across both entries and aligns well with the PR objectives. No unintended changes or regressions were introduced.

To ensure consistency across the codebase, let's verify if similar tooltips have been added to other relevant sections:

This will help us confirm if the tooltip implementation is consistent across all relevant pricing components.

✅ Verification successful

All tooltip implementations in pricing components are consistent

The tooltips have been successfully added to the "Channels" and "Connections" entries in the consumptionData array. A search within the src/core/Pricing directory confirms that these are the only tooltip implementations, ensuring consistency across the pricing components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other tooltip implementations in pricing-related files
rg --type typescript --type tsx 'tooltip:.*<p>' src/core/Pricing

Length of output: 101


Script:

#!/bin/bash
# Search for other tooltip implementations in pricing-related TypeScript files by file extension
rg 'tooltip:.*<p>' --glob '*.ts' --glob '*.tsx' src/core/Pricing

Length of output: 66

src/core/Pricing/PricingCards.tsx (1)

2-2: LGTM: Import statements are well-organized.

The separation of the throttle import and the addition of the Tooltip import improve code organization and support the new tooltip functionality.

Also applies to: 9-9

src/core/Tooltip.tsx (4)

36-36: LGTM!

The inclusion of the orientation property in the position state enhances tooltip positioning logic effectively.


Line range hint 50-84:
LGTM!

The logic for determining the tooltip's orientation based on viewport boundaries is well-implemented.


87-87: LGTM!

Resetting the position state when the tooltip is closed maintains the default orientation.


138-138: Ensure consistent fade-out behavior for interactive tooltips

In the onMouseLeave handler, consider verifying that the cursorTowardsTooltip function accurately detects when the cursor moves toward the tooltip in all orientations. This will ensure the tooltip remains visible when intended.

src/core/Tooltip.tsx Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (1)
src/core/Tooltip.tsx (1)

Line range hint 50-84: Improved positioning logic with orientation

The new positioning logic is a significant improvement. It intelligently adjusts the tooltip's position and orientation based on viewport constraints, ensuring better visibility and user experience.

A minor suggestion for improvement:

Consider extracting the positioning logic into a separate function for better readability and maintainability. This would make the useEffect hook cleaner and the positioning logic more reusable if needed elsewhere.

Example:

const calculatePosition = (floatingRect: DOMRect, referenceRect: DOMRect) => {
  // ... positioning logic ...
  return { x, y, orientation };
};

// In useEffect
const newPosition = calculatePosition(floatingRect, referenceRect);
setPosition(newPosition);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8ff30a8 and de9ec70.

📒 Files selected for processing (5)
  • package.json (1 hunks)
  • src/core/Pricing/PricingCards.tsx (2 hunks)
  • src/core/Pricing/data.tsx (2 hunks)
  • src/core/Pricing/types.ts (1 hunks)
  • src/core/Tooltip.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • package.json
  • src/core/Pricing/PricingCards.tsx
  • src/core/Pricing/data.tsx
  • src/core/Pricing/types.ts
🧰 Additional context used
🔇 Additional comments (5)
src/core/Tooltip.tsx (5)

36-36: LGTM: Addition of orientation to position state

The inclusion of the orientation property in the position state is a good addition. It provides a clear way to track and manage the tooltip's orientation, which is crucial for the new positioning logic.


87-87: LGTM: Consistent reset of position state

Resetting the orientation to "top" when closing the tooltip is a good practice. It ensures consistency with the initial state and prevents any potential issues if the tooltip is reopened in a different context.


105-122: Improved cursor position detection with orientation support

The renamed cursorTowardsTooltip function is a significant improvement. It now correctly handles cursor position detection for all orientations, addressing the issue mentioned in the previous review.

Great job on:

  1. Using height instead of width for vertical positioning in 'left' and 'right' orientations.
  2. Implementing separate logic for each orientation, improving accuracy and readability.

This change enhances the tooltip's interactive behavior, especially for edge cases where the tooltip changes orientation.


138-140: LGTM: Enhanced interactive behavior

The updated onMouseLeave event handler now correctly utilizes the cursorTowardsTooltip function. This change improves the tooltip's interactive behavior, preventing premature closing when the cursor moves towards the tooltip, regardless of its orientation.

This enhancement aligns well with the interactive tooltip functionality mentioned in the PR objectives.


Line range hint 1-190: Overall assessment: Significant improvements to Tooltip component

This update to the Tooltip component successfully addresses the PR objectives:

  1. It adds support for multiple tooltip orientations.
  2. It enhances the interactive behavior of the tooltip.

Key improvements:

  • Introduction of orientation-based positioning logic.
  • Improved cursor position detection for all orientations.
  • Enhanced interactive behavior preventing premature tooltip closing.

The changes are well-implemented, address previous review comments, and align with the provided AI summary. Great job on improving the functionality and user experience of the Tooltip component!

Copy link
Member

@kennethkalmer kennethkalmer left a comment

Choose a reason for hiding this comment

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

Looks good in Safari 👍

Copy link
Contributor

@aralovelace aralovelace left a comment

Choose a reason for hiding this comment

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

Looks good! display perfectly in different sizes, and it works on safari as well.

Since its code very well already, I just have few questions and suggestions what you think?

src/core/Tooltip.tsx Show resolved Hide resolved
src/core/Tooltip.tsx Show resolved Hide resolved
@jamiehenson
Copy link
Member Author

I added a bit extra to try and make interactive hovers a bit more stable - by determining whether the cursor is within the original triggering element upon leaving the tooltip after a short time has passed. Not 100% but it helps

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

🧹 Outside diff range and nitpick comments (2)
src/core/Tooltip.tsx (2)

Line range hint 50-84: Improved tooltip positioning logic

The new positioning logic is a significant improvement. It handles various edge cases and ensures the tooltip stays within the viewport. The dynamic orientation setting based on available space is particularly useful.

However, consider extracting the positioning logic into a separate function for better readability and maintainability.

Consider refactoring the positioning logic into a separate function:

const calculatePosition = (floatingRect: DOMRect, referenceRect: DOMRect) => {
  let x = /* ... */;
  let y = /* ... */;
  let orientation = "top";

  // ... (rest of the positioning logic)

  return { x, y, orientation };
};

// In useEffect
if (floatingRect && referenceRect) {
  const newPosition = calculatePosition(floatingRect, referenceRect);
  setPosition(newPosition);
}

This refactoring would make the useEffect hook cleaner and the positioning logic more reusable.


178-180: LGTM: Enhanced tooltip fade-out behavior

The addition of the onMouseLeave event to the tooltip itself is a good improvement. The delay before checking if the cursor is within the trigger enhances the user experience, especially for interactive tooltips.

Consider extracting the delay value to a constant for better maintainability:

const FADE_OUT_DELAY = 250;

// ...

onMouseLeave={(event) =>
  setTimeout(() => fadeOutIfNotWithinTrigger(event), FADE_OUT_DELAY)
}

This change would make it easier to adjust the delay if needed in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between de9ec70 and ae871fc.

📒 Files selected for processing (5)
  • package.json (1 hunks)
  • src/core/Pricing/PricingCards.tsx (2 hunks)
  • src/core/Pricing/data.tsx (2 hunks)
  • src/core/Pricing/types.ts (1 hunks)
  • src/core/Tooltip.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • package.json
  • src/core/Pricing/PricingCards.tsx
  • src/core/Pricing/data.tsx
  • src/core/Pricing/types.ts
🧰 Additional context used
🔇 Additional comments (6)
src/core/Tooltip.tsx (6)

36-36: LGTM: Enhanced position state with orientation

The addition of the orientation property to the position state is a good improvement. It allows for more flexible and precise positioning of the tooltip, which is consistent with the orientation-based logic introduced later in the component.


87-87: LGTM: Proper reset of tooltip state

Resetting the orientation to "top" when the tooltip is closed is a good practice. It ensures a consistent initial state for the tooltip, which can prevent unexpected behavior when the tooltip is reopened.


105-129: LGTM: Improved cursor position detection

The renamed cursorTowardsTooltip function with updated logic is a significant improvement. The switch statement for different orientations makes the code more readable and maintainable. The logic for each orientation is correct and uses the appropriate dimensions.

It's great to see that the past review comment about using 'height' instead of 'width' in some calculations has been addressed.


131-144: LGTM: Enhanced fade-out behavior

The new fadeOutIfNotWithinTrigger function is a valuable addition. It improves the user experience by ensuring the tooltip fades out when the cursor is outside the trigger element. The logic is clear, concise, and easy to understand.


152-154: LGTM: Improved tooltip behavior on mouse leave

The updated onMouseLeave event handler now uses the cursorTowardsTooltip function to determine whether to initiate fade-out. This change improves the tooltip's behavior, especially for interactive tooltips, providing a more intuitive user experience.


Line range hint 1-198: Overall assessment: Excellent improvements to the Tooltip component

This PR introduces significant enhancements to the Tooltip component, including:

  1. Dynamic orientation based on available space
  2. Improved positioning logic
  3. Enhanced fade-out behavior
  4. Better handling of interactive tooltips

These changes align well with the PR objectives and greatly improve the component's functionality and user experience. The code is generally well-structured and readable, with only minor suggestions for improvement (mainly related to extracting some logic into separate functions for better maintainability).

Great job on addressing previous review comments and implementing these valuable updates!

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

🧹 Outside diff range and nitpick comments (3)
src/core/Tooltip.tsx (3)

Line range hint 50-84: LGTM: Improved tooltip positioning logic

The new logic for determining tooltip orientation and adjusting its position is well-implemented. It effectively prevents tooltips from being cut off at screen edges, which enhances user experience.

A minor optimization suggestion:

Consider extracting the viewport dimensions calculation outside the if block to avoid recalculation:

+ const viewportWidth = window.innerWidth;
+ const viewportHeight = window.innerHeight;

  if (floatingRect && referenceRect) {
-   const viewportWidth = window.innerWidth;
-   const viewportHeight = window.innerHeight;
    // ... rest of the code
  }

This small change could slightly improve performance, especially if the effect runs frequently.


131-144: LGTM: Enhanced interactive tooltip behavior

The new fadeOutIfNotWithinTrigger function is a great addition that improves the interactive behavior of the tooltip. It provides a smoother user experience by preventing abrupt tooltip disappearances when the cursor leaves the trigger element.

A minor optimization suggestion:

Consider using destructuring to make the code more concise:

- const withinBounds =
-   clientX >= x &&
-   clientX <= x + width &&
-   clientY >= y &&
-   clientY <= y + height;
+ const withinBounds = 
+   clientX >= x && clientX <= x + width && 
+   clientY >= y && clientY <= y + height;

This change doesn't affect functionality but slightly improves readability.


178-180: LGTM: Enhanced interactive tooltip behavior

The addition of the onMouseLeave event handler with a delayed call to fadeOutIfNotWithinTrigger is an excellent improvement. It enhances the interactive behavior of the tooltip, allowing users to move the cursor to the tooltip content without it immediately disappearing. This change aligns well with the PR objectives and the author's comments about improving the stability of interactive hovers.

A minor suggestion for consistency:

Consider extracting the delay value to a constant at the top of the component:

const FADE_OUT_DELAY = 250;

// Then use it in both places:
setTimeout(() => fadeOutIfNotWithinTrigger(event), FADE_OUT_DELAY)

// and in the initiateFadeOut function:
fadeOutTimeoutRef.current = setTimeout(() => {
  setOpen(false);
  setFadeOut(false);
}, FADE_OUT_DELAY);

This change would make it easier to adjust the delay consistently across the component if needed in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ae871fc and bf53fd9.

⛔ Files ignored due to path filters (2)
  • src/core/Table/__snapshots__/Table.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Tooltip/__snapshots__/Tooltip.stories.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (5)
  • package.json (1 hunks)
  • src/core/Pricing/PricingCards.tsx (2 hunks)
  • src/core/Pricing/data.tsx (2 hunks)
  • src/core/Pricing/types.ts (1 hunks)
  • src/core/Tooltip.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • package.json
  • src/core/Pricing/PricingCards.tsx
  • src/core/Pricing/data.tsx
  • src/core/Pricing/types.ts
🧰 Additional context used
🔇 Additional comments (4)
src/core/Tooltip.tsx (4)

36-36: LGTM: Enhanced position state with orientation

The addition of the orientation property to the position state is a good improvement. It allows for more flexible positioning of the tooltip, which is consistent with the overall changes described in the PR objectives.


87-87: LGTM: Proper state reset on tooltip close

Resetting the position state, including the orientation, when the tooltip is closed is a good practice. It ensures a clean state for the next tooltip opening, preventing potential issues with stale positioning data.


105-129: LGTM: Improved cursor position detection

The cursorTowardsTooltip function has been significantly improved:

  1. It now correctly handles all four orientations (top, left, right, bottom).
  2. The use of a switch statement enhances readability and maintainability.
  3. The early return for a null ref is a good defensive programming practice.

These changes effectively address previous review comments and improve the overall functionality of the tooltip.


148-160: LGTM: Improved tooltip trigger styling and behavior

The changes to the tooltip trigger element are well-implemented:

  1. The additional class names provide more flexibility in styling, which is beneficial for maintaining consistent design across the application.
  2. The updated onMouseLeave handler, using the new cursorTowardsTooltip function, improves the interactive behavior of the tooltip, especially for the case when interactive is true.

These improvements align well with the PR objectives and enhance the overall user experience.

Copy link
Contributor

@aralovelace aralovelace left a comment

Choose a reason for hiding this comment

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

⭐⭐⭐⭐⭐

@jamiehenson jamiehenson merged commit 5c05eb2 into main Oct 10, 2024
4 checks passed
@jamiehenson jamiehenson deleted the pricing-accordion-card-changes branch October 10, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants