mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-29 02:04:48 +08:00
31 lines
635 B
TypeScript
31 lines
635 B
TypeScript
import { isUndefined } from "lodash-es";
|
|
import { create } from "zustand";
|
|
|
|
// reference: https://tailwindcss.com/docs/responsive-design
|
|
export enum ResponsiveWidth {
|
|
sm = 640,
|
|
lg = 1024,
|
|
}
|
|
|
|
interface LayoutState {
|
|
showSidebar: boolean;
|
|
toggleSidebar: (show?: boolean) => void;
|
|
}
|
|
|
|
export const useLayoutStore = create<LayoutState>()((set) => ({
|
|
showSidebar: true,
|
|
toggleSidebar: (show) => {
|
|
if (isUndefined(show)) {
|
|
set((state) => ({
|
|
...state,
|
|
showSidebar: !state.showSidebar,
|
|
}));
|
|
} else {
|
|
set((state) => ({
|
|
...state,
|
|
showSidebar: show,
|
|
}));
|
|
}
|
|
},
|
|
}));
|