File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ interface SkillCardProps {
1515 skill : Skill ;
1616}
1717
18+ /** Maximum number of metric contributions to display inline on a skill card */
19+ const MAX_DISPLAYED_CONTRIBUTIONS = 3 ;
20+
1821const SkillCard = ( { skill } : SkillCardProps ) => {
1922 const { updateSkill, deleteSkill } = useSkills ( ) ;
2023 const [ isEditDialogOpen , setIsEditDialogOpen ] = useState ( false ) ;
@@ -123,7 +126,7 @@ const SkillCard = ({ skill }: SkillCardProps) => {
123126 < TooltipProvider >
124127 < div className = "flex items-center gap-1 text-xs flex-wrap" >
125128 < Target className = "w-3 h-3 text-muted-foreground" />
126- { metricContributions . slice ( 0 , 3 ) . map ( ( contribution ) => (
129+ { metricContributions . slice ( 0 , MAX_DISPLAYED_CONTRIBUTIONS ) . map ( ( contribution ) => (
127130 < Tooltip key = { contribution . metricName } >
128131 < TooltipTrigger asChild >
129132 < span className = "text-muted-foreground bg-muted/50 px-1.5 py-0.5 rounded cursor-help" >
@@ -137,9 +140,9 @@ const SkillCard = ({ skill }: SkillCardProps) => {
137140 </ TooltipContent >
138141 </ Tooltip >
139142 ) ) }
140- { metricContributions . length > 3 && (
143+ { metricContributions . length > MAX_DISPLAYED_CONTRIBUTIONS && (
141144 < span className = "text-muted-foreground" >
142- +{ metricContributions . length - 3 } more
145+ +{ metricContributions . length - MAX_DISPLAYED_CONTRIBUTIONS } more
143146 </ span >
144147 ) }
145148 </ div >
Original file line number Diff line number Diff line change @@ -125,10 +125,13 @@ const RadarChart = () => {
125125 const dx = x - centerX ;
126126 const dy = y - centerY ;
127127 const clickAngle = Math . atan2 ( dy , dx ) ;
128- const distance = Math . sqrt ( dx * dx + dy * dy ) ;
128+
129+ // Use squared distance comparison to avoid expensive square root operation
130+ const distanceSquared = dx * dx + dy * dy ;
131+ const maxDistanceSquared = ( radius + 50 ) * ( radius + 50 ) ;
129132
130133 // Only respond to clicks near the chart area
131- if ( distance > radius + 50 ) return ;
134+ if ( distanceSquared > maxDistanceSquared ) return ;
132135
133136 // Find the closest axis
134137 let closestAxisIndex = 0 ;
You can’t perform that action at this time.
0 commit comments