-
Notifications
You must be signed in to change notification settings - Fork 529
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
feat: icons #2700
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
|
Caution Review failedThe pull request is closed. 📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces several new components and updates to the existing codebase, primarily focused on enhancing the icon functionality within the application. A new Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (11)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this 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 attributesWhile the current props are good for basic usage, consider adding more accessibility-focused props such as:
role?: string
- For explicit ARIA roleariaLabel?: string
- More semantic than using title for accessibilityariaHidden?: boolean
- For decorative iconsexport 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
androle
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
androle
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 iconsTo 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:
- Ensure consistent accessibility implementation
- Reduce code duplication
- Make icon components more focused on their specific paths/shapes
- Make it easier to modify common behavior across all icons
internal/icons/src/icons/book-bookmark.tsx (1)
5-5
: Add accessibility attributes to SVGFor better accessibility, consider adding
role="img"
andaria-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 SVGFor consistency with other icon components and better accessibility, add
role="img"
andaria-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 importsThe 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 adjectiveWhen "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 readabilityAdd 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 exampleThe 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
⛔ 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
export const Icon: React.FC<IconProps> = (props) => { | ||
return <svg className={props.className} />; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix incomplete SVG implementation
The current implementation has several critical issues:
- Missing required SVG attributes
- Not utilizing the title prop
- 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.
<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> |
There was a problem hiding this comment.
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.
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> | ||
); | ||
}; |
There was a problem hiding this comment.
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.
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> | |
); | |
}; |
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> | ||
); | ||
}; |
There was a problem hiding this comment.
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.
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> | ||
); | ||
}; |
There was a problem hiding this comment.
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.
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> | |
); | |
}; |
const snippet = | ||
props.customCodeSnippet ?? | ||
reactElementToJSXString(props.children, { | ||
showFunctions: true, | ||
useBooleanShorthandSyntax: true, | ||
|
||
displayName: (node) => { | ||
// @ts-ignore | ||
return node?.type.displayName ?? "Unknown"; | ||
}, | ||
}); |
There was a problem hiding this comment.
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.
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"; | |
} | |
})(); |
displayName: (node) => { | ||
// @ts-ignore | ||
return node?.type.displayName ?? "Unknown"; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
type: 'string | undefiend', | |
type: 'string | undefined', |
Summary by CodeRabbit
Release Notes
New Features
Icon
component for rendering customizable SVG icons.Bolt
,BookBookmark
,Check
,ChevronExpandY
,Nodes
,ShieldCheck
,Sparkle3
,TaskChecked
, andTaskUnchecked
.Bug Fixes
RenderComponentWithSnippet
component.Chores