Skip to content

Commit c36f667

Browse files
authored
minor fixes to drawer and modal (#1724)
* minor fixes to drawer and modal * bug: outsideclosed not passed to dialog
1 parent bc902da commit c36f667

File tree

6 files changed

+32
-39
lines changed

6 files changed

+32
-39
lines changed

src/lib/avatar/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const avatar = tv({
1515
false: ""
1616
},
1717
stacked: {
18-
true: "border-2 -ms-4 border-white dark:border-gray-800",
18+
true: "border-2 not-first:-ms-4 border-white dark:border-gray-800",
1919
false: ""
2020
},
2121
size: {

src/lib/dialog/Dialog.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
rect = dlg.getBoundingClientRect(),
4040
clickedInContent = ev.clientX >= rect.left && ev.clientX <= rect.right && ev.clientY >= rect.top && ev.clientY <= rect.bottom;
4141
42-
// if (outsideclose && ev.target === dlg) {
4342
if (outsideclose && !clickedInContent) {
4443
return cancel(dlg);
4544
}

src/lib/drawer/Drawer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { fly } from "svelte/transition";
88
import { drawer } from ".";
99
10-
let { children, open = $bindable(false), hidden = $bindable(), width, dismissable = false, placement = "left", class: className, classes, transitionParams, transition = fly, outsideclose, activateClickOutside, ...restProps }: DrawerProps = $props();
10+
let { children, open = $bindable(false), hidden = $bindable(), width, dismissable = false, placement = "left", class: className, transitionParams, transition = fly, outsideclose, activateClickOutside, ...restProps }: DrawerProps = $props();
1111
1212
// back compatibility
1313
if (hidden !== undefined) console.warn("'hidden' property is deprecated. Please use the 'open' property to manage 'Drawer'.");

src/lib/drawer/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { tv, type VariantProps } from "tailwind-variants";
22
import type { Classes } from "$lib/theme/themeUtils";
33
import { dialog } from "$lib/dialog/theme";
44

5-
export type DrawerVariants = VariantProps<typeof drawer> & Classes<typeof drawer>;
5+
export type DrawerVariants = VariantProps<typeof drawer> & Classes<typeof drawer> & Classes<typeof dialog>;
66

77
export const drawer = tv({
88
extend: dialog,

src/lib/modal/Modal.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { fade } from "svelte/transition";
77
import { modal as modalStyle } from ".";
88
9-
let { children, header, footer, title, open = $bindable(false), permanent = false, dismissable = true, closeBtnClass, headerClass, bodyClass, footerClass, outsideclose = true, size = "md", placement, class: className, classes, transitionParams, transition = fade, fullscreen = false, ...restProps }: ModalProps = $props();
9+
let { children, header, footer, title, open = $bindable(false), permanent = false, dismissable = true, closeBtnClass, headerClass, bodyClass, footerClass, size = "md", placement, class: className, classes, transitionParams, transition = fade, fullscreen = false, ...restProps }: ModalProps = $props();
1010
1111
// form, header, footer, body, close
1212
warnThemeDeprecation("Modal", { headerClass, bodyClass, footerClass, closeBtnClass }, { bodyClass: "body", headerClass: "header", footerClass: "footer", closeBtnClass: "close" });
@@ -20,7 +20,7 @@
2020
const { base, header: headerCls, footer: footerCls, body } = $derived(modalStyle({ placement, size }));
2121
</script>
2222

23-
<Dialog bind:open {transition} dismissable={dismissable && !title && !permanent} transitionParams={paramsOptions} {...restProps} class={base({ fullscreen, class: clsx(theme?.base, className) })}>
23+
<Dialog bind:open {transition} dismissable={dismissable && !title && !permanent} transitionParams={paramsOptions} {classes} {...restProps} class={base({ fullscreen, class: clsx(theme?.base, className) })}>
2424
{#if title || header}
2525
<div class={headerCls({ class: clsx(theme?.header, styling.header) })}>
2626
{#if title}
@@ -60,7 +60,6 @@
6060
@prop headerClass
6161
@prop bodyClass
6262
@prop footerClass
63-
@prop outsideclose = true
6463
@prop size = "md"
6564
@prop placement
6665
@prop class: className

src/routes/docs/components/drawer.md

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Use this example if you want to add form elements inside the drawer component in
182182

183183
```svelte example
184184
<script>
185-
import { Drawer, CardPlaceholder, Button, Label, Input, Textarea } from "flowbite-svelte";
185+
import { Avatar, Drawer, CardPlaceholder, Button, Label, Input, Textarea } from "flowbite-svelte";
186186
import { InfoCircleSolid, UserAddOutline, CalendarEditSolid } from "flowbite-svelte-icons";
187187
188188
let open4 = $state(false);
@@ -192,40 +192,35 @@ Use this example if you want to add form elements inside the drawer component in
192192
<Button onclick={() => (open4 = true)}>Show drawer form</Button>
193193
<CardPlaceholder size="2xl" class="mt-6" />
194194
</div>
195-
<Drawer bind:open={open4}>
195+
<Drawer form bind:open={open4} classes={{ form: "space-y-6 mb-6" }}>
196196
<h5 class="mb-6 inline-flex items-center text-base font-semibold text-gray-500 uppercase dark:text-gray-400">
197197
<InfoCircleSolid class="me-2.5 h-5 w-5" />New event
198198
</h5>
199-
<form method="dialog" class="mb-6">
200-
<div class="mb-6">
201-
<Label for="title" class="mb-2 block">Title</Label>
202-
<Input id="title" name="title" required placeholder="Apple Keynote" />
203-
</div>
204-
<div class="mb-6">
205-
<Label for="description" class="mb-2">Description</Label>
206-
<Textarea id="message" placeholder="Write event description..." rows={4} name="message" class="w-full" />
207-
</div>
208-
<div class="mb-6">
209-
<Input id="date" name="date" required type="date" />
210-
</div>
211-
<div class="mb-4">
212-
<div class="relative">
213-
<Input id="search" placeholder="Add guest email" class="p-3" />
214-
<Button class="bg-primary-700 hover:bg-primary-800 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800 absolute end-2 bottom-2 inline-flex items-center rounded-lg px-3 py-1 text-sm font-medium text-white focus:ring-4 focus:outline-hidden" type="submit">
215-
<UserAddOutline class="me-1.5 h-3 w-3 text-white" />Add
216-
</Button>
217-
</div>
218-
</div>
219-
<div class="mb-4 flex -space-x-4 rtl:space-x-reverse">
220-
<img class="h-8 w-8 rounded-full border-2 border-white dark:border-gray-800" src="/images/profile-picture-1.webp" alt="" />
221-
<img class="h-8 w-8 rounded-full border-2 border-white dark:border-gray-800" src="/images/profile-picture-2.webp" alt="" />
222-
<img class="h-8 w-8 rounded-full border-2 border-white dark:border-gray-800" src="/images/profile-picture-3.webp" alt="" />
223-
<img class="h-8 w-8 rounded-full border-2 border-white dark:border-gray-800" src="/images/profile-picture-4.webp" alt="" />
224-
</div>
225-
<Button type="submit" class="w-full">
226-
<CalendarEditSolid class="me-2.5 h-3.5 w-3.5 text-white" /> Create event
227-
</Button>
228-
</form>
199+
<Label>
200+
Title
201+
<Input name="title" class="mt-2" required placeholder="Apple Keynote" />
202+
</Label>
203+
<Label>
204+
Description
205+
<Textarea placeholder="Write event description..." rows={4} name="message" class="mt-2 w-full font-normal" />
206+
</Label>
207+
<Input name="date" required type="date" />
208+
<Input placeholder="Add guest email">
209+
{#snippet right()}
210+
<Button size="xs">
211+
<UserAddOutline class="me-1.5 h-4 w-4 text-white" />Add
212+
</Button>
213+
{/snippet}
214+
</Input>
215+
<div class="mb-4 flex">
216+
<Avatar src="/images/profile-picture-1.webp" stacked size="sm" />
217+
<Avatar src="/images/profile-picture-2.webp" stacked size="sm" />
218+
<Avatar src="/images/profile-picture-3.webp" stacked size="sm" />
219+
<Avatar src="/images/profile-picture-4.webp" stacked size="sm" />
220+
</div>
221+
<Button type="submit" class="w-full">
222+
<CalendarEditSolid class="me-2.5 h-3.5 w-3.5 text-white" /> Create event
223+
</Button>
229224
</Drawer>
230225
```
231226

0 commit comments

Comments
 (0)