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-3841] Pricing-oriented improvements #492

Merged
merged 12 commits into from
Sep 24, 2024
Merged

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Sep 24, 2024

Jira Ticket Link / Motivation

https://ably.atlassian.net/browse/WEB-3841

Summary of changes

The commits are fairly granular - this PR is a series of fixes and bumps for Accordion, Expander, PricingCards and Tooltip to serve design requirements in the upcoming pricing page.

How do you manually test this?

Kick back with a good book

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

    • Introduced a new darkTransparent theme for the Accordion component.
    • Added support for custom trigger elements in the Tooltip component.
    • Enhanced Accordion and Expander components with improved content structure and styling.
    • New story export WithResizableInnerContent added for the Accordion component.
  • Improvements

    • Updated the pricing card layout with a new border and backdrop blur effect for enhanced visual hierarchy.
    • Refined conditional rendering of the call-to-action button and improved responsiveness of sections.
    • Updated the pricing card to display the dollar sign only for valid amounts.
    • Updated dependencies in the project for better performance and compatibility.
  • Bug Fixes

    • Resolved issues related to theme handling and component visibility.
  • Documentation

    • Added new story exports and updated existing ones to reflect recent changes in components.

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

The changes include updates to the package.json file, where the package version was incremented, and a new dependency was added. Additionally, the react-dom dependency version was updated. Significant modifications were made to the PricingCards.tsx component, focusing on layout and styling enhancements, including a new border and backdrop blur effect, improved responsiveness, and refined conditional rendering for the call-to-action button. Lastly, the .storybook/test-runner.ts file was updated to simplify the reference to a story.

Changes

File Change Summary
package.json - Version incremented from 14.6.1 to 14.6.2.
- Added dependency @types/react-dom (^18.3.0).
- Updated react-dom from ^18.2.0 to ^18.3.1.
src/core/Pricing/PricingCards.tsx - Modified structure and styling of pricing cards, including layout adjustments, a new border, backdrop blur effect, and improved responsiveness.
- Reorganized title and description elements, and refined CTA button rendering.
.storybook/test-runner.ts - Updated flakyStories to remove the --signed-in suffix from components-meganav, simplifying the reference.

Poem

In the meadow where the code does bloom,
New borders and styles chase away the gloom.
With pricing cards bright and a blur so fine,
Our changes hop forth, like bunnies in line!
Let’s cheer for the updates, a joyful delight,
As we code and we play, everything feels right! 🐇✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 39782b8 and dfe0345.

Files ignored due to path filters (1)
  • src/core/Meganav/__snapshots__/Meganav.stories.tsx.snap is excluded by !**/*.snap
Files selected for processing (1)
  • .storybook/test-runner.ts (1 hunks)
Additional comments not posted (1)
.storybook/test-runner.ts (1)

3-3: LGTM! Consider verifying coverage and future scalability.

The change to simplify the components-meganav entry in the flakyStories array aligns with your intention to exclude all Meganav components from snapshotting. This is a good step towards reducing flaky tests.

To ensure this change captures all intended Meganav stories and doesn't unintentionally exclude other stories, please run the following verification:

Consider the following suggestions for future improvements:

  1. Update any relevant documentation to reflect this change in snapshot testing behavior for Meganav components.

  2. For better scalability, consider implementing a more dynamic approach to manage flaky stories. For example, you could use a configuration file or a naming convention that automatically excludes certain story categories from snapshot testing. This would make it easier to manage as the number of components grows.

Example of a more scalable approach:

const flakyStoryPatterns = [
  /components-status/,
  /components-meganav/,
  // Add more patterns as needed
];

// In the postVisit function
if (flakyStoryPatterns.some((pattern) => pattern.test(url))) {
  return;
}

This approach would allow for easier addition and management of flaky story patterns in the future.

Verification successful

Verified! Meganav stories are correctly excluded from snapshot testing.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: List all Meganav-related stories and verify they're excluded from snapshot testing

# Test: List all Meganav-related story files
echo "Meganav-related story files:"
fd -e stories.tsx meganav

# Test: Check if any Meganav stories are still included in snapshot testing
echo "Meganav stories potentially still included in snapshot testing:"
rg -i "meganav.*stories" .storybook | grep -v "flakyStories"

Length of output: 329


Script:

#!/bin/bash
# Description: Verify that all Meganav-related stories are excluded from snapshot testing

# Test: Search for usages of 'flakyStories' in test runner configuration
echo "Searching for 'flakyStories' usage in test runner configuration:"
rg "flakyStories" .storybook/test-runner.ts

# Test: Verify that 'components-meganav' is included in 'flakyStories'
echo "Verifying 'components-meganav' is in 'flakyStories':"
rg "flakyStories\s*=\s*\[.*\]" .storybook/test-runner.ts | grep "components-meganav"

# Test: Ensure that no Meganav stories are being snapshot tested elsewhere
echo "Ensuring no Meganav stories are included in snapshot testing elsewhere:"
rg -i "meganav.*snapshot" .storybook | grep -v "flakyStories"

Length of output: 808


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.

@jamiehenson
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Outside diff range and nitpick comments (11)
src/core/Accordion/types.ts (1)

38-38: LGTM! Consider updating documentation.

The addition of the optional border property to AccordionThemeColors is a good enhancement for customization.

Consider updating the component's documentation to reflect this new theming option. This will help developers understand and utilize the new border property effectively.

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

16-24: Improved layout and theme presentation.

The changes to the Central story significantly enhance the presentation of the Tooltip component:

  1. The new grid layout with two columns provides a clear side-by-side comparison of dark and light themes.
  2. The added styling for each theme (background color for dark theme) improves visual context.
  3. The consistent sizing and centering of tooltips in both themes allow for easy comparison.

These modifications align well with the PR objectives of improving design requirements for the upcoming pricing page.

For consistency, consider adding a label above each tooltip to indicate the theme, similar to how you've labeled the columns. This could be achieved by adding a <p> element above each tooltip with the theme name.

 <div className="grid grid-cols-2 gap-16 w-[600px]">
   <div className="font-mono text-center">dark</div>
   <div className="font-mono text-center">light</div>
   <div className="w-256 h-256 bg-neutral-1300 flex items-center justify-center m-24 border mx-auto rounded-lg">
+    <p className="absolute top-2 left-2 text-white">Dark theme</p>
     <Tooltip>{args.children}</Tooltip>
   </div>
   <div className="w-256 h-256 flex items-center justify-center m-24 border mx-auto rounded-lg">
+    <p className="absolute top-2 left-2">Light theme</p>
     <Tooltip theme="light">{args.children}</Tooltip>
   </div>
 </div>

This addition would further improve the clarity of the story for users viewing the component documentation.


31-39: Consistent improvements and demonstration of left-bound alignment.

The changes to the LeftBound story maintain consistency with the Central story while showcasing a different alignment:

  1. The grid layout and theme presentation are consistent with the Central story, which is good for maintaining a cohesive documentation style.
  2. The use of items-center without justify-center effectively demonstrates how the Tooltip behaves when left-aligned.

These changes contribute to a more comprehensive showcase of the Tooltip component's versatility.

To make the difference between the Central and LeftBound stories more apparent, consider adding a visual indicator or label that highlights the left-bound nature of this variation. This could be achieved by adding a vertical line or a label to the left of each tooltip. For example:

 <div className="grid grid-cols-2 gap-16 w-[600px]">
   <div className="font-mono text-center">dark</div>
   <div className="font-mono text-center">light</div>
-  <div className="w-256 h-256 bg-neutral-1300 flex items-center m-24 border mx-auto rounded-lg">
+  <div className="w-256 h-256 bg-neutral-1300 flex items-center m-24 border mx-auto rounded-lg relative">
+    <div className="absolute left-0 top-0 bottom-0 w-1 bg-red-500"></div>
+    <p className="absolute top-2 left-4 text-white text-sm">Left-bound</p>
     <Tooltip>{args.children}</Tooltip>
   </div>
-  <div className="w-256 h-256 flex items-center m-24 border mx-auto rounded-lg">
+  <div className="w-256 h-256 flex items-center m-24 border mx-auto rounded-lg relative">
+    <div className="absolute left-0 top-0 bottom-0 w-1 bg-red-500"></div>
+    <p className="absolute top-2 left-4 text-sm">Left-bound</p>
     <Tooltip theme="light">{args.children}</Tooltip>
   </div>
 </div>

This addition would make it immediately clear to users viewing the documentation that this story demonstrates a left-bound variation of the Tooltip.

src/core/Tooltip.tsx (3)

5-6: LGTM! Consider adding JSDoc comments for new props.

The new imports and type definitions align well with the component's enhanced functionality. The addition of triggerElement prop and the default value for theme improve the component's flexibility and usability.

Consider adding JSDoc comments for the new triggerElement prop and the updated theme prop to improve documentation:

/**
 * Custom element to trigger the tooltip. If not provided, a default info icon will be used.
 */
triggerElement?: ReactNode;

/**
 * Theme for the tooltip. Defaults to "dark".
 */
theme?: Theme;

Also applies to: 10-10, 12-13, 16-16, 19-19, 24-24, 27-27, 31-31


39-75: LGTM! Consider refactoring for improved readability.

The use of useLayoutEffect for synchronous layout calculations is appropriate. The positioning logic comprehensively handles edge cases for all sides of the viewport, ensuring the tooltip remains visible.

To improve readability and maintainability, consider refactoring the positioning logic into separate functions:

const calculateInitialPosition = (referenceRect: DOMRect, floatingRect: DOMRect) => {
  return {
    x: referenceRect.left + referenceRect.width / 2 - floatingRect.width / 2 + window.scrollX,
    y: referenceRect.top - floatingRect.height - offset + window.scrollY
  };
};

const adjustForViewportBounds = (position: {x: number, y: number}, floatingRect: DOMRect, referenceRect: DOMRect) => {
  let { x, y } = position;
  const viewportWidth = window.innerWidth;
  const viewportHeight = window.innerHeight;

  // Adjust for right edge
  if (x + floatingRect.width > viewportWidth + window.scrollX) {
    x = viewportWidth + window.scrollX - floatingRect.width - offset;
  }

  // Adjust for left edge
  if (x < window.scrollX) {
    x = window.scrollX + offset;
  }

  // Adjust for top edge
  if (y < window.scrollY) {
    y = referenceRect.bottom + offset + window.scrollY;
  }

  // Adjust for bottom edge
  if (y + floatingRect.height > viewportHeight + window.scrollY) {
    y = referenceRect.top - floatingRect.height - offset + window.scrollY;
  }

  return { x, y };
};

useLayoutEffect(() => {
  if (open) {
    const floatingRect = floating.current?.getBoundingClientRect();
    const referenceRect = reference.current?.getBoundingClientRect();

    if (floatingRect && referenceRect) {
      const initialPosition = calculateInitialPosition(referenceRect, floatingRect);
      const adjustedPosition = adjustForViewportBounds(initialPosition, floatingRect, referenceRect);
      setPosition(adjustedPosition);
    }
  } else {
    setPosition({ x: 0, y: 0 });
  }
}, [open]);

This refactoring separates the concerns of initial positioning and viewport boundary adjustments, making the code more modular and easier to understand.


115-135: LGTM! Consider extracting className logic.

The use of createPortal for rendering the tooltip is appropriate and helps avoid z-index issues. The positioning and styling are consistent with the earlier calculations.

To improve readability, consider extracting the complex className string into a separate function:

const getTooltipClassName = (theme: Theme, fadeOut: boolean, additionalClassName?: string) => {
  return `${t("bg-neutral-1000")} ${t("text-neutral-200")} ui-text-p3 font-medium p-16 rounded-lg pointer-events-none absolute ${
    additionalClassName ?? ""
  } ${fadeOut ? "animate-[tooltipExit_0.25s_ease-in-out]" : "animate-[tooltipEntry_0.25s_ease-in-out]"}`;
};

// Usage
className={getTooltipClassName(theme, fadeOut, tooltipProps?.className)}

This extraction would make the JSX more readable and the className logic more maintainable.

src/core/Accordion/Accordion.stories.tsx (3)

6-9: Improved code structure with reusable text content.

The introduction of loremText as a separate constant improves code reusability and maintainability. This change is beneficial for potential future localization or content updates.

Consider using a template literal for better readability:

-const loremText =
-  "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin scelerisque congue risus id lobortis. Vivamus blandit dolor at ultricies cursus. Phasellus pharetra nunc erat, quis porttitor mauris faucibus in. Donec feugiat dapibus orci et blandit. Duis eleifend accumsan est nec euismod. Proin imperdiet malesuada lacus, a aliquam eros aliquet nec. Sed eu dolor finibus, sodales nisl a, egestas mi. In semper interdum lacinia. Duis malesuada diam quis purus blandit, sit amet imperdiet neque accumsan. Morbi viverra vitae risus ut pellentesque. Praesent ac blandit augue. Aliquam purus lectus, lacinia in semper vitae, dictum eu felis. Donec vel pulvinar eros, id facilisis neque. Aenean odio arcu, accumsan vel est in, lobortis rhoncus ligula. Pellentesque sit amet odio velit.";
+const loremText = `
+  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin scelerisque congue risus id lobortis.
+  Vivamus blandit dolor at ultricies cursus. Phasellus pharetra nunc erat, quis porttitor mauris faucibus in.
+  Donec feugiat dapibus orci et blandit. Duis eleifend accumsan est nec euismod. Proin imperdiet malesuada lacus,
+  a aliquam eros aliquet nec. Sed eu dolor finibus, sodales nisl a, egestas mi. In semper interdum lacinia.
+  Duis malesuada diam quis purus blandit, sit amet imperdiet neque accumsan. Morbi viverra vitae risus ut pellentesque.
+  Praesent ac blandit augue. Aliquam purus lectus, lacinia in semper vitae, dictum eu felis.
+  Donec vel pulvinar eros, id facilisis neque. Aenean odio arcu, accumsan vel est in, lobortis rhoncus ligula.
+  Pellentesque sit amet odio velit.
+`.trim().replace(/\n\s+/g, ' ');

This change would make the text content more readable in the source code while preserving the single-line output.


11-15: New textarea element for demonstrating dynamic content.

The addition of the textarea constant provides a good way to showcase the Accordion's ability to handle resizable content. This is a valuable addition to the story.

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

 const textarea = (
   <textarea
     className="w-full h-256 bg-neutral-700 p-16 rounded-xl leading-relaxed"
     defaultValue={loremText}
+    aria-label="Resizable content example"
   />
 );

This change would make the textarea more accessible to screen readers.


160-173: New story showcasing resizable content functionality.

The addition of the WithResizableInnerContent story is an excellent way to demonstrate the Accordion's ability to handle dynamic, resizable content. The description provides clear instructions for manual testing.

Consider enhancing the description to provide more context:

 export const WithResizableInnerContent = {
   render: () =>
     AccordionPresentation({
       data: dataWithTextarea,
     }),
   parameters: {
     docs: {
       description: {
         story:
-          "Try resizing content within the Accordion entries - the container should respond to the new height accordingly",
+          "This story demonstrates the Accordion's ability to handle dynamic content. Try resizing the textarea within the Accordion entries - the container should respond to the new height accordingly, showcasing the component's flexibility with varying content sizes.",
       },
     },
   },
 };

This expanded description provides more context about the purpose of the story and what it's demonstrating.

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

Line range hint 153-180: Update play function to account for new JSX structure

The play function currently checks for the text content "Away with you, knave." directly. With the new JSX structure, this test might fail as it doesn't account for the added icon.

Consider updating the play function to either:

  1. Use a more flexible matching method, like:
await expect(canvas.getByTestId("expander-controls")).toHaveTextContent(/Away with you, knave/);
  1. Or, if you want to be more specific, check for both the text and the icon:
const controlsElement = canvas.getByTestId("expander-controls");
await expect(controlsElement).toHaveTextContent("Away with you, knave.");
await expect(controlsElement.querySelector('svg[name="icon-gui-warning"]')).toBeInTheDocument();
tailwind.config.js (1)

322-331: LGTM: Smooth tooltip animations added

The addition of tooltipEntry and tooltipExit keyframes is a great improvement for enhancing the user experience with smooth tooltip animations. The entry animation combines a slight upward movement with a fade-in effect, while the exit animation provides a clean fade-out.

Consider adding a subtle scale effect to the tooltipEntry animation for an even more polished look. For example:

 tooltipEntry: {
-  "0%": { transform: "translateY(8px)", opacity: 0 },
-  "100%": { transform: "translateY(0)", opacity: 1 },
+  "0%": { transform: "translateY(8px) scale(0.95)", opacity: 0 },
+  "100%": { transform: "translateY(0) scale(1)", opacity: 1 },
 },

This would add a slight "pop" effect as the tooltip appears, potentially making it more noticeable to users.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7b21df9 and fc2e10f.

Files ignored due to path filters (7)
  • 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/Meganav/__snapshots__/Meganav.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Pricing/__snapshots__/PricingCards.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Table/__snapshots__/Table.stories.tsx.snap is excluded by !**/*.snap
  • src/core/Tooltip/__snapshots__/Tooltip.stories.tsx.snap is excluded by !**/*.snap
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (13)
  • package.json (3 hunks)
  • src/core/Accordion.tsx (3 hunks)
  • src/core/Accordion/Accordion.stories.tsx (4 hunks)
  • src/core/Accordion/types.ts (2 hunks)
  • src/core/Expander.tsx (1 hunks)
  • src/core/Expander/Expander.stories.tsx (2 hunks)
  • src/core/Pricing/PricingCards.stories.tsx (1 hunks)
  • src/core/Pricing/PricingCards.tsx (1 hunks)
  • src/core/Tooltip.tsx (3 hunks)
  • src/core/Tooltip/Tooltip.stories.tsx (1 hunks)
  • src/core/styles/colors/types.ts (1 hunks)
  • src/core/styles/colors/utils.ts (1 hunks)
  • tailwind.config.js (2 hunks)
Additional context used
Learnings (1)
src/core/styles/colors/types.ts (1)
Learnt from: jamiehenson
PR: ably/ably-ui#486
File: src/core/styles/colors/types.ts:8-15
Timestamp: 2024-09-18T14:08:15.229Z
Learning: When updating `ColorClassVariants` and `ColorClassPrefixes`, only include variants and prefixes that relate to colour classes.
Additional comments not posted (34)
src/core/Accordion/types.ts (2)

Line range hint 1-48: Overall, the changes look good and enhance the Accordion component.

The additions of the "darkTransparent" theme and the optional border property improve the component's flexibility and customization options. These changes are well-implemented and maintain backward compatibility.

To ensure the best developer experience:

  1. Verify the implementation of the "darkTransparent" theme in the component's logic and styling.
  2. Update the component's documentation to reflect the new theming options.

22-27: LGTM! Verify the implementation of the new theme.

The addition of the "darkTransparent" theme to the accordionThemes array is a good enhancement to the Accordion component's flexibility.

Please ensure that the new "darkTransparent" theme is properly implemented in the component's logic and styling. Run the following script to verify the theme usage:

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

20-22: Clarify the purpose of the gradient background change

The background for the dark theme has been updated from a solid color (bg-neutral-1300) to a gradient (bg-gradient-to-r from-blue-500 to-pink-500). While this change enhances the visual appeal of the Storybook demo, I have a few points to consider:

  1. Does this gradient background align with the design requirements mentioned in the PR objectives for the upcoming pricing page?
  2. Have you verified that the gradient background doesn't negatively impact the readability of the PricingCards component in dark mode?
  3. Is this change intended for the actual application, or is it only for demonstration purposes in Storybook?

To ensure consistency across the codebase, let's check if similar gradient backgrounds are used elsewhere:

Additionally, could you provide before/after screenshots of the PricingCards component with this new background to help assess its visual impact?

Verification successful

Gradient background change is specific to PricingCards.stories.tsx

The search indicates that the gradient background (bg-gradient-to-r from-blue-500 to-pink-500) is only applied within src/core/Pricing/PricingCards.stories.tsx. This suggests that the change is confined to the Storybook environment and does not affect other parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar gradient background classes in other files
rg --type typescript --type javascript 'bg-gradient-to-r from-blue-500 to-pink-500'

Length of output: 120


Script:

#!/bin/bash
# Search for similar gradient background classes in TypeScript and JavaScript files
rg --type ts --type tsx --type js --type jsx 'bg-gradient-to-r from-blue-500 to-pink-500'

Length of output: 119


Script:

#!/bin/bash
# Search for similar gradient background classes in TypeScript and JavaScript files
rg --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.jsx' 'bg-gradient-to-r from-blue-500 to-pink-500'

Length of output: 244

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

9-10: Improved default content for better visualization.

The update to the children prop with a longer Lorem ipsum text is a good change. It provides a more realistic example of tooltip content, allowing for better visualization of how the component handles longer text. This modification will be helpful for testing and demonstrating the Tooltip's capabilities with various content lengths.


Line range hint 1-41: Summary: Improved Tooltip stories with enhanced layout and theme presentation

The changes made to this file significantly improve the presentation and testing capabilities of the Tooltip component:

  1. The default args now use a more realistic, longer text content.
  2. Both Central and LeftBound stories now showcase dark and light themes side by side.
  3. The new grid layout provides a clear and consistent way to compare different Tooltip variations.

These improvements align well with the PR objectives of enhancing design requirements for the upcoming pricing page. The changes will make it easier for developers and designers to visualize and test the Tooltip component in various scenarios.

Minor suggestions have been made to further improve clarity and consistency across the stories. Overall, these changes represent a positive step in improving the component's documentation and usability.

src/core/styles/colors/utils.ts (1)

29-32: Improved flexibility in color string processing

The changes to the determineThemeColor function enhance its ability to handle more complex color string formats. This is a positive improvement that allows for greater flexibility in the theming system.

However, consider the following points:

  1. Backward Compatibility: Ensure that this change doesn't break existing color string formats. It might be helpful to add a comment explaining the expected format of the color string.

  2. Edge Cases: Consider adding checks for edge cases, such as when splitColor.length is exactly 2 or less than 2.

  3. Input Validation: It may be beneficial to add input validation to ensure the color string is in the expected format before processing.

To ensure this change doesn't introduce any regressions, let's verify the usage of this function:

Verification successful

Verification Successful: No Issues Found

The updates to the determineThemeColor function have been verified across the codebase. All existing usages conform to the new color string format, and no regressions were detected.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of determineThemeColor function and color string formats

# Search for calls to determineThemeColor
echo "Calls to determineThemeColor:"
rg --type typescript "determineThemeColor\(" -A 3

# Search for color string definitions that might be affected
echo "\nColor string definitions:"
rg --type typescript "(const|let|var)\s+\w+\s*=\s*['\"]\w+(-\w+){2,}['\"]" -A 1

Length of output: 341


Script:

#!/bin/bash
# Description: Check usage of determineThemeColor function and color string formats

# Search for calls to determineThemeColor in .ts and .tsx files
echo "Calls to determineThemeColor:"
rg "determineThemeColor\(" --glob "*.ts" --glob "*.tsx" -A 3

# Search for color string definitions that might be affected in .ts and .tsx files
echo "\nColor string definitions:"
rg "(const|let|var)\s+\w+\s*=\s*['\"]\w+(-\w+){2,}['\"]" --glob "*.ts" --glob "*.tsx" -A 1

Length of output: 1323

src/core/styles/colors/types.ts (2)

15-15: LGTM: Addition of "border" to ColorClassPrefixes

The addition of "border" to the ColorClassPrefixes type is a good improvement. This change allows for the generation of border color classes, which is a common and useful feature in CSS styling. The modification is consistent with the existing color-related prefixes and aligns with the learning from the previous PR to include only color-related variants and prefixes.

This update will enable more flexible color styling options, particularly for border colors, throughout the application.


15-15: Verify usage of updated ColorClass type

While the change to ColorClassPrefixes is straightforward and beneficial, it's important to ensure that this update doesn't cause any unintended effects in other parts of the codebase that use the ColorClass type.

Let's check for any potential impacts:

This script will help identify any areas that might need attention due to the ColorClass type change.

src/core/Expander.tsx (3)

1-7: LGTM: Import statement updated correctly.

The addition of ReactNode to the import statement is consistent with its usage in the updated type definitions for controlsOpenedLabel and controlsClosedLabel.


1-16: Summary: Beneficial changes to Expander component.

The modifications to the Expander component, specifically the type changes for controlsOpenedLabel and controlsClosedLabel, enhance its flexibility by allowing both string and ReactNode inputs. This update aligns with modern React practices and potentially improves the component's reusability.

Key points:

  1. The import statement has been correctly updated to include ReactNode.
  2. The ExpanderProps type definition now allows more diverse inputs for control labels.

These changes are positive improvements to the component. However, it's crucial to verify that existing usages of the Expander component across the codebase are compatible with these new type definitions. The provided verification script will help identify any areas that may need updates.


15-16: Approve type changes and verify usage.

The update to allow both string and ReactNode for controlsOpenedLabel and controlsClosedLabel provides more flexibility in the Expander component. This change is beneficial and aligns with modern React practices.

To ensure this change doesn't introduce issues elsewhere, please run the following script to check the usage of the Expander component across the codebase:

Review the results to ensure that all usages of these props are compatible with the new type definition. If any incompatibilities are found, they should be updated accordingly.

Verification successful

Adjust the search script to correctly target TypeScript files and rerun verification.

The previous script encountered issues with unrecognized file types. Please use the updated script below to search for Expander component usages and the specific props within .ts and .tsx files:

Please execute this script and provide the output to continue the verification process.


Type changes verified: No issues found with controlsOpenedLabel and controlsClosedLabel usages.

The updates allowing string | ReactNode for controlsOpenedLabel and controlsClosedLabel are compatible with all existing usages in the codebase. No further actions are required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of the Expander component and check if controlsOpenedLabel or controlsClosedLabel are used.

# Search for Expander component usage
echo "Searching for Expander component usage:"
rg --type typescript --type typescriptreact '<Expander' -A 10

# Search for specific prop usage
echo "\nSearching for controlsOpenedLabel usage:"
rg --type typescript --type typescriptreact 'controlsOpenedLabel'

echo "\nSearching for controlsClosedLabel usage:"
rg --type typescript --type typescriptreact 'controlsClosedLabel'

Length of output: 579


Script:

#!/bin/bash
# Description: Find all usages of the Expander component and check if controlsOpenedLabel or controlsClosedLabel are used.

# Search for Expander component usage
echo "Searching for Expander component usage:"
rg '<Expander' -A 10 -g "*.ts" -g "*.tsx"

# Search for specific prop usage
echo "\nSearching for controlsOpenedLabel usage:"
rg 'controlsOpenedLabel' -g "*.ts" -g "*.tsx"

echo "\nSearching for controlsClosedLabel usage:"
rg 'controlsClosedLabel' -g "*.ts" -g "*.tsx"

Length of output: 4652

package.json (4)

3-3: Version update looks good.

The version has been incremented to 14.6.2-dev.7b98b73, which is appropriate for a development version. This aligns with the PR objectives mentioning updates to several components.


34-34: Good addition of @types/react-dom.

Adding type definitions for react-dom is a good practice. The version ^18.3.0 is compatible with the react-dom version being used (^18.3.1). This addition will improve type checking and developer experience.


Line range hint 1-95: Overall, the changes look good with one point to verify.

The package.json updates include:

  1. A version bump to a development version.
  2. Addition of @types/react-dom for improved TypeScript support.
  3. An update to react-dom.

These changes are generally positive, improving type definitions and keeping dependencies up-to-date. The main point to verify is the necessity and impact of the react-dom update from 18.2 to 18.3.

Please ensure all changes align with the PR objectives and have been thoroughly tested.


82-82: Verify the necessity of updating react-dom.

The update of react-dom from ^18.2.0 to ^18.3.1 is generally a good practice. However, please verify:

  1. Is this update necessary for the current PR objectives?
  2. Have you tested the application thoroughly to ensure this update doesn't introduce any breaking changes?
  3. Are there any new features in react-dom 18.3 that this project will utilize?

To help verify the impact of this change, you can run the following script:

src/core/Tooltip.tsx (4)

91-97: LGTM! Smooth fade-out animation implementation.

The implementation of the fade-out animation is well done. The use of setTimeout with a 250ms delay ensures that the animation completes before closing the tooltip, providing a smooth user experience.


106-112: LGTM! Flexible trigger element implementation.

The conditional rendering of either a custom triggerElement or the default Icon component provides excellent flexibility for the Tooltip usage. The color determination using the t function is consistent with the earlier implementation.


Line range hint 1-141: Overall, excellent improvements to the Tooltip component.

The changes in this file significantly enhance the functionality and user experience of the Tooltip component. The implementation of custom trigger elements, improved positioning logic, and smooth animations align well with the PR objectives. The use of createPortal and useLayoutEffect demonstrates a good understanding of React best practices.

While there are a few minor suggestions for improvements (such as adding JSDoc comments, refactoring complex logic, and extracting className calculations), the overall implementation is solid and well-thought-out.

Great job on these improvements!


37-38: Verify the correctness of the theme argument in determineThemeColor.

The t function is using "light" as the first argument to determineThemeColor, but the default theme for the component is set to "dark". This might lead to unexpected color determinations.

Please confirm if this is intentional or if it should be changed to use the theme prop:

const t = (color: ColorClass) => determineThemeColor(theme, theme, color);

To verify the usage of determineThemeColor, let's check its implementation:

src/core/Accordion/Accordion.stories.tsx (2)

28-31: New dataset with resizable content.

The introduction of dataWithTextarea is a good approach to create a dataset for demonstrating the Accordion with resizable content. It maintains the structure of the original data while replacing the content with the textarea element.

This change aligns well with the new story for resizable content that has been added.


47-52: Layout adjustment and theme-specific styling.

The changes to the AccordionPresentation component improve the layout and visual consistency:

  1. The grid layout has been changed from three columns to two, which may improve responsiveness or accommodate larger content.
  2. A conditional class for dark themes has been added, improving visual contrast for dark-themed accordions.

These changes are positive improvements to the component's presentation.

Please verify that the layout change from three columns to two doesn't negatively impact the visual presentation of the accordions. You can use the following script to check for any other grid column changes in the codebase:

This will help ensure that the column change is consistent with other parts of the UI.

Verification successful

Grid column changes are consistent across the codebase.

The modification to use grid-cols-2 in the AccordionPresentation component aligns with existing grid configurations in other components. No inconsistencies were found that would negatively impact the visual presentation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other grid column changes in the codebase

# Search for grid column class changes
echo "Searching for grid column class changes:"
rg --type tsx --type jsx 'grid-cols-[23]' -C 2

Length of output: 167


Script:

#!/bin/bash
# Description: Check for other grid column class changes in the codebase

# Searching for grid-cols-2 or grid-cols-3 in tsx and jsx files
echo "Searching for grid column class changes in tsx and jsx files:"
rg 'grid-cols-(2|3)' --glob '*.tsx' --glob '*.jsx' -C 2

Length of output: 5740

src/core/Expander/Expander.stories.tsx (3)

4-4: LGTM: Icon import added correctly

The import for the Icon component has been added appropriately. This import is necessary for the changes made in the OverriddenControls story.


140-145: LGTM: Enhanced visual representation of opened label

The change to the controlsOpenedLabel prop improves the visual representation by adding an icon alongside the text. The use of a flex container with gap ensures proper alignment. This update aligns well with the PR objectives of updating components to meet design requirements.


Line range hint 1-180: Summary: Good improvements with a minor test update needed

The changes to this file enhance the visual representation of the Expander component by adding an icon to the opened label. This aligns well with the PR objectives of updating components to meet design requirements. The Icon import and usage are implemented correctly.

The only suggestion is to update the play function to account for the new JSX structure of the controlsOpenedLabel. This will ensure that the tests continue to pass and accurately reflect the component's behavior.

Overall, these changes contribute positively to the "[WEB-3841] Pricing-oriented improvements" pull request.

tailwind.config.js (2)

14-14: LGTM: Enhanced styling flexibility with group-hover

The addition of the "group-hover" variant to this pattern is a good improvement. It allows for more dynamic styling options, particularly useful for interactive components where you want to change styles based on hovering over a parent element.


Line range hint 1-365: Summary: Tailwind config changes align with PR objectives

The changes made to tailwind.config.js are well-aligned with the PR objectives of improving components for the pricing page. The addition of the "group-hover" variant enhances styling flexibility, which can be particularly useful for interactive components like Accordion and Expander. The new tooltip animations will directly benefit the Tooltip component, providing a smoother and more polished user experience.

These improvements contribute to meeting the design requirements for the upcoming pricing page. The changes are focused and purposeful, adhering to the PR's goals without introducing unnecessary modifications.

src/core/Accordion.tsx (8)

51-56: Addition of border properties to the 'transparent' theme looks good

The inclusion of border in the transparent theme ensures consistent styling for accordion items when using this theme.


57-62: New 'darkTransparent' theme implemented correctly

The darkTransparent theme is correctly added, providing an option for dark-themed transparent accordions with appropriate styling attributes.


67-67: Updated isNonTransparentTheme function accommodates 'darkTransparent'

Modifying the isNonTransparentTheme function to include 'darkTransparent' ensures that padding and other style considerations are correctly applied based on the theme transparency.


84-88: Enhanced height adjustment using ResizeObserver

Replacing the throttled resize handler with a ResizeObserver improves performance and responsiveness by directly observing size changes of the content.


90-98: Properly observing and unobserving rowRef

The setup and cleanup of the ResizeObserver are correctly handled, preventing potential memory leaks and ensuring that the observer is active only when needed.


103-111: Destructuring theme properties including 'border'

Including border in the destructured properties from themeClasses[theme] ensures that all relevant styling attributes are applied to the accordion component based on the selected theme.


119-119: Applying border classes to the accordion row container

Adding the border class to the outer div correctly implements the border styling for each accordion row as defined by the theme.


138-138: Conditional padding applied based on theme transparency

Using the isNonTransparentTheme check to conditionally apply pt-16 ensures consistent spacing for non-transparent themes while maintaining design expectations for transparent themes.

src/core/Accordion.tsx Show resolved Hide resolved
src/core/Pricing/PricingCards.tsx Outdated Show resolved Hide resolved

handleHeight();
if (rowRef.current) {
resizeObserver.observe(rowRef.current);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a superior api for judging resize events as it also takes into account the resizing of the target element, not just the window. We need this for accordions-inside-of-accordions, as pricing demands

import throttle from "lodash.throttle";

type ExpanderProps = {
heightThreshold?: number;
className?: string;
fadeClassName?: string;
controlsClassName?: string;
controlsOpenedLabel?: string;
controlsClosedLabel?: string;
controlsOpenedLabel?: string | ReactNode;
Copy link
Member Author

Choose a reason for hiding this comment

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

This allows things like icons to be passed in as well

@@ -45,110 +45,109 @@ const PricingCards = ({
<Fragment key={title.content}>
{delimiterColumn(index)}
<div
className={`flex flex-1 p-1 bg-gradient-to-b ${t("from-neutral-1100")} ${t("to-neutral-1100")} rounded-2xl min-w-[272px]`}
className={`relative border ${t("border-neutral-1100")} flex-1 px-24 py-32 flex flex-col gap-24 rounded-2xl group ${delimiter ? "@[520px]:flex-row @[920px]:flex-col" : ""} min-w-[272px] overflow-hidden backdrop-blur`}
Copy link
Member Author

Choose a reason for hiding this comment

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

Lot of DOM juggling here but the tldr is a rejigging of the backgrounds so that we can support translucency. Alas we lose the gradient border but I made a call to ditch that in favour of the blur as it's more noticable

referenceRect.width / 2,
y: Math.min(floatingRect.height, floatingRect.top) + offset,
});
let x =
Copy link
Member Author

Choose a reason for hiding this comment

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

Sorted all this tooltip instantiation logic out, it was the bare minimum before. Now it takes into account the whole viewport and its own placement with respect to the edges, and is appended to the end of the body.

Copy link
Member Author

Choose a reason for hiding this comment

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

The tooltip also now has entry and exit animations

@@ -26,8 +26,10 @@ export const determineThemeColor = (
} else {
const splitColor = color.split("-");

if (splitColor.length === 3) {
const [property, palette, variant] = splitColor;
if (splitColor.length >= 3) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is to support prefixes like group-hover, whose hyphen messed up the old logic

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.

Firing up storybook next, one question on the 🐰's suggestion only

src/core/Pricing/PricingCards.tsx Outdated Show resolved Hide resolved
@jamiehenson
Copy link
Member Author

@kennethkalmer I re-added 🐰's suggestion, it was lost when I force pushed. Btw, you needn't pull down and run Storybook these days, we have review builds now. There's a link in the PR description.

@kennethkalmer
Copy link
Member

@kennethkalmer I re-added 🐰's suggestion, it was lost when I force pushed. Btw, you needn't pull down and run Storybook these days, we have review builds now. There's a link in the PR description.

@jamiehenson OMG this is awesome, I did not even notice

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.

Snapshot issues aside, this looks great @jamiehenson. I only tested in Safari, for completeness sake :P

@jamiehenson
Copy link
Member Author

Thanks - the Status widget keeps playing havoc with the snapshots, I'll exclude all the Meganav components from snapshotting

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.

2 participants