feat(SW-66, SW-348): search functionality and ui
This commit is contained in:
64
components/Blocks/index.tsx
Normal file
64
components/Blocks/index.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import CardsGrid from "@/components/Blocks/CardsGrid"
|
||||
import DynamicContent from "@/components/Blocks/DynamicContent"
|
||||
import Shortcuts from "@/components/Blocks/Shortcuts"
|
||||
import TextCols from "@/components/Blocks/TextCols"
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
|
||||
import type { BlocksProps } from "@/types/components/blocks"
|
||||
import { BlocksEnums } from "@/types/enums/blocks"
|
||||
|
||||
export default function Blocks({ blocks }: BlocksProps) {
|
||||
return blocks.map((block, idx) => {
|
||||
const firstItem = idx === 0
|
||||
switch (block.typename) {
|
||||
case BlocksEnums.block.CardsGrid:
|
||||
return (
|
||||
<CardsGrid
|
||||
cards_grid={block.cards_grid}
|
||||
key={`${block.cards_grid.title}-${idx}`}
|
||||
firstItem={firstItem}
|
||||
/>
|
||||
)
|
||||
case BlocksEnums.block.Content:
|
||||
return (
|
||||
<section key={`${block.typename}-${idx}`}>
|
||||
<JsonToHtml
|
||||
nodes={block.content.json.children}
|
||||
embeds={block.content.embedded_itemsConnection.edges}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
case BlocksEnums.block.DynamicContent:
|
||||
return (
|
||||
<DynamicContent
|
||||
dynamic_content={block.dynamic_content}
|
||||
firstItem={firstItem}
|
||||
key={`${block.dynamic_content.title}-${idx}`}
|
||||
/>
|
||||
)
|
||||
case BlocksEnums.block.Shortcuts:
|
||||
return (
|
||||
<Shortcuts
|
||||
firstItem={firstItem}
|
||||
key={`${block.shortcuts.title}-${idx}`}
|
||||
shortcuts={block.shortcuts.shortcuts}
|
||||
subtitle={block.shortcuts.subtitle}
|
||||
title={block.shortcuts.title}
|
||||
/>
|
||||
)
|
||||
case BlocksEnums.block.TextCols:
|
||||
return <TextCols text_cols={block.text_cols} />
|
||||
case BlocksEnums.block.TextContent:
|
||||
return (
|
||||
<section key={`${block.typename}-${idx}`}>
|
||||
<JsonToHtml
|
||||
embeds={block.text_content.content.embedded_itemsConnection.edges}
|
||||
nodes={block.text_content.content.json.children}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
default:
|
||||
return null
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user