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

14.6.4 - Interactive tooltip, accordion/expander/featuredlink updates #498

Merged
merged 9 commits into from
Oct 1, 2024

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Sep 27, 2024

Jira Ticket Link / Motivation

Summary of changes

How do you manually test this?

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

Release Notes

  • New Features

    • Updated version of the @ably/ui package to 14.6.4.
    • Introduced a new interactive prop for the Tooltip component, enhancing user interaction.
    • Added a new story for the Expander component to demonstrate the ZeroHeightContent functionality.
    • Added a new story for the Tooltip component, showcasing interactive tooltips.
  • Improvements

    • Enhanced styling and spacing adjustments in the Accordion and Expander components for better visual presentation.
    • Updated pricing data structure for improved clarity, including renaming sections and adding new limits.
    • Adjusted gradient background colors for improved aesthetics in the PricingCards component.
  • Bug Fixes

    • Adjusted CSS class applications in various components for consistent behavior across themes.

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

This pull request includes updates across multiple files, primarily focusing on version updates, modifications to component styling, and the introduction of new stories for documentation. The package.json file reflects a version increment for the @ably/ui package. Changes in component files involve adjustments to class names and properties to enhance UI behavior and presentation. Additionally, new stories have been added to showcase the usage of components with updated features.

Changes

File Change Summary
package.json Updated version of @ably/ui from 14.6.3 to 14.6.4.
src/core/Accordion.tsx Modified class attributes in AccordionRow for margin and padding adjustments.
src/core/Expander.tsx Changed className to conditionally apply margin-top based on component state.
src/core/Expander/Expander.stories.tsx Added new story ZeroHeightContent to demonstrate Expander with a height threshold of 0.
src/core/FeaturedLink.tsx Updated class names for anchor and icon elements to enhance hover effects.
src/core/Pricing/PricingCards.stories.tsx Altered gradient background color for the "dark" theme in a story.
src/core/Pricing/PricingCards.tsx Wrapped price.content in a styled div and adjusted layout for CTA elements.
src/core/Pricing/data.tsx Renamed "Capacity" to "Limits" and updated various items in pricing plans.
src/core/Pricing/types.ts Added a new type PricingDataFeatureCta and updated existing types to include optional cta properties.
src/core/Tooltip.tsx Introduced interactive prop for tooltips and modified event handling for fade-out logic.
src/core/Tooltip/Tooltip.stories.tsx Added new story Interactive to demonstrate tooltip behavior with the interactive prop.

Possibly related PRs

Suggested labels

review

Suggested reviewers

  • aralovelace
  • denissellu
  • kennethkalmer

🐰 "In the meadow, changes bloom,
With version updates, there's more room.
Tooltips dance and accordions sway,
New stories shine, brightening the day.
With every click, the joy will grow,
Hopping forward, let the features flow!" 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c148aa9 and 21a78bc.

⛔ Files ignored due to path filters (6)
  • src/core/Accordion/__snapshots__/Accordion.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Expander/__snapshots__/Expander.stories.tsx.snap is excluded by !**/*.snap
  • src/core/FeaturedLink/__snapshots__/FeaturedLink.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Pricing/__snapshots__/PricingCards.stories.tsx.snap is excluded by !**/*.snap
  • src/core/ProductTile/__snapshots__/ProductTile.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Tooltip/__snapshots__/Tooltip.stories.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (10)
  • src/core/Accordion.tsx (2 hunks)
  • src/core/Expander.tsx (1 hunks)
  • src/core/Expander/Expander.stories.tsx (1 hunks)
  • src/core/FeaturedLink.tsx (3 hunks)
  • src/core/Pricing/PricingCards.stories.tsx (1 hunks)
  • src/core/Pricing/PricingCards.tsx (2 hunks)
  • src/core/Pricing/data.tsx (8 hunks)
  • src/core/Pricing/types.ts (1 hunks)
  • src/core/Tooltip.tsx (7 hunks)
  • src/core/Tooltip/Tooltip.stories.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/core/Accordion.tsx
  • src/core/Expander.tsx
  • src/core/Expander/Expander.stories.tsx
  • src/core/FeaturedLink.tsx
  • src/core/Pricing/PricingCards.stories.tsx
  • src/core/Pricing/PricingCards.tsx
  • src/core/Pricing/data.tsx
  • src/core/Tooltip.tsx
  • src/core/Tooltip/Tooltip.stories.tsx
🔇 Additional comments (4)
src/core/Pricing/types.ts (4)

Line range hint 9-15: LGTM: Well-structured new type for CTA

The new PricingDataFeatureCta type is well-defined and covers all necessary properties for a call-to-action button. It includes text and URL for the link, optional class name for styling, a disabled state, and an optional onClick handler. This structure will provide flexibility in implementing CTAs within the pricing features.


Line range hint 17-22: LGTM: Appropriate update to PricingDataFeatureSection

The addition of the optional cta property to the PricingDataFeatureSection type is a good enhancement. It allows for the inclusion of a call-to-action within a feature section, providing more flexibility in the pricing data structure. The optional nature of the property ensures backward compatibility with existing code.


Line range hint 24-30: LGTM: Consistent update to PricingDataFeature

The addition of the optional cta property to the PricingDataFeature type is consistent with the previous changes and enhances the flexibility of the pricing data structure. It allows for a call-to-action to be associated directly with a pricing feature. The optional nature of the property ensures backward compatibility, and its placement in the type definition is appropriate.


Line range hint 9-30: Summary: Well-structured enhancements to pricing types

The changes to this file introduce a new PricingDataFeatureCta type and update the existing PricingDataFeatureSection and PricingDataFeature types to include optional CTA properties. These enhancements provide more flexibility in the pricing data structure, allowing for the inclusion of call-to-action elements at both the feature and feature section levels.

The changes are well-structured, maintain backward compatibility through the use of optional properties, and are consistent across the affected types. These updates will likely improve the ability to create more interactive and engaging pricing displays.


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

@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: 5

🧹 Outside diff range and nitpick comments (10)
src/core/Pricing/PricingCards.stories.tsx (1)

21-21: LGTM! Consider using Tailwind CSS color variables for consistency.

The change to darker gradient colors (from-blue-800 to-pink-800) for the dark theme is appropriate and likely improves contrast. Good job!

For better maintainability and consistency across the project, consider using Tailwind CSS color variables if they are defined in your project. For example:

- className={`${theme === "dark" ? "bg-gradient-to-r from-blue-800 to-pink-800" : ""} p-32`}
+ className={`${theme === "dark" ? "bg-gradient-to-r from-primary-800 to-secondary-800" : ""} p-32`}

This assumes you have primary and secondary color variables defined in your Tailwind config. If not, the current implementation is fine.

src/core/FeaturedLink.tsx (1)

88-88: Consistent group hover styling and refactoring opportunity

The update from group-hover:left-0 to group-hover/featured-link:left-0 in the Icon's additionalCSS prop is consistent with the earlier changes. This modification ensures that the hover effect is specifically tied to the FeaturedLink component, maintaining the existing functionality while improving style isolation.

Consider refactoring the common styles between the reverse and non-reverse cases to improve code maintainability. You could create a variable for the common classes and only vary the direction-specific classes. For example:

const commonIconClasses = `align-middle relative -top-1 transition-[left] ${disabled ? "" : "group-hover/featured-link:left-0"}`;
const reverseIconClasses = `${commonIconClasses} mr-8 -right-4 transform rotate-180`;
const forwardIconClasses = `${commonIconClasses} ml-8 -left-4`;

// Then use these in the respective Icon components
additionalCSS={reverseIconClasses}
// and
additionalCSS={forwardIconClasses}

This refactoring would make it easier to maintain consistent styling between the two cases and reduce code duplication.

src/core/Expander.tsx (1)

85-85: Improved flexibility, but consider further enhancements

The change improves the component's flexibility by conditionally applying the top margin. However, there are a few points to consider:

  1. The condition heightThreshold === 0 might be too specific. Consider using a more flexible condition, such as heightThreshold <= someSmallValue, to account for cases where a very small threshold should also trigger this behavior.

  2. The line is quite long, which may reduce readability. Consider splitting it for better maintainability:

className={`
  ${heightThreshold === 0 && !expanded ? "" : "mt-16"}
  cursor-pointer font-bold text-gui-blue-default-light hover:text-gui-blue-hover-light
  ${controlsClassName ?? ""}
`}
  1. Ensure to test this change with various heightThreshold values and in different layout contexts to verify that removing the margin doesn't negatively impact the overall layout.
src/core/Pricing/data.tsx (2)

20-26: Approved changes with a suggestion for consistency

The updates to the "Free" plan provide more precise information and align with industry terminology. The change from "Capacity" to "Limits" and the addition of specific limitations improve clarity for users.

For consistency with other plans, consider adding "Unlimited messages/month" instead of "6M messages/month". This would highlight the generous nature of the free plan while still setting clear expectations.


126-126: Approved changes with a suggestion for clarity

The updates to the Pro plan, including the consistent use of "Limits" and the improved support SLA, enhance the value proposition for users.

Consider clarifying the available support channels for the 2-hour SLA. The removal of "email" might imply multiple support options. If this is the case, it would be beneficial to specify them (e.g., "2 hour support SLA (email & chat)").

Also applies to: 135-135

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

145-149: LGTM: Enhanced FeaturedLink styling with smooth transitions

The updated additionalCSS prop improves the visual feedback on hover and maintains consistent theming. The use of responsive classes is a good practice.

Consider extracting the long string of classes into a separate constant or utility function to improve readability. For example:

const getFeaturedLinkClasses = (t: (color: ColorClass) => string) => `
  absolute sm:-translate-x-96 sm:opacity-0 sm:group-hover:translate-x-0
  duration-300 delay-0 sm:group-hover:delay-100 sm:group-hover:opacity-100
  transition-[transform,opacity] font-medium ui-text-p3
  ${t("text-neutral-500")} hover:${t("text-neutral-000")}
`.trim();

// Usage
additionalCSS={getFeaturedLinkClasses(t)}

153-157: LGTM: Added ellipsis with smooth transition

The addition of the ellipsis with transition effects enhances the visual feedback and complements the FeaturedLink hover state. The use of absolute positioning and transforms for the swap animation is a good approach.

Consider using a more semantic HTML element for the ellipsis, such as <span> instead of <div>, as it doesn't contain any block-level content. For example:

<span
  className={`absolute sm:translate-x-0 sm:opacity-100 sm:group-hover:translate-x-96 sm:group-hover:opacity-0 duration-200 delay-100 sm:group-hover:delay-0 transition-[transform,opacity] leading-6 tracking-widen-0.15 font-light text-p3 ${t("text-neutral-800")}`}
>
  •••
</span>

147-149: Improved robustness in icon color selection

The use of the nullish coalescing operator for fallback color selection is a good practice, improving the component's robustness.

Consider using a theme-aware fallback color instead of the hardcoded "text-white". This would ensure better consistency across different themes. For example:

iconColor={t(
  listItemColors?.foreground ?? "text-neutral-000"
)}

This way, the fallback color will be consistent with the current theme settings.

src/core/Tooltip.tsx (2)

22-22: Consider providing a default value for the interactive prop.

While interactive is an optional prop, specifying a default value can enhance clarity and prevent unintended behavior when the prop is undefined.

You can set a default value in the destructuring:

 const Tooltip = ({
   children,
   triggerElement,
   triggerProps,
   tooltipProps,
   theme = "dark",
-  interactive,
+  interactive = false,
   ...rest
 }: PropsWithChildren<TooltipProps>) => {

94-105: Ensure consistent behavior of cursorHeadsNorth across devices.

The cursorHeadsNorth function relies on mouse events and may not behave as expected on touch devices or in different browsers. Consider adding checks or fallbacks for touch events to ensure consistent tooltip behavior across all user devices.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6b5e9d4 and fd92135.

⛔ Files ignored due to path filters (6)
  • src/core/Accordion/__snapshots__/Accordion.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Expander/__snapshots__/Expander.stories.tsx.snap is excluded by !**/*.snap
  • src/core/FeaturedLink/__snapshots__/FeaturedLink.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Pricing/__snapshots__/PricingCards.stories.tsx.snap is excluded by !**/*.snap
  • src/core/ProductTile/__snapshots__/ProductTile.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Tooltip/__snapshots__/Tooltip.stories.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (11)
  • package.json (1 hunks)
  • src/core/Accordion.tsx (2 hunks)
  • src/core/Expander.tsx (1 hunks)
  • src/core/Expander/Expander.stories.tsx (1 hunks)
  • src/core/FeaturedLink.tsx (3 hunks)
  • src/core/Pricing/PricingCards.stories.tsx (1 hunks)
  • src/core/Pricing/PricingCards.tsx (2 hunks)
  • src/core/Pricing/data.tsx (8 hunks)
  • src/core/Pricing/types.ts (1 hunks)
  • src/core/Tooltip.tsx (6 hunks)
  • src/core/Tooltip/Tooltip.stories.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • package.json
  • src/core/Pricing/types.ts
🔇 Additional comments (10)
src/core/FeaturedLink.tsx (2)

57-59: Improved specificity in group styling

The change from group to group/featured-link in the class name is a good improvement. This modification aligns with Tailwind CSS best practices for component-specific styling, allowing for more precise targeting of styles and reducing the risk of unintended style conflicts with other components.


77-77: Consistent group hover styling for reverse icon

The update from group-hover:right-0 to group-hover/featured-link:right-0 in the Icon's additionalCSS prop is consistent with the earlier change to the group class. This modification ensures that the hover effect is specifically tied to the FeaturedLink component, maintaining the existing functionality while improving style isolation.

src/core/Tooltip/Tooltip.stories.tsx (1)

44-77: LGTM! Well-structured story demonstrating the interactive Tooltip.

The new 'Interactive' story effectively showcases the usage of the Tooltip component with the 'interactive' prop. The layout is consistent with other stories, providing a clear comparison between dark and light themes.

Consider adding a comment about the 'ui-link' class.

The interactive link within the Tooltip uses the 'ui-link' class. It might be helpful to add a brief comment explaining this class or referencing where it's defined for better maintainability.

Verify the interactive functionality.

While the story structure looks good, it's important to ensure that the interactive functionality works as expected across different browsers and devices.

To verify the interactive functionality, you can use the Storybook development environment:

Once Storybook is running, navigate to the Tooltip stories and test the following:

  1. Hover over the Tooltip to reveal its content.
  2. Move the cursor into the Tooltip without it disappearing.
  3. Click on the link within the Tooltip to ensure it's clickable.
  4. Verify that the behavior is consistent for both dark and light themes.
src/core/Accordion.tsx (3)

123-123: LGTM! Verify visual consistency across themes.

The addition of mb-16 class for non-transparent themes is a good improvement to the spacing. This change aligns with the PR objectives of updating the accordion component.

To ensure visual consistency, please verify the appearance of the accordion in both transparent and non-transparent themes. Consider adding before/after screenshots to the PR description for easier review.


138-138: LGTM! Verify spacing consistency across themes.

The removal of the conditional pt-16 class standardizes the top padding across all themes, which can lead to more consistent spacing.

Please ensure that this change, in combination with the added mb-16 on the button, provides the desired spacing for the accordion content across all themes. Consider the following:

  1. Test the accordion with various content lengths to ensure proper spacing.
  2. Verify that the removal of pt-16 doesn't create any unintended visual issues, especially for non-transparent themes.
  3. Add before/after screenshots to the PR description showcasing the accordion in different themes and states (open/closed) to facilitate easier review of these spacing changes.

Line range hint 1-194: Overall LGTM! Remember to complete the frontend checklist.

The changes to the Accordion component improve the spacing consistency and align with the PR objectives. Both modifications have been approved, but require visual verification.

As a reminder, please ensure you complete the frontend checklist mentioned in the PR description, including:

  1. Providing before/after screenshots
  2. Testing across different platforms and browsers
  3. Ensuring compliance with accessibility standards

These steps will help validate the visual and functional impact of the changes across various scenarios.

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

75-75: Approved change for consistency

The update from "Capacity" to "Limits" in the Standard plan maintains consistency with the Free plan and improves clarity.

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

80-82: LGTM: Improved styling for price content

The addition of the ui-text-p3 class to the price content wrapper improves styling consistency and aligns with the PR's objective of updating UI components.


Line range hint 1-174: Overall assessment: Well-implemented UI enhancements

The changes in this file successfully achieve the PR's objective of enhancing UI components, specifically for pricing cards. The modifications improve visual presentation, interaction, and responsiveness. The code maintains good practices in terms of theming and responsive design.

Key improvements:

  1. Enhanced styling for price content
  2. Smooth transition effects for interactive elements
  3. Addition of ellipsis for improved visual feedback
  4. More robust color handling

While there are no major issues, consider the minor suggestions provided in the previous comments to further refine the code quality and maintainability.

src/core/Tooltip.tsx (1)

151-151: Conditionally apply pointer-events based on interactive prop.

The application of the pointer-events-none class based on the interactive prop is a good approach to control user interaction with the tooltip content.

Comment on lines +184 to +197
export const ZeroHeightContent = {
render: () => (
<Expander fadeClassName="from-transparent" heightThreshold={0}>
{longContentInner}
</Expander>
),
parameters: {
docs: {
description: {
story: "A fully collapsed body of content.",
},
},
},
};
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 enhancing the ZeroHeightContent story for better demonstration and testing.

The new story effectively showcases a fully collapsed Expander component. However, there are a few suggestions to improve its demonstration and testing capabilities:

  1. Add a play function to simulate user interaction and verify the component's behavior when expanding from a fully collapsed state.
  2. Consider adding a custom control to toggle the heightThreshold between 0 and a larger value to demonstrate the difference in behavior.
  3. The fade effect might not be visible in the fully collapsed state. Consider adding a note in the documentation about this or adjusting the initial state to show a small portion of content.

Here's an example of how you could enhance the story:

export const ZeroHeightContent = {
  render: (args) => (
    <Expander fadeClassName="from-transparent" heightThreshold={args.heightThreshold}>
      {longContentInner}
    </Expander>
  ),
  args: {
    heightThreshold: 0,
  },
  argTypes: {
    heightThreshold: {
      control: { type: 'number' },
    },
  },
  play: async ({ canvasElement }) => {
    const canvas = within(canvasElement);
    const expander = canvas.getByTestId("expander-container");
    
    // Check initial collapsed state
    await expect(expander).toHaveStyle({ height: '0px' });
    
    // Simulate expanding
    const control = canvas.getByTestId("expander-controls");
    await userEvent.click(control);
    
    // Check expanded state
    await waitFor(() => expect(expander).not.toHaveStyle({ height: '0px' }));
  },
  parameters: {
    docs: {
      description: {
        story: "A fully collapsed body of content. Use the heightThreshold control to toggle between fully collapsed and partially visible states.",
      },
    },
  },
};

This enhancement allows for better interaction in Storybook and provides a more comprehensive test of the component's functionality.

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

@jamiehenson jamiehenson merged commit 621002f into main Oct 1, 2024
4 checks passed
@jamiehenson jamiehenson deleted the more-pricing-stuff branch October 1, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants