-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6583f8
commit 0ebac66
Showing
31 changed files
with
386 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Block } from '@/lib/types'; | ||
import { Button } from '../ui/button'; | ||
|
||
const ButtonBlock: Block = () => { | ||
return <Button>Click me</Button>; | ||
}; | ||
|
||
ButtonBlock.Schema = { | ||
name: 'button', | ||
id: 'button', | ||
sideEditingProps: [], | ||
defaultPropValues: {}, | ||
}; | ||
|
||
export default ButtonBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { BlockList } from '../../lib/exposed-types'; | ||
import BlogContent from './blog-content'; | ||
import ButtonBlock from './button'; | ||
import Footer from './footer'; | ||
import Hero from './hero'; | ||
import Navbar from './navbar'; | ||
import Table from './table'; | ||
import Testimonial from './testimonials'; | ||
import VideoSection from './video-section'; | ||
|
||
const blocks = [Hero, Navbar, Testimonial, Footer, BlogContent, VideoSection, Table] as unknown as BlockList[]; | ||
const blocks = [Hero, Navbar, Testimonial, Footer, BlogContent, VideoSection, Table, ButtonBlock] as unknown as BlockList[]; | ||
|
||
export default blocks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,75 @@ | ||
import BlockItem from "@/components/pages/page-content/components/bock-item" | ||
import EmptyPageDroppable from "@/components/pages/page-content/components/emptyPageDroppable" | ||
import { PageBlock } from "@/lib/exposed-types" | ||
import usePageContent from "@/lib/hooks/usePageContent" | ||
import { usePageContentState } from "@/lib/states/usePageContentState" | ||
import { useProjectConfigurationState } from "@/lib/states/useProjectConfigState" | ||
import { cn, getProjectMode } from "@/lib/utils" | ||
import BlockItem from '@/components/pages/page-content/components/bock-item'; | ||
import EmptyPageDroppable from '@/components/pages/page-content/components/emptyPageDroppable'; | ||
import { PageBlock } from '@/lib/exposed-types'; | ||
import usePageContent from '@/lib/hooks/usePageContent'; | ||
import { usePageContentState } from '@/lib/states/usePageContentState'; | ||
import { useProjectConfigurationState } from '@/lib/states/useProjectConfigState'; | ||
import { cn, getProjectMode } from '@/lib/utils'; | ||
|
||
type SlotProps = { | ||
pageBlocks: PageBlock[] | ||
direction?: 'horizontal' | 'vertical', | ||
className?: string, | ||
propName: string | ||
pageBlockId: string | ||
} | ||
export default function Slot({pageBlocks, direction, className, propName, pageBlockId}:SlotProps){ | ||
const { activePage } = usePageContent(); | ||
const { blocks: builderBlocks } = useProjectConfigurationState(); | ||
const {blocks: liveBlocks, globalBlocks} = usePageContentState(); | ||
const isLiveMode = getProjectMode() === 'LIVE' | ||
pageBlocks: PageBlock[]; | ||
direction?: 'horizontal' | 'vertical'; | ||
className?: string; | ||
propName: string; | ||
pageBlockId: string; | ||
}; | ||
export default function Slot({ pageBlocks, direction = 'vertical', className, propName, pageBlockId }: SlotProps) { | ||
const { activePage } = usePageContent(); | ||
const { blocks: builderBlocks } = useProjectConfigurationState(); | ||
const { blocks: liveBlocks, globalBlocks } = usePageContentState(); | ||
const isBuilderMode = getProjectMode() === 'BUILDER'; | ||
|
||
if (pageBlocks.length === 0 && activePage) { | ||
return ( | ||
<EmptyPageDroppable | ||
activePage={activePage} | ||
propName={propName} | ||
pageBlockId={pageBlockId} | ||
className="!visio-cms-h-full !visio-cms-min-h-[50px]" | ||
/> | ||
); | ||
} | ||
|
||
if (pageBlocks.length === 0 && activePage) { | ||
return <EmptyPageDroppable activePage={activePage} propName={propName} pageBlockId={pageBlockId} className="h-full" />; | ||
} | ||
const blocks = getProjectMode() === 'LIVE' ? liveBlocks : builderBlocks; | ||
|
||
const blocks = isLiveMode ? liveBlocks : builderBlocks | ||
const divClass = cn('visio-cms-relative visio-cms-flex', className, { | ||
'visio-cms-flex-row visio-cms-w-full visio-cms-items-center visio-cms-bg-red-500': direction === 'horizontal', | ||
'visio-cms-flex-col': direction === 'vertical', | ||
}); | ||
|
||
const divClass = cn('relative flex flex-col',className, { | ||
'flex-row': direction === 'horizontal', | ||
}) | ||
if (!isBuilderMode) { | ||
return ( | ||
<div className={cn(divClass)}> | ||
{pageBlocks?.map((block) => { | ||
const globalBlock = globalBlocks?.find((b) => b.id === block?.globalBlockId); | ||
const Block = blocks.find((b) => b.Schema.id === (globalBlock?.blockId || block.blockId)); | ||
if (!Block) return null; | ||
const inputs = { ...Block.Schema.defaultPropValues, ...block.inputs, ...globalBlock?.inputs }; | ||
return <Block key={block.id} {...inputs} />; | ||
})} | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className={cn(divClass)}> | ||
{pageBlocks.map((pageBlock, index) => { | ||
const { blockId } = pageBlock; | ||
const block = blocks.find((block) => block.Schema.id === blockId); | ||
|
||
if(isLiveMode){ | ||
if (!block) return null; | ||
return ( | ||
<div className={cn(divClass)}> | ||
{ pageBlocks?.map((block) => { | ||
const globalBlock = globalBlocks?.find((b) => b.id === block?.globalBlockId); | ||
const Block = blocks.find((b) => b.Schema.id === (globalBlock?.blockId || block.blockId)); | ||
if (!Block) return null; | ||
const inputs = { ...Block.Schema.defaultPropValues, ...block.inputs, ...globalBlock?.inputs }; | ||
return <Block key={block.id} {...inputs} />; | ||
})} | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div className={cn(divClass)}> | ||
{pageBlocks.map((pageBlock, index)=>{ | ||
const { blockId } = pageBlock; | ||
const block = blocks.find((block) => block.Schema.id === blockId); | ||
|
||
if (!block) return null; | ||
return ( | ||
<BlockItem parentBlockId={pageBlockId} propName={propName} key={pageBlock.id} block={block} index={index} pageBlock={pageBlock} pageBlocks={pageBlocks} /> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
<BlockItem | ||
droppableDirection={direction} | ||
parentBlockId={pageBlockId} | ||
propName={propName} | ||
key={pageBlock.id} | ||
block={block} | ||
index={index} | ||
pageBlock={pageBlock} | ||
pageBlocks={pageBlocks} | ||
/> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.