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

chore: update wds icon component #34950

Merged
merged 1 commit into from
Jul 22, 2024
Merged

chore: update wds icon component #34950

merged 1 commit into from
Jul 22, 2024

Conversation

KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented Jul 15, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Anvil"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9942515767
Commit: db1ef7c
Cypress dashboard.
Tags: @tag.Anvil
Spec:


Mon, 15 Jul 2024 16:12:38 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced icon library with new thematic icons and improved accessibility features.
    • Introduced a default option in dropdowns for color selection in the property pane.
  • Bug Fixes

    • Corrected naming inconsistencies in icon entries.
  • Improvements

    • Streamlined color handling for icon and text components, enhancing visual coherence.
    • Update to the icon component's logic for improved maintainability and clarity.
  • Documentation

    • Added comments for better understanding of the handling of type errors in the icon component's story.

@KelvinOm KelvinOm requested a review from jsartisan July 15, 2024 15:47
Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

This update primarily focuses on enhancing the design system's icon component by removing the Icon export from the main module, updating the @tabler/icons-react package, and refining the internal logic and accessibility of the _Icon component. Additionally, the icon library has been expanded with new entries, and modifications have been made to improve color handling and user interface configurations across various components.

Changes

File Path Change Summary
app/client/packages/design-system/headless/src/index.ts Removed export of the Icon component, altering the module's public API.
app/client/packages/design-system/widgets/package.json Updated @tabler/icons-react version from 2.45.0 to 3.10.0.
app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx Modified _Icon component's props, simplified icon loading logic, and enhanced color handling.
app/client/packages/design-system/widgets/src/components/Icon/src/icons.ts Expanded ICONS constant with new icons and corrected naming inconsistencies.
app/client/packages/design-system/widgets/src/components/Icon/src/styles.module.css Added dynamic color styling capabilities for the .icon class using a shared color module.
app/client/packages/design-system/widgets/src/components/Icon/src/types.ts Updated IconProps interface for better accessibility and replaced icon prop with color.
app/client/packages/design-system/widgets/src/components/Icon/stories/Icon.stories.tsx Added TypeScript directive to bypass type checking for icon prop in CustomIcon story.
app/client/packages/design-system/widgets/src/scripts/build-icons.ts Changed import statement for icons to import only the icons export, modifying how icons are referenced.
app/client/src/widgets/wds/WDSStatsWidget/component/index.tsx Enhanced color logic in StatsComponent for Icon and Text components based on valueColor prop.
app/client/src/widgets/wds/WDSStatsWidget/config/propertyPaneConfig/contentConfig.ts Modified options array in propertyPaneContentConfig for improved dropdown UI, removed validation logic.
app/client/src/widgets/wds/WDSStatsWidget/widget/types.ts Expanded valueColor property in StatsWidgetProps to accept a "default" option in addition to color keys.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@KelvinOm KelvinOm added the ok-to-test Required label for CI label Jul 15, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jul 15, 2024
@KelvinOm KelvinOm requested a review from ichik July 22, 2024 08:12
@KelvinOm KelvinOm marked this pull request as ready for review July 22, 2024 08:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
app/client/packages/design-system/widgets/src/components/Icon/stories/Icon.stories.tsx (1)

45-45: Usage of @ts-expect-error directive.

The @ts-expect-error directive is used to bypass TypeScript's type-checking for the icon prop. Ensure that this is necessary and consider adding a comment explaining why the type error is being ignored.

+      // @ts-expect-error we don't want to cast a type here
+      // Explanation: Add a brief explanation for why the type error is being ignored.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 70f8777 and db1ef7c.

Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (11)
  • app/client/packages/design-system/headless/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/package.json (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Icon/src/icons.ts (93 hunks)
  • app/client/packages/design-system/widgets/src/components/Icon/src/styles.module.css (2 hunks)
  • app/client/packages/design-system/widgets/src/components/Icon/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Icon/stories/Icon.stories.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/scripts/build-icons.ts (1 hunks)
  • app/client/src/widgets/wds/WDSStatsWidget/component/index.tsx (2 hunks)
  • app/client/src/widgets/wds/WDSStatsWidget/config/propertyPaneConfig/contentConfig.ts (1 hunks)
  • app/client/src/widgets/wds/WDSStatsWidget/widget/types.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/packages/design-system/widgets/src/scripts/build-icons.ts
Additional context used
Biome
app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx

[error] 20-20: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)


[error] 55-55: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

Additional comments not posted (21)
app/client/packages/design-system/headless/src/index.ts (1)

1-5: Verify the impact of removing the Icon component export.

The removal of the Icon component export might affect other parts of the codebase that rely on this export. Ensure that all dependencies on the Icon component are updated accordingly.

Verification successful

No issues found with the removal of the Icon component export.

The search did not find any occurrences of the Icon component being imported in the codebase, indicating that its removal does not impact other parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing the `Icon` component export.

# Test: Search for the usage of the `Icon` component export. Expect: No occurrences.
rg --type typescript -A 5 $'from "./components/Icon"'

Length of output: 89


Script:

#!/bin/bash
# Description: Verify the impact of removing the `Icon` component export.

# Test: Search for the usage of the `Icon` component export. Expect: No occurrences.
rg 'import .* from .*/components/Icon.*' --glob '*.ts' --glob '*.tsx'

Length of output: 71

app/client/src/widgets/wds/WDSStatsWidget/widget/types.ts (1)

11-11: LGTM! The change enhances flexibility.

The update to the valueColor property in the StatsWidgetProps interface to include the "default" option enhances flexibility by allowing a default color setting.

app/client/packages/design-system/widgets/src/components/Icon/src/styles.module.css (1)

1-1: LGTM! The changes improve styling capabilities.

The addition of the import statement and the loop for dynamic color application based on the data-color attribute significantly enhances the styling capabilities of the .icon class.

app/client/packages/design-system/widgets/package.json (1)

22-22: Upgrade of @tabler/icons-react package version.

The package version has been updated from ^2.45.0 to ^3.10.0. Ensure that the new version does not introduce breaking changes or regressions.

Consider running the tests and verifying the changelog of the new version.

app/client/packages/design-system/widgets/src/components/Icon/src/types.ts (2)

1-3: Import statements for updated IconProps interface.

The import statements are necessary for the updated IconProps interface and are correctly included.


5-30: Enhanced IconProps interface.

The IconProps interface has been updated to extend DOMProps and AriaLabelingProps, enhancing accessibility and functionality. The changes are well-structured and improve the component's compliance with accessibility standards.

app/client/src/widgets/wds/WDSStatsWidget/component/index.tsx (2)

26-30: Enhanced handling of color property for Icon component.

The Icon component now receives a color prop that defaults to undefined if valueColor is "default". This change improves flexibility in the icon's color representation.


47-50: Enhanced handling of color property for Text component.

The Text component's color prop now defaults to undefined if valueColor is "default". This change ensures consistency in color application across the component.

app/client/packages/design-system/widgets/src/components/Icon/src/Icon.tsx (6)

1-1: Import statement looks good.

The import statement correctly includes necessary modules and types.


10-10: Update the ref type.

The ref type has been changed from Ref<SVGSVGElement> to Ref<Component>. Ensure that this change aligns with the expected type of the component reference.


11-11: Destructure props correctly.

The props destructuring includes a new color property and removes the icon property. Ensure that the color prop is properly utilized and the icon prop is no longer needed.


16-16: Logic for deriving pascalName looks good.

The logic for deriving pascalName from ICONS[name] is clear and concise.


39-39: Memoization of Icon component looks good.

The use of useMemo for memoizing the Icon component is appropriate.


51-58: Rendering logic looks good.

The rendering logic within the Suspense component is clear and concise. Ensure that all props are correctly passed down.

Tools
Biome

[error] 55-55: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

app/client/src/widgets/wds/WDSStatsWidget/config/propertyPaneConfig/contentConfig.ts (1)

35-44: Addition of default option and removal of validation section.

The addition of a default option labeled "Default" enhances the user interface by providing a clear default selection. Ensure that the removal of the validation section does not negatively impact the component's behavior.

app/client/packages/design-system/widgets/src/components/Icon/src/icons.ts (6)

46-46: New icon entry added: IconAi.

The new icon entry follows the existing naming conventions and appears to be correctly added.


93-95: New icon entries added: IconAlignLeft2 and IconAlignRight2.

The new icon entries follow the existing naming conventions and appear to be correctly added.


97-104: New icon entries added: IconAlphabetArabic, IconAlphabetBangla, IconAlphabetCyrillic, IconAlphabetGreek, IconAlphabetHebrew, IconAlphabetKorean, IconAlphabetLatin, IconAlphabetThai.

The new icon entries follow the existing naming conventions and appear to be correctly added.


331-334: New icon entries added: IconAuth2fa, IconAutomaticGearbox, IconAutomation, IconAvocado.

The new icon entries follow the existing naming conventions and appear to be correctly added.


353-353: New icon entry added: IconBadgeAdOff.

The new icon entry follows the existing naming conventions and appears to be correctly added.


480-488: New icon entries added: IconBinoculars, IconBiohazard, IconBiohazardOff, IconBlade, IconBleach, IconBleachChlorine, IconBleachNoChlorine, IconBleachOff.

The new icon entries follow the existing naming conventions and appear to be correctly added.

Comment on lines +18 to +38
return lazy(async () =>
import("@tabler/icons-react").then((module) => {
if (Boolean(filled)) {
const filledVariant = `${pascalName}Filled`;

Icon = lazy(async () =>
import("@tabler/icons-react").then((module) => {
if (Boolean(filled)) {
const filledVariant = `${pascalName}Filled`;

if (filledVariant in module) {
return {
default: module[filledVariant] as React.ComponentType,
};
}
}

if (pascalName in module) {
if (filledVariant in module) {
return {
default: module[pascalName] as React.ComponentType,
default: module[filledVariant] as React.ComponentType,
};
}
}

if (pascalName in module) {
return {
default: module[pascalName] as React.ComponentType,
};
}

return { default: FallbackIcon };
}),
);
} else {
Icon = FallbackIcon;
}
return Icon;
}, [name, icon, filled]);
return { default: FallbackIcon };
}),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize icon loading logic.

The icon loading logic has been streamlined. However, the redundant Boolean calls should be removed.

-        if (Boolean(filled)) {
+        if (filled) {
-        if (Boolean(size)) {
+        if (size) {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return lazy(async () =>
import("@tabler/icons-react").then((module) => {
if (Boolean(filled)) {
const filledVariant = `${pascalName}Filled`;
Icon = lazy(async () =>
import("@tabler/icons-react").then((module) => {
if (Boolean(filled)) {
const filledVariant = `${pascalName}Filled`;
if (filledVariant in module) {
return {
default: module[filledVariant] as React.ComponentType,
};
}
}
if (pascalName in module) {
if (filledVariant in module) {
return {
default: module[pascalName] as React.ComponentType,
default: module[filledVariant] as React.ComponentType,
};
}
}
if (pascalName in module) {
return {
default: module[pascalName] as React.ComponentType,
};
}
return { default: FallbackIcon };
}),
);
} else {
Icon = FallbackIcon;
}
return Icon;
}, [name, icon, filled]);
return { default: FallbackIcon };
}),
);
return lazy(async () =>
import("@tabler/icons-react").then((module) => {
if (filled) {
const filledVariant = `${pascalName}Filled`;
if (filledVariant in module) {
return {
default: module[filledVariant] as React.ComponentType,
};
}
}
if (pascalName in module) {
return {
default: module[pascalName] as React.ComponentType,
};
}
return { default: FallbackIcon };
}),
);
Tools
Biome

[error] 20-20: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

@KelvinOm KelvinOm merged commit ae97421 into release Jul 22, 2024
52 of 53 checks passed
@KelvinOm KelvinOm deleted the chore/wds-icon branch July 22, 2024 08:56
@coderabbitai coderabbitai bot mentioned this pull request Oct 29, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants