Skip to content

Commit

Permalink
fix: add placeholder setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Pkcarreno committed Jan 8, 2025
1 parent 71a9c3f commit e5aa8df
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Label } from '@/components/ui/label';
import { Switch } from '@/components/ui/switch';
import { useSettingsStore } from '@/features/editor/stores/settings';

export const EditorPlaceholderSettings = () => {
const { editorPlaceholder, updateEditorPlaceholder } = useSettingsStore();

return (
<div className="grid gap-2">
<div className="flex items-center justify-between gap-2">
<Label>Placeholder</Label>
<Switch
onCheckedChange={updateEditorPlaceholder}
checked={editorPlaceholder}
/>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { EditorPlaceholderSettings } from './editor-placeholder-settings';
import { VimModeSettings } from './vim-mode-settings';

export const EditorSettings = () => {
return (
<div className="grid gap-4">
<h3 className="font-medium leading-none">Editor</h3>
<EditorPlaceholderSettings />
<VimModeSettings />
</div>
);
Expand Down
9 changes: 8 additions & 1 deletion src/features/editor/stores/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface SettingsState {
layout_direction: PanelGroupProps['direction'];
isFirstTime: boolean;
vimMode: boolean;
editorPlaceholder: boolean;
debugMode: boolean;
updateAutoRun: (value: boolean) => void;
updateAutoRunTimeout: (value: number) => void;
Expand All @@ -22,6 +23,7 @@ export interface SettingsState {
updateLayoutDirection: (value: PanelGroupProps['direction']) => void;
updateIsFirstTime: (value: boolean) => void;
updateVimMode: (value: boolean) => void;
updateEditorPlaceholder: (value: boolean) => void;
updateDebugMode: (value: boolean) => void;
}

Expand All @@ -36,6 +38,7 @@ const _useSettingsStore = create<SettingsState>()(
layout_direction: 'horizontal',
isFirstTime: true,
vimMode: false,
editorPlaceholder: false,
debugMode: false,
updateAutoRun: (value) => set({ auto_run: value }),
updateAutoRunTimeout: (value) => set({ auto_run_timeout: value }),
Expand All @@ -47,11 +50,12 @@ const _useSettingsStore = create<SettingsState>()(
updateLayoutDirection: (value) => set({ layout_direction: value }),
updateIsFirstTime: (value) => set({ isFirstTime: value }),
updateVimMode: (value) => set({ vimMode: value }),
updateEditorPlaceholder: (value) => set({ editorPlaceholder: value }),
updateDebugMode: (value) => set({ debugMode: value }),
}),
{
name: 'settings-storage',
version: 2,
version: 3,
migrate: (persistedState, version) => {
if (version === 0) {
(persistedState as SettingsState).vimMode = false;
Expand All @@ -61,6 +65,9 @@ const _useSettingsStore = create<SettingsState>()(
if (version === 1) {
(persistedState as SettingsState).auto_run = true;
}
if (version === 2) {
(persistedState as SettingsState).editorPlaceholder = true;
}

return persistedState;
},
Expand Down

0 comments on commit e5aa8df

Please sign in to comment.