* Icon and IconName * Button and ButtonGroup * UserAvatar * AvatarGroup * Avatar * WizardLayout * Dialogs * EmptyScreen * showToast and TextField * Editor * Skeleton * Skeleton * TopBanner and showToast * Button again * more * perf: Remove app-store reference from @calcom/ui * more * Fixing types * Icon * Fixed casing * dropdown * more * Select * more * Badge * List * more * Divider * more * fix * fix type check * refactor * fix * fix * fix * fix * fix * fix * fix * fix type check * fix * fix * fix * fix * more * more * more * more * add index file to components/command * fix * fix * fix * fix imports * fix * fix * fix * fix * fix * fix * fix * fix build errors * fix build errors * fix --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com>
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import type { IconName } from "@calcom/ui/components/icon";
|
|
import { Badge } from "@calcom/ui/components/badge";
|
|
import { Icon } from "@calcom/ui/components/icon";
|
|
|
|
type DisplayInfoType = {
|
|
label: string;
|
|
icon?: IconName;
|
|
value: string | string[];
|
|
coloredBadges?: boolean;
|
|
labelClassname?: string;
|
|
valueClassname?: string;
|
|
};
|
|
|
|
const badgeColors = ["warning", "success", "green", "gray", "blue", "red", "error"] as const;
|
|
|
|
const valueDefaultClassname = "text-emphasis inline-flex items-center gap-1 font-medium leading-5";
|
|
|
|
export function DisplayInfo({
|
|
label,
|
|
icon,
|
|
value,
|
|
coloredBadges,
|
|
labelClassname,
|
|
valueClassname = valueDefaultClassname,
|
|
}: DisplayInfoType) {
|
|
const displayAsBadges = Array.isArray(value);
|
|
|
|
return (
|
|
<div className="flex items-center gap-6">
|
|
<div className="flex w-[110px] items-center gap-2">
|
|
{icon ? <Icon className="text-subtle h-4 w-4" name={icon} /> : null}
|
|
<label className={labelClassname ? labelClassname : "text-subtle text-sm font-medium"}>{label}</label>
|
|
</div>
|
|
<div className="flex flex-1">
|
|
{displayAsBadges ? (
|
|
<div className="flex flex-wrap gap-2">
|
|
{value.map((v, idx) => {
|
|
return coloredBadges ? (
|
|
<Badge variant={badgeColors[idx % badgeColors.length]} key={v}>
|
|
{v}
|
|
</Badge>
|
|
) : (
|
|
<Badge variant="gray">{v}</Badge>
|
|
);
|
|
})}
|
|
</div>
|
|
) : (
|
|
<span className={valueClassname}>{value}</span>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|