MCPcopy
hub / github.com/claude-code-best/claude-code / ThemePicker

Function ThemePicker

src/components/ThemePicker.tsx:30–207  ·  view source on GitHub ↗
({
  onThemeSelect,
  showIntroText = false,
  helpText = '',
  showHelpTextBelow = false,
  hideEscToCancel = false,
  skipExitHandling = false,
  onCancel: onCancelProp,
}: ThemePickerProps)

Source from the content-addressed store, hash-verified

28};
29
30export 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 },

Callers

nothing calls this directly

Calls 15

useThemeFunction · 0.90
useThemeSettingFunction · 0.90
usePreviewThemeFunction · 0.90
useTerminalSizeFunction · 0.85
useAppStateFunction · 0.85
useSetAppStateFunction · 0.85
useShortcutDisplayFunction · 0.85
useKeybindingFunction · 0.85
updateSettingsForSourceFunction · 0.85
getSyntaxThemeFunction · 0.50

Tested by

no test coverage detected