/** * Component: Flag Configuration Row * Documentation: documentation/phase3/ranking-algorithm.md * * Allows configuration of indexer flag bonuses/penalties with visual slider feedback */ 'use client'; import React from 'react'; import { IndexerFlagConfig } from '@/lib/utils/ranking-algorithm'; import { TrashIcon } from '@heroicons/react/24/outline'; interface FlagConfigRowProps { config: IndexerFlagConfig; onChange: (config: IndexerFlagConfig) => void; onRemove: () => void; } export function FlagConfigRow({ config, onChange, onRemove }: FlagConfigRowProps) { const exampleBase = 85; const bonusPoints = exampleBase * (config.modifier / 100); const finalScore = exampleBase + bonusPoints; // Get color for modifier percentage display const getModifierColor = (modifier: number): string => { if (modifier < -50) return 'text-red-700 dark:text-red-400'; if (modifier < 0) return 'text-red-600 dark:text-red-500'; if (modifier === 0) return 'text-gray-600 dark:text-gray-400'; if (modifier > 50) return 'text-green-700 dark:text-green-400'; return 'text-green-600 dark:text-green-500'; }; // Get slider gradient based on current value const getSliderBackground = (modifier: number): string => { const normalizedPosition = ((modifier + 100) / 200) * 100; // -100 to 100 → 0% to 100% // Create gradient that fills from left up to current position // Red on left, yellow in middle, green on right return `linear-gradient(to right, #ef4444 0%, #ef4444 ${Math.max(0, normalizedPosition - 5)}%, #fbbf24 50%, #10b981 ${Math.min(100, normalizedPosition + 5)}%, #10b981 100%)`; }; return (
Example: Base score of {exampleBase} with "{config.name || 'this flag'}" {' → '} = 0 ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'}> {bonusPoints >= 0 ? '+' : ''}{bonusPoints.toFixed(1)} bonus points {bonusPoints < 0 && finalScore < 50 && ( {' '}⚠️ Would disqualify (final: {finalScore.toFixed(1)} < 50) )}