Skip to content

Commit

Permalink
fix: 🐛 fixed issue with tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Sep 26, 2024
1 parent 1e9ab71 commit 73e77ee
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 105 deletions.
8 changes: 1 addition & 7 deletions components/data-table/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ export const columns: ColumnDef<TestResultData>[] = [
accessorKey: 'method_name',
cell: ({ row }) => {
const value = row.getValue('method_name') as string;
return (
<>
<TooltipWrapper text={value}>
<CellData value={value} />
</TooltipWrapper>
</>
);
return <CellData value={value} />;
},
header: ({ column }) => (
<SortableHeader column={column} header='Method Name' />
Expand Down
14 changes: 2 additions & 12 deletions components/utils/tooltip-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
import { forwardRef } from 'react';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from '@/components/ui/tooltip';

const ForwardedWrapper = forwardRef<
HTMLDivElement,
{ children: React.ReactNode }
>((props, ref) => <div ref={ref}>{props.children}</div>);

ForwardedWrapper.displayName = 'ForwardedWrapper';

export const TooltipWrapper = ({
children,
text,
}: {
children: JSX.Element;
children: React.ReactNode;
text: string;
}): JSX.Element => {
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<ForwardedWrapper>{children}</ForwardedWrapper>
</TooltipTrigger>
<TooltipTrigger asChild>{children}</TooltipTrigger>
<TooltipContent>
<p>{text}</p>
</TooltipContent>
Expand Down
15 changes: 13 additions & 2 deletions lib/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { parse, format } from 'date-fns';

export const formatDuration = (duration: number): string =>
duration >= 1000 ? `${(duration / 1000).toFixed(2)} s` : `${duration} ms`;
export const formatDuration = (duration: number): string => {
const SECOND = 1000;
const MINUTE = 60 * SECOND;
const HOUR = 60 * MINUTE;

return duration >= HOUR
? `${(duration / HOUR).toFixed(2)} h`
: duration >= MINUTE
? `${(duration / MINUTE).toFixed(2)} m`
: duration >= SECOND
? `${(duration / SECOND).toFixed(2)} s`
: `${duration} ms`;
};

export const formatTime = (dateTime: string): string => {
const cleanedDateString = dateTime.replace('AST', 'UTC');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@next/eslint-plugin-next": "^14.2.13",
"@stylistic/eslint-plugin-js": "^2.8.0",
"@stylistic/eslint-plugin-ts": "^2.8.0",
"@types/node": "^22.7.0",
"@types/node": "^22.7.2",
"@types/react": "^18.3.9",
"@types/react-dom": "^18",
"@types/xml2js": "^0.4.14",
Expand Down
Loading

0 comments on commit 73e77ee

Please sign in to comment.