mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-17 14:04:21 +01:00
32 lines
837 B
TypeScript
32 lines
837 B
TypeScript
import { createContext, useContext, type JSX } from 'solid-js';
|
|
import { createStore } from 'solid-js/store';
|
|
|
|
export type ColumnContent = {
|
|
type: 'Replies';
|
|
eventId: string;
|
|
};
|
|
|
|
export type ColumnState = {
|
|
content?: ColumnContent;
|
|
};
|
|
|
|
export type UseColumnState = {
|
|
columnState: ColumnState;
|
|
setColumnContent: (content: ColumnContent) => void;
|
|
clearColumnContext: () => void;
|
|
};
|
|
|
|
export const ColumnContext = createContext<UseColumnState>();
|
|
|
|
export const useColumnContext = () => useContext(ColumnContext);
|
|
|
|
export const useColumnState = (): UseColumnState => {
|
|
const [columnState, setColumnState] = createStore<ColumnState>({});
|
|
|
|
return {
|
|
columnState,
|
|
setColumnContent: (content: ColumnContent) => setColumnState('content', content),
|
|
clearColumnContext: () => setColumnState('content', undefined),
|
|
};
|
|
};
|