mirror of
https://github.com/khairul169/code-share.git
synced 2026-10-24 11:53:58 +07:00
feat: rebuild app using vike
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { FileSchema } from "~/server/db/schema/file";
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
type TEditorContext = {
|
||||
onOpenFile: (fileId: number) => void;
|
||||
onFileChanged: (file: Omit<FileSchema, "content">) => void;
|
||||
onDeleteFile: (fileId: number) => void;
|
||||
};
|
||||
|
||||
const EditorContext = createContext<TEditorContext | null>(null);
|
||||
|
||||
export const useEditorContext = () => {
|
||||
const ctx = useContext(EditorContext);
|
||||
if (!ctx) {
|
||||
throw new Error("Component not in EditorContext!");
|
||||
}
|
||||
|
||||
return ctx;
|
||||
};
|
||||
|
||||
export default EditorContext;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
type TProjectContext = {
|
||||
slug: string;
|
||||
isCompact?: boolean;
|
||||
};
|
||||
|
||||
const ProjectContext = createContext<TProjectContext | null>(null);
|
||||
|
||||
export const useProjectContext = () => {
|
||||
const ctx = useContext(ProjectContext);
|
||||
if (!ctx) {
|
||||
throw new Error("Component not in ProjectContext!");
|
||||
}
|
||||
|
||||
return ctx;
|
||||
};
|
||||
|
||||
export default ProjectContext;
|
||||
Reference in New Issue
Block a user