+27









sean-brydon
Udit Takkar
Hariom Balhara
Leo Giovanetti
Alex van Andel
CarinaWolli
zomars
Peer Richelsen
Joe Au-Yeung
Udit Takkar
Keith Williams
Peer Richelsen
Syed Ali Shahbaz
gitstart-calcom
Shivam Kalra
cherish2003
rkreddy99
varun thummar
Crowdin Bot
Pradumn Kumar
Richard Poelderl
mohammed hussam
Carina Wollendorfer
Anik Dhabal Babu
nicktrn
sydwardrae
Janakiram Yellapu
GitStart-Cal.com
sajanlamsal
Cherish
Danila
Neel Patel
Rama Krishna Reddy
Varun Thummar
Bhargav
Pratik Kumar
Ritesh Patil
10ffd9bacd
Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Leo Giovanetti <[email protected]> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Syed Ali Shahbaz <[email protected]> Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: Shivam Kalra <[email protected]> Co-authored-by: cherish2003 <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: rkreddy99 <[email protected]> Co-authored-by: varun thummar <Varun> Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: Pradumn Kumar <[email protected]> Co-authored-by: Richard Poelderl <[email protected]> Co-authored-by: mohammed hussam <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: nicktrn <[email protected]> Co-authored-by: sydwardrae <[email protected]> Co-authored-by: Janakiram Yellapu <[email protected]> Co-authored-by: GitStart-Cal.com <[email protected]> Co-authored-by: sajanlamsal <[email protected]> Co-authored-by: Cherish <[email protected]> Co-authored-by: Danila <[email protected]> Co-authored-by: Neel Patel <[email protected]> Co-authored-by: Rama Krishna Reddy <[email protected]> Co-authored-by: Varun Thummar <[email protected]> Co-authored-by: Bhargav <[email protected]> Co-authored-by: Pratik Kumar <[email protected]> Co-authored-by: Ritesh Patil <[email protected]>
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import { classNames } from "@calcom/lib";
|
|
import { useCopy } from "@calcom/lib/hooks/useCopy";
|
|
import type { BadgeProps } from "@calcom/ui";
|
|
import { Badge, Button, Label } from "@calcom/ui";
|
|
import { ClipboardCheck, Clipboard } from "@calcom/ui/components/icon";
|
|
|
|
type DisplayInfoType<T extends boolean> = {
|
|
label: string;
|
|
value: T extends true ? string[] : string;
|
|
asBadge?: boolean;
|
|
isArray?: T;
|
|
displayCopy?: boolean;
|
|
badgeColor?: BadgeProps["variant"];
|
|
} & (T extends false
|
|
? { displayCopy?: boolean; displayCount?: never }
|
|
: { displayCopy?: never; displayCount?: number }); // Only show displayCopy if its not an array is false
|
|
|
|
export function DisplayInfo<T extends boolean>({
|
|
label,
|
|
value,
|
|
asBadge,
|
|
isArray,
|
|
displayCopy,
|
|
displayCount,
|
|
badgeColor,
|
|
}: DisplayInfoType<T>) {
|
|
const { copyToClipboard, isCopied } = useCopy();
|
|
const values = (isArray ? value : [value]) as string[];
|
|
|
|
return (
|
|
<div className="flex flex-col">
|
|
<Label className="text-subtle mb-1 text-xs font-semibold uppercase leading-none">
|
|
{label} {displayCount && `(${displayCount})`}
|
|
</Label>
|
|
<div className={classNames(asBadge ? "mt-0.5 flex space-x-2" : "flex flex-col")}>
|
|
<>
|
|
{values.map((v) => {
|
|
const content = (
|
|
<span
|
|
className={classNames(
|
|
"text-emphasis inline-flex items-center gap-1 font-normal leading-5",
|
|
asBadge ? "text-xs" : "text-sm"
|
|
)}>
|
|
{v}
|
|
{displayCopy && (
|
|
<Button
|
|
size="sm"
|
|
variant="icon"
|
|
onClick={() => copyToClipboard(v)}
|
|
color="minimal"
|
|
className="text-subtle rounded-md"
|
|
StartIcon={isCopied ? ClipboardCheck : Clipboard}
|
|
/>
|
|
)}
|
|
</span>
|
|
);
|
|
|
|
return asBadge ? (
|
|
<Badge variant={badgeColor} size="sm">
|
|
{content}
|
|
</Badge>
|
|
) : (
|
|
content
|
|
);
|
|
})}
|
|
</>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|