Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/prebuilds/configuration-input/ComboboxSelectedItem.tsx
2501 views
1
/**
2
* Copyright (c) 2024 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { FC, ReactNode } from "react";
8
import { cn } from "@podkit/lib/cn";
9
10
type Props = {
11
// Either a string of the icon source or an element
12
icon?: ReactNode;
13
loading?: boolean;
14
title: ReactNode;
15
subtitle?: ReactNode;
16
htmlTitle?: string;
17
titleClassName?: string;
18
};
19
export const ComboboxSelectedItem: FC<Props> = ({
20
icon,
21
loading = false,
22
title,
23
subtitle,
24
htmlTitle,
25
titleClassName,
26
}) => {
27
return (
28
<div
29
className={cn("flex items-center truncate", loading && "animate-pulse")}
30
title={htmlTitle}
31
aria-live="polite"
32
aria-busy={loading}
33
>
34
<div className="flex-col ml-1 flex-grow truncate">
35
{loading ? (
36
<div className="flex-col space-y-2">
37
<div className="bg-pk-content-tertiary/25 h-4 w-24 rounded" />
38
<div className="bg-pk-content-tertiary/25 h-2 w-40 rounded" />
39
</div>
40
) : (
41
<>
42
<div className={cn("text-pk-content-secondary font-semibold", titleClassName)}>{title}</div>
43
<div className="text-xs text-pk-content-tertiary truncate">{subtitle}</div>
44
</>
45
)}
46
</div>
47
</div>
48
);
49
};
50
51