mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 06:24:25 +01:00
feat: show thread
This commit is contained in:
31
src/components/ColumnContext.tsx
Normal file
31
src/components/ColumnContext.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
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),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user