import React, {useRef, useState} from 'react'; import {VscChevronDown} from '@react-icons/all-files/vsc/VscChevronDown'; import type {configOptions} from '../config'; import useClickAway from 'react-use/lib/useClickAway'; interface Props { defaultProfile: string; profiles: configOptions['profiles']; openNewTab: (name: string) => void; backgroundColor: string; borderColor: string; tabsVisible: boolean; } const isMac = /Mac/.test(navigator.userAgent); const DropdownButton = ({defaultProfile, profiles, openNewTab, backgroundColor, borderColor, tabsVisible}: Props) => { const [dropdownOpen, setDropdownOpen] = useState(false); const ref = useRef(null); const toggleDropdown = () => { setDropdownOpen(!dropdownOpen); }; useClickAway(ref, () => { setDropdownOpen(false); }); return (
e.stopPropagation()} onBlur={() => setDropdownOpen(false)} > {dropdownOpen && ( )}
); }; export default DropdownButton;