@@ -9,11 +9,7 @@ import {
99} from "../utils/config.js" ;
1010import { Header } from "../components/Header.js" ;
1111import { SuccessMessage } from "../components/SuccessMessage.js" ;
12- import {
13- colors ,
14- getCurrentTheme ,
15- setThemeMode ,
16- } from "../utils/theme.js" ;
12+ import { colors , getCurrentTheme , setThemeMode } from "../utils/theme.js" ;
1713
1814interface ThemeOption {
1915 value : "auto" | "light" | "dark" ;
@@ -51,13 +47,8 @@ const InteractiveThemeSelector = ({
5147 themeOptions . findIndex ( ( opt ) => opt . value === initialTheme ) ,
5248 ) ;
5349 const [ saved , setSaved ] = React . useState ( false ) ;
54- const [ detectedTheme ] = React . useState < "light" | "dark" > (
55- getCurrentTheme ( ) ,
56- ) ;
57- const [ currentTheme , setCurrentTheme ] = React . useState < "light" | "dark" > (
58- getCurrentTheme ( ) ,
59- ) ;
60-
50+ const [ detectedTheme ] = React . useState < "light" | "dark" > ( getCurrentTheme ( ) ) ;
51+
6152 // Update theme preview when selection changes
6253 React . useEffect ( ( ) => {
6354 const newTheme = themeOptions [ selectedIndex ] . value ;
@@ -73,7 +64,6 @@ const InteractiveThemeSelector = ({
7364
7465 // Apply theme change for preview
7566 setThemeMode ( targetTheme ) ;
76- setCurrentTheme ( targetTheme ) ;
7767 } , [ selectedIndex , detectedTheme ] ) ;
7868
7969 useInput ( ( input , key ) => {
@@ -90,12 +80,12 @@ const InteractiveThemeSelector = ({
9080 // Save the selected theme to config
9181 const selectedTheme = themeOptions [ selectedIndex ] . value ;
9282 setThemePreference ( selectedTheme ) ;
93-
83+
9484 // If setting to 'auto', clear cached detection for re-run
9585 if ( selectedTheme === "auto" ) {
9686 clearDetectedTheme ( ) ;
9787 }
98-
88+
9989 setSaved ( true ) ;
10090 setTimeout ( ( ) => exit ( ) , 1500 ) ;
10191 } else if ( key . escape || input === "q" ) {
@@ -167,9 +157,9 @@ const InteractiveThemeSelector = ({
167157 < Text color = { colors . text } bold >
168158 { figures . play } Live Preview:
169159 </ Text >
170- < Box
171- marginTop = { 1 }
172- marginLeft = { 2 }
160+ < Box
161+ marginTop = { 1 }
162+ marginLeft = { 2 }
173163 paddingX = { 2 }
174164 paddingY = { 1 }
175165 borderStyle = "round"
@@ -180,27 +170,21 @@ const InteractiveThemeSelector = ({
180170 < Text color = { colors . primary } bold >
181171 { figures . tick } Primary
182172 </ Text >
183- < Text > </ Text >
173+ < Text > </ Text >
184174 < Text color = { colors . secondary } bold >
185175 { figures . star } Secondary
186176 </ Text >
187177 </ Box >
188178 < Box >
189- < Text color = { colors . success } >
190- { figures . tick } Success
191- </ Text >
192- < Text > </ Text >
193- < Text color = { colors . warning } >
194- { figures . warning } Warning
195- </ Text >
196- < Text > </ Text >
197- < Text color = { colors . error } >
198- { figures . cross } Error
199- </ Text >
179+ < Text color = { colors . success } > { figures . tick } Success</ Text >
180+ < Text > </ Text >
181+ < Text color = { colors . warning } > { figures . warning } Warning</ Text >
182+ < Text > </ Text >
183+ < Text color = { colors . error } > { figures . cross } Error</ Text >
200184 </ Box >
201185 < Box >
202186 < Text color = { colors . text } > Normal text</ Text >
203- < Text > </ Text >
187+ < Text > </ Text >
204188 < Text color = { colors . textDim } > Dim text</ Text >
205189 </ Box >
206190 </ Box >
@@ -227,12 +211,12 @@ const StaticConfigUI = ({ action, value }: StaticConfigUIProps) => {
227211 React . useEffect ( ( ) => {
228212 if ( action === "set" && value ) {
229213 setThemePreference ( value ) ;
230-
214+
231215 // If setting to 'auto', clear the cached detection so it re-runs on next start
232216 if ( value === "auto" ) {
233217 clearDetectedTheme ( ) ;
234218 }
235-
219+
236220 setSaved ( true ) ;
237221 setTimeout ( ( ) => process . exit ( 0 ) , 1500 ) ;
238222 } else if ( action === "get" || ! action ) {
@@ -284,8 +268,8 @@ const StaticConfigUI = ({ action, value }: StaticConfigUIProps) => {
284268 background automatically
285269 </ Text >
286270 < Text color = { colors . textDim } >
287- • < Text color = { colors . primary } > light</ Text > - Force light mode
288- (dark text on light background)
271+ • < Text color = { colors . primary } > light</ Text > - Force light mode (dark
272+ text on light background)
289273 </ Text >
290274 < Text color = { colors . textDim } >
291275 • < Text color = { colors . primary } > dark</ Text > - Force dark mode (light
@@ -314,4 +298,3 @@ export function showThemeConfig() {
314298export function setThemeConfig ( theme : "auto" | "light" | "dark" ) {
315299 render ( < StaticConfigUI action = "set" value = { theme } /> ) ;
316300}
317-
0 commit comments