diff options
| author | Miguel Solorio <[email protected]> | 2025-07-11 18:05:21 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-12 01:05:21 +0000 |
| commit | d89ccf2250256bb67cdd9acfde1b679f39ca1f95 (patch) | |
| tree | f301effcacf489b7bdb40b2d964a0eed44676b73 /packages/cli/src/ui/components/ThemeDialog.tsx | |
| parent | 82bde578682fcd88b1ee9df053c9dd51c7b74522 (diff) | |
Add scrolling to theme dialog (#3895)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/components/ThemeDialog.tsx')
| -rw-r--r-- | packages/cli/src/ui/components/ThemeDialog.tsx | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/packages/cli/src/ui/components/ThemeDialog.tsx b/packages/cli/src/ui/components/ThemeDialog.tsx index ba49f8e3..e6c09225 100644 --- a/packages/cli/src/ui/components/ThemeDialog.tsx +++ b/packages/cli/src/ui/components/ThemeDialog.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { Box, Text, useInput } from 'ink'; import { Colors } from '../colors.js'; import { themeManager, DEFAULT_THEME } from '../themes/theme-manager.js'; @@ -60,19 +60,25 @@ export function ThemeDialog({ { label: 'System Settings', value: SettingScope.System }, ]; - const handleThemeSelect = (themeName: string) => { - onSelect(themeName, selectedScope); - }; + const handleThemeSelect = useCallback( + (themeName: string) => { + onSelect(themeName, selectedScope); + }, + [onSelect, selectedScope], + ); - const handleScopeHighlight = (scope: SettingScope) => { + const handleScopeHighlight = useCallback((scope: SettingScope) => { setSelectedScope(scope); setSelectInputKey(Date.now()); - }; + }, []); - const handleScopeSelect = (scope: SettingScope) => { - handleScopeHighlight(scope); - setFocusedSection('theme'); // Reset focus to theme section - }; + const handleScopeSelect = useCallback( + (scope: SettingScope) => { + handleScopeHighlight(scope); + setFocusedSection('theme'); // Reset focus to theme section + }, + [handleScopeHighlight], + ); const [focusedSection, setFocusedSection] = useState<'theme' | 'scope'>( 'theme', @@ -196,6 +202,7 @@ export function ThemeDialog({ onSelect={handleThemeSelect} onHighlight={onHighlight} isFocused={currenFocusedSection === 'theme'} + maxItemsToShow={8} /> {/* Scope Selection */} @@ -210,6 +217,7 @@ export function ThemeDialog({ onSelect={handleScopeSelect} onHighlight={handleScopeHighlight} isFocused={currenFocusedSection === 'scope'} + showScrollArrows={false} /> </Box> )} |
