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-3979] Encapsulated icons #487

Merged
merged 3 commits into from
Sep 19, 2024
Merged

[WEB-3979] Encapsulated icons #487

merged 3 commits into from
Sep 19, 2024

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Sep 19, 2024

Summary of changes

Not sure if Coderabbit will provide it's own summary anyway, but this PR adds theming to ProductTile, and allows icons to be dynamically encapsulated instead of providing separate assets (also useful with theming).

How do you manually test this?

Storybook link (at the bottom, the anchor link doesnt work)

Reviewer Tasks (optional)

Merge/Deploy Checklist

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

Frontend Checklist

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

Summary by CodeRabbit

  • New Features

    • Introduced EncapsulatedIcon component for styled icon rendering with customizable themes and sizes.
    • Enhanced icon rendering functionality with support for encapsulated icons and theming options.
  • Bug Fixes

    • Improved visual consistency for product icons by standardizing naming conventions.
  • Chores

    • Removed several encapsulated product icons to streamline the icon set.

Copy link
Contributor

coderabbitai bot commented Sep 19, 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 1 minutes and 56 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 d3f3c70 and 4ae83dc.

Walkthrough

The changes introduce a new React component, EncapsulatedIcon, which allows for rendering icons within a styled container that supports theming. The Icon.stories.tsx file is updated to include stories for encapsulated icons, enhancing the icon rendering functionality. Additionally, several encapsulated icons are removed from the productIcons array, and the ProductTile.tsx file is modified to utilize the new EncapsulatedIcon. The data.ts file reflects a standardized icon naming convention by removing the "-encapsulated" suffix from product icons.

Changes

File Change Summary
src/core/Icon.tsx Exported IconProps type for external accessibility.
src/core/Icon/EncapsulatedIcon.tsx Introduced EncapsulatedIcon component with props for theme, className, and icon-related properties. Implements theming and encapsulated styling for icons.
src/core/Icon/Icon.stories.tsx Modified renderIcons function to include optional encapsulated and theme parameters. Added stories for DarkEncapsulatedIcons and LightEncapsulatedIcons.
src/core/Icon/types.ts Removed several encapsulated product icons from the productIcons array, streamlining the icon set.
src/core/ProductTile.tsx Integrated EncapsulatedIcon into ProductTile, updating theming logic and class names for improved clarity and responsiveness.
src/core/ProductTile/data.ts Renamed product icons by removing the "-encapsulated" suffix for consistency across product entries.

Possibly related PRs

  • [WEB-3841] 14.6.0 - PricingCards component #486: The changes in the PricingCards component involve the introduction of the determineThemeColor function, which is similar to the theming logic discussed in the main PR regarding the EncapsulatedIcon component. Both PRs focus on enhancing theming capabilities within their respective components.

Suggested reviewers

  • jamiehenson

🐇 In the meadow, bright and wide,
New icons hop with joy and pride.
Encapsulated, themed just right,
They dance and twirl, a lovely sight!
With colors bold and shapes so fine,
Our UI shines, oh how divine! 🌼


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

Outside diff range and nitpick comments (1)
src/core/Icon/EncapsulatedIcon.tsx (1)

1-33: LGTM!

The EncapsulatedIcon component is well-structured and provides a nice way to render icons with a customizable appearance. The use of default prop values and the t function for determining theme colors is a good approach.

A few suggestions for further improvement:

  1. Consider adding prop types validation using PropTypes or TypeScript to ensure the correct types are passed to the component.

  2. The component could be made more reusable by allowing the user to pass additional CSS classes or styles as props, which can be merged with the existing classes and styles.

  3. The magic numbers used for padding and size calculations (e.g., size - 2, size - 12) could be extracted into named constants to improve readability and maintainability.

Overall, the component is a great addition to the codebase and enhances the UI by providing a visually distinct and thematically consistent representation of icons.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b1bb438 and 3accf51.

Files ignored due to path filters (7)
  • src/core/Icon/__snapshots__/Icon.stories.tsx.snap is excluded by !**/*.snap
  • src/core/ProductTile/__snapshots__/ProductTile.stories.tsx.snap is excluded by !**/*.snap
  • src/core/icons/icon-product-asset-tracking-encapsulated.svg is excluded by !**/*.svg
  • src/core/icons/icon-product-chat-encapsulated.svg is excluded by !**/*.svg
  • src/core/icons/icon-product-livesync-encapsulated.svg is excluded by !**/*.svg
  • src/core/icons/icon-product-pubsub-encapsulated.svg is excluded by !**/*.svg
  • src/core/icons/icon-product-spaces-encapsulated.svg is excluded by !**/*.svg
Files selected for processing (5)
  • src/core/Icon/EncapsulatedIcon.tsx (1 hunks)
  • src/core/Icon/Icon.stories.tsx (4 hunks)
  • src/core/Icon/types.ts (0 hunks)
  • src/core/ProductTile.tsx (2 hunks)
  • src/core/ProductTile/data.ts (1 hunks)
Files not reviewed due to no reviewable changes (1)
  • src/core/Icon/types.ts
Files skipped from review due to trivial changes (1)
  • src/core/ProductTile/data.ts
Additional comments not posted (15)
src/core/ProductTile.tsx (10)

2-2: LGTM!

The import statement for the new EncapsulatedIcon component is correct and aligns with the changes mentioned in the summary.


5-5: LGTM!

The import statement for the ColorClass type is correct and aligns with the changes mentioned in the summary.


6-6: LGTM!

The import statement for the determineThemeColor function is correct and aligns with the changes mentioned in the summary.


25-26: LGTM!

The new function t correctly encapsulates the logic for determining the theme color based on the selected state and the provided color class using the determineThemeColor function.


30-30: LGTM!

The usage of the t function to dynamically determine the background color class based on the selected state is correct and aligns with the changes mentioned in the summary.


33-36: LGTM!

The usage of the EncapsulatedIcon component with the name and theme props is correct and aligns with the changes mentioned in the summary.


41-41: LGTM!

The usage of the t function to dynamically determine the text color class based on the selected state is correct and aligns with the changes mentioned in the summary.


46-46: LGTM!

The usage of the t function to dynamically determine the text color class based on the selected state is correct and aligns with the changes mentioned in the summary.


54-54: LGTM!

The usage of the text-gui-unavailable class for the "COMING SOON" status is correct and aligns with the changes mentioned in the summary, improving visual consistency.


60-66: LGTM!

The usage of the t function to dynamically determine the text color class based on the selected state is correct and aligns with the changes mentioned in the summary.

src/core/Icon/Icon.stories.tsx (5)

3-3: LGTM!

The import statement for EncapsulatedIcon is necessary and the import path is correct.


6-6: LGTM!

The import statement for Theme type is necessary and the import path is correct.


17-21: LGTM!

The changes to the renderIcons function signature are valid and backward compatible. The new optional parameters, encapsulated and theme, allow for flexibility in rendering encapsulated icons with theme variations.


34-43: LGTM!

The conditional rendering logic is implemented correctly to switch between the EncapsulatedIcon and the standard Icon based on the encapsulated flag. The theme prop is properly passed to the EncapsulatedIcon with a default value of "dark". The existing Icon component usage remains unaffected.


102-104: LGTM!

The new story exports, DarkEncapsulatedIcons and LightEncapsulatedIcons, are implemented correctly. They effectively demonstrate the usage of the EncapsulatedIcon component with different theme variations. These stories enhance the documentation and provide visual examples of the encapsulated icons in both dark and light themes.

Also applies to: 106-108

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.

As 🐰🤖 said LGTM!

@jamiehenson jamiehenson force-pushed the encapsulated-icons branch 2 times, most recently from 252a6ae to 857d70b Compare September 19, 2024 12:45
@jamiehenson jamiehenson merged commit 18de5c0 into main Sep 19, 2024
4 checks passed
@jamiehenson jamiehenson deleted the encapsulated-icons branch September 19, 2024 12:57
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