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] 14.6.0 - PricingCards component #486

Merged
merged 7 commits into from
Sep 19, 2024
Merged

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Sep 18, 2024

Summary of changes

This PR adds the PricingCards component, which forms the basis of a couple of components on the Pricing page - it is being packaged as a part of ably-ui as it is also needed for a dashboard page on website, as well as the Pricing page on voltaire.

A Storybook link to this component is available here.

Additionally in this PR are the following things:

  • dynamic theming - there's a lot more talk of supporting both light and dark themes in our forthcoming designs and this starts to lay the groundwork for that. Using determineThemeColor, you can supply a reference theme, the active theme, and a color, and it will give you the correct colour for those conditions automatically without having to define two themes
  • an extension of the ColorClass typings to include hover and focus state variants of colour classes, as well as gradient classes
  • general Storybook fixes

How do you manually test this?

Use the Storybook link, or pull down and have a look yourself.

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 PricingCards component for displaying dynamic pricing options.
    • Added support for responsive design using container queries with Tailwind CSS.
  • Enhancements

    • Improved Storybook organization by adding a new "Features" category.
    • Enhanced icon loading for better visual representation in stories.
    • Updated color management to support dynamic theming and improved CSS transitions.
  • Bug Fixes

    • Adjusted the iconColor prop for more flexible usage in the FeaturedLink component.
  • Documentation

    • Added story definitions for PricingCards to enhance developer usability.

Copy link
Contributor

coderabbitai bot commented Sep 18, 2024

Warning

Rate limit exceeded

@jamiehenson has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 8 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 82b8019 and 024830b.

Walkthrough

The changes encompass updates across multiple files, focusing on enhancing the Storybook configuration, introducing a new PricingCards component, and adding TypeScript type definitions for pricing data. Key modifications include the addition of decorators in Storybook, new responsive design utilities, and improvements to existing components for better customization and performance. Furthermore, new utility functions for color management and adjustments to the Tailwind CSS configuration have been implemented to support these enhancements.

Changes

Files Change Summary
.storybook/preview.tsx Added a decorator to load icons before rendering stories; modified story sorting order to include "Features."
src/core/FeaturedLink.tsx Modified iconColor prop to be optional; updated CSS transition properties for icons.
src/core/Pricing/PricingCards.stories.tsx Added story definitions for PricingCards component with variations for dark and light modes.
src/core/Pricing/PricingCards.tsx Introduced PricingCards component to render pricing options based on provided data, supporting dynamic theming and responsive layouts.
src/core/Pricing/data.tsx Added planData and consumptionData arrays to define pricing information.
src/core/Pricing/types.ts Introduced TypeScript types for pricing data structures, enhancing type safety.
src/core/styles/colors/types.ts Expanded ColorClassPrefixes and introduced ColorClassVariants and Theme types for improved color management.
src/core/styles/colors/utils.ts Added utility functions convertTailwindClassToVar and determineThemeColor for color handling.
tailwind.config.js Modified to include new hover/focus variants, added neutral-000 color, streamlined borderRadius configuration, and included the @tailwindcss/container-queries plugin.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Storybook
    participant FeaturedLink
    participant PricingCards

    User->>Storybook: View Story
    Storybook->>FeaturedLink: Load Icons
    FeaturedLink->>Storybook: Render with Icons
    Storybook->>User: Display Story

    User->>PricingCards: View Pricing
    PricingCards->>PricingData: Fetch Pricing Data
    PricingCards->>User: Display Pricing Options
Loading

🐇 In a world of code and style,
🐰 Changes hop in with a smile.
📊 Pricing cards now dance in line,
🌈 Colors shift, oh how they shine!
🎉 With icons loaded, stories bloom,
🐇 Join the fun, let creativity zoom!


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.

},
};

export const PlansDarkMode = {
Copy link
Member Author

Choose a reason for hiding this comment

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

It would be ace if I could leverage Storybook's dark mode plugin to change this in the manager instead of defining things twice, but I can't twist it into doing that


type PricingCardsProps = {
data: PricingDataFeature[];
theme?: Theme;
Copy link
Member Author

Choose a reason for hiding this comment

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

In time, this will be set further up in a context and accessed within the component instead of having to drill it in here

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

Outside diff range and nitpick comments (1)
src/core/Pricing/data.tsx (1)

151-151: Standardize Data Types for 'price.amount'

In line 151, price.amount is set to "Custom", a string, whereas in other instances, price.amount is a number (e.g., 0, 29, 399). Mixing data types can lead to potential issues and more complex handling in the component logic. Consider standardizing price.amount to always be a number, and introduce a separate field for display purposes if needed.

You could adjust the data structure like this:

-price: { amount: "Custom" },
+price: { amount: null, display: "Custom" },

And update the component logic to handle the display field.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e6bea89 and 42b11c6.

Files ignored due to path filters (5)
  • src/core/FeaturedLink/__snapshots__/FeaturedLink.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/ProductTile/__snapshots__/ProductTile.stories.tsx.snap is excluded by !**/*.snap
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (11)
  • .storybook/preview.tsx (2 hunks)
  • package.json (1 hunks)
  • src/core/FeaturedLink.tsx (3 hunks)
  • src/core/Icon.tsx (1 hunks)
  • src/core/Pricing/PricingCards.stories.tsx (1 hunks)
  • src/core/Pricing/PricingCards.tsx (1 hunks)
  • src/core/Pricing/data.tsx (1 hunks)
  • src/core/Pricing/types.ts (1 hunks)
  • src/core/styles/colors/types.ts (1 hunks)
  • src/core/styles/colors/utils.ts (1 hunks)
  • tailwind.config.js (4 hunks)
Files skipped from review due to trivial changes (1)
  • src/core/FeaturedLink.tsx
Additional context used
Biome
src/core/Pricing/PricingCards.tsx

[error] 75-75: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

Additional comments not posted (5)
src/core/Icon.tsx (1)

5-5: Refactored to use shared utility function for color conversion

The local convertTailwindClassToVar function has been replaced with an import from ./styles/colors/utils. This promotes code reuse and improves maintainability.

package.json (1)

30-30: Add '@tailwindcss/container-queries' Dependency

The addition of '@tailwindcss/container-queries' version '^0.1.1' enhances styling capabilities by enabling container queries in Tailwind CSS, allowing for more responsive and adaptive designs.

tailwind.config.js (3)

60-60: Addition of 'neutral-000' in Colors

Adding 'neutral-000' to the color palette enhances the theme and ensures consistent styling across components that require this specific shade.


298-301: Extending 'borderRadius' Configurations

Defining borderRadius values under extend is appropriate. However, ensure that you are not overriding or removing existing default Tailwind borderRadius values unintentionally. This ensures that any components relying on the default values remain unaffected.

If you intend to keep the default values, you may want to merge them with your custom values:

extend: {
  borderRadius: {
    ...theme('borderRadius'),
    md: '0.1875rem',
    DEFAULT: '0.375rem',
  },
},

353-353: Include '@tailwindcss/container-queries' Plugin

Including the @tailwindcss/container-queries plugin enhances responsive design capabilities, allowing styles to adapt based on the container size rather than the viewport. This aligns with modern responsive design practices.

src/core/Pricing/types.ts Show resolved Hide resolved
src/core/Pricing/PricingCards.stories.tsx Outdated Show resolved Hide resolved
src/core/styles/colors/utils.ts Outdated Show resolved Hide resolved
.storybook/preview.tsx Show resolved Hide resolved
src/core/styles/colors/types.ts Outdated Show resolved Hide resolved
src/core/Pricing/PricingCards.tsx Outdated Show resolved Hide resolved
src/core/Pricing/PricingCards.tsx Outdated Show resolved Hide resolved
tailwind.config.js Show resolved Hide resolved
delimiter,
}: PricingCardsProps) => {
// work out a dynamic theme colouring, using dark theme colouring as the base
const t = (color: ColorClass) => determineThemeColor("dark", theme, color);
Copy link
Member Author

Choose a reason for hiding this comment

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

Any colour class supplied to t will be flipped across the palette if the theme isn't the base theme - in this case, "dark"

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 42b11c6 and 48f12f4.

Files selected for processing (3)
  • src/core/Pricing/PricingCards.stories.tsx (1 hunks)
  • src/core/Pricing/PricingCards.tsx (1 hunks)
  • src/core/styles/colors/utils.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/core/styles/colors/utils.ts
Additional context used
GitHub Check: ESLint
src/core/Pricing/PricingCards.stories.tsx

[failure] 19-19: src/core/Pricing/PricingCards.stories.tsx#L19
'data' is missing in props validation (react/prop-types)


[failure] 19-19: src/core/Pricing/PricingCards.stories.tsx#L19
'theme' is missing in props validation (react/prop-types)


[failure] 19-19: src/core/Pricing/PricingCards.stories.tsx#L19
'delimiter' is missing in props validation (react/prop-types)

src/core/Pricing/PricingCards.tsx

[failure] 45-45: src/core/Pricing/PricingCards.tsx#L45
Missing "key" prop for element in iterator (react/jsx-key)

Biome
src/core/Pricing/PricingCards.tsx

[error] 45-45: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

src/core/Pricing/PricingCards.stories.tsx Outdated Show resolved Hide resolved
src/core/Pricing/PricingCards.tsx Outdated Show resolved Hide resolved
@jamiehenson jamiehenson force-pushed the 14.6.0-pricing-stuff branch 2 times, most recently from 9153c41 to d46831a Compare September 18, 2024 14:21
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.

Really looks good! just few questions

  1. In mobile the featured link should they be visible all the time and not by just hover?
Screenshot 2024-09-19 at 10 36 40
  1. In the design the gap between these texts is like 4px which seems not the same as in the storybook
Screenshot 2024-09-19 at 10 40 24

So far that all I can see from design perspective

@jamiehenson
Copy link
Member Author

Good catches, thanks @aralovelace. Ready for re-review

jamiehenson and others added 2 commits September 19, 2024 11:28
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

All good! ⭐⭐⭐⭐⭐

@jamiehenson jamiehenson merged commit b1bb438 into main Sep 19, 2024
4 checks passed
@jamiehenson jamiehenson deleted the 14.6.0-pricing-stuff branch September 19, 2024 12:22
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