Skip to content

Commit

Permalink
feat: added optional tabs and exported useDraggedblock atom
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul-ku-Mo committed Dec 23, 2024
1 parent 0259d96 commit 65b72a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ const AddBlocksPanel = ({
className,
showHeading = true,
parentId = undefined,
tabs = ["library", "core", "html"],
}: {
parentId?: string;
showHeading?: boolean;
className?: string;
tabs?: string[];
}) => {
const { t } = useTranslation();
const [tab, setTab] = useAtom(addBlockTabAtom);
Expand Down Expand Up @@ -100,15 +102,15 @@ const AddBlocksPanel = ({
{importHTMLSupport ? <TabsTrigger value="html">{t("Import")}</TabsTrigger> : null}
</TabsList>
</Tabs>
{tab === "core" && (
{tabs.includes("core") && tab === "core" && (
<ScrollArea className="-mx-1.5 h-[calc(100vh-156px)] overflow-y-auto">
<div className="mt-2 w-full">
<DefaultChaiBlocks gridCols={"grid-cols-4"} parentId={parentId} />
</div>
</ScrollArea>
)}
{tab === "library" && <UILibraries parentId={parentId} />}
{tab === "html" && importHTMLSupport ? <ImportHTML parentId={parentId} /> : null}
{tabs.includes("library") && tab === "library" && <UILibraries parentId={parentId} />}
{tabs.includes("html") && tab === "html" && importHTMLSupport ? <ImportHTML parentId={parentId} /> : null}
</div>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/core/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useCodeEditor } from "./useCodeEditor.ts";
import { useGlobalBlocksList, useGlobalBlocksStore } from "./useGlobalBlocksStore.ts";
import { useLanguages } from "./useLanguages.ts";
import { useBlockHighlight } from "./useBlockHighlight.ts";
import { useDraggedBlock } from "./useDraggedBlock.ts";
export { useLayoutVariant } from "./useLayoutVariant.ts";
export { useBlocksStoreUndoableActions } from "../history/useBlocksStoreUndoableActions.ts";
export {
Expand All @@ -44,6 +45,7 @@ export {
useBuilderReset,
useAddBlock,
useAddClassesToBlocks,
useDraggedBlock,
useCanvasWidth,
useCanvasZoom,
useBuilderProp,
Expand Down
7 changes: 7 additions & 0 deletions src/core/hooks/useDraggedBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useAtom } from "jotai";
import { draggedBlockAtom } from "../components/canvas/dnd/atoms.ts";

export const useDraggedBlock = () => {
const [draggedBlock, setDraggedBlockAtom] = useAtom(draggedBlockAtom);
return [draggedBlock, setDraggedBlockAtom];
};

0 comments on commit 65b72a6

Please sign in to comment.