Chor/v2 more tidyup - Card - link icon button - tooltip (#6312)

* Card

* Step card

* Already in components

* Link Icon Button

* Tooltip

* Fix types

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2023-01-09 19:22:04 -07:00
1 parent 75aef09338
commit 62713940b0
13 files changed
+90 -123

No files matched your search

+1
View File
@@ -1,2 +1,3 @@
export { Button } from "./Button";
export type { ButtonBaseProps, ButtonProps } from "./Button";
export { default as LinkIconButton } from "./LinkIconButton";
@@ -4,7 +4,7 @@ import React from "react";
import classNames from "@calcom/lib/classNames";
import { Button } from "../../components/button";
import { Button } from "../button";
export type BaseCardProps = {
image?: string;
File renamed without changes.
@@ -0,0 +1,40 @@
import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
import { Examples, Example, Note, Title,CustomArgsTable,VariantsTable,VariantRow } from '@calcom/storybook/components'
import Card from './Card';
<Meta title="UI/Card" component={Card} />
<Title title="Card" suffix="Brief" subtitle="Version 2.0 — Last Update: 06 Jan 2023"/>
## Definition
All Cards used in Cal.com
<CustomArgsTable of={Card} />
export const tip = {
id: 1,
thumbnailUrl: "https://img.youtube.com/vi/60HJt8DOVNo/0.jpg",
mediaLink: "https://go.cal.com/dynamic-video",
title: "Dynamic booking links",
description: "Booking link that allows people to quickly schedule meetings.",
href: "https://cal.com/blog/cal-v-1-9",
}
<Canvas>
<Story name="Card">
<VariantsTable titles={['']} columnMinWidth={150}>
<VariantRow variant="Sidebar Card">
<Card
variant="SidebarCard"
thumbnailUrl={tip.thumbnailUrl}
mediaLink={tip.mediaLink}
title={tip.title}
description={tip.description}
learnMore={{ href: tip.href, text: "learn more" }}
actionButton={{ onClick: () => console.log("Clicked") }}
/>
</VariantRow>
</VariantsTable>
</Story>
</Canvas>
+3
View File
@@ -0,0 +1,3 @@
export { default as Card } from "./Card";
export type { BaseCardProps } from "./Card";
export { StepCard } from "./StepCard";
+4 -1
View File
@@ -3,7 +3,7 @@ export type { AvatarProps } from "./avatar";
export { Badge } from "./badge";
export type { BadgeProps } from "./badge";
export { Breadcrumb, BreadcrumbContainer, BreadcrumbItem } from "./breadcrumb";
export { Button } from "./button";
export { Button, LinkIconButton } from "./button";
export type { ButtonBaseProps, ButtonProps } from "./button";
export { ButtonGroup } from "./buttonGroup";
export {
@@ -56,6 +56,9 @@ export { List, ListItem, ListItemText, ListItemTitle, ListLinkItem } from "./lis
export type { ListItemProps, ListProps } from "./list";
export { HeadSeo } from "./head-seo";
export { Skeleton, SkeletonAvatar, SkeletonButton, SkeletonContainer, SkeletonText } from "./skeleton";
export { Card, StepCard } from "./card";
export type { BaseCardProps } from "./card";
export { Tooltip } from "./tooltip";
export { Editor, AddVariablesDropdown } from "./editor";
export {
Dialog,
@@ -31,7 +31,6 @@ export function Tooltip({
className={classNames(
side === "top" && "-mt-7",
side === "right" && "ml-2",
"relative z-40 rounded-md bg-gray-900 px-2 py-1 text-xs font-semibold text-white shadow-lg dark:bg-white dark:text-gray-600"
)}
side={side}
+1
View File
@@ -0,0 +1 @@
export { default as Tooltip } from "./Tooltip";
@@ -0,0 +1,35 @@
import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
import { Examples, Example, Note, Title,CustomArgsTable,VariantsTable,VariantRow } from '@calcom/storybook/components'
import { TooltipProvider } from "@radix-ui/react-tooltip";
import Tooltip from './Tooltip';
<Meta title="UI/Tooltip" component={Tooltip} />
<Title title="Tooltip" suffix="Brief" subtitle="Version 2.0 — Last Update: 06 Jan 2023"/>
## Definition
Tooltip components can be used to provide additional information about an element when the user hovers over or focuses on the element.
<CustomArgsTable of={Tooltip} />
<Canvas>
<Story name="Tooltip">
<TooltipProvider>
<VariantsTable titles={['']} columnMinWidth={150}>
<VariantRow variant="Default">
<Tooltip content="Copy to clipboard">
<span
className="dark:text-darkgray-50 p-2 bg-brand-500 rounded-md text-gray-100 dark:bg-darkgray-900 hover:cursor-pointer"
onClick={() => {
alert('Copied!');
}}>
Hover Me
</span>
</Tooltip>
</VariantRow>
</VariantsTable>
</TooltipProvider>
</Story>
</Canvas>
+5 -4
View File
@@ -51,12 +51,16 @@ export {
Alert,
TrendingAppsSlider,
AppCard,
Card,
AllApps,
AppSkeletonLoader,
SkeletonLoader,
AppStoreCategories,
Slider,
Tooltip,
useShouldShowArrows,
StepCard,
LinkIconButton,
Editor,
AddVariablesDropdown,
Dialog,
@@ -74,6 +78,7 @@ export type {
AvatarProps,
BadgeProps,
ButtonBaseProps,
BaseCardProps,
ButtonProps,
DialogProps,
ConfirmationDialogContentProps,
@@ -95,7 +100,6 @@ export {
SettingsToggle,
Swatch,
Switch,
Card,
VerticalTabs,
HorizontalTabItem,
VerticalTabItem,
@@ -130,11 +134,8 @@ export { default as MultiSelectCheckboxes } from "./v2/core/form/MultiSelectChec
export type { Option as MultiSelectCheckboxesOptionType } from "./v2/core/form/MultiSelectCheckboxes";
export { ToggleGroup } from "./v2/core/form/ToggleGroup";
export { default as ImageUploader } from "./v2/core/ImageUploader";
export { default as LinkIconButton } from "./v2/core/LinkIconButton";
export { default as MeetingTimeInTimezones } from "./v2/core/MeetingTimeInTimezones";
export { default as Meta, MetaProvider, useMeta } from "./v2/core/Meta";
export { StepCard } from "./v2/core/StepCard";
export { default as Stepper } from "./v2/core/Stepper";
export { Steps } from "./v2/core/Steps";
export { Tooltip } from "./v2/core/Tooltip";
export { default as WizardForm } from "./v2/core/WizardForm";
-112
View File
@@ -1,112 +0,0 @@
import React, { FC } from "react";
import { SVGComponent } from "@calcom/types/SVGComponent";
import {
Button,
Dropdown,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuPortal,
DropdownMenuTrigger,
Icon,
} from "../..";
export type ActionType = {
id: string;
icon?: SVGComponent;
iconClassName?: string;
label: string;
disabled?: boolean;
color?: "primary" | "secondary";
} & (
| { href: string; onClick?: never; actions?: never }
| { href?: never; onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void; actions?: never }
| { actions?: ActionType[]; href?: never; onClick?: never }
);
interface Props {
actions: ActionType[];
}
const defaultAction = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
e.stopPropagation();
};
const DropdownActions = ({
actions,
actionTrigger,
}: {
actions: ActionType[];
actionTrigger?: React.ReactNode;
}) => {
return (
<Dropdown>
{!actionTrigger ? (
<DropdownMenuTrigger asChild>
<Button type="button" color="minimal" size="icon" StartIcon={Icon.FiMoreHorizontal} />
</DropdownMenuTrigger>
) : (
<DropdownMenuTrigger asChild className="">
{actionTrigger}
</DropdownMenuTrigger>
)}
<DropdownMenuPortal>
<DropdownMenuContent>
{actions.map((action) => (
<DropdownMenuItem key={action.id} className="focus-visible:outline-none">
<Button
type="button"
color="minimal"
href={action.href}
StartIcon={action.icon}
onClick={action.onClick || defaultAction}
data-testid={action.id}>
{action.label}
</Button>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenuPortal>
</Dropdown>
);
};
const TableActions: FC<Props> = ({ actions }) => {
const mobileActions = actions.flatMap((action) => {
if (action.actions) {
return action.actions;
}
return action;
});
return (
<>
<div className="hidden flex-row items-center space-x-2 rtl:space-x-reverse md:flex md:flex-row md:items-center">
{actions.map((action) => {
const button = (
<Button
key={action.id}
data-testid={action.id}
href={action.href}
onClick={action.onClick || defaultAction}
StartIcon={action.icon}
{...(action?.actions ? { EndIcon: Icon.FiChevronDown } : null)}
disabled={action.disabled}
color={action.color || "secondary"}>
{action.label}
</Button>
);
if (!action.actions) {
return button;
}
return <DropdownActions key={action.id} actions={action.actions} actionTrigger={button} />;
})}
</div>
<div className="inline-block text-left md:hidden">
<DropdownActions actions={mobileActions} />
</div>
</>
);
};
export default TableActions;
-4
View File
@@ -1,5 +1,3 @@
export { Card } from "./Card";
export type { BaseCardProps } from "./Card";
export { default as ColorPicker } from "./colorpicker";
export {
ButtonOrLink,
@@ -18,7 +16,6 @@ export {
DropdownMenuTriggerItem,
} from "./Dropdown";
export { Checkbox, DatePicker, FormStep } from "./form";
export { default as LinkIconButton } from "./LinkIconButton";
export { default as Loader } from "./Loader";
export { default as MeetingTimeInTimezones } from "./MeetingTimeInTimezones";
export type { HorizontalTabItemProps } from "./navigation/tabs/HorizontalTabItem";
@@ -30,5 +27,4 @@ export { default as Shell } from "./Shell";
export { default as Stepper } from "./Stepper";
export { default as Swatch } from "./Swatch";
export { default as Switch } from "./Switch";
export { default as Tooltip } from "./Tooltip";
export { default as WizardForm } from "./WizardForm";