Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Mar 1, 2023
1 parent 52316e0 commit cb42b27
Show file tree
Hide file tree
Showing 3 changed files with 504 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/playground-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
"clean": "rimraf ./.next"
},
"dependencies": {
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@headlessui/react": "*",
"@headlessui/tailwindcss": "*",
"@heroicons/react": "^1.0.6",
"@mui/material": "^5.11.11",
"@mui/x-date-pickers-pro": "^5.0.20",
"@popperjs/core": "^2.6.0",
"@tailwindcss/forms": "^0.5.2",
"@tailwindcss/typography": "^0.5.2",
"autoprefixer": "^10.4.7",
"dayjs": "^1.11.7",
"framer-motion": "^6.0.0",
"next": "^12.1.4",
"postcss": "^8.4.14",
Expand Down
110 changes: 110 additions & 0 deletions packages/playground-react/pages/dialog/repro.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { Dialog, Transition } from '@headlessui/react'
import { Fragment, useState } from 'react'

import * as React from 'react'
import { Dayjs } from 'dayjs'
import TextField from '@mui/material/TextField'
import Box from '@mui/material/Box'
import { LocalizationProvider } from '@mui/x-date-pickers-pro'
import { AdapterDayjs } from '@mui/x-date-pickers-pro/AdapterDayjs'
import { DateRangePicker, DateRange } from '@mui/x-date-pickers-pro/DateRangePicker'

export function BasicDateRangePicker() {
const [value, setValue] = React.useState<DateRange<Dayjs>>([null, null])

return (
<LocalizationProvider
dateAdapter={AdapterDayjs}
localeText={{ start: 'Check-in', end: 'Check-out' }}
>
<DateRangePicker
value={value}
onChange={(newValue) => {
setValue(newValue)
}}
renderInput={(startProps, endProps) => (
<React.Fragment>
<TextField {...startProps} />
<Box sx={{ mx: 2 }}> to </Box>
<TextField {...endProps} />
</React.Fragment>
)}
/>
</LocalizationProvider>
)
}

export default function MyModal() {
let [isOpen, setIsOpen] = useState(false)

function closeModal() {
setIsOpen(false)
}

function openModal() {
setIsOpen(true)
}

return (
<>
<div className="fixed inset-0 flex items-center justify-center">
<button
type="button"
onClick={openModal}
className="rounded-md bg-black bg-opacity-20 px-4 py-2 text-sm font-medium text-white hover:bg-opacity-30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75"
>
Open dialog
</button>
</div>

<Transition appear show={isOpen} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={closeModal}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-25" />
</Transition.Child>

<div className="fixed inset-0 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all">
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900">
Payment successful
</Dialog.Title>
<div className="mt-2">
<BasicDateRangePicker />
</div>

<div className="mt-4">
<button
type="button"
className="inline-flex justify-center rounded-md border border-transparent bg-blue-100 px-4 py-2 text-sm font-medium text-blue-900 hover:bg-blue-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"
onClick={closeModal}
>
Got it, thanks!
</button>
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition>
</>
)
}
Loading

0 comments on commit cb42b27

Please sign in to comment.