From 83b60de6400713705fdb50c7abbe98382d25c9e8 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Thu, 22 Dec 2022 11:41:43 +0000 Subject: [PATCH] Chor/move table actions (#6157) * Move table actions * Move table actions Co-authored-by: Peer Richelsen --- .../web/components/booking/BookingListItem.tsx | 2 +- packages/ui/components/index.ts | 2 ++ .../ui/components/table}/TableActions.tsx | 18 ++++++++---------- packages/ui/index.tsx | 3 +++ 4 files changed, 14 insertions(+), 11 deletions(-) rename {apps/web/components/ui => packages/ui/components/table}/TableActions.tsx (87%) diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 4c165a7663..0dc3a59d05 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -23,12 +23,12 @@ import { TextArea, Tooltip, } from "@calcom/ui"; +import { ActionType, TableActions } from "@calcom/ui"; import useMeQuery from "@lib/hooks/useMeQuery"; import { EditLocationDialog } from "@components/dialog/EditLocationDialog"; import { RescheduleDialog } from "@components/dialog/RescheduleDialog"; -import TableActions, { ActionType } from "@components/ui/TableActions"; type BookingListingStatus = RouterInputs["viewer"]["bookings"]["get"]["status"]; diff --git a/packages/ui/components/index.ts b/packages/ui/components/index.ts index d79b8dbbc0..bb1c224de7 100644 --- a/packages/ui/components/index.ts +++ b/packages/ui/components/index.ts @@ -29,3 +29,5 @@ export { } from "./form"; export { TopBanner } from "./top-banner"; export type { TopBannerProps } from "./top-banner"; +export { TableActions, DropdownActions } from "./table/TableActions"; +export type { ActionType } from "./table/TableActions"; diff --git a/apps/web/components/ui/TableActions.tsx b/packages/ui/components/table/TableActions.tsx similarity index 87% rename from apps/web/components/ui/TableActions.tsx rename to packages/ui/components/table/TableActions.tsx index 08352a8254..ff8f480444 100644 --- a/apps/web/components/ui/TableActions.tsx +++ b/packages/ui/components/table/TableActions.tsx @@ -1,4 +1,5 @@ import React, { FC } from "react"; +import { IconType } from "react-icons/lib"; import { Button, @@ -7,18 +8,17 @@ import { DropdownMenuItem, DropdownMenuPortal, DropdownMenuTrigger, + ButtonBaseProps, Icon, } from "@calcom/ui"; -import { SVGComponent } from "@lib/types/SVGComponent"; - export type ActionType = { id: string; - icon?: SVGComponent; + icon?: IconType; iconClassName?: string; label: string; disabled?: boolean; - color?: "primary" | "secondary"; + color?: ButtonBaseProps["color"]; } & ( | { href: string; onClick?: never; actions?: never } | { href?: never; onClick: (e: React.MouseEvent) => void; actions?: never } @@ -33,7 +33,7 @@ const defaultAction = (e: React.MouseEvent) => { e.stopPropagation(); }; -const DropdownActions = ({ +export const DropdownActions = ({ actions, actionTrigger, }: { @@ -52,10 +52,10 @@ const DropdownActions = ({ {actions.map((action) => ( - +