-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(svelte/demo/daisyui): svelte 5 migration
- Loading branch information
1 parent
9128d8c
commit 526b694
Showing
18 changed files
with
148 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import App from './App.svelte'; | ||
import {mount} from 'svelte'; | ||
|
||
export const main = new App({ | ||
export const main = mount(App, { | ||
target: document.getElementById('root')!, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
<script lang="ts"> | ||
import Modal from './Modal.svelte'; | ||
let visible = false; | ||
<script> | ||
import {openModal} from './modal'; | ||
const onclick = () => openModal({children: modalContent, closeOnOutsideClick: true}); | ||
</script> | ||
|
||
<Modal bind:visible closeOnOutsideClick> | ||
{#snippet modalContent()} | ||
<h3 class="font-bold text-lg">A simple modal</h3> | ||
<p class="py-4">Press ESC key, click on ✕ button or click outside the modal to close</p> | ||
</Modal> | ||
<button class="btn" aria-haspopup="dialog" on:click={() => (visible = true)}> Open modal </button> | ||
{/snippet} | ||
<button class="btn" aria-haspopup="dialog" {onclick}> Open modal </button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type {ModalProps} from '@agnos-ui/svelte-headless/components/modal'; | ||
import Modal from './Modal.svelte'; | ||
import {mount, unmount, type Snippet} from 'svelte'; | ||
|
||
export type DaisyModalProps = Partial< | ||
Pick<ModalProps, 'closeOnOutsideClick' | 'ariaCloseButtonLabel' | 'closeButton' | 'visible' | 'onVisibleChange'> | ||
> & {children: Snippet}; | ||
|
||
export async function openModal(options: DaisyModalProps) { | ||
const target = document.createElement('div'); | ||
document.body.append(target); | ||
const component = mount(Modal, { | ||
target, | ||
props: options, | ||
}); | ||
try { | ||
return await component.api.open(); | ||
} finally { | ||
target.remove(); | ||
unmount(component); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.