Skip to content

Commit

Permalink
chore: upgrade react-tooltip to v5 (#325)
Browse files Browse the repository at this point in the history
## Changes
- upgrade `react-tooltip` from 4.2.21 to 5.26.4
- update imports for `react-tooltip` to use named imports
- update usage of `data-tip` to `data-tooltip-content`
- update usage of `data-for` to `data-tooltip-id`
- remove `effect="solid"` prop which became default in v5

## Test plan
- go to https://evm-codes-git-chore-upgrade-react-tooltip-to-v5-smlxl.vercel.app/playground
- hover over icons to the right of the playground panel
- expect tooltips to work like before
  • Loading branch information
mcmxcdev authored Apr 29, 2024
1 parent 866727c commit 5eae7f6
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 35 deletions.
8 changes: 4 additions & 4 deletions components/Editor/ExecutionStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext } from 'react'

import { useRegisterActions } from 'kbar'
import ReactTooltip from 'react-tooltip'
import { Tooltip } from 'react-tooltip'

import { EthereumContext } from 'context/ethereumContext'

Expand Down Expand Up @@ -45,7 +45,7 @@ const ExecutionStatus = () => {
</span>
<span
className="inline-block mr-4 select-all cursor-help"
data-tip="Gas consumed for the current instruction"
data-tooltip-content="Gas consumed for the current instruction"
>
{executionState.currentGas || 0}
</span>
Expand All @@ -54,12 +54,12 @@ const ExecutionStatus = () => {
</span>
<span
className="inline-block mr-4 select-all cursor-help"
data-tip="Total gas consumed"
data-tooltip-content="Total gas consumed"
>
{executionState.totalGas || 0}
</span>

<ReactTooltip className="tooltip" effect="solid" />
<Tooltip className="tooltip" />
</div>

<div>
Expand Down
2 changes: 1 addition & 1 deletion components/Editor/SolidityAdvanceModeTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ const SolidityAdvanceModeTab: FC<Props> = ({
<Button onClick={handleCopyPermalink} transparent padded={false}>
<span
className="inline-block mr-4 select-all"
data-tip="Share permalink"
data-tooltip-content="Share permalink"
>
<Icon name="links-line" className="text-indigo-500 mr-1" />
</span>
Expand Down
2 changes: 1 addition & 1 deletion components/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ const Editor = ({ readOnly = false }: Props) => {
>
<span
className="inline-block mr-4 select-all"
data-tip="Share permalink"
data-tooltip-content="Share permalink"
>
<Icon
name="links-line"
Expand Down
9 changes: 4 additions & 5 deletions components/Reference/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import useWindowSize from 'lib/useWindowResize'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useTable, useExpanded, useFilters, HeaderGroup } from 'react-table'
import ReactTooltip from 'react-tooltip'
import { Tooltip } from 'react-tooltip'
import { IReferenceItem, IItemDocs, IGasDocs } from 'types'

import {
Expand Down Expand Up @@ -266,13 +266,12 @@ const ReferenceTable = ({
!!dynamicFeeForkName && (
<span
className="inline-block pl-2 text-gray-400 dark:text-black-400"
data-tip="Has additional dynamic gas cost, expand to estimate it"
data-for={`tip-${cell.row.id}`}
data-tooltip-content="Has additional dynamic gas cost, expand to estimate it"
data-tooltip-id={`tip-${cell.row.id}`}
>
<Icon name="question-line" />
<ReactTooltip
<Tooltip
className="tooltip"
effect="solid"
id={`tip-${cell.row.id}`}
/>
</span>
Expand Down
12 changes: 4 additions & 8 deletions components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'

import cn from 'classnames'
import ReactTooltip from 'react-tooltip'
import { Tooltip } from 'react-tooltip'

type Props = {
children: React.ReactNode | string
Expand Down Expand Up @@ -54,19 +54,15 @@ export const Button: React.FC<Props> = ({
},
className,
)}
data-tip={tooltip}
data-for={tooltipIdPrefixed}
data-tooltip-content={tooltip}
data-tooltip-id={tooltipIdPrefixed}
{...rest}
>
<div className={cn('flex items-center', contentClassName)}>
{children}
</div>
{tooltip && tooltipId && (
<ReactTooltip
className="tooltip"
id={tooltipIdPrefixed}
effect="solid"
/>
<Tooltip className="tooltip" id={tooltipIdPrefixed} />
)}
</button>
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"react-select": "^5.8.0",
"react-simple-code-editor": "^0.13.1",
"react-table": "^7.8.0",
"react-tooltip": "^4.2.21",
"react-tooltip": "^5.26.4",
"readable-stream": "^4.5.2",
"solc": "^0.8.23-fixed",
"tailwind-merge": "^2.2.0",
Expand Down
41 changes: 26 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5eae7f6

Please sign in to comment.