nitropage
Version:
A free and open source, extensible visual page builder based on SolidStart.
27 lines (23 loc) • 696 B
text/typescript
import { createId } from "@paralleldrive/cuid2";
import { createMemo, useContext } from "solid-js";
import { Element } from "../../../../../types";
import { NONE_BLUEPRINT_ID } from "../../../../lib/constants";
import { EditorUiContext } from "../../../../lib/context/admin";
export const useCanHover = () => {
const [editorUi] = useContext(EditorUiContext)!;
return createMemo(
() =>
["selecting", "moving", "deleting"].indexOf(editorUi.viewport.tool) !==
-1,
);
};
export const createElement = (parentSlotId?: string) => {
const id = createId();
return {
id,
parentSlotId,
blueprintId: NONE_BLUEPRINT_ID,
data: {},
slots: {},
} as Element;
};