Skip to content

Commit 90867dd

Browse files
feat: add TooltipWrapper component with theme support
1 parent e510b5f commit 90867dd

File tree

8 files changed

+477
-8
lines changed

8 files changed

+477
-8
lines changed

package-lock.json

Lines changed: 425 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@radix-ui/react-slot": "^1.1.0",
6464
"@radix-ui/react-switch": "^1.1.0",
6565
"@radix-ui/react-tabs": "^1.1.0",
66+
"@radix-ui/react-tooltip": "^1.2.8",
6667
"@tanstack/react-query": "^5.52.1",
6768
"@tanstack/react-table": "^8.20.1",
6869
"axios": "^1.7.2",

src/components/ui/tooltip.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as Tooltip from "@radix-ui/react-tooltip";
2+
import { ReactNode } from "react";
3+
4+
interface TooltipWrapperProps {
5+
content: string; // o texto que vai aparecer no tooltip
6+
children: ReactNode; // o trigger (qualquer elemento)
7+
side?: "top" | "right" | "bottom" | "left"; // posição opcional
8+
}
9+
10+
export function TooltipWrapper({ content, children, side = "top" }: TooltipWrapperProps) {
11+
return (
12+
<Tooltip.Provider delayDuration={200}>
13+
<Tooltip.Root>
14+
<Tooltip.Trigger asChild>
15+
{children}
16+
</Tooltip.Trigger>
17+
<Tooltip.Portal>
18+
<Tooltip.Content
19+
side={side}
20+
className="
21+
rounded px-3 py-1.5 text-sm z-50 border shadow-lg
22+
bg-gray-100 text-gray-900 border-gray-300
23+
dark:bg-gray-800 dark:text-gray-100 dark:border-gray-700
24+
"
25+
>
26+
{content}
27+
<Tooltip.Arrow className="fill-gray-100 dark:fill-gray-800" width={18} height={9} />
28+
</Tooltip.Content>
29+
</Tooltip.Portal>
30+
</Tooltip.Root>
31+
</Tooltip.Provider>
32+
);
33+
}

src/pages/Dashboard/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useManageInstance } from "@/lib/queries/instance/manageInstance";
1919
import { Instance } from "@/types/evolution.types";
2020

2121
import { NewInstance } from "./NewInstance";
22+
import { TooltipWrapper } from "@/components/ui/tooltip";
2223

2324
function Dashboard() {
2425
const { t } = useTranslation();
@@ -119,10 +120,15 @@ function Dashboard() {
119120
<Card key={instance.id}>
120121
<CardHeader>
121122
<Link to={`/manager/instance/${instance.id}/dashboard`} className="flex w-full flex-row items-center justify-between gap-4">
122-
<h3 className="text-wrap font-semibold">{instance.name}</h3>
123-
<Button variant="ghost" size="icon">
124-
<Cog className="card-icon" size="20" />
125-
</Button>
123+
<TooltipWrapper content={instance.name} side="top">
124+
<h3 className="text-wrap font-semibold truncate">{instance.name}</h3>
125+
</TooltipWrapper>
126+
127+
<TooltipWrapper content={t("dashboard.settings")} side="top">
128+
<Button variant="ghost" size="icon">
129+
<Cog className="card-icon" size="20" />
130+
</Button>
131+
</TooltipWrapper>
126132
</Link>
127133
</CardHeader>
128134
<CardContent className="flex-1 space-y-6">

src/translate/languages/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"dashboard": {
33
"title": "Instances",
44
"search": "Search",
5-
"status": "Status"
5+
"status": "Status",
6+
"settings": "Settings"
67
},
78
"button": {
89
"delete": "Delete",

src/translate/languages/es-ES.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"dashboard": {
33
"title": "Instancias",
44
"search": "Buscar",
5-
"status": "Estado"
5+
"status": "Estado",
6+
"settings": "Configuraciones"
67
},
78
"button": {
89
"delete": "Eliminar",

src/translate/languages/fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"dashboard": {
33
"title": "Instances",
44
"search": "Rechercher",
5-
"status": "Statut"
5+
"status": "Statut",
6+
"settings": "Paramètres"
67
},
78
"button": {
89
"delete": "Supprimer",

src/translate/languages/pt-BR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"dashboard": {
33
"title": "Instâncias",
44
"search": "Pesquisar",
5-
"status": "Status"
5+
"status": "Status",
6+
"settings": "Configurações"
67
},
78
"button": {
89
"delete": "Excluir",

0 commit comments

Comments
 (0)