fdd2629795
* use esbuild for React instead of tsdx * remove tsdx from Vue * use consistent names * add jest and prettier * update scripts * ignore some folders for prettier * run lint script instead of tsdx lint * run prettier en-masse This has a few changes because of the new prettier version. * bump typescript to latest version * make typescript happy * cleanup playground package.json * make esbuild a dev dependency * make scripts consistent * fix husky hooks * add dedicated watch script * add `yarn playground-react` and `yarn react-playground` (alias) This will make sure to run a watcher for the actual @headlessui/react package, and start a development server in the playground-react package. * ignore formatting in the .next folder * run prettier on playground-react package * setup playground-vue Still not 100% working, but getting there! * add playground aliases in @headlessui/vue and @headlessui/react This allows you to run `yarn react playground` or `yarn vue playground` from the root. * add `clean` script * move examples folder in playground-vue to root * ensure new lines for consistency in scripts * fix typescript issue * fix typescript issues in playgrounds * make sure to run prettier on everything it can * run prettier on all files * improve error output If you minify the code, then it could happen that the errors are a bit obscure. This will hardcode the component name to improve errors. * add the `prettier-plugin-tailwindcss` plugin, party! * update changelog
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import React, { useState, ReactNode } from 'react'
|
|
import { Transition } from '@headlessui/react'
|
|
|
|
export default function Home() {
|
|
let [isOpen, setIsOpen] = useState(true)
|
|
|
|
return (
|
|
<>
|
|
<div className="flex h-full w-screen justify-center bg-gray-50 p-12">
|
|
<div className="w-96 space-y-2">
|
|
<span className="inline-flex rounded-md shadow-sm">
|
|
<button
|
|
type="button"
|
|
onClick={() => setIsOpen((v) => !v)}
|
|
className="duration-150-out focus:shadow-outline-blue inline-flex items-center rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium leading-4 text-gray-700 transition hover:text-gray-500 focus:border-blue-300 focus:outline-none active:bg-gray-50 active:text-gray-800"
|
|
>
|
|
{isOpen ? 'Hide' : 'Show'}
|
|
</button>
|
|
</span>
|
|
|
|
<Transition show={isOpen} unmount={false}>
|
|
<Box>
|
|
<Box>
|
|
<Box>
|
|
<Box />
|
|
</Box>
|
|
<Box>
|
|
<Box>
|
|
<Box>
|
|
<Box />
|
|
</Box>
|
|
</Box>
|
|
</Box>
|
|
</Box>
|
|
</Box>
|
|
</Transition>
|
|
</div>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
function Box({ children }: { children?: ReactNode }) {
|
|
return (
|
|
<Transition.Child
|
|
unmount={false}
|
|
enter="transition translate duration-300"
|
|
enterFrom="transform -translate-x-full"
|
|
enterTo="transform translate-x-0"
|
|
leave="transition translate duration-300"
|
|
leaveFrom="transform translate-x-0"
|
|
leaveTo="transform translate-x-full"
|
|
>
|
|
<div className="space-y-2 rounded-md bg-white p-4 text-sm font-semibold uppercase tracking-wide text-gray-700 shadow">
|
|
<span>This is a box</span>
|
|
{children}
|
|
</div>
|
|
</Transition.Child>
|
|
)
|
|
}
|