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

feat: icons #2700

Merged
merged 2 commits into from
Dec 3, 2024
Merged

feat: icons #2700

merged 2 commits into from
Dec 3, 2024

Conversation

chronark
Copy link
Collaborator

@chronark chronark commented Dec 3, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced the Icon component for rendering customizable SVG icons.
    • Added several new icon components: Bolt, BookBookmark, Check, ChevronExpandY, Nodes, ShieldCheck, Sparkle3, TaskChecked, and TaskUnchecked.
    • Enhanced documentation for using Nucleo Icons, including guidelines for customization and importing.
  • Bug Fixes

    • Improved rendering logic for code snippets in the RenderComponentWithSnippet component.
  • Chores

    • Added new dependencies for icon management and updated Tailwind CSS configuration to include new icon paths.
    • Introduced licensing information for Nucleo Icons and updated related documentation.

Copy link

vercel bot commented Dec 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 11:09pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 11:09pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 11:09pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
dashboard ⬜️ Ignored (Inspect) Visit Preview Dec 3, 2024 11:09pm

Copy link

changeset-bot bot commented Dec 3, 2024

⚠️ No Changeset found

Latest commit: b6358c2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces several new components and updates to the existing codebase, primarily focused on enhancing the icon functionality within the application. A new Icon component is added, along with various SVG icon components such as Bolt, BookBookmark, Check, and others. Additionally, updates to the RenderComponentWithSnippet enhance its props definition. Documentation for using Nucleo Icons is provided, along with new type definitions and configuration changes that support the integration of these icons into the project.

Changes

File Path Change Summary
apps/engineering/app/components/icon-swatch.tsx New React component Icon created, accepting name prop and children, rendering a styled div and span.
apps/engineering/app/components/render.tsx New Props type with optional customCodeSnippet, updated RenderComponentWithSnippet to prioritize customCodeSnippet for rendering logic.
apps/engineering/content/design/icons.mdx New documentation file created for Nucleo Icons, detailing usage, customization, and licensing information.
apps/engineering/package.json Added dependency @unkey/icons with version workspace:^.
apps/engineering/tailwind.config.js Updated content array to include path for Tailwind CSS scanning: "../../internal/icons/**/*.tsx".
internal/icons/LICENSE New license file for Nucleo Icons detailing copyright and usage restrictions.
internal/icons/package.json New package.json for @unkey/icons, specifying package name, version, main entry point, and development dependencies.
internal/icons/src/Readme.txt Added documentation for icon instance properties including width, height, fill, etc.
internal/icons/src/icons/bolt.tsx New React component Bolt created, rendering an SVG icon with specified attributes.
internal/icons/src/icons/book-bookmark.tsx New React component BookBookmark created, rendering an SVG icon with multiple graphical elements.
internal/icons/src/icons/check.tsx New React component Check created, rendering an SVG checkmark icon.
internal/icons/src/icons/chevron-expand-y.tsx New React component ChevronExpandY created, rendering a chevron icon.
internal/icons/src/icons/nodes.tsx New React component Nodes created, rendering an SVG graphic with various elements.
internal/icons/src/icons/shield-check.tsx New React component ShieldCheck created, rendering a shield icon with a checkmark.
internal/icons/src/icons/sparkle-3.tsx New React component Sparkle3 created, rendering an SVG icon with specific shapes.
internal/icons/src/icons/task-checked.tsx New React component TaskChecked created, rendering an SVG graphic with a checkmark.
internal/icons/src/icons/task-unchecked.tsx New React component TaskUnchecked created, rendering an SVG graphic for an unchecked task.
internal/icons/src/index.ts Added export statements for multiple icon modules to facilitate centralized access.
internal/icons/src/props.ts New type IconProps introduced, defining optional properties for icon components.
internal/icons/src/template.tsx New React component Icon created, establishing a basic structure for an icon component.

Possibly related PRs

  • feat: design system #2667: The introduction of the RenderComponentWithSnippet and Row components in the design system is related to the main PR as it involves the creation of new React components that enhance the UI structure, similar to the new Icon component added in the main PR. Both PRs focus on expanding the component library for better UI representation.

Suggested labels

Feature, Dashboard, 🕹️ oss.gg, :joystick: 300 points, hacktoberfest

Suggested reviewers

  • mcstepp
  • perkinsjr
  • MichaelUnkey

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b6358c2 and 7793e1f.

📒 Files selected for processing (11)
  • LICENSE (1 hunks)
  • apps/engineering/content/design/icons.mdx (1 hunks)
  • internal/icons/src/icons/bolt.tsx (1 hunks)
  • internal/icons/src/icons/book-bookmark.tsx (1 hunks)
  • internal/icons/src/icons/check.tsx (1 hunks)
  • internal/icons/src/icons/chevron-expand-y.tsx (1 hunks)
  • internal/icons/src/icons/nodes.tsx (1 hunks)
  • internal/icons/src/icons/shield-check.tsx (1 hunks)
  • internal/icons/src/icons/sparkle-3.tsx (1 hunks)
  • internal/icons/src/icons/task-checked.tsx (1 hunks)
  • internal/icons/src/icons/task-unchecked.tsx (1 hunks)

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

github-actions bot commented Dec 3, 2024

Thank you for following the naming conventions for pull request titles! 🙏

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 (16)
internal/icons/src/props.ts (1)

1-4: Consider enhancing accessibility attributes

While the current props are good for basic usage, consider adding more accessibility-focused props such as:

  • role?: string - For explicit ARIA role
  • ariaLabel?: string - More semantic than using title for accessibility
  • ariaHidden?: boolean - For decorative icons
 export type IconProps = {
   className?: string;
   title?: string;
+  role?: string;
+  ariaLabel?: string;
+  ariaHidden?: boolean;
 };
internal/icons/src/icons/check.tsx (2)

5-5: Consider moving props spreading after fixed attributes.

For better security and to prevent unintended attribute overrides, consider moving the props spread after the fixed attributes:

-    <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
+    <svg height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" {...props}>

5-16: Consider making icon dimensions configurable.

The icon has fixed dimensions of 18x18. Consider making these configurable through props while maintaining the aspect ratio, allowing for more flexible usage in different contexts.

apps/engineering/app/components/icon-swatch.tsx (1)

3-5: Consider extending Props interface for size customization.

The component uses a fixed size-12 class. Consider making the size configurable through props for more flexible usage.

 type Props = {
   name: string;
+  size?: 'sm' | 'md' | 'lg';  // or number for direct size values
 };
internal/icons/src/icons/bolt.tsx (2)

7-16: Remove unnecessary group element.

The <g> element serves no purpose as it has no attributes or transformations. Consider removing it for cleaner markup:

    <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
-     <g>
        <path
          d="m8.597,16.41l5.872-8.265c.118-.166,0-.395-.204-.395h-5.016l.604-5.98c.037-.26-.299-.394-.451-.18L3.531,9.855c-.118.166,0,.395.204.395h5.016l-.604,5.98c-.037.26.299.394.451.18Z"
          fill="none"
          stroke="currentColor"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="1.5"
        />
-     </g>
    </svg>

6-6: Consider moving props spreading after fixed attributes.

For consistency with other icon components and to prevent unintended attribute overrides, consider moving the props spread after the fixed attributes.

-    <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
+    <svg height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" {...props}>
internal/icons/src/icons/chevron-expand-y.tsx (1)

6-6: Add accessibility attributes to SVG.

For better accessibility and semantic meaning, consider adding aria-hidden and role attributes to the SVG.

-    <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
+    <svg
+      {...props}
+      height="18"
+      width="18"
+      viewBox="0 0 18 18"
+      xmlns="http://www.w3.org/2000/svg"
+      aria-hidden="true"
+      role="img"
+    >
internal/icons/src/icons/task-unchecked.tsx (2)

6-6: Add accessibility attributes to SVG.

For better accessibility and semantic meaning, consider adding aria-hidden and role attributes to the SVG.

-    <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
+    <svg
+      {...props}
+      height="18"
+      width="18"
+      viewBox="0 0 18 18"
+      xmlns="http://www.w3.org/2000/svg"
+      aria-hidden="true"
+      role="img"
+    >

21-28: Consider optimizing the SVG path.

The path definition contains many decimal points which could be rounded to reduce file size without visual impact.

-          d="M2.801,11.998L1.772,5.074c-.162-1.093,.592-2.11,1.684-2.272l6.924-1.029c.933-.139,1.81,.39,2.148,1.228"
+          d="M2.8 12L1.77 5.07c-.16-1.1.6-2.1 1.68-2.27l6.92-1.03c.93-.14 1.81.39 2.15 1.23"
internal/icons/src/icons/task-checked.tsx (1)

1-1: Consider implementing a higher-order component for icons

To improve maintainability and ensure consistent implementation across all icon components, consider creating a higher-order component that handles common concerns:

// withIconWrapper.tsx
import React from 'react';
import type { IconProps } from './props';

export const withIconWrapper = (WrappedIcon: React.ComponentType<IconProps>) => {
  return function IconWrapper(props: IconProps) {
    const { title, ...rest } = props;
    return (
      <svg
        {...rest}
        role="img"
        aria-hidden={!title}
        height="18"
        width="18"
        viewBox="0 0 18 18"
        xmlns="http://www.w3.org/2000/svg"
      >
        {title && <title>{title}</title>}
        <WrappedIcon {...props} />
      </svg>
    );
  };
};

This would:

  1. Ensure consistent accessibility implementation
  2. Reduce code duplication
  3. Make icon components more focused on their specific paths/shapes
  4. Make it easier to modify common behavior across all icons
internal/icons/src/icons/book-bookmark.tsx (1)

5-5: Add accessibility attributes to SVG

For better accessibility, consider adding role="img" and aria-label attributes to the SVG element.

-    <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
+    <svg
+      {...props}
+      height="18"
+      width="18"
+      viewBox="0 0 18 18"
+      xmlns="http://www.w3.org/2000/svg"
+      role="img"
+      aria-label="Book with bookmark"
+    >
internal/icons/src/icons/nodes.tsx (1)

6-6: Add accessibility attributes to SVG

For consistency with other icon components and better accessibility, add role="img" and aria-label attributes to the SVG element.

-    <svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
+    <svg
+      {...props}
+      height="18"
+      width="18"
+      viewBox="0 0 18 18"
+      xmlns="http://www.w3.org/2000/svg"
+      role="img"
+      aria-label="Connected nodes diagram"
+    >
apps/engineering/content/design/icons.mdx (4)

12-12: Fix inconsistent spacing in imports

The spacing between imported icons is inconsistent, which affects readability.

-import {Bolt,BookBookmark,Check,ChevronExpandY,Nodes,ShieldCheck,Sparkle3,TaskChecked, TaskUnchecked   } from "@unkey/icons"
+import { Bolt, BookBookmark, Check, ChevronExpandY, Nodes, ShieldCheck, Sparkle3, TaskChecked, TaskUnchecked } from "@unkey/icons"

18-18: Add hyphen to compound adjective

When "open source" is used as a compound adjective modifying "application", it should be hyphenated.

-Unkey owns a license to use up to 100 icons in our open source application.
+Unkey owns a license to use up to 100 icons in our open-source application.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~18-~18: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...a license to use up to 100 icons in our open source application. See [https://nucleoapp....

(EN_COMPOUND_ADJECTIVE_INTERNAL)


40-40: Improve sentence readability

Add a comma for better readability.

-As a rule of thumb, you should only customize the color, but there's always an edge case.
+As a rule of thumb, you should only customize the color, but there's always an edge case.

88-89: Consider adding a code example

The guidelines would be clearer with a before/after code example showing the transformation of an exported icon file.

Consider adding an example like this:

// Before (from Nucleo export)
function IconName() {
  return <svg>...</svg>
}
export default IconName

// After (following our guidelines)
import { IconProps } from '../props'

export const IconName: React.FC<IconProps> = (props) => {
  return <svg {...props}>...</svg>
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6338f2b and b6358c2.

⛔ Files ignored due to path filters (2)
  • apps/engineering/content/design/icons-export-settings.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • apps/engineering/app/components/icon-swatch.tsx (1 hunks)
  • apps/engineering/app/components/render.tsx (1 hunks)
  • apps/engineering/content/design/icons.mdx (1 hunks)
  • apps/engineering/package.json (1 hunks)
  • apps/engineering/tailwind.config.js (1 hunks)
  • internal/icons/LICENSE (1 hunks)
  • internal/icons/package.json (1 hunks)
  • internal/icons/src/Readme.txt (1 hunks)
  • internal/icons/src/icons/bolt.tsx (1 hunks)
  • internal/icons/src/icons/book-bookmark.tsx (1 hunks)
  • internal/icons/src/icons/check.tsx (1 hunks)
  • internal/icons/src/icons/chevron-expand-y.tsx (1 hunks)
  • internal/icons/src/icons/nodes.tsx (1 hunks)
  • internal/icons/src/icons/shield-check.tsx (1 hunks)
  • internal/icons/src/icons/sparkle-3.tsx (1 hunks)
  • internal/icons/src/icons/task-checked.tsx (1 hunks)
  • internal/icons/src/icons/task-unchecked.tsx (1 hunks)
  • internal/icons/src/index.ts (1 hunks)
  • internal/icons/src/props.ts (1 hunks)
  • internal/icons/src/template.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • internal/icons/package.json
  • internal/icons/src/Readme.txt
  • internal/icons/LICENSE
  • internal/icons/src/index.ts
🧰 Additional context used
🪛 LanguageTool
apps/engineering/content/design/icons.mdx

[uncategorized] ~18-~18: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...a license to use up to 100 icons in our open source application. See [https://nucleoapp....

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[formatting] ~30-~30: Insert a comma after ‘cases’: “In most cases,”?
Context: ... to override the styling in edge cases. In most cases you should not change the size of the i...

(IN_MOST_CASES_COMMA)


[uncategorized] ~46-~46: Loose punctuation mark.
Context: ...hecked className="size-[12px]"/> `}> <Nodes className="text-error-9...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (3)
apps/engineering/tailwind.config.js (1)

12-12: LGTM!

The content path addition is correct and follows the existing pattern for internal packages.

apps/engineering/package.json (1)

13-13: LGTM! Workspace dependency correctly configured.

The addition of @unkey/icons as a workspace dependency is appropriate for this monorepo setup.

apps/engineering/content/design/icons.mdx (1)

57-57: Verify icon exports

Let's ensure all showcased icons are properly exported from the package.

✅ Verification successful

Let me verify the actual icon files since the fd command didn't show any results. I'll use a different approach to check the files.


All icons are properly exported and available

The verification confirms that all icons mentioned in the documentation are:

  • Present as individual files in internal/icons/src/icons/
  • Correctly exported through the barrel file internal/icons/src/index.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all icons shown in the documentation are exported from @unkey/icons
# Get the list of icons from the barrel file
echo "Checking exports in internal/icons/src/index.ts..."
cat internal/icons/src/index.ts

# Verify individual icon files exist
echo "\nVerifying icon files..."
for icon in Bolt BookBookmark Check ChevronExpandY Nodes ShieldCheck Sparkle3 TaskChecked TaskUnchecked; do
  fd "$icon.tsx$" internal/icons/src/icons/
done

Length of output: 1917


Script:

#!/bin/bash
# Check if the icon files exist with case-insensitive search and show their content
echo "Checking icon files with case-insensitive search..."
fd -i "bolt\.tsx$|book-bookmark\.tsx$|check\.tsx$|chevron-expand-y\.tsx$|nodes\.tsx$|shield-check\.tsx$|sparkle-3\.tsx$|task-checked\.tsx$|task-unchecked\.tsx$" internal/icons/src/icons/

# Also check the directory structure
echo -e "\nListing files in icons directory..."
ls -la internal/icons/src/icons/

Length of output: 1471

Comment on lines +4 to +6
export const Icon: React.FC<IconProps> = (props) => {
return <svg className={props.className} />;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incomplete SVG implementation

The current implementation has several critical issues:

  1. Missing required SVG attributes
  2. Not utilizing the title prop
  3. No way to pass SVG content

Apply this fix:

 export const Icon: React.FC<IconProps> = (props) => {
-  return <svg className={props.className} />;
+  return (
+    <svg
+      xmlns="http://www.w3.org/2000/svg"
+      viewBox="0 0 24 24"
+      className={props.className}
+      aria-hidden={!props.title}
+      role="img"
+    >
+      {props.title && <title>{props.title}</title>}
+      {props.children}
+    </svg>
+  );
 };

Also update the type to accept children:

-export const Icon: React.FC<IconProps>
+export const Icon: React.FC<IconProps & { children?: React.ReactNode }>

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +8 to +11
<div className="flex flex-col justify-center items-center text-gray-12 gap-4">
<div className="size-12 flex items-center justify-center aspect-square border border-gray-5 rounded-lg bg-gray-3 ">
{props.children}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance accessibility for icon container.

The icon container should have proper accessibility attributes to improve screen reader support.

     <div className="flex flex-col justify-center items-center text-gray-12 gap-4">
-      <div className="size-12 flex items-center  justify-center aspect-square border border-gray-5 rounded-lg bg-gray-3 ">
+      <div 
+        className="size-12 flex items-center justify-center aspect-square border border-gray-5 rounded-lg bg-gray-3"
+        role="img"
+        aria-label={`${props.name} icon`}
+      >

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +4 to +27
export const ShieldCheck: React.FC<IconProps> = (props) => {
return (
<svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
<g fill="currentColor">
<path
d="M9.305,1.848l5.25,1.68c.414,.133,.695,.518,.695,.952v6.52c0,3.03-4.684,4.748-5.942,5.155-.203,.066-.413,.066-.616,0-1.258-.407-5.942-2.125-5.942-5.155V4.48c0-.435,.281-.82,.695-.952l5.25-1.68c.198-.063,.411-.063,.61,0Z"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<polyline
fill="none"
points="6.497 9.75 8.106 11.25 11.503 6.75"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance accessibility and flexibility of the icon component

The component needs accessibility improvements and could be more flexible:

 export const ShieldCheck: React.FC<IconProps> = (props) => {
+  const { title, ...rest } = props;
   return (
     <svg
-      {...props}
+      {...rest}
+      role="img"
+      aria-hidden={!title}
       height="18"
       width="18"
       viewBox="0 0 18 18"
       xmlns="http://www.w3.org/2000/svg"
     >
+      {title && <title>{title}</title>}
       <g fill="currentColor">
📝 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
export const ShieldCheck: React.FC<IconProps> = (props) => {
return (
<svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
<g fill="currentColor">
<path
d="M9.305,1.848l5.25,1.68c.414,.133,.695,.518,.695,.952v6.52c0,3.03-4.684,4.748-5.942,5.155-.203,.066-.413,.066-.616,0-1.258-.407-5.942-2.125-5.942-5.155V4.48c0-.435,.281-.82,.695-.952l5.25-1.68c.198-.063,.411-.063,.61,0Z"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<polyline
fill="none"
points="6.497 9.75 8.106 11.25 11.503 6.75"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
};
export const ShieldCheck: React.FC<IconProps> = (props) => {
const { title, ...rest } = props;
return (
<svg
{...rest}
role="img"
aria-hidden={!title}
height="18"
width="18"
viewBox="0 0 18 18"
xmlns="http://www.w3.org/2000/svg"
>
{title && <title>{title}</title>}
<g fill="currentColor">
<path
d="M9.305,1.848l5.25,1.68c.414,.133,.695,.518,.695,.952v6.52c0,3.03-4.684,4.748-5.942,5.155-.203,.066-.413,.066-.616,0-1.258-.407-5.942-2.125-5.942-5.155V4.48c0-.435,.281-.82,.695-.952l5.25-1.68c.198-.063,.411-.063,.61,0Z"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<polyline
fill="none"
points="6.497 9.75 8.106 11.25 11.503 6.75"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
};

Comment on lines +4 to +24
export const Sparkle3: React.FC<IconProps> = (props) => {
return (
<svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
<g fill="currentColor">
<path
d="M5.658,2.99l-1.263-.421-.421-1.263c-.137-.408-.812-.408-.949,0l-.421,1.263-1.263,.421c-.204,.068-.342,.259-.342,.474s.138,.406,.342,.474l1.263,.421,.421,1.263c.068,.204,.26,.342,.475,.342s.406-.138,.475-.342l.421-1.263,1.263-.421c.204-.068,.342-.259,.342-.474s-.138-.406-.342-.474Z"
fill="currentColor"
stroke="none"
/>
<polygon
fill="none"
points="9.5 2.75 11.412 7.587 16.25 9.5 11.412 11.413 9.5 16.25 7.587 11.413 2.75 9.5 7.587 7.587 9.5 2.75"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize SVG attributes and enhance accessibility

The component has redundant attributes and needs accessibility improvements:

 export const Sparkle3: React.FC<IconProps> = (props) => {
+  const { title, ...rest } = props;
   return (
     <svg
-      {...props}
+      {...rest}
+      role="img"
+      aria-hidden={!title}
       height="18"
       width="18"
       viewBox="0 0 18 18"
       xmlns="http://www.w3.org/2000/svg"
     >
+      {title && <title>{title}</title>}
       <g fill="currentColor">
         <path
           d="M5.658,2.99l-1.263-.421-.421-1.263c-.137-.408-.812-.408-.949,0l-.421,1.263-1.263,.421c-.204,.068-.342,.259-.342,.474s.138,.406,.342,.474l1.263,.421,.421,1.263c.068,.204,.26,.342,.475,.342s.406-.138,.475-.342l.421-1.263,1.263-.421c.204-.068,.342-.259,.342-.474s-.138-.406-.342-.474Z"
           fill="currentColor"
-          stroke="none"
         />

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +4 to +40
export const TaskChecked: React.FC<IconProps> = (props) => {
return (
<svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
<g fill="currentColor">
<polyline
fill="none"
points="8.247 11.5 9.856 13 13.253 8.5"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<rect
height="11"
width="11"
fill="none"
rx="2"
ry="2"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
x="5.25"
y="5.25"
/>
<path
d="M2.801,11.998L1.772,5.074c-.162-1.093,.592-2.11,1.684-2.272l6.924-1.029c.933-.139,1.81,.39,2.148,1.228"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add accessibility attributes and consider path optimization

The component needs accessibility improvements and could benefit from path optimization:

 export const TaskChecked: React.FC<IconProps> = (props) => {
+  const { title, ...rest } = props;
   return (
     <svg
-      {...props}
+      {...rest}
+      role="img"
+      aria-hidden={!title}
       height="18"
       width="18"
       viewBox="0 0 18 18"
       xmlns="http://www.w3.org/2000/svg"
     >
+      {title && <title>{title}</title>}
       <g fill="currentColor">

Consider using a tool like SVGO to optimize the SVG paths and potentially reduce the file size. The complex path for the checkmark and decorative elements could potentially be simplified while maintaining the same visual appearance.

📝 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
export const TaskChecked: React.FC<IconProps> = (props) => {
return (
<svg {...props} height="18" width="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
<g fill="currentColor">
<polyline
fill="none"
points="8.247 11.5 9.856 13 13.253 8.5"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<rect
height="11"
width="11"
fill="none"
rx="2"
ry="2"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
x="5.25"
y="5.25"
/>
<path
d="M2.801,11.998L1.772,5.074c-.162-1.093,.592-2.11,1.684-2.272l6.924-1.029c.933-.139,1.81,.39,2.148,1.228"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
};
export const TaskChecked: React.FC<IconProps> = (props) => {
const { title, ...rest } = props;
return (
<svg
{...rest}
role="img"
aria-hidden={!title}
height="18"
width="18"
viewBox="0 0 18 18"
xmlns="http://www.w3.org/2000/svg"
>
{title && <title>{title}</title>}
<g fill="currentColor">
<polyline
fill="none"
points="8.247 11.5 9.856 13 13.253 8.5"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<rect
height="11"
width="11"
fill="none"
rx="2"
ry="2"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
x="5.25"
y="5.25"
/>
<path
d="M2.801,11.998L1.772,5.074c-.162-1.093,.592-2.11,1.684-2.272l6.924-1.029c.933-.139,1.81,.39,2.148,1.228"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
};

Comment on lines +14 to +24
const snippet =
props.customCodeSnippet ??
reactElementToJSXString(props.children, {
showFunctions: true,
useBooleanShorthandSyntax: true,

displayName: (node) => {
// @ts-ignore
return node?.type.displayName ?? "Unknown";
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for reactElementToJSXString

The reactElementToJSXString call could throw an error if the children prop contains invalid elements. Consider wrapping it in a try-catch block.

   const snippet =
     props.customCodeSnippet ??
-    reactElementToJSXString(props.children, {
-      showFunctions: true,
-      useBooleanShorthandSyntax: true,
-
-      displayName: (node) => {
-        // @ts-ignore
-        return node?.type.displayName ?? "Unknown";
-      },
-    });
+    (() => {
+      try {
+        return reactElementToJSXString(props.children, {
+          showFunctions: true,
+          useBooleanShorthandSyntax: true,
+          displayName: (node: { type: { displayName?: string } }) => {
+            return node.type.displayName ?? "Unknown";
+          },
+        });
+      } catch (error) {
+        console.error("Failed to convert children to JSX string:", error);
+        return "Error: Could not generate code snippet";
+      }
+    })();
📝 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
const snippet =
props.customCodeSnippet ??
reactElementToJSXString(props.children, {
showFunctions: true,
useBooleanShorthandSyntax: true,
displayName: (node) => {
// @ts-ignore
return node?.type.displayName ?? "Unknown";
},
});
const snippet =
props.customCodeSnippet ??
(() => {
try {
return reactElementToJSXString(props.children, {
showFunctions: true,
useBooleanShorthandSyntax: true,
displayName: (node: { type: { displayName?: string } }) => {
return node.type.displayName ?? "Unknown";
},
});
} catch (error) {
console.error("Failed to convert children to JSX string:", error);
return "Error: Could not generate code snippet";
}
})();

Comment on lines +20 to +23
displayName: (node) => {
// @ts-ignore
return node?.type.displayName ?? "Unknown";
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove @ts-ignore and handle type properly

The @ts-ignore comment suppresses a type error that should be handled properly. Consider defining the correct type for the node parameter.

-      displayName: (node) => {
-        // @ts-ignore
-        return node?.type.displayName ?? "Unknown";
-      },
+      displayName: (node: { type: { displayName?: string } }) => {
+        return node.type.displayName ?? "Unknown";
+      },
📝 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
displayName: (node) => {
// @ts-ignore
return node?.type.displayName ?? "Unknown";
},
displayName: (node: { type: { displayName?: string } }) => {
return node.type.displayName ?? "Unknown";
},

className: {
description:
'A className applied to the icon to override the styling in edge cases. In most cases you should not change the size of the icon.',
type: 'string | undefiend',
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo in type definition

There's a typo in the type definition that needs to be corrected.

-      type: 'string | undefiend',
+      type: 'string | undefined',
📝 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
type: 'string | undefiend',
type: 'string | undefined',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant