Skip to content

Commit

Permalink
highlight matched hoc name
Browse files Browse the repository at this point in the history
  • Loading branch information
bl00mber committed May 1, 2020
1 parent 3b654cd commit 2f70df9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,20 @@ type Props = {|
className?: string,
hocDisplayNames: Array<string> | null,
type: ElementType,
children: React$Node,
|};

export default function Badge({className, hocDisplayNames, type}: Props) {
let hocDisplayName = null;
export default function Badge({className, hocDisplayNames, type, children}: Props) {
let totalBadgeCount = 0;
let typeLabel = null;

if (hocDisplayNames !== null) {
hocDisplayName = hocDisplayNames[0];
totalBadgeCount += hocDisplayNames.length;
}

if (hocDisplayNames === null && typeLabel === null) {
return null;
}

return (
<Fragment>
<div className={`${styles.Badge} ${className || ''}`}>
{hocDisplayName || typeLabel}
{children}
</div>
{totalBadgeCount > 1 && (
<div className={styles.ExtraLabel}>+{totalBadgeCount - 1}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ export default function ElementView({data, index, style}: Props) {
"
</Fragment>
)}
<Badge
className={styles.Badge}
hocDisplayNames={hocDisplayNames}
type={type}
/>
{hocDisplayNames !== null ? (
<Badge
className={styles.Badge}
hocDisplayNames={hocDisplayNames}
type={type}
>
<DisplayName displayName={hocDisplayNames[0]} id={((id: any): number)} />
</Badge>
) : null}
</div>
</div>
);
Expand Down

0 comments on commit 2f70df9

Please sign in to comment.