Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DialogPanel? #112

Open
ivarlovlie opened this issue Aug 22, 2022 · 18 comments
Open

Implement DialogPanel? #112

ivarlovlie opened this issue Aug 22, 2022 · 18 comments

Comments

@ivarlovlie
Copy link

Headless ui has Dialog.Panel, I am unable to find it in svelte-headlessui. Is this because it is not implemented here, or am i missing something about the need for Dialog.Panel in this port?

Thanks!

@karmaral
Copy link

karmaral commented Sep 9, 2022

+1 for this

@ivarlovlie
Copy link
Author

ivarlovlie commented Sep 15, 2022

I would be willing to invest time in a PR if there was documentation with pointers on how to port components. I haven't found it.

@ivarlovlie
Copy link
Author

My first pass on this seems to do the job, probably not production ready, but would love to make it so in a pr.

@petr24
Copy link

petr24 commented Oct 14, 2022

@extremelygooddeveloper Unless there is a misunderstanding but the dialog panel is on the example page here https://svelte-headlessui.goss.io/docs/dialog

@ivarlovlie
Copy link
Author

@petr24 Hmm, i only see these
image

@petr24
Copy link

petr24 commented Oct 18, 2022

Have no idea what page you're visiting, I go to the link on chrome and this is what you should see...

Screen Shot 2022-10-18 at 10 59 02 AM

@ivarlovlie
Copy link
Author

Yes, there is no DialogPanel on that page.

@petr24
Copy link

petr24 commented Oct 20, 2022

Well there is no "DialogPanel" in tailwind css or headless UI, it's called just "Dialog". I think this can be closed out.

@petr24
Copy link

petr24 commented Oct 20, 2022

Well there is no "DialogPanel" in tailwind css or headless UI, it's called just "Dialog". I think this can be closed out.

I mis-understood your question, and my answers were wrong. I see you were asking about "Dialog.Panel" with svelte variant being "DialogPanel", however I'm not sure it's necessary. I looked at the DOM for both headless UI example, and svelte headless UI, and it's the same. Parent Div with three children, h3, two divs. So it seems like this package has the function of Dialog.Panel without explicitly copying the headless UI api.

Svelte Headless UI
Screen Shot 2022-10-20 at 8 08 55 AM

Headless UI
Screen Shot 2022-10-20 at 8 14 59 AM

@coin-au-carre
Copy link

coin-au-carre commented Nov 14, 2022

For reference, if it can be useful these layouts use DialogPanel: https://tailwindui.com/components/application-ui/application-shells/sidebar see Vue Code.

I have tried to replace in my code DialogPanel with Dialog. However the visual is not good for the moment.

@ivarlovlie
Copy link
Author

@coin-au-carre Yes, that was my experience as well, iirc my first pass on implementing DialogPanel worked for me.
Feel free to try it out:
Repo: https://github.com/extremelygooddeveloper/svelte-headlessui
npm: https://www.npmjs.com/package/@developermuch/dev-svelte-headlessui

@coin-au-carre
Copy link

coin-au-carre commented Nov 15, 2022

Thanks @extremelygooddeveloper I will try it :). Maybe you should propose a PR ?

@AaronNBrock
Copy link

Bumping that @iv-ar should turn this into a PR!

@rgossiaux rgossiaux pinned this issue Jun 11, 2023
@HemalR
Copy link

HemalR commented Jul 1, 2023

I mis-understood your question, and my answers were wrong. I see you were asking about "Dialog.Panel" with svelte variant being "DialogPanel", however I'm not sure it's necessary. I looked at the DOM for both headless UI example, and svelte headless UI, and it's the same. Parent Div with three children, h3, two divs. So it seems like this package has the function of Dialog.Panel without explicitly copying the headless UI api.

I think the main functionality is to trigger a close of the dialog when a click-event is made outside of it. I would echo the requests for @iv-ar to turn this into a PR. Thank you all in advance!

@zach-hopkins
Copy link

zach-hopkins commented Jul 4, 2023

I'm not really sure what DialogPanel does. I've just replaced them with divs and never noticed anything wrong.

@HemalR
Copy link

HemalR commented Jul 4, 2023

I'm not really sure what DialogPanel does. I've just replaced them with divs and never noticed anything wrong.

Are you able to close the dialog by clicking outside of it?

@zach-hopkins
Copy link

I'm not really sure what DialogPanel does. I've just replaced them with divs and never noticed anything wrong.

Are you able to close the dialog by clicking outside of it?

Ah yes I believe that may be it. I cannot do that by default, however I do not mind creating that functionality manually.

@petr24
Copy link

petr24 commented Jul 17, 2023

From the documentation, clicking outside modal/dialog works as expected.
Is this not working for everyone?

The close event is fired when an open dialog is dismissed, 
which happens when the user clicks outside of the contents of your dialog or presses the Escape key. 
You can use this callback to set open back to false and close your dialog.

<script>
  import {
    Dialog,
    DialogOverlay,
    DialogTitle,
    DialogDescription,
  } from "@rgossiaux/svelte-headlessui";
  let isOpen = true;
</script>

<!-- Pass `isOpen` to the `open` prop and use the `on:close` handler to set it back to false when the user clicks outside of the dialog or presses the escape key. -->
<Dialog open={isOpen} on:close={() => (isOpen = false)}>
  <DialogOverlay />

  <DialogTitle>Deactivate account</DialogTitle>
  <DialogDescription>
    This will permanently deactivate your account
  </DialogDescription>

  <p>
    Are you sure you want to deactivate your account? All of your data will be
    permanently removed. This action cannot be undone.
  </p>

  <!-- You can render additional buttons to dismiss your dialog by setting `isOpen` to `false`. -->
  <button on:click={() => (isOpen = false)}>Deactivate</button>
  <button on:click={() => (isOpen = false)}>Cancel</button>
</Dialog>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants