()
| 6 | const MAX_INDENT = 8; |
| 7 | |
| 8 | export function IndentPreference() { |
| 9 | const [preferences, setPreferences] = usePreferences(); |
| 10 | |
| 11 | const updatePreferences = (e: React.ChangeEvent<HTMLInputElement>) => { |
| 12 | let newIdent = Number(e.target.value); |
| 13 | if (newIdent < MIN_INDENT) newIdent = MIN_INDENT; |
| 14 | if (newIdent > MAX_INDENT) newIdent = MAX_INDENT; |
| 15 | e.target.value = newIdent.toString(); |
| 16 | setPreferences({ ...preferences, indent: newIdent }); |
| 17 | }; |
| 18 | |
| 19 | return ( |
| 20 | <div className="flex items-center -mt-0.5"> |
| 21 | <label |
| 22 | className="pr-2 text-slate-800 transition dark:text-white" |
| 23 | htmlFor="indent" |
| 24 | > |
| 25 | <Body>Indent</Body> |
| 26 | </label> |
| 27 | <input |
| 28 | type="number" |
| 29 | className="py-0 pr-0 pl-1 w-9 rounded-sm text-sm h-[23px] bg-slate-300 transition hover:bg-slate-400 hover:bg-opacity-50 dark:bg-slate-800 dark:text-slate-400 hover:cursor-pointer hover:dark:bg-slate-700 hover:dark:bg-opacity-70" |
| 30 | defaultValue={preferences?.indent} |
| 31 | min={MIN_INDENT} |
| 32 | max={MAX_INDENT} |
| 33 | onChange={updatePreferences} |
| 34 | /> |
| 35 | </div> |
| 36 | ); |
| 37 | } |
nothing calls this directly
no test coverage detected