33
44import { Card } from "@/components/ui/card" ;
55import { Progress } from "@/components/ui/progress" ;
6+ import { formatTickerForDisplay } from "@/lib/tickers" ;
67import type { RebalancePosition } from "../types" ;
78
89interface PortfolioCompositionProps {
@@ -25,28 +26,31 @@ export function PortfolioComposition({
2526
2627 { /* Stacked Bar */ }
2728 < div className = "w-full h-10 flex rounded-lg overflow-hidden border" >
28- { positions . map ( ( position ) => (
29- < div
30- key = { position . ticker }
31- className = "relative group transition-opacity hover:opacity-90"
32- style = { {
33- width : `${ position . currentAllocation } %` ,
34- backgroundColor : positionColors [ position . ticker ]
35- } }
36- >
37- { /* Show percentage if space allows */ }
38- { position . currentAllocation >= 8 && (
39- < span className = "absolute inset-0 flex items-center justify-center text-white text-xs font-medium drop-shadow" >
40- { position . currentAllocation . toFixed ( 1 ) } %
41- </ span >
42- ) }
29+ { positions . map ( ( position ) => {
30+ const displayTicker = formatTickerForDisplay ( position . ticker , { assetClass : position . assetClass , assetSymbol : position . assetSymbol } ) ;
31+ return (
32+ < div
33+ key = { position . ticker }
34+ className = "relative group transition-opacity hover:opacity-90"
35+ style = { {
36+ width : `${ position . currentAllocation } %` ,
37+ backgroundColor : positionColors [ position . ticker ]
38+ } }
39+ >
40+ { /* Show percentage if space allows */ }
41+ { position . currentAllocation >= 8 && (
42+ < span className = "absolute inset-0 flex items-center justify-center text-white text-xs font-medium drop-shadow" >
43+ { position . currentAllocation . toFixed ( 1 ) } %
44+ </ span >
45+ ) }
4346
44- { /* Tooltip on hover */ }
45- < div className = "opacity-0 group-hover:opacity-100 absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded whitespace-nowrap z-10 pointer-events-none transition-opacity" >
46- { position . ticker } : { position . currentAllocation . toFixed ( 1 ) } %
47+ { /* Tooltip on hover */ }
48+ < div className = "opacity-0 group-hover:opacity-100 absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 text-white text-xs rounded whitespace-nowrap z-10 pointer-events-none transition-opacity" >
49+ { displayTicker } : { position . currentAllocation . toFixed ( 1 ) } %
50+ </ div >
4751 </ div >
48- </ div >
49- ) ) }
52+ ) ;
53+ } ) }
5054
5155 { /* Cash portion */ }
5256 { cashAllocation > 0 && (
@@ -70,16 +74,19 @@ export function PortfolioComposition({
7074
7175 { /* Legend */ }
7276 < div className = "flex flex-wrap gap-3 text-xs" >
73- { positions . map ( ( position ) => (
74- < div key = { position . ticker } className = "flex items-center gap-1.5" >
75- < div
76- className = "w-3 h-3 rounded"
77- style = { { backgroundColor : positionColors [ position . ticker ] } }
78- />
79- < span className = "font-medium" > { position . ticker } :</ span >
80- < span className = "text-muted-foreground" > { position . currentAllocation . toFixed ( 1 ) } %</ span >
81- </ div >
82- ) ) }
77+ { positions . map ( ( position ) => {
78+ const displayTicker = formatTickerForDisplay ( position . ticker , { assetClass : position . assetClass , assetSymbol : position . assetSymbol } ) ;
79+ return (
80+ < div key = { position . ticker } className = "flex items-center gap-1.5" >
81+ < div
82+ className = "w-3 h-3 rounded"
83+ style = { { backgroundColor : positionColors [ position . ticker ] } }
84+ />
85+ < span className = "font-medium" > { displayTicker } :</ span >
86+ < span className = "text-muted-foreground" > { position . currentAllocation . toFixed ( 1 ) } %</ span >
87+ </ div >
88+ ) ;
89+ } ) }
8390 { cashAllocation > 0 && (
8491 < div className = "flex items-center gap-1.5" >
8592 < div className = "w-3 h-3 rounded bg-gray-500" />
@@ -91,4 +98,4 @@ export function PortfolioComposition({
9198 </ div >
9299 </ Card >
93100 ) ;
94- }
101+ }
0 commit comments