summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/ThemeDialog.tsx
blob: b3e4f0634312010a558188a5c9a69c71e49d2aa0 (plain)
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
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

import React from 'react';
import { Box, Text } from 'ink';
import { Colors } from '../colors.js';
import { themeManager } from '../themes/theme-manager.js';
import { RadioButtonSelect } from './shared/RadioButtonSelect.js';

interface ThemeDialogProps {
  /** Callback function when a theme is selected */
  onSelect: (themeName: string) => void;
}

export function ThemeDialog({ onSelect }: ThemeDialogProps): React.JSX.Element {
  const themeItems = themeManager.getAvailableThemes().map((theme) => ({
    label: theme.active ? `${theme.name} (Active)` : theme.name,
    value: theme.name,
  }));
  const initialIndex = themeItems.findIndex(
    (item) => item.value === themeManager.getActiveTheme().name,
  );
  return (
    <Box
      borderStyle="round"
      borderColor={Colors.AccentCyan}
      flexDirection="column"
      padding={1}
      width="50%"
    >
      <Box marginBottom={1}>
        <Text bold>Select Theme</Text>
      </Box>
      <RadioButtonSelect
        items={themeItems}
        initialIndex={initialIndex}
        onSelect={onSelect}
      />
      <Box marginTop={1}>
        <Text color={Colors.SubtleComment}>
          (Use ↑/↓ arrows and Enter to select)
        </Text>
      </Box>
    </Box>
  );
}