toggle search input

This commit is contained in:
AykutSarac 2022-04-09 23:20:07 +03:00
parent 75850a7709
commit 7282bfd2af
3 changed files with 13 additions and 0 deletions

View File

@ -38,6 +38,7 @@ export const defaultConfig: StorageConfig = {
expand: true,
autoformat: true,
hideEditor: false,
showSearch: false,
zoomScale: 0.8,
transform: 0,
searchNode: "",

View File

@ -8,6 +8,7 @@ export enum ConfigActionType {
TOGGLE_EXPAND,
TOGGLE_AUTOFORMAT,
TOGGLE_DOCK,
TOGGLE_SEARCH,
ZOOM_IN,
ZOOM_OUT,
CENTER_VIEW,
@ -28,6 +29,16 @@ export const useConfigReducer: React.Reducer<AppConfig, ReducerAction> = (
case ConfigActionType.SET_CONFIG:
return { ...state, settings: action.payload };
case ConfigActionType.TOGGLE_SEARCH:
return {
...state,
settings: {
...state.settings,
showSearch: !state.settings.showSearch,
...(state.settings.showSearch && { searchNode: "" }),
},
};
case ConfigActionType.SET_SEARCH_NODE:
return {
...state,

View File

@ -5,6 +5,7 @@ export interface StorageConfig {
expand: boolean;
autoformat: boolean;
hideEditor: boolean;
showSearch: boolean;
zoomScale: number;
transform: number;
searchNode: string;