Skip to content

Commit

Permalink
update playgrounds to reflect tag change
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Apr 18, 2024
1 parent c2215f7 commit 965a335
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 22 deletions.
5 changes: 2 additions & 3 deletions playgrounds/react/pages/dialog/dialog-scroll-issue.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Dialog, Transition } from '@headlessui/react'
import { Fragment, useState } from 'react'
import { useState } from 'react'

function MyDialog({ open, close }) {
return (
<>
<Transition show={open} as={Fragment}>
<Transition show={open}>
<Dialog onClose={close} className="relative z-50">
<Transition.Child
as={Fragment}
enter="transition duration-500 ease-out"
enterFrom="opacity-0"
enterTo="opacity-100"
Expand Down
4 changes: 1 addition & 3 deletions playgrounds/react/pages/dialog/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dialog, Menu, Portal, Transition } from '@headlessui/react'
import { Fragment, useState } from 'react'
import { useState } from 'react'
import Flatpickr from 'react-flatpickr'
import { Button } from '../../components/button'
import { classNames } from '../../utils/class-names'
Expand Down Expand Up @@ -64,7 +64,6 @@ export default function Home() {
<Transition
data-debug="Dialog"
show={isOpen}
as={Fragment}
beforeEnter={() => console.log('[Transition] Before enter')}
afterEnter={() => console.log('[Transition] After enter')}
beforeLeave={() => console.log('[Transition] Before leave')}
Expand All @@ -79,7 +78,6 @@ export default function Home() {
<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-screen items-end justify-center px-4 pb-20 pt-4 text-center sm:block sm:p-0">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-75"
Expand Down
6 changes: 2 additions & 4 deletions playgrounds/react/pages/dialog/scrollable-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dialog, Transition } from '@headlessui/react'
import { ExclamationIcon } from '@heroicons/react/outline'
import { Fragment, useRef, useState } from 'react'
import { useRef, useState } from 'react'

export default function Example() {
const [open, setOpen] = useState(false)
Expand All @@ -18,10 +18,9 @@ export default function Example() {
Open Dialog
</button>
</div>
<Transition.Root show={open} as={Fragment}>
<Transition.Root show={open}>
<Dialog as="div" className="relative z-10" initialFocus={cancelButtonRef} onClose={setOpen}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
Expand All @@ -35,7 +34,6 @@ export default function Example() {
<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dialog, Transition } from '@headlessui/react'
import { Fragment, useState } from 'react'
import { useState } from 'react'

export default function Home() {
let [isOpen, setIsOpen] = useState(false)
Expand Down Expand Up @@ -37,7 +37,6 @@ export default function Home() {
<Transition
data-debug="Dialog"
show={isOpen}
as={Fragment}
beforeEnter={() => console.log('[Transition] Before enter')}
afterEnter={() => console.log('[Transition] After enter')}
beforeLeave={() => console.log('[Transition] Before leave')}
Expand All @@ -52,7 +51,6 @@ export default function Home() {
<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-screen items-end justify-center px-4 pb-20 pt-4 text-center sm:block sm:p-0">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-75"
Expand All @@ -69,6 +67,7 @@ export default function Home() {
</Transition.Child>

<Transition.Child
as="div"
enter="ease-out transform duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Listbox, Transition } from '@headlessui/react'
import { Fragment, useEffect, useState } from 'react'
import { useEffect, useState } from 'react'

let people = [
'Wade Cooper',
Expand Down Expand Up @@ -60,7 +60,6 @@ export default function Home() {
</span>

<Transition
as={Fragment}
enter="transition duration-500 ease-out"
enterFrom="transform scale-95 opacity-0"
enterTo="transform scale-100 opacity-100"
Expand Down
2 changes: 0 additions & 2 deletions playgrounds/react/pages/menu/menu-with-transition.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Menu, Transition } from '@headlessui/react'
import { Fragment } from 'react'
import { Button } from '../../components/button'
import { classNames } from '../../utils/class-names'

Expand Down Expand Up @@ -30,7 +29,6 @@ export default function Home() {
</span>

<Transition
as={Fragment}
enter="transition duration-500 ease-out"
enterFrom="transform scale-95 opacity-0"
enterTo="transform scale-100 opacity-100"
Expand Down
3 changes: 1 addition & 2 deletions playgrounds/react/pages/popover/popover.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Popover, Portal, Transition } from '@headlessui/react'
import React, { Fragment, forwardRef } from 'react'
import React, { forwardRef } from 'react'
import { usePopper } from '../../utils/hooks/use-popper'

let Button = forwardRef(
Expand Down Expand Up @@ -33,7 +33,6 @@ export default function Home() {
<Popover.Group as="nav" aria-label="Mythical University" className="flex space-x-3">
<Popover as="div" className="relative">
<Transition
as={Fragment}
enter="transition ease-out duration-300 transform"
enterFrom="opacity-0"
enterTo="opacity-100"
Expand Down
8 changes: 8 additions & 0 deletions playgrounds/react/pages/transitions/appear.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function AppearExample() {
<span className="mb-2">Initial render</span>
<div className="grid max-w-6xl grid-cols-4 gap-4">
<Transition
as="div"
show={show}
appear={true}
unmount={true}
Expand Down Expand Up @@ -50,6 +51,7 @@ export default function AppearExample() {
</Transition>

<Transition
as="div"
show={show}
appear={false}
unmount={true}
Expand Down Expand Up @@ -82,6 +84,7 @@ export default function AppearExample() {
</Transition>

<Transition
as="div"
show={show}
appear={true}
unmount={false}
Expand Down Expand Up @@ -114,6 +117,7 @@ export default function AppearExample() {
</Transition>

<Transition
as="div"
show={show}
appear={false}
unmount={false}
Expand Down Expand Up @@ -152,6 +156,7 @@ export default function AppearExample() {
<span className="mb-2">Not on the initial render</span>
<div className="grid max-w-6xl grid-cols-4 gap-4">
<Transition
as="div"
show={show}
appear={true}
unmount={true}
Expand Down Expand Up @@ -184,6 +189,7 @@ export default function AppearExample() {
</Transition>

<Transition
as="div"
show={show}
appear={false}
unmount={true}
Expand Down Expand Up @@ -216,6 +222,7 @@ export default function AppearExample() {
</Transition>

<Transition
as="div"
show={show}
appear={true}
unmount={false}
Expand Down Expand Up @@ -248,6 +255,7 @@ export default function AppearExample() {
</Transition>

<Transition
as="div"
show={show}
appear={false}
unmount={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function Dropdown() {
</div>

<Transition
as="div"
show={isOpen}
enter="transition ease-out duration-75"
enterFrom="transform opacity-0 scale-95"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function Home() {
</div>

<Transition
as="div"
show={isOpen}
className="fixed inset-0 z-10 overflow-y-auto"
beforeEnter={() => {
Expand Down Expand Up @@ -78,6 +79,7 @@ export default function Home() {
{/* This element is to trick the browser into centering the modal contents. */}
<span className="hidden sm:inline-block sm:h-screen sm:align-middle"></span>&#8203;
<Transition.Child
as="div"
className="inline-block transform overflow-hidden rounded-lg bg-white text-left align-bottom shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:align-middle"
role="dialog"
aria-modal="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Home() {
</button>
</span>

<Transition show={isOpen} unmount={false}>
<Transition as="div" show={isOpen} unmount={false}>
<Box>
<Box>
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Home() {
</button>
</span>

<Transition show={isOpen} unmount={true}>
<Transition as="div" show={isOpen} unmount={true}>
<Box>
<Box>
<Box>
Expand All @@ -43,6 +43,7 @@ export default function Home() {
function Box({ children }: { children?: ReactNode }) {
return (
<Transition.Child
as="div"
unmount={true}
enter="transition translate duration-300"
enterFrom="transform -translate-x-full"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function Home() {
</span>

<Transition
as="div"
show={isOpen}
appear={false}
beforeEnter={() => console.log('beforeEnter')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function FullPageTransition() {
<div className="relative h-96 overflow-hidden rounded-lg">
{pages.map((page, i) => (
<Transition
as="div"
appear={false}
key={page}
show={activePage === i}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export default function App() {

<div className="bg-cool-gray-100 flex h-screen overflow-hidden">
{/* Off-canvas menu for mobile */}
<Transition show={mobileOpen} unmount={false} className="fixed inset-0 z-40 flex">
<Transition as="div" show={mobileOpen} unmount={false} className="fixed inset-0 z-40 flex">
{/* Off-canvas menu overlay, show/hide based on off-canvas menu state. */}
<Transition.Child
as="div"
unmount={false}
enter="transition-opacity ease-linear duration-300"
enterFrom="opacity-0"
Expand All @@ -49,6 +50,7 @@ export default function App() {

{/* Off-canvas menu, show/hide based on off-canvas menu state. */}
<Transition.Child
as="div"
unmount={false}
enter="transition ease-in-out duration-300 transform"
enterFrom="-translate-x-full"
Expand Down
1 change: 1 addition & 0 deletions playgrounds/react/pages/transitions/react-hot-toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const TailwindToaster = () => {
{(t) => (
<Transition
appear
as="div"
show={t.visible}
className="flex transform rounded bg-white p-4 shadow-lg"
enter="transition-all duration-500"
Expand Down

0 comments on commit 965a335

Please sign in to comment.