({
onThemeSelect,
showIntroText = false,
helpText = '',
showHelpTextBelow = false,
hideEscToCancel = false,
skipExitHandling = false,
onCancel: onCancelProp,
}: ThemePickerProps)
| 28 | }; |
| 29 | |
| 30 | export function ThemePicker({ |
| 31 | onThemeSelect, |
| 32 | showIntroText = false, |
| 33 | helpText = '', |
| 34 | showHelpTextBelow = false, |
| 35 | hideEscToCancel = false, |
| 36 | skipExitHandling = false, |
| 37 | onCancel: onCancelProp, |
| 38 | }: ThemePickerProps): React.ReactNode { |
| 39 | const [theme] = useTheme(); |
| 40 | const themeSetting = useThemeSetting(); |
| 41 | const { columns } = useTerminalSize(); |
| 42 | const colorModuleUnavailableReason = getColorModuleUnavailableReason(); |
| 43 | const syntaxTheme = colorModuleUnavailableReason === null ? getSyntaxTheme(theme) : null; |
| 44 | const { setPreviewTheme, savePreview, cancelPreview } = usePreviewTheme(); |
| 45 | const syntaxHighlightingDisabled = useAppState(s => s.settings.syntaxHighlightingDisabled) ?? false; |
| 46 | const setAppState = useSetAppState(); |
| 47 | |
| 48 | // Register ThemePicker context so its keybindings take precedence over Global |
| 49 | useRegisterKeybindingContext('ThemePicker'); |
| 50 | |
| 51 | const syntaxToggleShortcut = useShortcutDisplay('theme:toggleSyntaxHighlighting', 'ThemePicker', 'ctrl+t'); |
| 52 | |
| 53 | useKeybinding( |
| 54 | 'theme:toggleSyntaxHighlighting', |
| 55 | () => { |
| 56 | if (colorModuleUnavailableReason === null) { |
| 57 | const newValue = !syntaxHighlightingDisabled; |
| 58 | updateSettingsForSource('userSettings', { |
| 59 | syntaxHighlightingDisabled: newValue, |
| 60 | }); |
| 61 | setAppState(prev => ({ |
| 62 | ...prev, |
| 63 | settings: { ...prev.settings, syntaxHighlightingDisabled: newValue }, |
| 64 | })); |
| 65 | } |
| 66 | }, |
| 67 | { context: 'ThemePicker' }, |
| 68 | ); |
| 69 | // Always call the hook to follow React rules, but conditionally assign the exit handler |
| 70 | const exitState = useExitOnCtrlCDWithKeybindings(skipExitHandling ? () => {} : undefined); |
| 71 | |
| 72 | const themeOptions: { label: string; value: ThemeSetting }[] = [ |
| 73 | ...(feature('AUTO_THEME') ? [{ label: 'Auto (match terminal)', value: 'auto' as const }] : []), |
| 74 | { label: 'Dark mode', value: 'dark' }, |
| 75 | { label: 'Light mode', value: 'light' }, |
| 76 | { |
| 77 | label: 'Dark mode (colorblind-friendly)', |
| 78 | value: 'dark-daltonized', |
| 79 | }, |
| 80 | { |
| 81 | label: 'Light mode (colorblind-friendly)', |
| 82 | value: 'light-daltonized', |
| 83 | }, |
| 84 | { |
| 85 | label: 'Dark mode (ANSI colors only)', |
| 86 | value: 'dark-ansi', |
| 87 | }, |
nothing calls this directly
no test coverage detected