/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { useEffect, useRef, useState } from "react"; // plane imports import { useOutsideClickDetector } from "@plane/hooks"; import { ChevronDownOutline } from "@makeplane/propel/icons"; import { Tooltip } from "@plane/propel/tooltip"; // local imports import type { TCustomImageAlignment } from "../../types"; import { IMAGE_ALIGNMENT_OPTIONS } from "../../utils"; type Props = { activeAlignment: TCustomImageAlignment; handleChange: (alignment: TCustomImageAlignment) => void; isTouchDevice: boolean; toggleToolbarViewStatus: (val: boolean) => void; }; export function ImageAlignmentAction(props: Props) { const { activeAlignment, handleChange, isTouchDevice, toggleToolbarViewStatus } = props; // states const [isDropdownOpen, setIsDropdownOpen] = useState(false); // refs const dropdownRef = useRef(null); // derived values const activeAlignmentDetails = IMAGE_ALIGNMENT_OPTIONS.find((option) => option.value === activeAlignment); useOutsideClickDetector(dropdownRef, () => setIsDropdownOpen(false)); useEffect(() => { toggleToolbarViewStatus(isDropdownOpen); }, [isDropdownOpen, toggleToolbarViewStatus]); return (
{isDropdownOpen && (
{IMAGE_ALIGNMENT_OPTIONS.map((option) => ( ))}
)}
); }