File tree Expand file tree Collapse file tree 5 files changed +78
-10
lines changed
Expand file tree Collapse file tree 5 files changed +78
-10
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ document.body.style.setProperty()
4545- [ CheckboxGroup] ( https://github.com/mpiorowski/svelte-init/blob/main/docs/CHECKBOX-GROUP.md )
4646- [ Toast] ( https://github.com/mpiorowski/svelte-init/blob/main/docs/TOAST.md )
4747- [ Drawer] ( https://github.com/mpiorowski/svelte-init/blob/main/docs/DRAWER.md )
48+ - [ Modal] ( https://github.com/mpiorowski/svelte-init/blob/main/docs/MODAL.md )
4849- [ Dropdown] ( https://github.com/mpiorowski/svelte-init/blob/main/docs/DROPDOWN.md )
4950- [ Tooltip] ( https://github.com/mpiorowski/svelte-init/blob/main/docs/TOOLTIP.md )
5051- [ Table] ( https://github.com/mpiorowski/svelte-init/blob/main/docs/TABLE.md )
Original file line number Diff line number Diff line change 1+ ### [ Go back] ( https://github.com/mpiorowski/svelte-init#components )
2+
3+ # Modal
4+
5+ ```
6+ import { Modal } from "@mpiorowski/svelte-init";
7+ ```
8+
9+ # Usage
10+
11+ ```
12+ <script lang="ts">
13+ import { Button, Modal } from "@mpiorowski/svelte-init";
14+
15+ let isOpen = false;
16+ let size: 'sm' | 'md' | 'lg' = 'md';
17+ </script>
18+
19+ <Modal {isOpen} onClose={() => (isOpen = false)} {size}>
20+ <svelte:fragment slot="content">
21+ <h2>Modal</h2>
22+ <p>Modal content</p>
23+ </svelte:fragment>
24+ <svelte:fragment slot="footer">
25+ <Button on:click={() => (isOpen = false)} type="ghost">
26+ Close
27+ </Button>
28+ <Button on:click={() => (isOpen = false)}>Submit</Button>
29+ </svelte:fragment>
30+ <div>Modal</div>
31+ </Modal>
32+
33+ <Button on:click={() => (isOpen = true)}>Open modal</Button>
34+ ```
35+
36+ # Confirmation Modal
37+
38+ ```
39+ import { Confirmation } from "@mpiorowski/svelte-init";
40+ ```
41+
42+ # Usage
43+
44+ ```
45+ <script lang="ts">
46+ import { Confirmation } from "@mpiorowski/svelte-init";
47+ </script>
48+
49+ <Confirmation
50+ {size}
51+ action={() => {
52+ alert('Confirmed');
53+ }}
54+ actionBtn="primary"
55+ cancelText="Cancel"
56+ confirmBtn="error"
57+ confirmText="Confirm"
58+ >
59+ <svelte:fragment slot="button">Open confirmation modal</svelte:fragment>
60+ <svelte:fragment slot="content">
61+ <h2>Confirmation</h2>
62+ <p>Do you really want to delete this item?</p>
63+ </svelte:fragment>
64+ </Confirmation>
65+ ```
Original file line number Diff line number Diff line change 1515 },
1616 "homepage" : " https://svelte-init.vercel.app" ,
1717 "license" : " MIT" ,
18- "version" : " 1.6 .0" ,
18+ "version" : " 1.7 .0" ,
1919 "type" : " module" ,
2020 "scripts" : {
2121 "start" : " vite dev" ,
Original file line number Diff line number Diff line change 33
44 export let size: ' sm' | ' md' | ' lg' = ' md' ;
55 export let actionBtn: ' primary' | ' ghost' | ' error' = ' error' ;
6- export let confirmBtm : ' primary' | ' ghost' | ' error' = ' error' ;
6+ export let confirmBtn : ' primary' | ' ghost' | ' error' = ' error' ;
77 export let action: () => Promise <void > | void ;
88 export let confirmText = ' Confirm' ;
99 export let cancelText = ' Cancel' ;
3131 loading = false ;
3232 isOpen = false ;
3333 }}
34- type ={confirmBtm }
34+ type ={confirmBtn }
3535 {loading }
3636 >
3737 {confirmText }
Original file line number Diff line number Diff line change 3434 action ={() => {
3535 alert (' Confirmed' );
3636 }}
37+ actionBtn =" primary"
38+ cancelText =" Cancel"
39+ confirmBtn =" error"
40+ confirmText =" Confirm"
3741 >
38- <svelte:fragment slot =" button" >
39- Open confirmation modal
40- </svelte:fragment >
41- <svelte:fragment slot =" content" >
42- <h2 >Confirmation</h2 >
43- <p >Confirmation content</p >
44- </svelte:fragment >
42+ <svelte:fragment slot =" button" >Open confirmation modal</svelte:fragment >
43+ <svelte:fragment slot =" content" >
44+ <h2 >Confirmation</h2 >
45+ <p >Confirmation content</p >
46+ </svelte:fragment >
4547 </Confirmation >
4648</div >
You can’t perform that action at this time.
0 commit comments