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. import {Fragment} from 'react';
    
  12. import styles from './Badge.css';
    
  13. 
    
  14. import type {ElementType} from 'react-devtools-shared/src/frontend/types';
    
  15. 
    
  16. type Props = {
    
  17.   className?: string,
    
  18.   hocDisplayNames: Array<string> | null,
    
  19.   type: ElementType,
    
  20.   children: React$Node,
    
  21. };
    
  22. 
    
  23. export default function Badge({
    
  24.   className,
    
  25.   hocDisplayNames,
    
  26.   type,
    
  27.   children,
    
  28. }: Props): React.Node {
    
  29.   if (hocDisplayNames === null || hocDisplayNames.length === 0) {
    
  30.     return null;
    
  31.   }
    
  32. 
    
  33.   const totalBadgeCount = hocDisplayNames.length;
    
  34. 
    
  35.   return (
    
  36.     <Fragment>
    
  37.       <div className={`${styles.Badge} ${className || ''}`}>{children}</div>
    
  38.       {totalBadgeCount > 1 && (
    
  39.         <div className={styles.ExtraLabel}>+{totalBadgeCount - 1}</div>
    
  40.       )}
    
  41.     </Fragment>
    
  42.   );
    
  43. }