Reduce bundle size by importing single icons at a time (#6644)

* Removed barrel import for icons to reduce bundle size.

* Fixed replacement mistakes

* Reverted unneccesary yarn.lock updates

* Added some missed Icon. import conversions

* Remove merge artifact import in @calcom/ui

* Don't import Icon in pages/[user]

* Update packages/ui/package.json

Co-authored-by: Alex van Andel <[email protected]>
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-01-23 23:08:01 +00:00
1 parent a888be6e04
commit cfa8fd8b67
155 files changed
+881 -768

No files matched your search

@@ -2,7 +2,8 @@ import React from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SVGComponent } from "@calcom/types/SVGComponent";
import { Button, Icon } from "@calcom/ui";
import { Button } from "@calcom/ui";
import { FiSmartphone, FiMail, FiPlus } from "@calcom/ui/components/icon";
type WorkflowExampleType = {
Icon: SVGComponent;
@@ -50,12 +51,12 @@ export default function EmptyScreen({
const { t } = useLocale();
const workflowsExamples = [
{ icon: Icon.FiSmartphone, text: t("workflow_example_1") },
{ icon: Icon.FiSmartphone, text: t("workflow_example_2") },
{ icon: Icon.FiMail, text: t("workflow_example_3") },
{ icon: Icon.FiMail, text: t("workflow_example_4") },
{ icon: Icon.FiMail, text: t("workflow_example_5") },
{ icon: Icon.FiSmartphone, text: t("workflow_example_6") },
{ icon: FiSmartphone, text: t("workflow_example_1") },
{ icon: FiSmartphone, text: t("workflow_example_2") },
{ icon: FiMail, text: t("workflow_example_3") },
{ icon: FiMail, text: t("workflow_example_4") },
{ icon: FiMail, text: t("workflow_example_5") },
{ icon: FiSmartphone, text: t("workflow_example_6") },
];
// new workflow example when 'after meetings ends' trigger is implemented: Send custom thank you email to attendee after event (FiSmile icon),
@@ -73,7 +74,7 @@ export default function EmptyScreen({
{buttonOnClick && buttonText && (
<Button
type="button"
StartIcon={Icon.FiPlus}
StartIcon={FiPlus}
onClick={(e) => buttonOnClick(e)}
loading={isLoading}
className="mx-auto mt-8">
@@ -7,7 +7,8 @@ import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
import { trpc } from "@calcom/trpc/react";
import { Button, EmptyScreen, Icon, showToast, Switch, Tooltip } from "@calcom/ui";
import { Button, EmptyScreen, showToast, Switch, Tooltip } from "@calcom/ui";
import { FiExternalLink, FiZap } from "@calcom/ui/components/icon";
import LicenseRequired from "../../common/components/v2/LicenseRequired";
import { getActionIcon } from "../lib/getActionIcon";
@@ -125,7 +126,7 @@ const WorkflowListItem = (props: ItemProps) => {
<Link href={`/workflows/${workflow.id}`} passHref={true} target="_blank">
<Button type="button" color="minimal" className="mr-4">
<div className="hidden ltr:mr-2 rtl:ml-2 sm:block">{t("edit")}</div>
<Icon.FiExternalLink className="-mt-[2px] h-4 w-4 stroke-2 text-gray-600" />
<FiExternalLink className="-mt-[2px] h-4 w-4 stroke-2 text-gray-600" />
</Button>
</Link>
</div>
@@ -204,7 +205,7 @@ function EventWorkflowsTab(props: Props) {
) : (
<div className="pt-4 before:border-0">
<EmptyScreen
Icon={Icon.FiZap}
Icon={FiZap}
headline={t("workflows")}
description={t("no_workflows_description")}
buttonRaw={
@@ -1,4 +1,5 @@
import { Icon, SkeletonText } from "@calcom/ui";
import { SkeletonText } from "@calcom/ui";
import { FiBell, FiLink } from "@calcom/ui/components/icon";
function SkeletonLoader() {
return (
@@ -20,9 +21,9 @@ function SkeletonItem() {
<div className="flex flex-col space-y-2">
<SkeletonText className="h-4 w-16 sm:w-24" />
<div className="flex">
<Icon.FiBell className="mt-0.5 mr-1.5 inline h-4 w-4 text-gray-200" />
<FiBell className="mt-0.5 mr-1.5 inline h-4 w-4 text-gray-200" />
<SkeletonText className="h-4 w-16 ltr:mr-2 rtl:ml-2 sm:w-28" />
<Icon.FiLink className="mt-0.5 mr-1.5 inline h-4 w-4 text-gray-200" />
<FiLink className="mt-0.5 mr-1.5 inline h-4 w-4 text-gray-200" />
<SkeletonText className="h-4 w-28 sm:w-36" />
</div>
</div>
@@ -8,9 +8,9 @@ import {
DropdownMenuItem,
DropdownItem,
DropdownMenuTrigger,
Icon,
TextField,
} from "@calcom/ui";
import { FiChevronDown } from "@calcom/ui/components/icon";
import { getWorkflowTimeUnitOptions } from "../lib/getOptions";
import type { FormValues } from "../pages/workflow";
@@ -44,7 +44,7 @@ export const TimeTimeUnitInput = (props: Props) => {
{timeUnit ? t(`${timeUnit.toLowerCase()}_timeUnit`) : "undefined"}{" "}
</div>
<div className="w-1/4 pt-1">
<Icon.FiChevronDown />
<FiChevronDown />
</div>
</button>
</DropdownMenuTrigger>
@@ -7,7 +7,8 @@ import { SENDER_ID, SENDER_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import type { MultiSelectCheckboxesOptionType as Option } from "@calcom/ui";
import { Button, Icon, Label, MultiSelectCheckboxes, TextField } from "@calcom/ui";
import { Button, Label, MultiSelectCheckboxes, TextField } from "@calcom/ui";
import { FiArrowDown, FiTrash2 } from "@calcom/ui/components/icon";
import { isSMSAction } from "../lib/isSMSAction";
import type { FormValues } from "../pages/workflow";
@@ -115,7 +116,7 @@ export default function WorkflowDetailsPage(props: Props) {
<div className="my-7 border-transparent md:border-t md:border-gray-200" />
<Button
type="button"
StartIcon={Icon.FiTrash2}
StartIcon={FiTrash2}
color="destructive"
className="border"
onClick={() => setDeleteDialogOpen(true)}>
@@ -147,7 +148,7 @@ export default function WorkflowDetailsPage(props: Props) {
</>
)}
<div className="my-3 flex justify-center">
<Icon.FiArrowDown className="stroke-[1.5px] text-3xl text-gray-500" />
<FiArrowDown className="stroke-[1.5px] text-3xl text-gray-500" />
</div>
<div className="flex justify-center">
<Button
@@ -15,10 +15,10 @@ import {
DropdownMenuItem,
DropdownItem,
DropdownMenuTrigger,
Icon,
showToast,
Tooltip,
} from "@calcom/ui";
import { FiEdit2, FiLink, FiMoreHorizontal, FiTrash2, FiZap } from "@calcom/ui/components/icon";
import { getActionIcon } from "../lib/getActionIcon";
import { DeleteDialog } from "./DeleteDialog";
@@ -49,7 +49,7 @@ const CreateEmptyWorkflowView = () => {
<EmptyScreen
buttonText={t("create_workflow")}
buttonOnClick={() => createMutation.mutate()}
IconHeading={Icon.FiZap}
IconHeading={FiZap}
headline={t("workflows")}
description={t("no_workflows_description")}
isLoading={createMutation.isLoading}
@@ -122,13 +122,13 @@ export default function WorkflowListPage({ workflows }: Props) {
<p key={key}>{activeOn.eventType.title}</p>
))}>
<div>
<Icon.FiLink className="mr-1.5 inline h-3 w-3" aria-hidden="true" />
<FiLink className="mr-1.5 inline h-3 w-3" aria-hidden="true" />
{t("active_on_event_types", { count: workflow.activeOn.length })}
</div>
</Tooltip>
) : (
<div>
<Icon.FiLink className="mr-1.5 inline h-3 w-3" aria-hidden="true" />
<FiLink className="mr-1.5 inline h-3 w-3" aria-hidden="true" />
{t("no_active_event_types")}
</div>
)}
@@ -144,7 +144,7 @@ export default function WorkflowListPage({ workflows }: Props) {
type="button"
color="secondary"
variant="icon"
StartIcon={Icon.FiEdit2}
StartIcon={FiEdit2}
onClick={async () => await router.replace("/workflows/" + workflow.id)}
/>
</Tooltip>
@@ -156,7 +156,7 @@ export default function WorkflowListPage({ workflows }: Props) {
}}
color="secondary"
variant="icon"
StartIcon={Icon.FiTrash2}
StartIcon={FiTrash2}
/>
</Tooltip>
</ButtonGroup>
@@ -164,18 +164,13 @@ export default function WorkflowListPage({ workflows }: Props) {
<div className="block sm:hidden">
<Dropdown>
<DropdownMenuTrigger asChild>
<Button
type="button"
color="minimal"
variant="icon"
StartIcon={Icon.FiMoreHorizontal}
/>
<Button type="button" color="minimal" variant="icon" StartIcon={FiMoreHorizontal} />
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>
<DropdownItem
type="button"
StartIcon={Icon.FiEdit2}
StartIcon={FiEdit2}
onClick={async () => await router.replace("/workflows/" + workflow.id)}>
{t("edit")}
</DropdownItem>
@@ -184,7 +179,7 @@ export default function WorkflowListPage({ workflows }: Props) {
<DropdownItem
type="button"
color="destructive"
StartIcon={Icon.FiTrash2}
StartIcon={FiTrash2}
onClick={() => {
setDeleteDialogOpen(true);
setwWorkflowToDeleteId(workflow.id);
@@ -14,12 +14,11 @@ import { SENDER_ID } from "@calcom/lib/constants";
import { SENDER_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
import { trpc, TRPCClientError } from "@calcom/trpc/react";
import { trpc } from "@calcom/trpc/react";
import {
Badge,
Button,
Checkbox,
ConfirmationDialogContent,
Dialog,
DialogClose,
DialogContent,
@@ -29,7 +28,6 @@ import {
DropdownItem,
DropdownMenuTrigger,
EmailField,
Icon,
Label,
PhoneInput,
Select,
@@ -40,6 +38,7 @@ import {
AddVariablesDropdown,
Input,
} from "@calcom/ui";
import { FiArrowDown, FiMoreHorizontal, FiTrash2, FiHelpCircle } from "@calcom/ui/components/icon";
import { DYNAMIC_TEXT_VARIABLES } from "../lib/constants";
import { getWorkflowTemplateOptions, getWorkflowTriggerOptions } from "../lib/getOptions";
@@ -276,7 +275,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
return (
<>
<div className="my-3 flex justify-center">
<Icon.FiArrowDown className="stroke-[1.5px] text-3xl text-gray-500" />
<FiArrowDown className="stroke-[1.5px] text-3xl text-gray-500" />
</div>
<div className="flex justify-center">
<div className="min-w-80 flex w-full rounded-md border border-gray-200 bg-white p-7">
@@ -296,18 +295,13 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
<div>
<Dropdown>
<DropdownMenuTrigger asChild>
<Button
type="button"
color="minimal"
variant="icon"
StartIcon={Icon.FiMoreHorizontal}
/>
<Button type="button" color="minimal" variant="icon" StartIcon={FiMoreHorizontal} />
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>
<DropdownItem
type="button"
StartIcon={Icon.FiTrash2}
StartIcon={FiTrash2}
color="destructive"
onClick={() => {
const steps = form.getValues("steps");
@@ -638,7 +632,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
<div className="mt-3 ">
<button type="button" onClick={() => setIsAdditionalInputsDialogOpen(true)}>
<div className="mt-2 flex text-sm text-gray-600">
<Icon.FiHelpCircle className="mt-[3px] h-3 w-3 ltr:mr-2 rtl:ml-2" />
<FiHelpCircle className="mt-[3px] h-3 w-3 ltr:mr-2 rtl:ml-2" />
<p className="text-left">{t("using_additional_inputs_as_variables")}</p>
</div>
</button>
@@ -1,32 +1,26 @@
import { WorkflowActions, WorkflowStep } from "@prisma/client";
import { classNames } from "@calcom/lib";
import { Icon } from "@calcom/ui";
import { FiZap, FiSmartphone, FiMail, FiBell } from "@calcom/ui/components/icon";
export function getActionIcon(steps: WorkflowStep[], className?: string): JSX.Element {
if (steps.length === 0) {
return (
<Icon.FiZap
className={classNames(className ? className : "mr-1.5 inline h-3 w-3")}
aria-hidden="true"
/>
<FiZap className={classNames(className ? className : "mr-1.5 inline h-3 w-3")} aria-hidden="true" />
);
}
if (steps.length === 1) {
if (steps[0].action === WorkflowActions.SMS_ATTENDEE || steps[0].action === WorkflowActions.SMS_NUMBER) {
return (
<Icon.FiSmartphone
<FiSmartphone
className={classNames(className ? className : "mr-1.5 inline h-3 w-3")}
aria-hidden="true"
/>
);
} else {
return (
<Icon.FiMail
className={classNames(className ? className : "mr-1.5 inline h-3 w-3")}
aria-hidden="true"
/>
<FiMail className={classNames(className ? className : "mr-1.5 inline h-3 w-3")} aria-hidden="true" />
);
}
}
@@ -55,30 +49,27 @@ export function getActionIcon(steps: WorkflowStep[], className?: string): JSX.El
switch (messageType) {
case "SMS":
return (
<Icon.FiSmartphone
<FiSmartphone
className={classNames(className ? className : "mr-1.5 inline h-3 w-3")}
aria-hidden="true"
/>
);
case "EMAIL":
return (
<Icon.FiMail
<FiMail
className={classNames(className ? className : "mr-1.5 inline h-3 w-3")}
aria-hidden="true"
/>
);
case "MIX":
return (
<Icon.FiBell
<FiBell
className={classNames(className ? className : "mr-1.5 inline h-3 w-3")}
aria-hidden="true"
/>
);
default:
<Icon.FiZap
className={classNames(className ? className : "mr-1.5 inline h-3 w-3")}
aria-hidden="true"
/>;
<FiZap className={classNames(className ? className : "mr-1.5 inline h-3 w-3")} aria-hidden="true" />;
}
}
@@ -5,7 +5,8 @@ import Shell from "@calcom/features/shell/Shell";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
import { trpc } from "@calcom/trpc/react";
import { Button, Icon, showToast } from "@calcom/ui";
import { Button, showToast } from "@calcom/ui";
import { FiPlus } from "@calcom/ui/components/icon";
import LicenseRequired from "../../common/components/v2/LicenseRequired";
import SkeletonLoader from "../components/SkeletonLoaderList";
@@ -45,7 +46,7 @@ function WorkflowsPage() {
session.data?.hasValidLicense && data?.workflows && data?.workflows.length > 0 ? (
<Button
variant="fab"
StartIcon={Icon.FiPlus}
StartIcon={FiPlus}
onClick={() => createMutation.mutate()}
loading={createMutation.isLoading}>
{t("new")}