+28









sean-brydon
GitHub
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 <Varun>
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 <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Leo Giovanetti <hello@leog.me> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Shivam Kalra <shivamkalra98@gmail.com> Co-authored-by: cherish2003 <saicherissh90@gmail.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: rkreddy99 <rreddy@e2clouds.com> Co-authored-by: varun thummar <Varun> Co-authored-by: Crowdin Bot <support+bot@crowdin.com> Co-authored-by: Pradumn Kumar <47187878+Pradumn27@users.noreply.github.com> Co-authored-by: Richard Poelderl <richard.poelderl@gmail.com> Co-authored-by: mohammed hussam <hussamkhatib20@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: nicktrn <55853254+nicktrn@users.noreply.github.com> Co-authored-by: sydwardrae <94979838+sydwardrae@users.noreply.github.com> Co-authored-by: Janakiram Yellapu <jyellapu@vmware.com> Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com> Co-authored-by: sajanlamsal <saznlamsal@gmail.com> Co-authored-by: Cherish <88829894+cherish2003@users.noreply.github.com> Co-authored-by: Danila <daniil.demidovich@gmail.com> Co-authored-by: Neel Patel <29038590+N-NeelPatel@users.noreply.github.com> Co-authored-by: Rama Krishna Reddy <49095575+rkreddy99@users.noreply.github.com> Co-authored-by: Varun Thummar <110765105+VARUN949@users.noreply.github.com> Co-authored-by: Bhargav <bhargavtenali@gmail.com> Co-authored-by: Pratik Kumar <kpratik1929@gmail.com> Co-authored-by: Ritesh Patil <riteshsp2000@gmail.com>
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>
|
|
);
|
|
}
|