huntabyte / vaul-svelte

An unstyled drawer component for Svelte.
https://vaul-svelte.com
MIT License
395 stars 16 forks source link

API #58

Open MentalGear opened 5 months ago

MentalGear commented 5 months ago

Describe the feature in detail (code, mocks, or screenshots encouraged)

Thanks for porting this to svelte!

A code-only API (not bound to components) would be tremendously helpful, e.g. for triggering the drawer/modal in shallow routing (sveltekit) or just closing it from an lower component (like a form). Thx!

What type of pull request would this be?

None

Provide relevant links or additional information.

No response

huntabyte commented 5 months ago

Can you provide some more details on what you're looking to do?

k00lagin commented 4 months ago

@MentalGear Don't know if your use case is similar to mine. I've checked lib sources and come up with this solution to use drawer with shallow routing. Assuming minimal example, you can replace this part:

{#if $page.state.showModal}
    <Modal close={() => history.back()} />
{/if}

with this:

<Drawer.Root open={$page.state.showModal} onClose={()=>history.back()}>
    <!-- CONTENTS -->
    <!-- Dont add trigger here, use showModal() instead -->
</Drawer.Root>