Skip to content

Commit c3e7dab

Browse files
committed
feat: add Zustand store for managing flow view side panel state
1 parent 55d50aa commit c3e7dab

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {create} from "zustand"
2+
3+
/**
4+
* Shared state for the flow view side panels (file / execution). Lifting this out of
5+
* the page component lets deeply nested components (e.g. the definition panel dialog)
6+
* open a specific panel without prop drilling.
7+
*/
8+
interface FlowViewState {
9+
tab?: string
10+
setTab: (tab?: string) => void
11+
toggleTab: (tab: string) => void
12+
}
13+
14+
export const useFlowViewStore = create<FlowViewState>((setState) => ({
15+
tab: undefined,
16+
setTab: (tab) => setState({tab}),
17+
toggleTab: (tab) => setState((state) => ({tab: state.tab === tab ? undefined : tab})),
18+
}))

0 commit comments

Comments
 (0)