import _ from 'lodash' import React from 'react' window.lodash = _.noConflict() import { Switch } from "@headlessui/react"; declare global { interface Props {} interface Window { wp:any, lodash:any } interface Math { round:(x: number) => number } } const CustomToggle:React.FC<{ title:string,attrname:string,attrval:boolean,width?:string,className?:string,style?:any,setAttributes:any }> = props => { const {title,attrname,attrval,width="6",className="",style={},setAttributes=()=>{}} = props; let w = Math.round((parseInt(width)/12)*100)+'%' return (
{title} {setAttributes({[attrname]:!attrval});}} className={`${ attrval ? "bg-teal-600" : "bg-gray-200" } relative inline-flex flex-shrink-0 h-6 transition-colors duration-200 ease-in-out border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:shadow-outline`}> {({ checked }) => ( )}
); } export default CustomToggle