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: replaced Heroicons with corresponding lucide-react icons #2221

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

Dhruwang
Copy link
Contributor

What does this PR do?

Fixes 1704

How should this be tested?

Check icons

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Copy link

vercel bot commented Mar 12, 2024

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

2 Ignored Deployments
Name Status Preview Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Mar 12, 2024 9:24am
formbricks-com ⬜️ Ignored (Inspect) Mar 12, 2024 9:24am

Copy link
Contributor

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

Copy link
Contributor

apps/web/app/(app)/environments/[environmentId]/(actionsAndAttributes)/actions/components/ActionActivityTab.tsx

Instead 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.
Create Issue
See the diff
Checkout the fix

    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;
    }
git fetch origin && git checkout -b ReviewBot/Impro-8c5ca6e origin/ReviewBot/Impro-8c5ca6e

apps/formbricks-com/components/shared/PricingTable.tsx

There 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.
Create Issue
See the diff
Checkout the fix

    // 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" />}
git fetch origin && git checkout -b ReviewBot/Impro-viaiob3 origin/ReviewBot/Impro-viaiob3

apps/formbricks-com/components/shared/Header.tsx

Consider 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.
Create Issue
See the diff
Checkout the fix

    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));
git fetch origin && git checkout -b ReviewBot/The-c-nl4panm origin/ReviewBot/The-c-nl4panm

Comment on lines 126 to 134
<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>
Copy link
Contributor

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.

Suggested change
<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";
Copy link
Contributor

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.

Suggested change
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));

Copy link
Member

@mattinannt mattinannt left a 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 😊🚀

@mattinannt mattinannt added this pull request to the merge queue Mar 12, 2024
Merged via the queue into main with commit 99da20f Mar 12, 2024
14 of 16 checks passed
@mattinannt mattinannt deleted the replace-heroicons branch March 12, 2024 12:35
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.

None yet

2 participants