main
js 53 lines 1.26 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 import * as React from 'react';
11
12 import Badge from './Badge';
13 import ForgetBadge from './ForgetBadge';
14
15 import styles from './ElementBadges.css';
16
17 type Props = {
18 hocDisplayNames: Array<string> | null,
19 environmentName: string | null,
20 compiledWithForget: boolean,
21 className?: string,
22 };
23
24 export default function ElementBadges({
25 compiledWithForget,
26 environmentName,
27 hocDisplayNames,
28 className = '',
29 }: Props): React.Node {
30 if (
31 !compiledWithForget &&
32 (hocDisplayNames == null || hocDisplayNames.length === 0) &&
33 environmentName == null
34 ) {
35 return null;
36 }
37
38 return (
39 <div className={`${styles.Root} ${className}`}>
40 {compiledWithForget && <ForgetBadge indexable={false} />}
41
42 {environmentName != null ? <Badge>{environmentName}</Badge> : null}
43
44 {hocDisplayNames != null && hocDisplayNames.length > 0 && (
45 <Badge>{hocDisplayNames[0]}</Badge>
46 )}
47
48 {hocDisplayNames != null && hocDisplayNames.length > 1 && (
49 <div className={styles.ExtraLabel}>+{hocDisplayNames.length - 1}</div>
50 )}
51 </div>
52 );
53 }