From 1f68770efc656cec10afd32792d76791893a0dd0 Mon Sep 17 00:00:00 2001 From: saeed0920 Date: Tue, 16 Sep 2025 04:40:42 +0330 Subject: [PATCH] fix the show of sentecnse of the popup --- .../dashboard/strategic-alignment-popup.tsx | 20 +++++++++++- app/components/ui/truncatedText.tsx | 31 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 app/components/ui/truncatedText.tsx diff --git a/app/components/dashboard/strategic-alignment-popup.tsx b/app/components/dashboard/strategic-alignment-popup.tsx index 36f4136..cebb0bb 100644 --- a/app/components/dashboard/strategic-alignment-popup.tsx +++ b/app/components/dashboard/strategic-alignment-popup.tsx @@ -20,6 +20,7 @@ import apiService from "~/lib/api"; import { Skeleton } from "~/components/ui/skeleton"; import { formatNumber } from "~/lib/utils"; import { ChartContainer } from "../ui/chart"; +import { TruncatedText } from "../ui/truncatedText"; interface StrategicAlignmentData { strategic_theme: string; @@ -153,7 +154,22 @@ export function StrategicAlignmentPopup({ tickLine={false} axisLine={false} tickMargin={10} - tick={{ fill: "#94a3b8", fontSize: 12 }} + interval={0} + style={{ fill: "#94a3b8", fontSize: 12 }} + tick={(props) => { + const { x, y, payload } = props; + console.log(payload) + return ( + + + + + + ); + }} /> `${formatNumber(Math.round(value))}%` } + + label={{ value: "تعداد برنامه ها" , angle: -90, diff --git a/app/components/ui/truncatedText.tsx b/app/components/ui/truncatedText.tsx new file mode 100644 index 0000000..72cdd58 --- /dev/null +++ b/app/components/ui/truncatedText.tsx @@ -0,0 +1,31 @@ +import * as React from "react" +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip" + +interface TruncatedTextProps { + text: string + maxWords?: number +} + +export function TruncatedText({ text, maxWords = 4 }: TruncatedTextProps) { + const words = text.trim().split(/\s+/) + console.log(words) + const shouldTruncate = words.length > maxWords + const displayText = shouldTruncate ? words.slice(0, maxWords).join(" ") + " ..." : text + + return ( + + + + = 4 ? "cursor-help" : ""} text-foreground`}> + {displayText} + + + {shouldTruncate && ( + + {text} + + )} + + + ) +}