|
| 1 | +/** |
| 2 | + * @fileoverview CCIP Chain-Specific Tooltip Configuration |
| 3 | + * |
| 4 | + * Centralized configuration for chain-specific tooltips displayed in the CCIP directory. |
| 5 | + * This approach provides: |
| 6 | + * - Type safety with TypeScript |
| 7 | + * - Stable chain ID references (not display names) |
| 8 | + * - Easy content updates without code changes |
| 9 | + * - Scalable for adding new chains |
| 10 | + * - Separation of content from component logic |
| 11 | + * |
| 12 | + * @example |
| 13 | + * ```typescript |
| 14 | + * const tooltipConfig = getChainTooltip(network.chain); |
| 15 | + * if (tooltipConfig) { |
| 16 | + * return <Tooltip tip={tooltipConfig.content} hoverable={tooltipConfig.hoverable} /> |
| 17 | + * } |
| 18 | + * ``` |
| 19 | + */ |
| 20 | + |
| 21 | +import { type ReactNode } from "react" |
| 22 | + |
| 23 | +/** |
| 24 | + * Configuration for a chain-specific tooltip |
| 25 | + */ |
| 26 | +export interface ChainTooltipConfig { |
| 27 | + /** The tooltip content (supports JSX for interactive elements) */ |
| 28 | + content: ReactNode |
| 29 | + /** Whether the tooltip should be hoverable (for interactive content) */ |
| 30 | + hoverable: boolean |
| 31 | + /** Optional custom hide delay for hoverable tooltips */ |
| 32 | + hideDelay?: number |
| 33 | +} |
| 34 | + |
| 35 | +/** |
| 36 | + * Chain-specific tooltip configurations mapped by stable chain IDs. |
| 37 | + * |
| 38 | + * **Adding a new chain tooltip:** |
| 39 | + * 1. Add the chain ID as a key (use network.chain, not network.name) |
| 40 | + * 2. Provide content and interaction settings |
| 41 | + * 3. Use hoverable=true for content with links |
| 42 | + * |
| 43 | + * **Content Guidelines:** |
| 44 | + * - Keep tooltips concise and actionable |
| 45 | + * - Use JSX for links and formatting |
| 46 | + * - Test on mobile for long content |
| 47 | + */ |
| 48 | +export const CHAIN_TOOLTIPS: Record<string, ChainTooltipConfig> = { |
| 49 | + "hyperliquid-mainnet": { |
| 50 | + content: ( |
| 51 | + <> |
| 52 | + Before using or integrating HyperEVM on CCIP, it is recommended to review{" "} |
| 53 | + <a href="/ccip/service-limits/network-specific-limits">Network-Specific Service Limits</a>. |
| 54 | + </> |
| 55 | + ), |
| 56 | + hoverable: true, |
| 57 | + hideDelay: 300, |
| 58 | + }, |
| 59 | + |
| 60 | + // Example: Add more chains as needed |
| 61 | + // "abstract-mainnet": { |
| 62 | + // content: ( |
| 63 | + // <> |
| 64 | + // Abstract requires special configuration. See{" "} |
| 65 | + // <a href="/ccip/abstract-setup">setup guide</a> for details. |
| 66 | + // </> |
| 67 | + // ), |
| 68 | + // hoverable: true, |
| 69 | + // }, |
| 70 | + |
| 71 | + // "polygon-mainnet": { |
| 72 | + // content: "Polygon CCIP integration is fully supported with standard configuration.", |
| 73 | + // hoverable: false, |
| 74 | + // }, |
| 75 | +} as const |
| 76 | + |
| 77 | +/** |
| 78 | + * Gets the tooltip configuration for a specific chain. |
| 79 | + * |
| 80 | + * @param chainId - The stable chain identifier (e.g., 'hyperliquid-mainnet') |
| 81 | + * @returns Tooltip configuration if exists, null otherwise |
| 82 | + * |
| 83 | + * @example |
| 84 | + * ```typescript |
| 85 | + * const tooltipConfig = getChainTooltip(network.chain); |
| 86 | + * if (tooltipConfig) { |
| 87 | + * return <Tooltip tip={tooltipConfig.content} hoverable={tooltipConfig.hoverable} /> |
| 88 | + * } |
| 89 | + * ``` |
| 90 | + */ |
| 91 | +export function getChainTooltip(chainId: string): ChainTooltipConfig | null { |
| 92 | + return CHAIN_TOOLTIPS[chainId] || null |
| 93 | +} |
| 94 | + |
| 95 | +/** |
| 96 | + * Gets all chain IDs that have tooltip configurations. |
| 97 | + * Useful for debugging or administrative purposes. |
| 98 | + * |
| 99 | + * @returns Array of chain IDs with configured tooltips |
| 100 | + */ |
| 101 | +export function getTooltipEnabledChains(): string[] { |
| 102 | + return Object.keys(CHAIN_TOOLTIPS) |
| 103 | +} |
| 104 | + |
| 105 | +/** |
| 106 | + * Type guard to check if a chain has a tooltip configuration. |
| 107 | + * |
| 108 | + * @param chainId - The chain identifier to check |
| 109 | + * @returns True if the chain has a tooltip configuration |
| 110 | + */ |
| 111 | +export function hasChainTooltip(chainId: string): boolean { |
| 112 | + return chainId in CHAIN_TOOLTIPS |
| 113 | +} |
0 commit comments