diff --git a/src/components/common/CategoryTag.tsx b/src/components/common/CategoryTag.tsx index 28d47aa..c3b233c 100644 --- a/src/components/common/CategoryTag.tsx +++ b/src/components/common/CategoryTag.tsx @@ -1,4 +1,5 @@ import { cn } from '@/lib/utils'; +import { TruncatedText } from '@/components/ui/truncated-text'; interface CategoryTagProps { label?: string; @@ -15,9 +16,12 @@ const CategoryTag: React.FC = ({ 'inline-flex max-w-full items-center rounded-md border border-white/15 bg-white/10 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-white/80', className )} - title={label} > - {label} + ); }; diff --git a/src/components/common/MiniStatChip.tsx b/src/components/common/MiniStatChip.tsx index 8a64623..6d74039 100644 --- a/src/components/common/MiniStatChip.tsx +++ b/src/components/common/MiniStatChip.tsx @@ -1,5 +1,6 @@ import { cn } from '@/lib/utils'; import AccessibleInfoTrigger from '@/components/common/AccessibleInfoTrigger'; +import { TruncatedText } from '@/components/ui/truncated-text'; interface MiniStatChipProps { label: string; @@ -30,9 +31,11 @@ const MiniStatChip: React.FC = ({ {label} - - {value} - + {explanation && ( (null); + const [isTruncated, setIsTruncated] = useState(false); + const maxWidthValue = typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth; + + useEffect(() => { + const node = textRef.current; + if (!node) return; + + const updateTruncation = () => { + setIsTruncated(node.scrollWidth > node.clientWidth); + }; + + updateTruncation(); + + if (typeof ResizeObserver !== 'undefined') { + const observer = new ResizeObserver(updateTruncation); + observer.observe(node); + return () => observer.disconnect(); + } + + window.addEventListener('resize', updateTruncation); + return () => window.removeEventListener('resize', updateTruncation); + }, [text]); + + const content = ( + + {text} + + ); + + return isTruncated ? {content} : content; +}