diff --git a/package-lock.json b/package-lock.json index 36c25e3ab..19ad8a38b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tabs": "^1.0.4", + "@radix-ui/react-tooltip": "^1.0.7", "@tauri-apps/api": "^1.5.3", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", @@ -1410,6 +1411,40 @@ } } }, + "node_modules/@radix-ui/react-tooltip": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.0.7.tgz", + "integrity": "sha512-lPh5iKNFVQ/jav/j6ZrWq3blfDJ0OH9R6FlNUHPMqdLuQ9vwDgFsRxvl8b7Asuy5c8xmoojHUxKHQSOAvMHxyw==", + "dependencies": { + "@babel/runtime": "^7.13.10", + "@radix-ui/primitive": "1.0.1", + "@radix-ui/react-compose-refs": "1.0.1", + "@radix-ui/react-context": "1.0.1", + "@radix-ui/react-dismissable-layer": "1.0.5", + "@radix-ui/react-id": "1.0.1", + "@radix-ui/react-popper": "1.1.3", + "@radix-ui/react-portal": "1.0.4", + "@radix-ui/react-presence": "1.0.1", + "@radix-ui/react-primitive": "1.0.3", + "@radix-ui/react-slot": "1.0.2", + "@radix-ui/react-use-controllable-state": "1.0.1", + "@radix-ui/react-visually-hidden": "1.0.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-use-callback-ref": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.1.tgz", diff --git a/package.json b/package.json index 9fdcd5c35..267f2340a 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tabs": "^1.0.4", + "@radix-ui/react-tooltip": "^1.0.7", "@tauri-apps/api": "^1.5.3", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", diff --git a/src/App.tsx b/src/App.tsx index a0e12ac6d..c892af60a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,15 +3,18 @@ import { routes } from './App.routes' import { RouterProvider, createBrowserRouter } from 'react-router-dom' import { ThemeProvider } from './features/theme/context/theme-provider' import { LayoutProvider } from './features/layout/context/layout-provider' +import { TooltipProvider } from './features/common/components/tooltip' const router = createBrowserRouter(routes) function App() { return ( - - - + + + + + ) } diff --git a/src/features/common/components/tooltip.tsx b/src/features/common/components/tooltip.tsx new file mode 100644 index 000000000..f1ae97972 --- /dev/null +++ b/src/features/common/components/tooltip.tsx @@ -0,0 +1,28 @@ +import * as React from 'react' +import * as TooltipPrimitive from '@radix-ui/react-tooltip' + +import { cn } from '@/features/common/utils' + +const TooltipProvider = TooltipPrimitive.Provider + +const Tooltip = TooltipPrimitive.Root + +const TooltipTrigger = TooltipPrimitive.Trigger + +const TooltipContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, sideOffset = 4, ...props }, ref) => ( + +)) +TooltipContent.displayName = TooltipPrimitive.Content.displayName + +export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } diff --git a/src/features/transactions/pages/group-page.tsx b/src/features/transactions/pages/group-page.tsx index bc2542a73..a22035f52 100644 --- a/src/features/transactions/pages/group-page.tsx +++ b/src/features/transactions/pages/group-page.tsx @@ -1,7 +1,9 @@ import SvgCircle from '@/features/common/components/svg/circle' import SvgPointerLeft from '@/features/common/components/svg/pointer-left' import SvgPointerRight from '@/features/common/components/svg/pointer-right' +import { Tooltip, TooltipContent, TooltipTrigger } from '@/features/common/components/tooltip' import { cn } from '@/features/common/utils' +import { fixedForwardRef } from '@/utils/fixed-forward-ref' import { isDefined } from '@/utils/is-defined' import { useMemo } from 'react' @@ -82,40 +84,42 @@ function ConnectionToChildren({ indentLevel }: { indentLevel: number | undefined ) } -function DisplayArrow({ arrow: transactionArrow }: { arrow: Arrow }) { +const DisplayArrow = fixedForwardRef(({ arrow, ...rest }: { arrow: Arrow }, ref?: React.LegacyRef) => { return (
- {transactionArrow.direction === 'rightToLeft' && } + {arrow.direction === 'rightToLeft' && }
- {transactionArrow.direction === 'leftToRight' && } + {arrow.direction === 'leftToRight' && }
) -} +}) -function DisplaySelfTransaction() { +const DisplaySelfTransaction = fixedForwardRef((props: object, ref?: React.LegacyRef) => { return ( -
+
) -} +}) type TransactionRowProps = { transaction: Transaction @@ -153,8 +157,28 @@ function TransactionRow({
{accounts.map((_, index) => { if (index < arrow.from || index > arrow.to) return
- if (index === arrow.from && index === arrow.to) return - if (index === arrow.from) return + if (index === arrow.from && index === arrow.to) + return ( + + + + + +
Transaction: {transaction.name}
+
+
+ ) + if (index === arrow.from) + return ( + + + + + +
Transaction: {transaction.name}
+
+
+ ) else return null })}