import React, { useState, Fragment } from 'react' import { Dialog, Menu, Portal, Transition } from '@headlessui/react' import { usePopper } from '../../playground-utils/hooks/use-popper' function classNames(...classes) { return classes.filter(Boolean).join(' ') } function resolveClass({ active, disabled }) { return classNames( 'flex justify-between w-full px-4 py-2 text-sm leading-5 text-left', active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', disabled && 'cursor-not-allowed opacity-50' ) } function Nested({ onClose, level = 0 }) { let [showChild, setShowChild] = useState(false) return ( <> {true && } Level: {level} setShowChild(true)}> Open (1) setShowChild(true)}> Open (2) setShowChild(true)}> Open (3) {showChild && setShowChild(false)} level={level + 1} />} > ) } export default function Home() { let [isOpen, setIsOpen] = useState(false) let [nested, setNested] = useState(false) let [trigger, container] = usePopper({ placement: 'bottom-end', strategy: 'fixed', modifiers: [{ name: 'offset', options: { offset: [0, 10] } }], }) return ( <> setIsOpen(v => !v)} className="m-12 px-4 py-2 text-base font-medium leading-6 text-gray-700 transition duration-150 ease-in-out bg-white border border-gray-300 rounded-md shadow-sm hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue sm:text-sm sm:leading-5" > Toggle! setNested(true)}>Show nested {nested && setNested(false)} />} {/* This element is to trick the browser into centering the modal contents. */} {/* Heroicon name: exclamation */} Deactivate account Are you sure you want to deactivate your account? All of your data will be permanently removed. This action cannot be undone. {({ open }) => ( <> Choose a reason Signed in as tom@example.com Account settings Support New feature (soon) License Sign out > )} setIsOpen(false)} className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:shadow-outline-red sm:ml-3 sm:w-auto sm:text-sm" > Deactivate setIsOpen(false)} className="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:shadow-outline-indigo sm:mt-0 sm:w-auto sm:text-sm" > Cancel > ) }
Level: {level}
Are you sure you want to deactivate your account? All of your data will be permanently removed. This action cannot be undone.
Signed in as
tom@example.com