import { isEditor } from "../../controls/controls"; import TemplateOne from "../shared/templates/templateCards/templateOne"; import { usePanelBodyContext } from "../../context"; import { Fragment, useEffect, useRef, useState } from "@wordpress/element"; import { ProTopBar } from "../shared/helpFn"; const ListDivider = () => { const { togglePanelBody } = usePanelBodyContext(); return (
(editPage ? togglePanelBody("divider", e) : () => {})} className="sp-smart-post-list-divider" >
); }; const Render = ({ attributes, posts }) => { const { postListLayout, contentVerticalPosition, showHideDivider, imageOverlayColor, catTabCategoryPosition, blockName } = attributes; const containerRef = useRef(null); const layoutClass = () => { if ( "sp-smart-post-list-two-layout-four" === postListLayout || "sp-smart-post-list-two-layout-seven" === postListLayout || "sp-smart-post-list-two-layout-eight" === postListLayout || "sp-smart-post-list-two-layout-three" === postListLayout ) { return "sp-smart-post-list-two-layout-three" !== postListLayout ? `sp-smart-post-list-two-layout-three ${postListLayout}` : postListLayout; } return `sp-smart-post-list-two-bg-layout ${postListLayout}`; }; const bgClass = [ "sp-smart-post-list-two-layout-one", "sp-smart-post-list-two-layout-two", "sp-smart-post-list-two-layout-five", "sp-smart-post-list-two-layout-six", ].includes(postListLayout) ? "sp-smart-post-background-layout" : ""; const [selectedPostId, setSelectedPostId] = useState(null); useEffect(() => { const handleClickOutside = (event) => { if (containerRef.current && !containerRef.current.contains(event.target)) { setSelectedPostId(null); } }; document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); }, []); const TemplateOneSimplify = ({ post, type }) => { return ( setSelectedPostId(post?.post_id)} /> ); }; return ( <>
{posts?.slice(0, 1)?.map((post, i) => { return (
{/* setSelectedPostId(post?.post_id) } /> */}
); })}
{showHideDivider && [ "sp-smart-post-list-two-layout-three", "sp-smart-post-list-two-layout-four", "sp-smart-post-list-two-layout-seven", "sp-smart-post-list-two-layout-eight", ].includes(postListLayout) && }
{posts?.slice(1)?.map((post, i) => { return (
{/* setSelectedPostId(post?.post_id) } /> */}
{showHideDivider && [ "sp-smart-post-list-two-layout-one", "sp-smart-post-list-two-layout-seven", ].includes(postListLayout) && }
); })}
); }; export default Render;