chore: icon cleanup (#13770)

Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-04-03 23:23:57 +00:00
1 parent 7421cea0da
commit 3f02de8214
294 files changed
+3161 -1715

No files matched your search

+16 -12
View File
@@ -1,10 +1,8 @@
import classNames from "classnames";
import type { ReactNode } from "react";
import { forwardRef } from "react";
import type { IconType } from "react-icons";
import type { LucideIcon } from "@calcom/ui/components/icon";
import { CheckCircle2, Info, XCircle, AlertTriangle } from "@calcom/ui/components/icon";
import { Icon, type IconName } from "../..";
export interface AlertProps {
title?: ReactNode;
@@ -16,7 +14,7 @@ export interface AlertProps {
iconClassName?: string;
// @TODO: Success and info shouldn't exist as per design?
severity: "success" | "warning" | "error" | "info" | "neutral" | "green";
CustomIcon?: IconType | LucideIcon;
CustomIcon?: IconName;
customIconColor?: string;
}
export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
@@ -39,7 +37,8 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
<div className="relative flex md:flex-row">
{CustomIcon ? (
<div className="flex-shrink-0">
<CustomIcon
<Icon
name={CustomIcon}
data-testid="custom-icon"
aria-hidden="true"
className={classNames(`h-5 w-5`, iconClassName, customIconColor ?? "text-default")}
@@ -48,36 +47,41 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
) : (
<div className="flex-shrink-0">
{severity === "error" && (
<XCircle
data-testid="x-circle"
<Icon
name="circle-x"
data-testid="circle-x"
className={classNames("h-5 w-5 text-red-900 dark:text-red-200", iconClassName)}
aria-hidden="true"
/>
)}
{severity === "warning" && (
<AlertTriangle
<Icon
name="triangle-alert"
data-testid="alert-triangle"
className={classNames("text-attention h-5 w-5 dark:text-orange-200", iconClassName)}
aria-hidden="true"
/>
)}
{severity === "info" && (
<Info
<Icon
name="info"
data-testid="info"
className={classNames("h-5 w-5 text-blue-900 dark:text-blue-200", iconClassName)}
aria-hidden="true"
/>
)}
{severity === "neutral" && (
<Info
<Icon
name="info"
data-testid="neutral"
className={classNames("text-default h-5 w-5 fill-transparent", iconClassName)}
aria-hidden="true"
/>
)}
{severity === "success" && (
<CheckCircle2
data-testid="check-circle-2"
<Icon
name="circle-check"
data-testid="circle-check"
className={classNames("fill-muted text-default h-5 w-5", iconClassName)}
aria-hidden="true"
/>
+10 -10
View File
@@ -14,28 +14,28 @@ describe("Tests for Alert component", () => {
expect(screen.getByText("Click Me")).toBeInTheDocument();
});
test("Should render corresponding icon: error", () => {
test("Should render corresponding icon: error", async () => {
render(<Alert severity="error" />);
expect(screen.getByTestId("x-circle")).toBeInTheDocument();
expect(await screen.findByTestId("circle-x")).toBeInTheDocument();
});
test("Should render corresponding icon: warning", () => {
test("Should render corresponding icon: warning", async () => {
render(<Alert severity="warning" />);
expect(screen.getByTestId("alert-triangle")).toBeInTheDocument();
expect(await screen.findByTestId("alert-triangle")).toBeInTheDocument();
});
test("Should render corresponding icon: info", () => {
test("Should render corresponding icon: info", async () => {
render(<Alert severity="info" />);
expect(screen.getByTestId("info")).toBeInTheDocument();
expect(await screen.findByTestId("info")).toBeInTheDocument();
});
test("Should render corresponding icon: neutral", () => {
test("Should render corresponding icon: neutral", async () => {
render(<Alert severity="neutral" />);
expect(screen.getByTestId("neutral")).toBeInTheDocument();
expect(await screen.findByTestId("neutral")).toBeInTheDocument();
});
test("Should render corresponding icon: success", () => {
test("Should render corresponding icon: success", async () => {
render(<Alert severity="success" />);
expect(screen.getByTestId("check-circle-2")).toBeInTheDocument();
expect(await screen.findByTestId("circle-check")).toBeInTheDocument();
});
});
+4 -4
View File
@@ -11,8 +11,8 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { AppFrontendPayload as App } from "@calcom/types/App";
import type { CredentialFrontendPayload as Credential } from "@calcom/types/Credential";
import { Icon } from "../..";
import { EmptyScreen } from "../empty-screen";
import { ChevronLeft, ChevronRight, Search } from "../icon";
import { AppCard } from "./AppCard";
export function useShouldShowArrows() {
@@ -85,7 +85,7 @@ function CategoryTab({ selectedCategory, categories, searchText }: CategoryTabPr
{leftVisible && (
<button onClick={handleLeft} className="absolute bottom-0 flex md:-top-1 md:left-1/2">
<div className="bg-default flex h-12 w-5 items-center justify-end">
<ChevronLeft className="text-subtle h-4 w-4" />
<Icon name="chevron-left" className="text-subtle h-4 w-4" />
</div>
<div className="to-default flex h-12 w-5 bg-gradient-to-l from-transparent" />
</button>
@@ -132,7 +132,7 @@ function CategoryTab({ selectedCategory, categories, searchText }: CategoryTabPr
<button onClick={handleRight} className="absolute bottom-0 right-0 flex md:-top-1">
<div className="to-default flex h-12 w-5 bg-gradient-to-r from-transparent" />
<div className="bg-default flex h-12 w-5 items-center justify-end">
<ChevronRight className="text-subtle h-4 w-4" />
<Icon name="chevron-right" className="text-subtle h-4 w-4" />
</div>
</button>
)}
@@ -192,7 +192,7 @@ export function AllApps({ apps, searchText, categories, userAdminTeams }: AllApp
</div>
) : (
<EmptyScreen
Icon={Search}
Icon="search"
headline={t("no_results")}
description={searchText ? searchText?.toString() : ""}
/>
+13 -16
View File
@@ -1,5 +1,4 @@
import { usePathname } from "next/navigation";
import { useRouter } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
@@ -14,18 +13,17 @@ import type { AppFrontendPayload as App } from "@calcom/types/App";
import type { CredentialFrontendPayload as Credential } from "@calcom/types/Credential";
import type { ButtonProps } from "@calcom/ui";
import {
Dropdown,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuPortal,
DropdownMenuLabel,
DropdownItem,
Avatar,
Badge,
Dropdown,
DropdownItem,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuPortal,
DropdownMenuTrigger,
} from "@calcom/ui";
import { Button } from "../button";
import { Plus } from "../icon";
import { showToast } from "../toast";
interface AppCardProps {
@@ -81,7 +79,7 @@ export function AppCard({ app, credentials, searchText, userAdminTeams }: AppCar
</h3>
</div>
{/* TODO: add reviews <div className="flex text-sm text-default">
<span>{props.rating} stars</span> <StarIcon className="ml-1 mt-0.5 h-4 w-4 text-yellow-600" />
<span>{props.rating} stars</span> <Icon name="star" className="ml-1 mt-0.5 h-4 w-4 text-yellow-600" />
<span className="pl-1 text-subtle">{props.reviews} reviews</span>
</div> */}
<p
@@ -214,7 +212,7 @@ const InstallAppButtonChild = ({
<Button
color="secondary"
className="[@media(max-width:260px)]:w-full [@media(max-width:260px)]:justify-center"
StartIcon={Plus}
StartIcon="plus"
data-testid="install-app-button"
{...props}>
{paid.trial ? t("start_paid_trial") : t("subscribe")}
@@ -230,7 +228,7 @@ const InstallAppButtonChild = ({
<Button
color="secondary"
className="[@media(max-width:260px)]:w-full [@media(max-width:260px)]:justify-center"
StartIcon={Plus}
StartIcon="plus"
data-testid="install-app-button"
{...props}>
{t("install")}
@@ -244,7 +242,7 @@ const InstallAppButtonChild = ({
<Button
color="secondary"
className="[@media(max-width:260px)]:w-full [@media(max-width:260px)]:justify-center"
StartIcon={Plus}
StartIcon="plus"
data-testid="install-app-button"
{...props}>
{t("install")}
@@ -273,14 +271,13 @@ const InstallAppButtonChild = ({
type="button"
disabled={isInstalledTeamOrUser}
key={team.id}
StartIcon={(props: { className?: string }) => (
CustomStartIcon={
<Avatar
alt={team.logo || ""}
imageSrc={team.logo || `${WEBAPP_URL}/${team.logo}/avatar.png`} // if no image, use default avatar
size="sm"
{...props}
/>
)}
}
onClick={() => {
mutation.mutate(
team.isUser ? addAppMutationInput : { ...addAppMutationInput, teamId: team.id }
+2 -2
View File
@@ -3,7 +3,7 @@ import Link from "next/link";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ArrowRight } from "../icon";
import { Icon } from "../..";
import { SkeletonText } from "../skeleton";
import { Slider } from "./Slider";
@@ -52,7 +52,7 @@ export function AppStoreCategories({
)}
<p className="text-subtle pt-2 text-sm font-medium">
{isLocaleReady ? t("number_apps", { count: category.count }) : <SkeletonText invisible />}{" "}
<ArrowRight className="inline-block h-4 w-4" />
<Icon name="arrow-right" className="inline-block h-4 w-4" />
</p>
</div>
</Link>
+3 -3
View File
@@ -7,7 +7,7 @@ import { useEffect, useRef } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ArrowLeft, ArrowRight } from "../icon";
import { Icon } from "../..";
import { SkeletonText } from "../skeleton";
const SliderButton: FC<ComponentProps<"button">> = (props) => {
@@ -63,10 +63,10 @@ export const Slider = <T extends string | unknown>({
)}
<div className="glide__arrows ml-auto flex items-center gap-x-1" data-glide-el="controls">
<SliderButton data-glide-dir="<">
<ArrowLeft className="h-5 w-5" />
<Icon name="arrow-left" className="h-5 w-5" />
</SliderButton>
<SliderButton data-glide-dir=">">
<ArrowRight className="h-5 w-5" />
<Icon name="arrow-right" className="h-5 w-5" />
</SliderButton>
</div>
</div>
@@ -1,4 +1,4 @@
import { ArrowUp, ArrowDown } from "@calcom/ui/components/icon";
import { Icon } from "../..";
export type ArrowButtonProps = {
arrowDirection: "up" | "down";
@@ -10,15 +10,15 @@ export function ArrowButton(props: ArrowButtonProps) {
<>
{props.arrowDirection === "up" ? (
<button
className="bg-default text-muted hover:text-emphasis border-default hover:border-emphasis invisible absolute left-0 -ml-4 -mt-4 mb-4 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-3"
className="bg-default text-muted hover:text-emphasis border-default hover:border-emphasis invisible absolute left-0 -ml-4 -mt-4 mb-4 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-3"
onClick={props.onClick}>
<ArrowUp className="h-5 w-5" />
<Icon name="arrow-up" className="h-5 w-5" />
</button>
) : (
<button
className="bg-default text-muted border-default hover:text-emphasis hover:border-emphasis invisible absolute left-0 -ml-4 mt-8 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-3"
className="bg-default text-muted border-default hover:text-emphasis hover:border-emphasis invisible absolute left-0 -ml-4 mt-8 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-3"
onClick={props.onClick}>
<ArrowDown className="h-5 w-5" />
<Icon name="arrow-down" className="h-5 w-5" />
</button>
)}
</>
+23 -10
View File
@@ -1,11 +1,10 @@
import type { VariantProps } from "class-variance-authority";
import { cva } from "class-variance-authority";
import React from "react";
import { GoPrimitiveDot } from "react-icons/go";
import classNames from "@calcom/lib/classNames";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { LucideIcon } from "@calcom/ui/components/icon";
import { Icon, type IconName } from "../..";
export const badgeStyles = cva("font-medium inline-flex items-center justify-center rounded gap-x-1", {
variants: {
@@ -37,14 +36,15 @@ type InferredBadgeStyles = VariantProps<typeof badgeStyles>;
type IconOrDot =
| {
startIcon?: SVGComponent | LucideIcon;
withDot?: unknown;
startIcon?: IconName;
withDot?: never;
}
| { startIcon?: unknown; withDot?: boolean };
| { startIcon?: never; withDot?: true };
export type BadgeBaseProps = InferredBadgeStyles & {
children: React.ReactNode;
rounded?: boolean;
customStartIcon?: React.ReactNode;
} & IconOrDot;
export type BadgeProps =
@@ -58,9 +58,19 @@ export type BadgeProps =
| (BadgeBaseProps & Omit<React.HTMLAttributes<HTMLButtonElement>, "onClick"> & { onClick: () => void });
export const Badge = function Badge(props: BadgeProps) {
const { variant, className, size, startIcon, withDot, children, rounded, ...passThroughProps } = props;
const {
customStartIcon,
variant,
className,
size,
startIcon,
withDot,
children,
rounded,
...passThroughProps
} = props;
const isButton = "onClick" in passThroughProps && passThroughProps.onClick !== undefined;
const StartIcon = startIcon ? (startIcon as SVGComponent) : undefined;
const StartIcon = startIcon;
const classes = classNames(
badgeStyles({ variant, size }),
rounded && "h-5 w-5 rounded-full p-0",
@@ -69,8 +79,11 @@ export const Badge = function Badge(props: BadgeProps) {
const Children = () => (
<>
{withDot ? <GoPrimitiveDot data-testid="go-primitive-dot" className="h-3 w-3 stroke-[3px]" /> : null}
{StartIcon ? <StartIcon data-testid="start-icon" className="h-3 w-3 stroke-[3px]" /> : null}
{withDot ? <Icon name="dot" data-testid="go-primitive-dot" className="h-3 w-3 stroke-[3px]" /> : null}
{customStartIcon ||
(StartIcon ? (
<Icon name={StartIcon} data-testid="start-icon" className="h-3 w-3 stroke-[3px]" />
) : null)}
{children}
</>
);
+2 -2
View File
@@ -1,4 +1,4 @@
import { Info } from "../icon";
import { Icon } from "../..";
import { Tooltip } from "../tooltip/Tooltip";
export function InfoBadge({ content }: { content: string }) {
@@ -6,7 +6,7 @@ export function InfoBadge({ content }: { content: string }) {
<>
<Tooltip side="top" content={content}>
<span title={content}>
<Info className="text-subtle relative left-1 right-1 top-px mt-px h-4 w-4" />
<Icon name="info" className="text-subtle relative left-1 right-1 top-px mt-px h-4 w-4" />
</span>
</Tooltip>
</>
@@ -50,7 +50,7 @@ Status badge communicate status information. It is generally used within a conta
<Badge withDot>Button Text</Badge>
</Example>
<Example title="With Icon">
<Badge startIcon={Plus}>Button Text</Badge>
<Badge startIcon="plus">Button Text</Badge>
</Example>
</Examples>
@@ -89,7 +89,7 @@ Alert badge is used in conjunction with an item, profile or label to indicate nu
<Badge variant={severity} withDot>
{label}
</Badge>
<Badge variant={severity} startIcon={Plus}>
<Badge variant={severity} startIcon="plus">
{label}
</Badge>
</VariantRow>
+3 -4
View File
@@ -42,17 +42,16 @@ describe("Tests for Badge component", () => {
expect(screen.getByText(children)).toBeInTheDocument();
});
test("Should render WithDot if the prop is true and shouldn't render if is false", () => {
test("Should render WithDot if the prop is true and shouldn't render if is false", async () => {
const { rerender } = render(<Badge withDot>{children}</Badge>);
expect(screen.getByTestId("go-primitive-dot")).toBeInTheDocument();
expect(await screen.findByTestId("go-primitive-dot")).toBeInTheDocument();
rerender(<Badge>{children}</Badge>);
expect(screen.queryByTestId("go-primitive-dot")).not.toBeInTheDocument();
});
test("Should render with a startIcon when startIcon prop is provided shouldn't render if is false", () => {
const startIcon = () => <svg data-testid="start-icon" />;
const { rerender } = render(<Badge startIcon={startIcon}>{children}</Badge>);
const { rerender } = render(<Badge customStartIcon={<svg data-testid="start-icon" />}>{children}</Badge>);
expect(screen.getByTestId("start-icon")).toBeInTheDocument();
rerender(<Badge>{children}</Badge>);
+31 -25
View File
@@ -5,10 +5,8 @@ import Link from "next/link";
import React, { forwardRef } from "react";
import classNames from "@calcom/lib/classNames";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { LucideIcon } from "@calcom/ui/components/icon";
import { Plus } from "../icon";
import { Icon, type IconName } from "../..";
import { Tooltip } from "../tooltip";
type InferredVariantProps = VariantProps<typeof buttonClasses>;
@@ -18,9 +16,10 @@ export type ButtonBaseProps = {
/** Action that happens when the button is clicked */
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
/**Left aligned icon*/
StartIcon?: SVGComponent | React.ElementType | LucideIcon;
CustomStartIcon?: React.ReactNode;
StartIcon?: IconName;
/**Right aligned icon */
EndIcon?: SVGComponent | LucideIcon;
EndIcon?: IconName;
shallow?: boolean;
/**Tool tip used when icon size is set to small */
tooltip?: string;
@@ -129,6 +128,7 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
tooltipSide = "top",
tooltipOffset = 4,
StartIcon,
CustomStartIcon,
EndIcon,
shallow,
// attributes propagated from `HTMLAnchorProps` or `HTMLButtonProps`
@@ -155,23 +155,28 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
: props.onClick,
},
<>
{StartIcon && (
<>
{variant === "fab" ? (
<>
<StartIcon className="hidden h-4 w-4 stroke-[1.5px] ltr:-ml-1 ltr:mr-2 rtl:-mr-1 rtl:ml-2 md:inline-flex" />
<Plus data-testid="plus" className="inline h-6 w-6 md:hidden" />
</>
) : (
<StartIcon
className={classNames(
variant === "icon" && "h-4 w-4",
variant === "button" && "h-4 w-4 stroke-[1.5px] ltr:-ml-1 ltr:mr-2 rtl:-mr-1 rtl:ml-2"
)}
/>
)}
</>
)}
{CustomStartIcon ||
(StartIcon && (
<>
{variant === "fab" ? (
<>
<Icon
name={StartIcon}
className="hidden h-4 w-4 stroke-[1.5px] ltr:-ml-1 ltr:mr-2 rtl:-mr-1 rtl:ml-2 md:inline-flex"
/>
<Icon name="plus" data-testid="plus" className="inline h-6 w-6 md:hidden" />
</>
) : (
<Icon
name={StartIcon}
className={classNames(
variant === "icon" && "h-4 w-4",
variant === "button" && "h-4 w-4 stroke-[1.5px] ltr:-ml-1 ltr:mr-2 rtl:-mr-1 rtl:ml-2"
)}
/>
)}
</>
))}
{variant === "fab" ? <span className="hidden md:inline">{props.children}</span> : props.children}
{loading && (
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform">
@@ -196,11 +201,12 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
<>
{variant === "fab" ? (
<>
<EndIcon className="-mr-1 me-2 ms-2 hidden h-5 w-5 md:inline" />
<Plus data-testid="plus" className="inline h-6 w-6 md:hidden" />
<Icon name={EndIcon} className="-mr-1 me-2 ms-2 hidden h-5 w-5 md:inline" />
<Icon name="plus" data-testid="plus" className="inline h-6 w-6 md:hidden" />
</>
) : (
<EndIcon
<Icon
name={EndIcon}
className={classNames(
"inline-flex",
variant === "icon" && "h-4 w-4",
@@ -1,10 +1,9 @@
import React from "react";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { LucideIcon } from "@calcom/ui/components/icon";
import { Icon, type IconName } from "@calcom/ui";
interface LinkIconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
Icon: SVGComponent | LucideIcon;
Icon: IconName;
}
export default function LinkIconButton(props: LinkIconButtonProps) {
@@ -14,7 +13,7 @@ export default function LinkIconButton(props: LinkIconButtonProps) {
type="button"
{...props}
className="text-md hover:bg-emphasis hover:text-emphasis text-default flex items-center rounded-md px-2 py-1 text-sm font-medium">
<props.Icon className="text-subtle h-4 w-4 ltr:mr-2 rtl:ml-2" />
<Icon name={props.Icon} className="text-subtle h-4 w-4 ltr:mr-2 rtl:ml-2" />
{props.children}
</button>
</div>
@@ -71,22 +71,22 @@ Button are clickable elements that initiates user actions. Labels in the button
<Button>Button text</Button>
</Example>
<Example title="Icon left">
<Button StartIcon={Plus}>Button text</Button>
<Button StartIcon="plus">Button text</Button>
</Example>
<Example title="Icon right">
<Button EndIcon={Plus}>Button text</Button>
<Button EndIcon="plus">Button text</Button>
</Example>
</Examples>
<Examples title="Icons">
<Example title="Icon Normal">
<Button StartIcon={X} variant="icon" size="base" color="minimal"></Button>
<Button StartIcon="x" variant="icon" size="base" color="minimal"></Button>
</Example>
<Example title="Icon Small">
<Button StartIcon={X} variant="icon" size="sm" color="minimal"></Button>
<Button StartIcon="x" variant="icon" size="sm" color="minimal"></Button>
</Example>
<Example title="Icon Loading">
<Button StartIcon={X} variant="icon" size="sm" color="minimal" loading></Button>
<Button StartIcon="x" variant="icon" size="sm" color="minimal" loading></Button>
</Example>
</Examples>
@@ -113,7 +113,7 @@ Button are clickable elements that initiates user actions. Labels in the button
<Button color="secondary">Button text</Button>
<Button color="minimal">Button text</Button>
<Button color="destructive">Button text</Button>
<Button color="destructive" variant="icon" StartIcon={X}></Button>
<Button color="destructive" variant="icon" StartIcon="x"></Button>
</VariantRow>
<VariantRow variant="Hover">
<Button className="sb-pseudo--hover">Button text</Button>
@@ -126,7 +126,7 @@ Button are clickable elements that initiates user actions. Labels in the button
<Button className="sb-pseudo--hover" color="destructive">
Button text
</Button>
<Button className="sb-pseudo--hover" color="destructive" variant="icon" StartIcon={X}></Button>
<Button className="sb-pseudo--hover" color="destructive" variant="icon" StartIcon="x"></Button>
</VariantRow>
<VariantRow variant="Focus">
<Button className="sb-pseudo--focus">Button text</Button>
@@ -139,7 +139,7 @@ Button are clickable elements that initiates user actions. Labels in the button
<Button className="sb-pseudo--focus" color="destructive">
Button text
</Button>
<Button className="sb-pseudo--focus" color="destructive" variant="icon" StartIcon={X}></Button>
<Button className="sb-pseudo--focus" color="destructive" variant="icon" StartIcon="x"></Button>
</VariantRow>
<VariantRow variant="Loading">
<Button loading>Button text</Button>
@@ -152,7 +152,7 @@ Button are clickable elements that initiates user actions. Labels in the button
<Button loading color="destructive">
Button text
</Button>
<Button loading color="destructive" variant="icon" StartIcon={X}></Button>
<Button loading color="destructive" variant="icon" StartIcon="x"></Button>
</VariantRow>
<VariantRow variant="Disabled">
<Button disabled>Button text</Button>
@@ -165,7 +165,7 @@ Button are clickable elements that initiates user actions. Labels in the button
<Button disabled color="destructive">
Button text
</Button>
<Button disabled color="minimal" variant="icon" StartIcon={X}></Button>
<Button disabled color="minimal" variant="icon" StartIcon="x"></Button>
</VariantRow>
</VariantsTable>
</Story>
+15 -17
View File
@@ -1,10 +1,8 @@
/* eslint-disable playwright/missing-playwright-await */
import { render, screen, fireEvent } from "@testing-library/react";
import { fireEvent, render, screen } from "@testing-library/react";
import { useState } from "react";
import { vi } from "vitest";
import { Plus } from "@calcom/ui/components/icon";
import { Button, buttonClasses } from "./Button";
const observeMock = vi.fn();
@@ -138,43 +136,43 @@ describe("Tests for Button component", () => {
expect(button.tagName).toBe("BUTTON");
});
test("Should render StartIcon and Plus icon if is fab variant", () => {
test("Should render StartIcon and Plus icon if is fab variant", async () => {
render(
<Button variant="fab" StartIcon={Plus} data-testid="start-icon">
<Button variant="fab" StartIcon="plus" data-testid="start-icon">
Test Button
</Button>
);
expect(screen.getByTestId("start-icon")).toBeInTheDocument();
expect(screen.getByTestId("plus")).toBeInTheDocument();
expect(await screen.findByTestId("start-icon")).toBeInTheDocument();
expect(await screen.findByTestId("plus")).toBeInTheDocument();
});
test("Should render just StartIcon if is not fab variant", () => {
test("Should render just StartIcon if is not fab variant", async () => {
render(
<Button StartIcon={Plus} data-testid="start-icon">
<Button StartIcon="plus" data-testid="start-icon">
Test Button
</Button>
);
expect(screen.getByTestId("start-icon")).toBeInTheDocument();
expect(await screen.findByTestId("start-icon")).toBeInTheDocument();
expect(screen.queryByTestId("plus")).not.toBeInTheDocument();
});
test("Should render EndIcon and Plus icon if is fab variant", () => {
test("Should render EndIcon and Plus icon if is fab variant", async () => {
render(
<Button variant="fab" EndIcon={Plus} data-testid="end-icon">
<Button variant="fab" EndIcon="plus" data-testid="end-icon">
Test Button
</Button>
);
expect(screen.getByTestId("end-icon")).toBeInTheDocument();
expect(screen.getByTestId("plus")).toBeInTheDocument();
expect(await screen.findByTestId("end-icon")).toBeInTheDocument();
expect(await screen.findByTestId("plus")).toBeInTheDocument();
});
test("Should render just EndIcon if is not fab variant", () => {
test("Should render just EndIcon if is not fab variant", async () => {
render(
<Button EndIcon={Plus} data-testid="end-icon">
<Button EndIcon="plus" data-testid="end-icon">
Test Button
</Button>
);
expect(screen.getByTestId("end-icon")).toBeInTheDocument();
expect(await screen.findByTestId("end-icon")).toBeInTheDocument();
expect(screen.queryByTestId("plus")).not.toBeInTheDocument();
});
@@ -10,8 +10,8 @@ import {
VariantRow,
} from "@calcom/storybook/components";
import { Icon } from "../..";
import { Button } from "../button/Button";
import { Trash, Navigation, Clipboard } from "../icon";
import { ButtonGroup } from "./ButtonGroup";
<Meta title="UI/Button Group" component={ButtonGroup} />
@@ -39,16 +39,16 @@ Button group enables multiple buttons to be combined into a single unit. It offe
}>
<Example title="Default">
<ButtonGroup>
<Button StartIcon={Trash} variant="icon" color="secondary" />
<Button StartIcon={Navigation} variant="icon" color="secondary" />
<Button StartIcon={Clipboard} variant="icon" color="secondary" />
<Button StartIcon="trash" variant="icon" color="secondary" />
<Button StartIcon="navigation" variant="icon" color="secondary" />
<Button StartIcon="clipboard" variant="icon" color="secondary" />
</ButtonGroup>
</Example>
<Example title="Combined">
<ButtonGroup combined>
<Button StartIcon={Trash} variant="icon" color="secondary" />
<Button StartIcon={Navigation} variant="icon" color="secondary" />
<Button StartIcon={Clipboard} variant="icon" color="secondary" />
<Button StartIcon="trash" variant="icon" color="secondary" />
<Button StartIcon="navigation" variant="icon" color="secondary" />
<Button StartIcon="clipboard" variant="icon" color="secondary" />
</ButtonGroup>
</Example>
</Examples>
@@ -58,31 +58,31 @@ Button group enables multiple buttons to be combined into a single unit. It offe
<VariantsTable titles={["Default", "Secondary", "Minimal"]} columnMinWidth={150}>
<VariantRow variant="Default">
<ButtonGroup>
<Button StartIcon={Trash} variant="icon" />
<Button StartIcon={Navigation} variant="icon" />
<Button StartIcon={Clipboard} variant="icon" />
<Button StartIcon="trash" variant="icon" />
<Button StartIcon="navigation" variant="icon" />
<Button StartIcon="clipboard" variant="icon" />
</ButtonGroup>
<ButtonGroup>
<Button StartIcon={Trash} variant="icon" color="secondary" />
<Button StartIcon={Navigation} variant="icon" color="secondary" />
<Button StartIcon={Clipboard} variant="icon" color="secondary" />
<Button StartIcon="trash" variant="icon" color="secondary" />
<Button StartIcon="navigation" variant="icon" color="secondary" />
<Button StartIcon="clipboard" variant="icon" color="secondary" />
</ButtonGroup>
<ButtonGroup>
<Button StartIcon={Trash} variant="icon" color="minimal" />
<Button StartIcon={Navigation} variant="icon" color="minimal" />
<Button StartIcon={Clipboard} variant="icon" color="minimal" />
<Button StartIcon="trash" variant="icon" color="minimal" />
<Button StartIcon="navigation" variant="icon" color="minimal" />
<Button StartIcon="clipboard" variant="icon" color="minimal" />
</ButtonGroup>
</VariantRow>
<VariantRow variant="Combined">
<ButtonGroup combined>
<Button StartIcon={Trash} variant="icon" />
<Button StartIcon={Navigation} variant="icon" />
<Button StartIcon={Clipboard} variant="icon" />
<Button StartIcon="trash" variant="icon" />
<Button StartIcon="navigation" variant="icon" />
<Button StartIcon="clipboard" variant="icon" />
</ButtonGroup>
<ButtonGroup combined>
<Button StartIcon={Trash} variant="icon" color="secondary" />
<Button StartIcon={Navigation} variant="icon" color="secondary" />
<Button StartIcon={Clipboard} variant="icon" color="secondary" />
<Button StartIcon="trash" variant="icon" color="secondary" />
<Button StartIcon="navigation" variant="icon" color="secondary" />
<Button StartIcon="clipboard" variant="icon" color="secondary" />
</ButtonGroup>
</VariantRow>
</VariantsTable>
@@ -113,9 +113,9 @@ Button group enables multiple buttons to be combined into a single unit. It offe
<VariantsTable titles={[`${color}`]} columnMinWidth={150}>
<VariantRow variant="">
<ButtonGroup combined={combined}>
<Button StartIcon={Trash} variant="icon" color={color} />
<Button StartIcon={Navigation} variant="icon" color={color} />
<Button StartIcon={Clipboard} variant="icon" color={color} />
<Button StartIcon="trash" variant="icon" color={color} />
<Button StartIcon="navigation" variant="icon" color={color} />
<Button StartIcon="clipboard" variant="icon" color={color} />
</ButtonGroup>
</VariantRow>
</VariantsTable>
+1 -2
View File
@@ -6,7 +6,6 @@ import type { ReactNode } from "react";
import React from "react";
import classNames from "@calcom/lib/classNames";
import { ArrowRight } from "@calcom/ui/components/icon";
import { Button } from "../button";
@@ -210,7 +209,7 @@ export function Card({
color="secondary"
href={actionButton?.href}
className="mt-10"
EndIcon={ArrowRight}
EndIcon="arrow-right"
data-testId={actionButton["data-testId"]}>
{actionButton?.child}
</Button>
+4 -5
View File
@@ -3,9 +3,8 @@ import Link from "next/link";
import { classNames } from "@calcom/lib";
import type { BadgeProps } from "../..";
import { Badge } from "../..";
import { Badge, Icon } from "../..";
import { Divider } from "../divider";
import { ArrowDown, ArrowUp, Trash2 } from "../icon";
type Action = { check: () => boolean; fn: () => void };
export default function FormCard({
@@ -39,7 +38,7 @@ export default function FormCard({
type="button"
className="bg-default text-muted hover:text-emphasis invisible absolute left-0 -ml-[13px] -mt-10 flex h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all hover:border-transparent hover:shadow group-hover:visible group-hover:scale-100 "
onClick={() => moveUp?.fn()}>
<ArrowUp />
<Icon name="arrow-up" />
</button>
) : null}
{moveDown?.check() ? (
@@ -47,7 +46,7 @@ export default function FormCard({
type="button"
className="bg-default text-muted hover:text-emphasis invisible absolute left-0 -ml-[13px] -mt-2 flex h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all hover:border-transparent hover:shadow group-hover:visible group-hover:scale-100"
onClick={() => moveDown?.fn()}>
<ArrowDown />
<Icon name="arrow-down" />
</button>
) : null}
</div>
@@ -68,7 +67,7 @@ export default function FormCard({
deleteField?.fn();
}}
color="secondary">
<Trash2 className="text-default h-4 w-4" />
<Icon name="trash-2" className="text-default h-4 w-4" />
</button>
) : null}
</div>
@@ -13,7 +13,6 @@ import {
DropdownMenuLabel,
DropdownMenuTrigger,
} from "@calcom/ui";
import { Plus } from "@calcom/ui/components/icon";
export interface Option {
platform?: boolean;
@@ -86,7 +85,7 @@ export function CreateButton(props: CreateBtnProps) {
: null
}
data-testid="create-button"
StartIcon={Plus}
StartIcon="plus"
loading={isPending}
variant={disableMobileButton ? "button" : "fab"}
{...restProps}>
@@ -97,7 +96,7 @@ export function CreateButton(props: CreateBtnProps) {
<DropdownMenuTrigger asChild>
<Button
variant={disableMobileButton ? "button" : "fab"}
StartIcon={Plus}
StartIcon="plus"
data-testid="create-button-dropdown"
loading={isPending}
{...restProps}>
@@ -113,9 +112,7 @@ export function CreateButton(props: CreateBtnProps) {
<DropdownItem
type="button"
data-testid={`option${option.teamId ? "-team" : ""}-${idx}`}
StartIcon={(props: { className?: string }) => (
<Avatar alt={option.label || ""} imageSrc={option.image} size="sm" {...props} />
)}
CustomStartIcon={<Avatar alt={option.label || ""} imageSrc={option.image} size="sm" />}
onClick={() =>
!!CreateDialog
? openModal(option)
@@ -1,21 +1,21 @@
import type { Column } from "@tanstack/react-table";
import type { LucideIcon } from "lucide-react";
import { Check, Filter } from "lucide-react";
import { classNames } from "@calcom/lib";
import { Icon } from "../..";
import { Badge } from "../badge";
import { Button } from "../button";
import {
Command,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
} from "../command";
import { Popover, PopoverTrigger, PopoverContent } from "../popover";
import { Popover, PopoverContent, PopoverTrigger } from "../popover";
interface DataTableFilter<TData, TValue> {
column?: Column<TData, TValue>;
@@ -34,7 +34,7 @@ export function DataTableFilter<TData, TValue>({ column, title, options }: DataT
<Popover>
<PopoverTrigger asChild>
<Button color="secondary" size="sm" className="border-subtle h-8 rounded-md">
<Filter className="mr-2 h-4 w-4" />
<Icon name="filter" className="mr-2 h-4 w-4" />
{title}
{selectedValues?.size > 0 && (
<>
@@ -83,7 +83,7 @@ export function DataTableFilter<TData, TValue>({ column, title, options }: DataT
"border-subtle mr-2 flex h-4 w-4 items-center justify-center rounded-sm border",
isSelected ? "text-emphasis" : "opacity-50 [&_svg]:invisible"
)}>
<Check className={classNames("h-4 w-4")} />
<Icon name="check" className={classNames("h-4 w-4")} />
</div>
{option.icon && <option.icon className="text-muted mr-2 h-4 w-4" />}
<span>{option.label}</span>
@@ -1,5 +1,4 @@
import type { Table } from "@tanstack/react-table";
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react";
import { Button } from "../button";
@@ -22,7 +21,7 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
<Button
color="secondary"
variant="icon"
StartIcon={ChevronsLeft}
StartIcon="chevrons-left"
className="hidden h-8 w-8 p-0 lg:flex"
onClick={() => table.setPageIndex(0)}>
<span className="sr-only">Go to first page</span>
@@ -33,13 +32,13 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
className="h-8 w-8 p-0"
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
StartIcon={ChevronLeft}>
StartIcon="chevron-left">
<span className="sr-only">Go to previous page</span>
</Button>
<Button
color="secondary"
variant="icon"
StartIcon={ChevronRight}
StartIcon="chevron-right"
className="h-8 w-8 p-0"
disabled={!table.getCanNextPage()}
onClick={() => table.nextPage()}>
@@ -49,7 +48,7 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
color="secondary"
variant="icon"
className="hidden h-8 w-8 p-0 lg:flex"
StartIcon={ChevronsRight}
StartIcon="chevrons-right"
onClick={() => table.setPageIndex(table.getPageCount())}>
<span className="sr-only">Go to last page</span>
</Button>
@@ -1,9 +1,8 @@
import type { Table } from "@tanstack/react-table";
import { motion, AnimatePresence } from "framer-motion";
import { AnimatePresence, motion } from "framer-motion";
import { Fragment } from "react";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { IconName } from "../..";
import { Button } from "../button";
export type ActionItem<TData> =
@@ -11,7 +10,7 @@ export type ActionItem<TData> =
type: "action";
label: string;
onClick: () => void;
icon?: SVGComponent;
icon?: IconName;
}
| {
type: "render";
@@ -2,7 +2,6 @@
import type { Table } from "@tanstack/react-table";
import type { LucideIcon } from "lucide-react";
import { X } from "lucide-react";
import { useEffect, useState } from "react";
import { useDebounce } from "@calcom/lib/hooks/useDebounce";
@@ -72,7 +71,7 @@ export function DataTableToolbar<TData>({
{isFiltered && (
<Button
color="minimal"
EndIcon={X}
EndIcon="x"
onClick={() => table.resetColumnFilters()}
className="h-8 px-2 lg:px-3">
{t("clear")}
@@ -1,5 +1,3 @@
import { StopCircle, Users } from "lucide-react";
export type DataTableUserStorybook = {
id: string;
username: string;
@@ -13,14 +11,14 @@ export const dataTableSelectionActions = [
onClick: () => {
console.log("Add To Team");
},
icon: Users,
icon: "users",
},
{
label: "Delete",
onClick: () => {
console.log("Delete");
},
icon: StopCircle,
icon: "stop-circle",
},
];
@@ -4,7 +4,7 @@ import React from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { AlertCircle, Check } from "../icon";
import { Icon } from "../..";
import { DialogClose, DialogContent } from "./Dialog";
type ConfirmBtnType =
@@ -49,17 +49,17 @@ export const ConfirmationContent = (props: PropsWithChildren<ConfirmationDialogC
<div className="mt-0.5 ltr:mr-3">
{variety === "danger" && (
<div className="bg-error mx-auto rounded-full p-2 text-center">
<AlertCircle className="h-5 w-5 text-red-600 dark:text-red-100" />
<Icon name="circle-alert" className="h-5 w-5 text-red-600 dark:text-red-100" />
</div>
)}
{variety === "warning" && (
<div className="bg-attention mx-auto rounded-full p-2 text-center">
<AlertCircle className="h-5 w-5 text-orange-600" />
<Icon name="circle-alert" className="h-5 w-5 text-orange-600" />
</div>
)}
{variety === "success" && (
<div className="bg-success mx-auto rounded-full p-2 text-center">
<Check className="h-5 w-5 text-green-600" />
<Icon name="check" className="h-5 w-5 text-green-600" />
</div>
)}
</div>
+9 -10
View File
@@ -1,16 +1,15 @@
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { usePathname, useRouter } from "next/navigation";
import { useMemo } from "react";
import type { ReactNode, ForwardRefExoticComponent, ReactElement } from "react";
import React, { useState } from "react";
import type { ForwardRefExoticComponent, ReactElement, ReactNode } from "react";
import React, { useMemo, useState } from "react";
import { useIsPlatform, Dialog as PlatformDialogPrimitives } from "@calcom/atoms/monorepo";
import { Dialog as PlatformDialogPrimitives, useIsPlatform } from "@calcom/atoms/monorepo";
import classNames from "@calcom/lib/classNames";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { LucideIcon } from "@calcom/ui/components/icon";
import type { IconName } from "../..";
import { Icon } from "../..";
import type { ButtonProps } from "../../components/button";
import { Button } from "../../components/button";
@@ -86,13 +85,13 @@ type DialogContentProps = React.ComponentProps<(typeof DialogPrimitive)["Content
description?: string | JSX.Element | null;
closeText?: string;
actionDisabled?: boolean;
Icon?: SVGComponent | LucideIcon;
Icon?: IconName;
enableOverflow?: boolean;
};
// enableOverflow:- use this prop whenever content inside DialogContent could overflow and require scrollbar
export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
({ children, title, Icon, enableOverflow, type = "creation", ...props }, forwardedRef) => {
({ children, title, Icon: icon, enableOverflow, type = "creation", ...props }, forwardedRef) => {
const isPlatform = useIsPlatform();
const [Portal, Overlay, Content] = useMemo(
() =>
@@ -134,9 +133,9 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps
)}
{type === "confirmation" && (
<div className="flex">
{Icon && (
{icon && (
<div className="bg-emphasis mr-4 inline-flex h-10 w-10 items-center justify-center rounded-full">
<Icon className="text-emphasis h-4 w-4" />
<Icon name={icon} className="text-emphasis h-4 w-4" />
</div>
)}
<div className="w-full">
@@ -2,7 +2,7 @@ import classNames from "classnames";
import { useState } from "react";
import type { ControllerRenderProps } from "react-hook-form";
import { Edit2 } from "@calcom/ui/components/icon";
import { Icon } from "../..";
export const EditableHeading = function EditableHeading({
value,
@@ -23,7 +23,10 @@ export const EditableHeading = function EditableHeading({
<label className="min-w-8 relative inline-block">
<span className="whitespace-pre text-xl tracking-normal text-transparent">{value}&nbsp;</span>
{!isEditing && isReady && (
<Edit2 className=" text-subtle group-hover:text-subtle -mt-px ml-1 inline h-3 w-3" />
<Icon
name="pencil"
className=" text-subtle group-hover:text-subtle -mt-px ml-1 inline h-3 w-3"
/>
)}
<input
{...passThroughProps}
@@ -1,7 +1,7 @@
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Icon } from "../../..";
import { Dropdown, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../form/dropdown";
import { ChevronDown } from "../../icon";
interface IAddVariablesDropdown {
addVariable: (variable: string) => void;
@@ -20,14 +20,14 @@ export const AddVariablesDropdown = (props: IAddVariablesDropdown) => {
<>
<div className="hidden sm:flex">
{t("add_variable")}
<ChevronDown className="ml-1 mt-[2px] h-4 w-4" />
<Icon name="chevron-down" className="ml-1 mt-[2px] h-4 w-4" />
</div>
<div className="block sm:hidden">+</div>
</>
) : (
<div className="flex">
{t("add_variable")}
<ChevronDown className="ml-1 mt-[2px] h-4 w-4" />
<Icon name="chevron-down" className="ml-1 mt-[2px] h-4 w-4" />
</div>
)}
</div>
@@ -25,9 +25,9 @@ import {
import { useCallback, useEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
import { Icon } from "../../..";
import { Button } from "../../button";
import { Dropdown, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../form/dropdown";
import { Bold, ChevronDown, Italic, Link } from "../../icon";
import type { TextEditorProps } from "../Editor";
import { AddVariablesDropdown } from "./AddVariablesDropdown";
@@ -424,7 +424,7 @@ export default function ToolbarPlugin(props: TextEditorProps) {
<span className="text text-default hidden sm:flex">
{blockTypeToBlockName[blockType as keyof BlockType]}
</span>
<ChevronDown className="text-default ml-2 h-4 w-4" />
<Icon name="chevron-down" className="text-default ml-2 h-4 w-4" />
</>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
@@ -458,7 +458,7 @@ export default function ToolbarPlugin(props: TextEditorProps) {
color="minimal"
variant="icon"
type="button"
StartIcon={Bold}
StartIcon="bold"
onClick={() => {
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold");
}}
@@ -470,7 +470,7 @@ export default function ToolbarPlugin(props: TextEditorProps) {
color="minimal"
variant="icon"
type="button"
StartIcon={Italic}
StartIcon="italic"
onClick={() => {
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "italic");
}}
@@ -483,7 +483,7 @@ export default function ToolbarPlugin(props: TextEditorProps) {
color="minimal"
variant="icon"
type="button"
StartIcon={Link}
StartIcon="link"
onClick={insertLink}
className={isLink ? "bg-subtle" : ""}
/>
@@ -1,14 +1,14 @@
import type { LucideIcon as IconType } from "lucide-react";
import type { ReactNode } from "react";
import React from "react";
import { classNames } from "@calcom/lib";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { IconName } from "../..";
import { Icon } from "../..";
import { Button } from "../../components/button";
export function EmptyScreen({
Icon,
Icon: icon,
avatar,
headline,
description,
@@ -19,7 +19,7 @@ export function EmptyScreen({
dashedBorder = true,
className,
}: {
Icon?: SVGComponent | IconType;
Icon?: IconName;
avatar?: React.ReactElement;
headline: string | React.ReactElement;
description?: string | React.ReactElement;
@@ -42,16 +42,16 @@ export function EmptyScreen({
{!avatar ? null : (
<div className="flex h-[72px] w-[72px] items-center justify-center rounded-full">{avatar}</div>
)}
{!Icon ? null : (
{!icon ? null : (
<div className="bg-emphasis flex h-[72px] w-[72px] items-center justify-center rounded-full ">
<Icon className="text-default inline-block h-10 w-10 stroke-[1.3px]" />
<Icon name={icon} className="text-default inline-block h-10 w-10 stroke-[1.3px]" />
</div>
)}
<div className="flex max-w-[420px] flex-col items-center">
<h2
className={classNames(
"text-semibold font-cal text-emphasis text-center text-xl",
Icon && "mt-6"
icon && "mt-6"
)}>
{headline}
</h2>
@@ -46,7 +46,7 @@ The CTA button can prompt the user to add the info/ apps needed for the page.
<VariantsTable titles={[]} columnMinWidth={150}>
<VariantRow variant="Default">
<EmptyScreen
Icon={Calendar}
Icon="calendar"
headline={headline}
description={description}
buttonText={buttonText}
@@ -1,10 +1,10 @@
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { useId } from "@radix-ui/react-id";
import { Check } from "lucide-react";
import type { InputHTMLAttributes } from "react";
import React, { forwardRef } from "react";
import classNames from "@calcom/lib/classNames";
import { Icon } from "@calcom/ui";
type Props = InputHTMLAttributes<HTMLInputElement> & {
label?: React.ReactNode;
@@ -32,7 +32,7 @@ const Checkbox = React.forwardRef<
)}
{...props}>
<CheckboxPrimitive.Indicator className={classNames("flex items-center justify-center text-current")}>
<Check className="h-4 w-4" />
<Icon name="check" className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
));
@@ -1,4 +1,4 @@
import { render, screen, fireEvent } from "@testing-library/react";
import { fireEvent, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { act } from "react-dom/test-utils";
import { vi } from "vitest";
@@ -8,7 +8,10 @@ import { Button } from "../../button";
import ColorPicker from "./colorpicker";
vi.mock("@calcom/ui", async () => {
return { Button: ({ tooltip, ...rest }: ButtonProps) => <Button {...rest}>{tooltip}</Button> };
return {
Icon: () => <svg data-testid="dummy-icon" />,
Button: ({ tooltip, ...rest }: ButtonProps) => <Button {...rest}>{tooltip}</Button>,
};
});
describe("Tests for ColorPicker component", () => {
@@ -5,7 +5,6 @@ import { HexColorInput, HexColorPicker } from "react-colorful";
import cx from "@calcom/lib/classNames";
import { fallBackHex, isValidHexCode } from "@calcom/lib/getBrandColours";
import { Button } from "@calcom/ui";
import { RotateCcw } from "@calcom/ui/components/icon";
export type ColorPickerProps = {
defaultValue: string;
@@ -72,7 +71,7 @@ const ColorPicker = (props: ColorPickerProps) => {
target="_blank"
variant="icon"
rel="noreferrer"
StartIcon={RotateCcw}
StartIcon="rotate-ccw"
tooltip="Reset to default"
onClick={() => {
setColor(fallBackHex(resetDefaultValue, false));
@@ -2,7 +2,7 @@
import "@wojtekmaj/react-daterange-picker/dist/DateRangePicker.css";
import PrimitiveDateRangePicker from "@wojtekmaj/react-daterange-picker/dist/entry.nostyle";
import { ArrowRight, Calendar, ChevronLeft, ChevronRight } from "../../icon";
import { Icon } from "../../..";
import "./styles.css";
type Props = {
@@ -19,14 +19,14 @@ const DateRangePicker = ({ disabled, startDate, endDate, onDatesChange }: Props)
disabled={disabled || false}
className="border-default rounded-sm text-sm"
clearIcon={null}
calendarIcon={<Calendar className="text-subtle h-4 w-4" />}
rangeDivider={<ArrowRight className="text-muted h-4 w-4 ltr:mr-2 rtl:ml-2" />}
calendarIcon={<Icon name="calendar" className="text-subtle h-4 w-4" />}
rangeDivider={<Icon name="arrow-right" className="text-muted h-4 w-4 ltr:mr-2 rtl:ml-2" />}
value={[startDate, endDate]}
onChange={([startDate, endDate]: [Date, Date]) => {
if (typeof onDatesChange === "function") onDatesChange({ startDate, endDate });
}}
nextLabel={<ChevronRight className="text-subtle h-4 w-4" />}
prevLabel={<ChevronLeft className="text-subtle h-4 w-4" />}
nextLabel={<Icon name="chevron-right" className="text-subtle h-4 w-4" />}
prevLabel={<Icon name="chevron-left" className="text-subtle h-4 w-4" />}
/>
</>
);
@@ -4,7 +4,7 @@ import PrimitiveDatePicker from "react-date-picker/dist/entry.nostyle";
import classNames from "@calcom/lib/classNames";
import { Calendar } from "../../icon";
import { Icon } from "../../..";
type Props = {
date: Date;
@@ -23,7 +23,7 @@ const DatePicker = ({ minDate, disabled, date, onDatesChange, className }: Props
)}
calendarClassName="rounded-md dark:text-black"
clearIcon={null}
calendarIcon={<Calendar className="text-subtle h-5 w-5 rounded-md" />}
calendarIcon={<Icon name="calendar" className="text-subtle h-5 w-5 rounded-md" />}
value={date}
minDate={minDate}
disabled={disabled}
@@ -4,9 +4,7 @@ import type { ComponentProps } from "react";
import { forwardRef } from "react";
import { classNames } from "@calcom/lib";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import { CheckCircle } from "@calcom/ui/components/icon";
import type { LucideIcon } from "@calcom/ui/components/icon";
import { Icon, type IconName } from "@calcom/ui";
import type { ButtonColor } from "../../button/Button";
@@ -78,7 +76,7 @@ export const DropdownMenuCheckboxItem = forwardRef<HTMLDivElement, DropdownMenuC
<DropdownMenuPrimitive.CheckboxItem {...props} ref={forwardedRef} className="">
{children}
<DropdownMenuPrimitive.ItemIndicator>
<CheckCircle />
<Icon name="circle-check" />
</DropdownMenuPrimitive.ItemIndicator>
</DropdownMenuPrimitive.CheckboxItem>
);
@@ -95,7 +93,7 @@ export const DropdownMenuRadioItem = forwardRef<HTMLDivElement, DropdownMenuRadi
<DropdownMenuPrimitive.RadioItem {...props} ref={forwardedRef}>
{children}
<DropdownMenuPrimitive.ItemIndicator>
<CheckCircle />
<Icon name="circle-check" />
</DropdownMenuPrimitive.ItemIndicator>
</DropdownMenuPrimitive.RadioItem>
);
@@ -106,8 +104,9 @@ DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
type DropdownItemProps = {
children: React.ReactNode;
color?: ButtonColor;
StartIcon?: SVGComponent | LucideIcon;
EndIcon?: SVGComponent | LucideIcon;
StartIcon?: IconName;
CustomStartIcon?: React.ReactNode;
EndIcon?: IconName;
href?: string;
disabled?: boolean;
childrenClassName?: string;
@@ -132,7 +131,7 @@ export function ButtonOrLink({ href, ...props }: ButtonOrLinkProps) {
}
export const DropdownItem = (props: DropdownItemProps) => {
const { StartIcon, EndIcon, children, color, childrenClassName, ...rest } = props;
const { CustomStartIcon, StartIcon, EndIcon, children, color, childrenClassName, ...rest } = props;
return (
<ButtonOrLink
@@ -145,9 +144,9 @@ export const DropdownItem = (props: DropdownItemProps) => {
props.className
)}>
<>
{StartIcon && <StartIcon className="h-4 w-4" />}
{CustomStartIcon || (StartIcon && <Icon name={StartIcon} className="h-4 w-4" />)}
<div className={classNames("text-sm font-medium leading-5", childrenClassName)}>{children}</div>
{EndIcon && <EndIcon className="h-4 w-4" />}
{EndIcon && <Icon name={EndIcon} className="h-4 w-4" />}
</>
</ButtonOrLink>
);
@@ -1,5 +1,4 @@
import { Canvas, Story, Meta } from "@storybook/addon-docs";
import { Button } from "@calcom/ui";
import {
Examples,
@@ -9,8 +8,9 @@ import {
VariantRow,
VariantsTable,
} from "@calcom/storybook/components";
import { Button } from "@calcom/ui";
import { Icon } from "@calcom/ui";
import { Plus, Trash, Copy } from "@calcom/ui/components/icon";
import {
Dropdown,
DropdownMenuTrigger,
@@ -115,7 +115,7 @@ The `Dropdown` component can be used to display a menu to the user.
<Example title="Button Icon">
<Dropdown>
<DropdownMenuTrigger asChild>
<Button StartIcon={Plus} />
<Button StartIcon="plus" />
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>
@@ -266,14 +266,14 @@ The `Dropdown` component can be used to display a menu to the user.
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>
<DropdownItem StartIcon={Trash}>First</DropdownItem>
<DropdownItem StartIcon="trash">First</DropdownItem>
</DropdownMenuItem>
<DropdownMenuItem>
<DropdownItem StartIcon={Plus}>Second</DropdownItem>
<DropdownItem StartIcon="plus">Second</DropdownItem>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>
<DropdownItem StartIcon={Copy}>Third</DropdownItem>
<DropdownItem StartIcon="copy">Third</DropdownItem>
</DropdownMenuItem>
</DropdownMenuContent>
</Dropdown>
@@ -310,7 +310,7 @@ The `Dropdown` component can be used to display a menu to the user.
asChild: false,
align: "start",
disabled: false,
sideOffset: 0
sideOffset: 0,
}}
argTypes={{
sideOffset: {
@@ -320,8 +320,8 @@ The `Dropdown` component can be used to display a menu to the user.
},
asChild: {
control: {
type: "boolean"
}
type: "boolean",
},
},
align: {
control: {
@@ -331,9 +331,9 @@ The `Dropdown` component can be used to display a menu to the user.
},
disabled: {
control: {
type: "boolean"
}
}
type: "boolean",
},
},
}}>
{({ dir, asChild, sideOffset, align, disabled }) => (
<VariantsTable titles={["Default"]} columnMinWidth={150}>
@@ -344,13 +344,13 @@ The `Dropdown` component can be used to display a menu to the user.
</DropdownMenuTrigger>
<DropdownMenuContent align={align} sideOffset={sideOffset}>
<DropdownMenuItem>
<DropdownItem StartIcon={Trash}>First</DropdownItem>
<DropdownItem StartIcon="trash">First</DropdownItem>
</DropdownMenuItem>
<DropdownMenuItem>
<DropdownItem StartIcon={Plus}>Second</DropdownItem>
<DropdownItem StartIcon="plus">Second</DropdownItem>
</DropdownMenuItem>
<DropdownMenuItem>
<DropdownItem StartIcon={Copy}>Third</DropdownItem>
<DropdownItem StartIcon="copy">Third</DropdownItem>
</DropdownMenuItem>
</DropdownMenuContent>
</Dropdown>
@@ -1,7 +1,7 @@
import type { FieldValues } from "react-hook-form";
import { useFormContext } from "react-hook-form";
import { Check, Circle, X } from "../../icon";
import { Icon } from "../../..";
import { InputError } from "./InputError";
type hintsOrErrorsProps = {
@@ -55,12 +55,27 @@ export function HintsOrErrors<T extends FieldValues = FieldValues>({
className={error !== undefined ? (submitted ? "text-red-500" : "") : "text-green-600"}>
{error !== undefined ? (
submitted ? (
<X size="12" strokeWidth="3" className="-ml-1 inline-block ltr:mr-2 rtl:ml-2" />
<Icon
name="x"
size="12"
strokeWidth="3"
className="-ml-1 inline-block ltr:mr-2 rtl:ml-2"
/>
) : (
<Circle fill="currentColor" size="5" className="inline-block ltr:mr-2 rtl:ml-2" />
<Icon
name="circle"
fill="currentColor"
size="5"
className="inline-block ltr:mr-2 rtl:ml-2"
/>
)
) : (
<Check size="12" strokeWidth="3" className="-ml-1 inline-block ltr:mr-2 rtl:ml-2" />
<Icon
name="check"
size="12"
strokeWidth="3"
className="-ml-1 inline-block ltr:mr-2 rtl:ml-2"
/>
)}
{t(`${fieldName}_hint_${key}`)}
</li>
@@ -88,9 +103,14 @@ export function HintsOrErrors<T extends FieldValues = FieldValues>({
return (
<li key={key} className={!!dirty ? "text-green-600" : ""}>
{!!dirty ? (
<Check size="12" strokeWidth="3" className="-ml-1 inline-block ltr:mr-2 rtl:ml-2" />
<Icon
name="check"
size="12"
strokeWidth="3"
className="-ml-1 inline-block ltr:mr-2 rtl:ml-2"
/>
) : (
<Circle fill="currentColor" size="5" className="inline-block ltr:mr-2 rtl:ml-2" />
<Icon name="circle" fill="currentColor" size="5" className="inline-block ltr:mr-2 rtl:ml-2" />
)}
{t(`${fieldName}_hint_${key}`)}
</li>
+4 -5
View File
@@ -5,8 +5,7 @@ import { useFormContext } from "react-hook-form";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert, Input, InputField, Tooltip } from "../../..";
import { Eye, EyeOff, Search } from "../../icon";
import { Alert, Icon, Input, InputField, Tooltip } from "../../..";
import { Label } from "./Label";
import type { InputFieldProps } from "./types";
@@ -49,9 +48,9 @@ export const PasswordField = forwardRef<HTMLInputElement, InputFieldProps>(funct
type="button"
onClick={() => toggleIsPasswordVisible()}>
{isPasswordVisible ? (
<EyeOff className="h-4 stroke-[2.5px]" />
<Icon name="eye-off" className="h-4 stroke-[2.5px]" />
) : (
<Eye className="h-4 stroke-[2.5px]" />
<Icon name="eye" className="h-4 stroke-[2.5px]" />
)}
<span className="sr-only">{textLabel}</span>
</button>
@@ -189,7 +188,7 @@ export const FilterSearchField = forwardRef<HTMLInputElement, InputFieldProps>(f
dir="ltr"
className="focus-within:ring-brand-default group relative mx-3 mb-1 mt-2.5 flex items-center rounded-md focus-within:outline-none focus-within:ring-2">
<div className="addon-wrapper border-default [input:hover_+_&]:border-emphasis [input:hover_+_&]:border-l-default [&:has(+_input:hover)]:border-emphasis [&:has(+_input:hover)]:border-r-default flex h-7 items-center justify-center rounded-l-md border border-r-0">
<Search className="ms-3 h-4 w-4" data-testid="search-icon" />
<Icon name="search" className="ms-3 h-4 w-4" data-testid="search-icon" />
</div>
<Input
ref={ref}
@@ -1,4 +1,4 @@
import { Info } from "../../icon";
import { Icon } from "../../..";
type InputErrorProp = {
message: string;
@@ -7,7 +7,7 @@ type InputErrorProp = {
export const InputError = ({ message }: InputErrorProp) => (
<div data-testid="field-error" className="text-gray mt-2 flex items-center gap-x-2 text-sm text-red-700">
<div>
<Info className="h-3 w-3" />
<Icon name="info" className="h-3 w-3" />
</div>
<p>{message}</p>
</div>
@@ -3,8 +3,7 @@ import React, { forwardRef, useId, useState } from "react";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Skeleton } from "../../..";
import { X } from "../../icon";
import { Icon, Skeleton } from "../../..";
import { HintsOrErrors } from "./HintOrErrors";
import { Label } from "./Label";
import type { InputFieldProps, InputProps } from "./types";
@@ -157,7 +156,8 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
</Addon>
)}
{type === "search" && inputValue?.toString().length > 0 && (
<X
<Icon
name="x"
className="text-subtle absolute top-2.5 h-4 w-4 cursor-pointer ltr:right-2 rtl:left-2"
onClick={(e) => {
setInputValue("");
@@ -162,10 +162,10 @@ describe("Tests for NumberInput Component", () => {
});
describe("Tests for FilterSearchField Component", () => {
test("Should render correctly with Search icon and input", () => {
const { getByRole, getByTestId } = render(<FilterSearchField name="searchField" />);
test("Should render correctly with Search icon and input", async () => {
const { getByRole, findByTestId } = render(<FilterSearchField name="searchField" />);
const searchInput = getByRole("textbox");
const searchIcon = getByTestId("search-icon");
const searchIcon = await findByTestId("search-icon");
expect(searchInput).toBeInTheDocument();
expect(searchIcon).toBeInTheDocument();
@@ -3,8 +3,8 @@ import { components as reactSelectComponents } from "react-select";
import { classNames } from "@calcom/lib";
import { Icon } from "../../..";
import { UpgradeTeamsBadge, UpgradeOrgsBadge } from "../../badge";
import { Check } from "../../icon";
import type { SelectProps } from "./Select";
export const InputComponent = <
@@ -55,7 +55,7 @@ export const OptionComponent = <
) : (
<></>
)}
{props.isSelected && <Check className="ml-2 h-4 w-4" />}
{props.isSelected && <Icon name="check" className="ml-2 h-4 w-4" />}
</div>
</reactSelectComponents.Option>
);
@@ -9,7 +9,6 @@ import {
VariantsTable,
} from "@calcom/storybook/components";
import { Plus } from "../../icon";
import { SelectField } from "./Select";
<Meta title="UI/Form/Select Field" component={SelectField} />
@@ -80,7 +79,7 @@ const BadSelect = (props) => (
);
// Good: Custom component declared outside of the Select scope
const Control = <IconLeading icon={Plus} />;
const Control = <IconLeading icon="plus" />;
const GoodSelect = (props) => <Select {...props} components={{ Control }} />;
```
@@ -9,7 +9,7 @@ import {
VariantsTable,
VariantRow,
} from "@calcom/storybook/components";
import { ArrowRight } from "@calcom/ui/components/icon";
import { Icon } from "@calcom/ui";
import { ToggleGroup } from "./ToggleGroup";
@@ -32,16 +32,16 @@ The `ToggleGroup` component is used to create a group of toggle items with optio
<TooltipProvider>
<ToggleGroup
options={[
{ value: "option1", label: "Option 1", tooltip: "Tooltip for Option 1", iconLeft: <ArrowRight /> },
{ value: "option2", label: "Option 2", iconLeft: <ArrowRight /> },
{ value: "option3", label: "Option 3", iconLeft: <ArrowRight /> },
{ value: "option1", label: "Option 1", tooltip: "Tooltip for Option 1", iconLeft: <Icon name="arrow-right" /> },
{ value: "option2", label: "Option 2", iconLeft: <Icon name="arrow-right" /> },
{ value: "option3", label: "Option 3", iconLeft: <Icon name="arrow-right" /> },
{
value: "option4",
label: "Option 4",
tooltip: "Tooltip for Option 4",
iconLeft: <ArrowRight />,
iconLeft: <Icon name="arrow-right" />,
},
{ value: "option5", label: "Option 5", iconLeft: <ArrowRight />, disabled: true },
{ value: "option5", label: "Option 5", iconLeft: <Icon name="arrow-right" />, disabled: true },
]}
/>
</TooltipProvider>
+23 -1
View File
@@ -1,3 +1,25 @@
// find all lucide icons at https://lucide.dev/
// github https://github.com/lucide-icons/lucide
export * from "lucide-react";
import type { LucideProps } from "lucide-react";
import dynamic from "next/dynamic";
import { memo } from "react";
import type { IconName } from "./dynamicIconImports";
interface IconProps extends Omit<LucideProps, "ref"> {
name: IconName;
}
const IconDev = dynamic(() => import("./IconDev"));
const IconProd = dynamic(() => import("./IconProd"));
const Icon = memo((props: IconProps) => {
// Fast refresh doesn't play nice with dynamic imports
// This prevent slowdowns in development mode
if (process.env.NODE_ENV === "development") return <IconDev {...props} />;
return <IconProd {...props} />;
});
Icon.displayName = "Icon";
export default Icon;
+22
View File
@@ -0,0 +1,22 @@
// find all lucide icons at https://lucide.dev/
// github https://github.com/lucide-icons/lucide
import type { LucideProps } from "lucide-react";
import { icons } from "lucide-react";
import type { IconName } from "./dynamicIconImports";
interface IconProps extends Omit<LucideProps, "ref"> {
name: IconName;
}
const clearAndUpper = (text: string) => text.replace(/-/, "").toUpperCase();
const toPascalCase = (text: string) => text.replace(/(^\w|-\w)/g, clearAndUpper);
const IconDev = ({ name, ...props }: IconProps) => {
const CamelCaseName = toPascalCase(name);
const LucideIcon = icons[CamelCaseName as keyof typeof icons];
if (!LucideIcon) return null;
return <LucideIcon {...props} />;
};
export default IconDev;
+30
View File
@@ -0,0 +1,30 @@
"use client";
// find all lucide icons at https://lucide.dev/
// github https://github.com/lucide-icons/lucide
import type { LucideProps } from "lucide-react";
import { memo } from "react";
import { dynamicIconImports } from "./dynamicIconImports";
export type IconName = keyof typeof dynamicIconImports;
interface IconProps extends Omit<LucideProps, "ref"> {
name: IconName;
}
const fallback = <div className="bg-emphasis h-4 w-4 animate-pulse rounded-lg" />;
const LazyIcon = memo(({ name, ...props }: IconProps) => {
const LucideIcon = dynamicIconImports[name];
// This should never happen, but just in case
if (!LucideIcon) return fallback;
// @ts-expect-error - LucideIcon is a lazy loaded component
return <LucideIcon {...props} />;
});
LazyIcon.displayName = "LazyIcon";
export default LazyIcon;
File diff suppressed because it is too large. Load diff
-1
View File
@@ -1 +0,0 @@
export * from "./Icon";
@@ -3,9 +3,8 @@ import Link from "next/link";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useUrlMatchesCurrentUrl } from "@calcom/lib/hooks/useUrlMatchesCurrentUrl";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { LucideIcon } from "@calcom/ui/components/icon";
import { Icon, type IconName } from "../../..";
import { Avatar } from "../../avatar";
import { SkeletonText } from "../../skeleton";
@@ -17,7 +16,7 @@ export type HorizontalTabItemProps = {
href: string;
linkShallow?: boolean;
linkScroll?: boolean;
icon?: SVGComponent | LucideIcon;
icon?: IconName;
avatar?: string;
};
@@ -49,9 +48,8 @@ const HorizontalTabItem = function ({
data-testid={`horizontal-tab-${name}`}
aria-current={isCurrent ? "page" : undefined}>
{props.icon && (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
<props.icon
<Icon
name={props.icon}
className={classNames(
isCurrent ? "text-emphasis" : "group-hover:text-subtle text-muted",
"-ml-0.5 hidden h-4 w-4 ltr:mr-2 rtl:ml-2 sm:inline-block"
@@ -4,16 +4,14 @@ import { Fragment } from "react";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useUrlMatchesCurrentUrl } from "@calcom/lib/hooks/useUrlMatchesCurrentUrl";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import type { LucideIcon } from "@calcom/ui/components/icon";
import { ChevronRight, ExternalLink } from "../../icon";
import { Icon, type IconName } from "../../..";
import { Skeleton } from "../../skeleton";
export type VerticalTabItemProps = {
name: string;
info?: string;
icon?: SVGComponent | LucideIcon;
icon?: IconName;
disabled?: boolean;
children?: VerticalTabItemProps[];
textClassNames?: string;
@@ -63,7 +61,8 @@ const VerticalTabItem = ({
data-testid={`vertical-tab-${name}`}
aria-current={isCurrent ? "page" : undefined}>
{props.icon && (
<props.icon
<Icon
name={props.icon}
className={classNames(
"mr-2 h-[16px] w-[16px] stroke-[2px] ltr:mr-2 rtl:ml-2 md:mt-0",
props.iconClassName
@@ -76,7 +75,7 @@ const VerticalTabItem = ({
<Skeleton title={t(name)} as="p" className="max-w-36 min-h-4 mt-px truncate">
{t(name)}
</Skeleton>
{props.isExternalLink ? <ExternalLink data-testid="external-link" /> : null}
{props.isExternalLink ? <Icon name="external-link" data-testid="external-link" /> : null}
</span>
{info && (
<Skeleton
@@ -90,7 +89,8 @@ const VerticalTabItem = ({
</div>
{!disableChevron && isCurrent && (
<div className="ml-auto self-center">
<ChevronRight
<Icon
name="chevron-right"
width={20}
height={20}
className="text-default h-auto w-[20px] stroke-[1.5px]"
@@ -8,7 +8,7 @@ import {
Examples,
Example,
} from "@calcom/storybook/components";
import { Plus } from "@calcom/ui/components/icon";
import { Icon } from "@calcom/ui";
import HorizontalTabs from "../HorizontalTabs";
@@ -8,7 +8,7 @@ import {
VariantsTable,
VariantRow,
} from "@calcom/storybook/components";
import { Plus } from "@calcom/ui/components/icon";
import { Icon } from "@calcom/ui";
import VerticalTabs from "../VerticalTabs";
@@ -1,6 +1,5 @@
/* eslint-disable playwright/missing-playwright-await */
import { fireEvent, render, screen } from "@testing-library/react";
import { PlusIcon } from "lucide-react";
import { vi } from "vitest";
import HorizontalTabs from "./HorizontalTabs";
@@ -82,7 +81,7 @@ describe("Tests for navigation folder", () => {
href: "/tab1",
disableChevron: true,
disabled: true,
icon: PlusIcon,
icon: "plus" as const,
},
{ name: "Tab 2", href: "/tab2", isExternalLink: true },
{ name: "Tab 3", href: "/tab3", info: "info" },
@@ -104,12 +103,12 @@ describe("Tests for navigation folder", () => {
});
});
test("Should render correctly if props are passed", () => {
test("Should render correctly if props are passed", async () => {
render(<VerticalTabs tabs={mockTabs} />);
const iconElement = screen.getAllByTestId("icon-component");
const externalLink = screen.getAllByTestId("external-link");
const chevronRight = screen.getAllByTestId("chevron-right");
const iconElement = await screen.findAllByTestId("icon-component");
const externalLink = await screen.findAllByTestId("external-link");
const chevronRight = await screen.findAllByTestId("chevron-right");
mockTabs.forEach((tab) => {
const tabName = screen.getByText(tab.name);
@@ -4,7 +4,7 @@ import React from "react";
import { classNames } from "@calcom/lib";
import { Tooltip } from "@calcom/ui";
import { ChevronDown } from "../icon";
import { Icon } from "../..";
export const AnimatedPopover = ({
text,
@@ -72,7 +72,8 @@ export const AnimatedPopover = ({
)}
</div>
</Tooltip>
<ChevronDown
<Icon
name="chevron-down"
className={classNames("ml-2 w-4 transition-transform duration-150", open && "rotate-180")}
/>
</div>
@@ -4,11 +4,11 @@ import {
formatTime,
isNextDayInTimezone,
isPreviousDayInTimezone,
sortByTimezone,
isSupportedTimeZone,
sortByTimezone,
} from "@calcom/lib/date-fns";
import { Globe } from "../icon";
import { Icon } from "../..";
type Attendee = {
id: number;
@@ -67,7 +67,7 @@ const MeetingTimeInTimezones = ({
<Popover.Trigger
onClick={preventBubbling}
className="popover-button text-emphasis hover:bg-emphasis focus:bg-emphasis invisible ml-2 inline-flex h-5 w-5 items-center justify-center rounded-sm transition-colors group-hover:visible">
<Globe className="h-3.5 w-3.5" />
<Icon name="globe" className="h-3.5 w-3.5" />
</Popover.Trigger>
<Popover.Portal>
<Popover.Content
+2 -2
View File
@@ -1,9 +1,9 @@
import * as SheetPrimitive from "@radix-ui/react-dialog";
import { cva, type VariantProps } from "class-variance-authority";
import { X } from "lucide-react";
import * as React from "react";
import classNames from "@calcom/lib/classNames";
import { Icon } from "@calcom/ui";
const Sheet = SheetPrimitive.Root;
@@ -157,7 +157,7 @@ const SheetContent = React.forwardRef<React.ElementRef<typeof SheetPrimitive.Con
</div>
)}
<SheetPrimitive.Close className="focus:ring-emphasis data-[state=open]:bg-deafult absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none">
<X className="h-4 w-4" />
<Icon name="x" className="h-4 w-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
@@ -1,22 +1,21 @@
import type { LucideIcon as IconType } from "lucide-react";
import type { FC } from "react";
import React from "react";
import type { IconName } from "../..";
import type { ButtonBaseProps } from "../button";
import { Button } from "../button";
import {
Dropdown,
DropdownItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownItem,
DropdownMenuPortal,
DropdownMenuTrigger,
} from "../form/dropdown";
import { ChevronDown, MoreHorizontal } from "../icon";
export type ActionType = {
id: string;
icon?: IconType;
icon?: IconName;
iconClassName?: string;
label: string;
disabled?: boolean;
@@ -47,7 +46,7 @@ export const DropdownActions = ({
<Dropdown>
{!actionTrigger ? (
<DropdownMenuTrigger asChild>
<Button type="button" color="secondary" variant="icon" StartIcon={MoreHorizontal} />
<Button type="button" color="secondary" variant="icon" StartIcon="ellipsis" />
</DropdownMenuTrigger>
) : (
<DropdownMenuTrigger asChild>{actionTrigger}</DropdownMenuTrigger>
@@ -87,7 +86,7 @@ export const TableActions: FC<Props> = ({ actions }) => {
href={action.href}
onClick={action.onClick || defaultAction}
StartIcon={action.icon}
{...(action?.actions ? { EndIcon: ChevronDown } : null)}
{...(action?.actions ? { EndIcon: "chevron-down" } : null)}
disabled={action.disabled}
data-bookingid={action.bookingId}
color={action.color || "secondary"}>
+5 -5
View File
@@ -2,7 +2,7 @@ import classNames from "classnames";
import type { ToastOptions, Toast } from "react-hot-toast";
import toast from "react-hot-toast";
import { Check, Info } from "../icon";
import { Icon } from "../..";
type IToast = {
message: string;
@@ -19,7 +19,7 @@ export const SuccessToast = ({ message, toastVisible, onClose, toastId }: IToast
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Check className="h-4 w-4" />
<Icon name="check" className="h-4 w-4" />
</span>
<p data-testid="toast-success" className="text-left">
{message}
@@ -35,7 +35,7 @@ export const ErrorToast = ({ message, toastVisible, onClose, toastId }: IToast)
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Info className="h-4 w-4" />
<Icon name="info" className="h-4 w-4" />
</span>
<p data-testid="toast-error" className="text-left">
{message}
@@ -51,7 +51,7 @@ export const WarningToast = ({ message, toastVisible, onClose, toastId }: IToast
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Info className="h-4 w-4" />
<Icon name="info" className="h-4 w-4" />
</span>
<p data-testid="toast-warning" className="text-left">
{message}
@@ -67,7 +67,7 @@ export const DefaultToast = ({ message, toastVisible, onClose, toastId }: IToast
)}
onClick={() => onClose(toastId)}>
<span className="mt-0.5">
<Check className="h-4 w-4" />
<Icon name="check" className="h-4 w-4" />
</span>
<p data-testid="toast-default" className="text-left">
{message}
@@ -1,12 +1,13 @@
import classNames from "classnames";
import type { ComponentType, ReactNode } from "react";
import type { LucideProps } from "lucide-react";
import type { ReactNode } from "react";
import { TOP_BANNER_HEIGHT } from "@calcom/lib/constants";
import type { LucideIcon, LucideProps } from "@calcom/ui/components/icon";
import { AlertTriangle, Info } from "@calcom/ui/components/icon";
import { Icon, type IconName } from "../..";
export type TopBannerProps = {
Icon?: ComponentType<LucideProps> & LucideIcon;
icon?: IconName;
text: string;
variant?: keyof typeof variantClassName;
actions?: ReactNode;
@@ -24,14 +25,14 @@ const defaultIconProps = {
} as LucideProps;
export function TopBanner(props: TopBannerProps) {
const { Icon, variant = "default", text, actions } = props;
const { icon, variant = "default", text, actions } = props;
const renderDefaultIconByVariant = () => {
switch (variant) {
case "error":
return <AlertTriangle {...defaultIconProps} data-testid="variant-error" />;
return <Icon {...defaultIconProps} name="triangle-alert" data-testid="variant-error" />;
case "warning":
return <Info {...defaultIconProps} data-testid="variant-warning" />;
return <Icon {...defaultIconProps} name="info" data-testid="variant-warning" />;
default:
return null;
}
@@ -48,7 +49,7 @@ export function TopBanner(props: TopBannerProps) {
)}>
<div className="flex flex-1 flex-col items-start justify-center gap-2 px-1 py-0.5 lg:flex-row lg:items-center">
<p className="text-emphasis flex flex-col items-start justify-center gap-2 text-left font-sans text-sm font-medium leading-4 lg:flex-row lg:items-center">
{Icon ? <Icon data-testid="variant-default" {...defaultIconProps} /> : defaultIcon}
{icon ? <Icon {...defaultIconProps} name={icon} data-testid="variant-default" /> : defaultIcon}
{text}
</p>
{actions && <div className="text-sm font-medium">{actions}</div>}
@@ -1,7 +1,5 @@
import { render, screen } from "@testing-library/react";
import { ArrowDown } from "@calcom/ui/components/icon";
import { TopBanner } from "./TopBanner";
describe("Tests for TopBanner component", () => {
@@ -22,24 +20,24 @@ describe("Tests for TopBanner component", () => {
expect(ctaElt).toBeInTheDocument();
});
test("Should render the default variant", () => {
render(<TopBanner text="the banner test" Icon={ArrowDown} />);
test("Should render the default variant", async () => {
render(<TopBanner text="the banner test" icon="arrow-down" />);
const variant = screen.getByTestId("variant-default");
const variant = await screen.findByTestId("variant-default");
expect(variant).toBeInTheDocument();
});
test("Should render the alert variant", () => {
test("Should render the alert variant", async () => {
render(<TopBanner text="the banner test" variant="error" />);
const variant = screen.getByTestId("variant-error");
const variant = await screen.findByTestId("variant-error");
expect(variant).toBeInTheDocument();
});
test("Should render the warning variant", () => {
test("Should render the warning variant", async () => {
render(<TopBanner text="the banner test" variant="warning" />);
const variant = screen.getByTestId("variant-warning");
const variant = await screen.findByTestId("variant-warning");
expect(variant).toBeInTheDocument();
});
});