Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | 'use client' import { css } from '@styled/css' import type { RuleMode } from '../../displayRules' import { OperatorIcon } from './OperatorIcon' export interface RuleThermometerProps { label: string description: string value: RuleMode onChange: (value: RuleMode) => void isDark?: boolean /** When value is 'auto', this shows which value 'auto' resolves to (single operator mode) */ resolvedValue?: RuleMode /** When value is 'auto' in mixed mode, shows which value addition defers to */ resolvedAdditionValue?: RuleMode /** When value is 'auto' in mixed mode, shows which value subtraction defers to */ resolvedSubtractionValue?: RuleMode } const RULE_OPTIONS: Array<{ value: RuleMode; label: string; short: string }> = [ { value: 'auto', label: 'Auto (Use Mastery Progression)', short: 'Auto' }, { value: 'always', label: 'Always', short: 'Always' }, { value: 'whenRegrouping', label: 'When Regrouping', short: 'Regroup' }, { value: 'whenMultipleRegroups', label: 'Multiple Regroups', short: '2+ reg', }, { value: 'when3PlusDigits', label: '3+ Digits', short: '3+ dig' }, { value: 'never', label: 'Never', short: 'Never' }, ] export function RuleThermometer({ label, description, value, onChange, isDark = false, resolvedValue, resolvedAdditionValue, resolvedSubtractionValue, }: RuleThermometerProps) { const selectedIndex = RULE_OPTIONS.findIndex((opt) => opt.value === value) const isAutoSelected = value === 'auto' const isMixedMode = resolvedAdditionValue !== undefined && resolvedSubtractionValue !== undefined return ( <div className={css({ display: 'flex', flexDirection: 'column', gap: '1.5', })} > {/* Label */} <div> <div className={css({ fontSize: 'xs', fontWeight: 'semibold', color: isDark ? 'gray.300' : 'gray.700', mb: '0.5', })} > {label} </div> <div className={css({ fontSize: '2xs', color: isDark ? 'gray.400' : 'gray.500', lineHeight: '1.3', })} > {description} </div> </div> {/* Horizontal thermometer */} <div className={css({ display: 'flex', gap: '0', bg: isDark ? 'gray.700' : 'gray.100', rounded: 'md', p: '1', border: '1px solid', borderColor: isDark ? 'gray.600' : 'gray.200', })} > {RULE_OPTIONS.map((option, index) => { const isSelected = value === option.value // Check which operators defer to this option (for mixed mode) const additionDefersHere = isMixedMode && isAutoSelected && resolvedAdditionValue === option.value const subtractionDefersHere = isMixedMode && isAutoSelected && resolvedSubtractionValue === option.value const isAutoResolvedMixed = additionDefersHere || subtractionDefersHere // For single operator mode const isAutoResolved = !isMixedMode && isAutoSelected && resolvedValue === option.value // Determine which operator to show let operatorToShow: 'addition' | 'subtraction' | 'mixed' | null = null if (isAutoResolvedMixed) { if (additionDefersHere && subtractionDefersHere) { operatorToShow = 'mixed' // Both defer here } else if (additionDefersHere) { operatorToShow = 'addition' // Only addition } else if (subtractionDefersHere) { operatorToShow = 'subtraction' // Only subtraction } } const showHighlight = isAutoResolved || isAutoResolvedMixed const isLeftmost = index === 0 const isRightmost = index === RULE_OPTIONS.length - 1 return ( <button key={option.value} type="button" onClick={() => onChange(option.value)} title={ isAutoResolvedMixed && operatorToShow ? `${option.label} (${operatorToShow} selected by Auto)` : isAutoResolved ? `${option.label} (currently selected by Auto)` : option.label } className={css({ flex: 1, px: '2', py: '1.5', fontSize: '2xs', fontWeight: isSelected ? 'bold' : showHighlight ? 'semibold' : 'medium', color: isSelected ? 'white' : showHighlight ? isDark ? 'green.300' : 'green.700' : isDark ? 'gray.400' : 'gray.600', bg: isSelected ? 'brand.500' : showHighlight ? isDark ? 'green.900/30' : 'green.100' : 'transparent', outline: showHighlight ? '1px solid' : 'none', outlineColor: showHighlight ? (isDark ? 'green.700' : 'green.300') : 'transparent', borderTopLeftRadius: isLeftmost ? 'md' : '0', borderBottomLeftRadius: isLeftmost ? 'md' : '0', borderTopRightRadius: isRightmost ? 'md' : '0', borderBottomRightRadius: isRightmost ? 'md' : '0', cursor: 'pointer', transition: 'all 0.15s', position: 'relative', // For absolute positioning of operator symbol _hover: { bg: isSelected ? 'brand.600' : showHighlight ? isDark ? 'green.800/40' : 'green.200' : isDark ? 'gray.600' : 'gray.200', color: isSelected ? 'white' : isDark ? 'gray.200' : 'gray.800', }, })} > {/* Operator icon for mixed mode - positioned absolutely on left */} {operatorToShow && ( <div className={css({ position: 'absolute', left: '0.25rem', top: '50%', transform: 'translateY(-50%)', })} > <OperatorIcon operator={operatorToShow} size="lg" isDark={isDark} color="green" /> </div> )} {option.short} </button> ) })} </div> </div> ) } |