@@ -73,9 +73,8 @@ export function useCommandPaletteGlobalCommands() {
7373 const { locale, locales, setLocale, t } = useI18n ( )
7474 const route = useRoute ( )
7575 const colorMode = useColorMode ( )
76- const { accentColors, selectedAccentColorOptionId, setAccentColor } = useAccentColor ( )
77- const { backgroundThemes, selectedBackgroundThemeOptionId, setBackgroundTheme } =
78- useBackgroundTheme ( )
76+ const { accentColors, selectedAccentColor, setAccentColor } = useAccentColor ( )
77+ const { backgroundThemes, selectedBackgroundTheme, setBackgroundTheme } = useBackgroundTheme ( )
7978 const connectorModal = useModal ( 'connector-modal' )
8079 const authModal = useModal ( 'auth-modal' )
8180 const keyboardShortcutsModal = useModal ( 'keyboard-shortcuts-modal' )
@@ -108,28 +107,25 @@ export function useCommandPaletteGlobalCommands() {
108107 return typeof current === 'string' ? current : ( current . name ?? current . code )
109108 } )
110109 const currentAccentColorLabel = computed ( ( ) => {
111- const activeAccentColorId = selectedAccentColorOptionId . value
112- const activeAccentColor = accentColors . value . find ( color => color . id === activeAccentColorId )
113-
114- if ( ! activeAccentColor ) return activeAccentColorId
115- return activeAccentColor . id === 'neutral'
116- ? t ( 'settings.accent_colors.neutral' )
117- : activeAccentColor . label
110+ const id = selectedAccentColor . value
111+ if ( ! id ) return t ( 'settings.accent_colors.neutral' )
112+ const color = accentColors . value . find ( c => c . id === id )
113+ return color ?. label ?? id
118114 } )
119115 const currentAccentColorPreview = computed ( ( ) => {
120- const activeAccentColorId = selectedAccentColorOptionId . value
121- return accentColors . value . find ( color => color . id === activeAccentColorId ) ?. value ?? null
116+ const id = selectedAccentColor . value
117+ if ( ! id ) return null
118+ return accentColors . value . find ( c => c . id === id ) ?. value ?? null
122119 } )
123120 const currentBackgroundThemeLabel = computed ( ( ) => {
124- const activeBackgroundThemeId = selectedBackgroundThemeOptionId . value
125- return (
126- backgroundThemes . value . find ( theme => theme . id === activeBackgroundThemeId ) ?. label ??
127- activeBackgroundThemeId
128- )
121+ const id = selectedBackgroundTheme . value
122+ if ( ! id ) return t ( 'settings.background_themes.neutral' )
123+ return backgroundThemes . value . find ( t => t . id === id ) ?. label ?? id
129124 } )
130125 const currentBackgroundThemePreview = computed ( ( ) => {
131- const activeBackgroundThemeId = selectedBackgroundThemeOptionId . value
132- return backgroundThemes . value . find ( theme => theme . id === activeBackgroundThemeId ) ?. value ?? null
126+ const id = selectedBackgroundTheme . value
127+ if ( ! id ) return null
128+ return backgroundThemes . value . find ( t => t . id === id ) ?. value ?? null
133129 } )
134130 const localeCommands = computed < CommandPaletteCommand [ ] > ( ( ) =>
135131 locales . value . map ( entry => {
@@ -159,7 +155,7 @@ export function useCommandPaletteGlobalCommands() {
159155 } ) ,
160156 )
161157 const accentColorCommands = computed < CommandPaletteCommand [ ] > ( ( ) => {
162- const activeAccentColorId = selectedAccentColorOptionId . value
158+ const activeId = selectedAccentColor . value
163159
164160 return accentColors . value . map ( color => ( {
165161 id : `accent-color:${ color . id } ` ,
@@ -168,11 +164,13 @@ export function useCommandPaletteGlobalCommands() {
168164 keywords : [ color . label , color . id , t ( 'settings.accent_colors.label' ) , t ( 'settings.theme' ) ] ,
169165 iconClass : 'i-lucide:palette' ,
170166 previewColor : color . value ,
171- active : color . id === activeAccentColorId ,
172- activeLabel : color . id === activeAccentColorId ? t ( 'command_palette.current' ) : null ,
167+ active : color . id === 'neutral' ? ! activeId : color . id === activeId ,
168+ activeLabel : ( color . id === 'neutral' ? ! activeId : color . id === activeId )
169+ ? t ( 'command_palette.current' )
170+ : null ,
173171 action : runThenAnnounce (
174172 ( ) => {
175- setAccentColor ( color . id )
173+ setAccentColor ( color . id === 'neutral' ? null : color . id )
176174 } ,
177175 ( ) =>
178176 t ( 'command_palette.announcements.accent_color_changed' , {
@@ -182,7 +180,7 @@ export function useCommandPaletteGlobalCommands() {
182180 } ) )
183181 } )
184182 const backgroundThemeCommands = computed < CommandPaletteCommand [ ] > ( ( ) => {
185- const activeBackgroundThemeId = selectedBackgroundThemeOptionId . value
183+ const activeId = selectedBackgroundTheme . value
186184
187185 return backgroundThemes . value . map ( theme => ( {
188186 id : `background-theme:${ theme . id } ` ,
@@ -191,8 +189,10 @@ export function useCommandPaletteGlobalCommands() {
191189 keywords : [ theme . label , theme . id , t ( 'settings.background_themes.label' ) , t ( 'settings.theme' ) ] ,
192190 iconClass : 'i-lucide:swatch-book' ,
193191 previewColor : theme . value ,
194- active : theme . id === activeBackgroundThemeId ,
195- activeLabel : theme . id === activeBackgroundThemeId ? t ( 'command_palette.current' ) : null ,
192+ active : theme . id === 'neutral' ? ! activeId : theme . id === activeId ,
193+ activeLabel : ( theme . id === 'neutral' ? ! activeId : theme . id === activeId )
194+ ? t ( 'command_palette.current' )
195+ : null ,
196196 action : runThenAnnounce (
197197 ( ) => {
198198 setBackgroundTheme ( theme . id )
0 commit comments