Files
pezkuwi-apps/packages/react-components/src/Icon.tsx
T
Satoshi Qazi Muhammed 09fbca8121 react-tooltip 4 -> 6
react-tooltip 4 brought uuid 7 (open advisory, fixed only in 11) and
had not been maintained since 2022. Tooltip now wraps the v6 component
(no more cast); triggers use data-tooltip-id instead of data-for and
data-tip (Icon, Badge, Tag, claims payload). v6 renders the content in
.react-tooltip-content-wrapper and draws the arrow as its own element
that inherits the background, so the wrapper's child selectors point
there and the ::after arrow colours for accounts-badge are gone.

The accounts-badge block in the global styles was never closed (as
upstream); it is closed now with the same nesting, so its link colours
still apply only inside badge tooltips.

Checked in a headless browser on Zagros, the "available on all
networks" account badge: with v4 the tooltip was one 1525px line
starting off-screen at x=-260; with v6 it is 300px wide (the max-width
already in the styles), wrapped, on screen, arrow on the badge, and in
the light accounts-badge style the styles define.
2026-10-10 06:02:46 +04:00

90 lines
1.8 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { IconName } from '@fortawesome/fontawesome-svg-core';
import { library } from '@fortawesome/fontawesome-svg-core';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react';
import { styled } from './styled.js';
interface Props {
className?: string;
color?: 'gray' | 'green' | 'normal' | 'orange' | 'red' | 'transparent' | 'white' | 'darkGray';
icon: IconName;
isPadded?: boolean;
isSpinning?: boolean;
onClick?: (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => void;
size?: '1x' | '2x';
tooltip?: string;
}
// one-time init of FA libraries
library.add(fas);
function Icon ({ className = '', color = 'normal', icon, isPadded, isSpinning, onClick, size = '1x', tooltip }: Props): React.ReactElement<Props> {
const extraProps: Record<string, unknown> = {
'data-testid': icon,
...(tooltip
? { 'data-tooltip-id': tooltip }
: {}
)
};
return (
<StyledFAI
{...extraProps}
className={`${className} ui--Icon ${color}Color${onClick ? ' isClickable' : ''}${isPadded ? ' isPadded' : ''}`}
icon={icon}
onClick={onClick}
size={size}
spin={isSpinning}
tabIndex={-1}
/>
);
}
const StyledFAI = styled(FontAwesomeIcon)`
outline: none;
&.isClickable {
cursor: pointer;
}
&.isPadded {
margin: 0 0.25rem;
}
&.grayColor {
opacity: 0.25;
}
&.greenColor {
color: green;
}
&.orangeColor {
color: darkorange;
}
&.redColor {
color: darkred;
}
&.transparentColor {
color: transparent;
}
&.whiteColor {
color: white;
}
&.darkGrayColor {
color: #8B8B8B;
}
`;
export default React.memo(Icon);