import { Dropdown, Tooltip } from "@wordpress/components"; import { useRef, useState } from "@wordpress/element"; import "./editor.scss"; import { DropdownIcon } from "../../icons/icons"; const SPIconPicker = ({ attributes, attributesKey, setAttributes, label, closeBtn = true, iconType = "socialIcon", }) => { const socialIcon = [ "facebook", "x", "linkedin", "pinterest", "instagram", "vkontakte", "digg", "tumblr", "reddit", "whatsapp", "pocket", "xing", "mail", ]; const arrowIcon = [ "right-circled2", "left-circled2", "right-open", "right-open-mini", "right-open-big", "right-open-one", "left-open-one", "right-open-outline", "left-open", "left-open-mini", "left-open-big", "left-open-outline", "left-dir", "right-dir", "left-one", "right-one", "angles-right-solid", "arrow-right-solid", "forward-solid", "right-long-solid", "angle-up", ]; const icons = iconType === "socialIcon" ? socialIcon : arrowIcon; const activeIconRef = useRef(null); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const handleChange = (newIcon) => { setAttributes({ [attributesKey]: newIcon }); }; const handleClose = () => { setAttributes({ [attributesKey]: "" }); }; return (
{label}
{/* modal */} (
{ setIsDropdownOpen((prev) => !prev); onToggle(); }} aria-expanded={isOpen} className="sp-smart-post-icon-picker-dropdown-input" >
{attributes ? ( <>
{closeBtn && ( )} ) : ( )}
)} onClose={(event, isInside) => { setIsDropdownOpen(false); if (isInside) { event.stopPropagation(); } }} renderContent={({ onToggle }) => (
{ event.stopPropagation(); }} className="sp-smart-post-icon-picker-popup" >
Select an Icon Choose an icon for this collection.
{icons?.map((icon, index) => ( handleChange(icon)} > ))}
)} />
); }; export default SPIconPicker;