Files
pwap/pezkuwi-sdk-ui/packages/react-components/src/Tooltip.tsx
T
pezkuwichain 971df8edba Rebrand: Remove 3rd party chains, update domains to PezkuwiChain
- Remove all 3rd party parachain configurations from endpoints:
  - productionRelayPolkadot.ts: Keep only system parachains
  - productionRelayDicle.ts: Keep only system parachains
  - testingRelayZagros.ts: Keep only system parachains
  - testingRelayTeyrChain.ts: Keep only system parachains

- Update domain references:
  - polkadot.js.org → pezkuwichain.app
  - wiki.polkadot.network → wiki.pezkuwichain.io
  - dotapps.io → pezkuwichain.app
  - statement.polkadot.network → docs.pezkuwichain.io/statement
  - support.polkadot.network → docs.pezkuwichain.io

- Update repository references:
  - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap

- Rename system parachains to Pezkuwi ecosystem:
  - PolkadotAssetHub → PezkuwiAssetHub
  - polkadotBridgeHub → pezkuwiBridgeHub
  - polkadotCollectives → pezkuwiCollectives
  - polkadotCoretime → pezkuwiCoretime
  - polkadotPeople → pezkuwiPeople

- Update network name in claims utility:
  - Polkadot → Pezkuwi
2026-01-09 03:08:11 +03:00

128 lines
2.8 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React, { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import ReactTooltip from 'react-tooltip';
import { styled } from './styled.js';
function rootElement () {
return typeof document === 'undefined'
? null // This hack is required for server side rendering
: document.getElementById('tooltips');
}
interface Props {
children?: React.ReactNode;
className?: string;
isClickable?: boolean;
place?: 'bottom' | 'top' | 'right' | 'left';
text?: React.ReactNode;
trigger: string;
}
function Tooltip ({ children, className = '', isClickable = false, place, text, trigger }: Props): React.ReactElement<Props> | null {
const [tooltipContainer] = useState(
typeof document === 'undefined'
? {} as HTMLElement // This hack is required for server side rendering
: document.createElement('div')
);
useEffect((): () => void => {
const root = rootElement();
root?.appendChild(tooltipContainer);
return (): void => {
root?.removeChild(tooltipContainer);
};
}, [tooltipContainer]);
return createPortal(
<StyledReactTooltip
className={`${className} ui--Tooltip`}
clickable={isClickable}
effect='solid'
id={trigger}
place={place}
>
<div className='tooltipSpacer'>
{text}{children}
</div>
</StyledReactTooltip>,
tooltipContainer
);
}
// FIXME This cast should really not be needed since the export is React.Component<TooltipProps>,
// however while it works as specified, it fails here on the definition. Until we have the component
// upgraded to latest, we probably don't want to start digging...
const StyledReactTooltip = styled(ReactTooltip as unknown as React.ComponentType<any>)`
.tooltipSpacer {
padding-bottom: 0.1rem;
}
> div {
overflow: hidden;
}
&.ui--Tooltip {
z-index: 1002;
word-break: break-word; /* Fallback for older browsers */
overflow-wrap: break-word; /* Modern standard */
hyphens: auto; /* Enables automatic hyphenation */
}
table {
border: 0;
overflow: hidden;
width: 100%;
td {
text-align: left;
}
td:first-child {
opacity: 0.75;
padding-right: 0.25rem;
text-align: right;
white-space: nowrap;
}
}
div+table,
table+div {
margin-top: 0.75rem;
}
> div+div {
margin-top: 0.5rem;
}
&.address div {
overflow: hidden;
text-overflow: ellipsis;
}
.faded {
margin-top: 0;
opacity: 0.75 !important;
font-size: var(--font-size-tiny) !important;
.faded {
font-size: 1em !important;
}
}
.faded+.faded {
margin-top: 0;
}
.row+.row {
margin-top: 0.5rem;
}
`;
export default React.memo(Tooltip);