-
Notifications
You must be signed in to change notification settings - Fork 902
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: replaced Heroicons with corresponding lucide-react icons #2221
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
Thank you for following the naming conventions for pull request titles! 🙏 |
apps/web/app/(app)/environments/[environmentId]/(actionsAndAttributes)/actions/components/ActionActivityTab.tsxInstead of using multiple ternary operators to check the type of the actionClass, you can use a switch statement. This will make your code easier to read and maintain. let icon;
switch(actionClass.type) {
case 'code':
icon = <Code2Icon className="h-5 w-5" />;
break;
case 'noCode':
icon = <MousePointerClickIcon className="h-5 w-5" />;
break;
case 'automatic':
icon = <SparklesIcon className="h-5 w-5" />;
break;
default:
icon = null;
}
apps/formbricks-com/components/shared/PricingTable.tsxThere are repeated blocks of code for rendering the CheckIcon and XIcon with their respective styles. This can be extracted into a separate component to improve code readability and maintainability. // New component
const StatusIcon = ({ type }) => {
const commonClasses = "rounded-full p-0.5";
const iconProps = {
className: commonClasses,
};
if (type === "check") {
return (
<CheckIcon
{...iconProps}
className={`${commonClasses} border-green-300 bg-green-100 text-green-500 dark:border-green-600 dark:bg-green-900 dark:text-green-300`}
/>
);
}
if (type === "x") {
return (
<XIcon
{...iconProps}
className={`${commonClasses} border-red-300 bg-red-100 text-red-500 dark:border-red-500 dark:bg-red-300 dark:text-red-600`}
/>
);
}
return null;
};
// Usage
{feature.free ? <StatusIcon type="check" /> : <StatusIcon type="x" />}
apps/formbricks-com/components/shared/Header.tsxConsider using dynamic imports for the icons. This way, the icons will only be loaded when they are needed, which can improve the initial load time of your application. import dynamic from 'next/dynamic';
const ChevronDownIcon = dynamic(() => import('lucide-react').then((mod) => mod.ChevronDownIcon));
const ChevronRightIcon = dynamic(() => import('lucide-react').then((mod) => mod.ChevronRightIcon));
const MenuIcon = dynamic(() => import('lucide-react').then((mod) => mod.MenuIcon));
const XIcon = dynamic(() => import('lucide-react').then((mod) => mod.XIcon));
|
<div className="mr-1.5 h-4 w-4 text-slate-600"> | ||
{actionClass.type === "code" ? ( | ||
<CodeBracketIcon /> | ||
<Code2Icon className="h-5 w-5" /> | ||
) : actionClass.type === "noCode" ? ( | ||
<CursorArrowRaysIcon /> | ||
<MousePointerClickIcon className="h-5 w-5" /> | ||
) : actionClass.type === "automatic" ? ( | ||
<SparklesIcon /> | ||
<SparklesIcon className="h-5 w-5" /> | ||
) : null} | ||
</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.
Replaced the multiple ternary operators with a switch statement for better readability and maintainability.
<div className="mr-1.5 h-4 w-4 text-slate-600"> | |
{actionClass.type === "code" ? ( | |
<CodeBracketIcon /> | |
<Code2Icon className="h-5 w-5" /> | |
) : actionClass.type === "noCode" ? ( | |
<CursorArrowRaysIcon /> | |
<MousePointerClickIcon className="h-5 w-5" /> | |
) : actionClass.type === "automatic" ? ( | |
<SparklesIcon /> | |
<SparklesIcon className="h-5 w-5" /> | |
) : null} | |
</div> | |
let icon; | |
switch(actionClass.type) { | |
case 'code': | |
icon = <Code2Icon className="h-5 w-5" />; | |
break; | |
case 'noCode': | |
icon = <MousePointerClickIcon className="h-5 w-5" />; | |
break; | |
case 'automatic': | |
icon = <SparklesIcon className="h-5 w-5" />; | |
break; | |
default: | |
icon = null; | |
} | |
<div className="mr-1.5 h-4 w-4 text-slate-600"> | |
{icon} | |
</div> |
import clsx from "clsx"; | ||
import { ChevronDownIcon, ChevronRightIcon, MenuIcon, XIcon } from "lucide-react"; |
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.
The icons from the 'lucide-react' library are now dynamically imported. This change will improve the initial load time of the application as the icons will only be loaded when they are needed.
import { ChevronDownIcon, ChevronRightIcon, MenuIcon, XIcon } from "lucide-react"; | |
import dynamic from 'next/dynamic'; | |
const ChevronDownIcon = dynamic(() => import('lucide-react').then((mod) => mod.ChevronDownIcon)); | |
const ChevronRightIcon = dynamic(() => import('lucide-react').then((mod) => mod.ChevronRightIcon)); | |
const MenuIcon = dynamic(() => import('lucide-react').then((mod) => mod.MenuIcon)); | |
const XIcon = dynamic(() => import('lucide-react').then((mod) => mod.XIcon)); |
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.
@Dhruwang Wow, that are a lot of changes 😲 Thanks a lot for this; very happy we can remove a dependency from Formbricks 😊🚀
What does this PR do?
Fixes 1704
How should this be tested?
Check icons
Checklist
Required
pnpm build
console.logs
git pull origin main
Appreciated