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 | 'use client' import * as Select from '@radix-ui/react-select' import { css } from '@styled/css' import type { RuleMode } from '../../displayRules' export interface RuleDropdownProps { label: string description: string value: RuleMode onChange: (value: RuleMode) => void isDark?: boolean } const RULE_OPTIONS: Array<{ value: RuleMode label: string description: string }> = [ { value: 'always', label: 'Always', description: 'Show for all problems' }, { value: 'never', label: 'Never', description: 'Hide for all problems' }, { value: 'whenRegrouping', label: 'When Regrouping', description: 'Show only when problem requires regrouping', }, { value: 'whenMultipleRegroups', label: 'Multiple Regroups', description: 'Show when 2+ place values regroup', }, { value: 'when3PlusDigits', label: '3+ Digits', description: 'Show when problem has 3+ digits', }, ] export function RuleDropdown({ label, description, value, onChange, isDark = false, }: RuleDropdownProps) { const selectedOption = RULE_OPTIONS.find((opt) => opt.value === value) return ( <div className={css({ display: 'flex', flexDirection: 'column', gap: '1.5', })} > <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> <Select.Root value={value} onValueChange={onChange}> <Select.Trigger className={css({ display: 'flex', alignItems: 'center', justifyContent: 'space-between', w: 'full', px: '2.5', py: '1.5', bg: isDark ? 'gray.700' : 'white', border: '1px solid', borderColor: isDark ? 'gray.600' : 'gray.300', rounded: 'md', fontSize: 'xs', color: isDark ? 'gray.200' : 'gray.700', cursor: 'pointer', _hover: { borderColor: isDark ? 'gray.500' : 'brand.400', }, _focus: { outline: 'none', borderColor: 'brand.500', boxShadow: '0 0 0 3px rgba(59, 130, 246, 0.1)', }, })} > <Select.Value>{selectedOption?.label || 'Select...'}</Select.Value> <Select.Icon className={css({ ml: '2', color: isDark ? 'gray.400' : 'gray.500', })} > ▼ </Select.Icon> </Select.Trigger> <Select.Portal> <Select.Content className={css({ bg: isDark ? 'gray.800' : 'white', border: '1px solid', borderColor: isDark ? 'gray.600' : 'gray.200', rounded: 'md', shadow: 'lg', overflow: 'hidden', zIndex: 1000, })} position="popper" sideOffset={5} > <Select.Viewport> {RULE_OPTIONS.map((option) => ( <Select.Item key={option.value} value={option.value} className={css({ px: '3', py: '2', fontSize: 'xs', color: isDark ? 'gray.200' : 'gray.700', cursor: 'pointer', outline: 'none', _hover: { bg: isDark ? 'gray.700' : 'brand.50', }, '&[data-state="checked"]': { bg: isDark ? 'gray.700' : 'brand.50', color: isDark ? 'brand.300' : 'brand.700', fontWeight: 'semibold', }, })} > <div> <Select.ItemText>{option.label}</Select.ItemText> <div className={css({ fontSize: '2xs', color: isDark ? 'gray.400' : 'gray.500', mt: '0.5', })} > {option.description} </div> </div> </Select.Item> ))} </Select.Viewport> </Select.Content> </Select.Portal> </Select.Root> </div> ) } |