@ims360/svelte-ivory 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/layout/drawer/Drawer.svelte +60 -0
- package/dist/components/layout/drawer/Drawer.svelte.d.ts +12 -0
- package/dist/components/layout/index.d.ts +1 -0
- package/dist/components/layout/index.js +1 -0
- package/dist/components/layout/modal/Modal.svelte +4 -1
- package/package.json +1 -1
- package/src/lib/components/layout/drawer/Drawer.svelte +60 -0
- package/src/lib/components/layout/index.ts +1 -0
- package/src/lib/components/layout/modal/Modal.svelte +4 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Eventually we will add more documentation and examples to make it easier for dev
|
|
|
9
9
|
Include this line in your `app.css` file, so the TW classes used in the lib are included:
|
|
10
10
|
|
|
11
11
|
```css
|
|
12
|
-
@source "../node_modules/@ims360/svelte-
|
|
12
|
+
@source "../node_modules/@ims360/svelte-ivory";
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
_You may need to adjust the path if your `app.css` is not located in `/src`_
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { X } from '@lucide/svelte';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { fly } from 'svelte/transition';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import Heading from '../heading';
|
|
8
|
+
import HiddenBackground from '../hiddenBackground';
|
|
9
|
+
|
|
10
|
+
type DrawerPlacement = 'left' | 'right';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
class?: string;
|
|
14
|
+
b_open: boolean;
|
|
15
|
+
title?: string;
|
|
16
|
+
children: Snippet;
|
|
17
|
+
placement?: DrawerPlacement;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
class: clazz,
|
|
22
|
+
b_open = $bindable(false),
|
|
23
|
+
children,
|
|
24
|
+
title,
|
|
25
|
+
placement = 'right'
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
|
|
28
|
+
const close = () => {
|
|
29
|
+
b_open = false;
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if b_open}
|
|
34
|
+
<HiddenBackground onclose={close}>
|
|
35
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
36
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
37
|
+
<div
|
|
38
|
+
class={twMerge(
|
|
39
|
+
clsx([
|
|
40
|
+
'bg-surface-50-950 absolute top-0 flex h-full flex-col gap-4 p-4',
|
|
41
|
+
placement === 'left' && 'left-0',
|
|
42
|
+
placement === 'right' && 'right-0',
|
|
43
|
+
clazz
|
|
44
|
+
])
|
|
45
|
+
)}
|
|
46
|
+
transition:fly={{ x: placement === 'right' ? '100%' : '-100%', duration: 200 }}
|
|
47
|
+
onclick={(e) => e.stopPropagation()}
|
|
48
|
+
>
|
|
49
|
+
<div class="flex flex-row items-center justify-between gap-8">
|
|
50
|
+
{#if title}
|
|
51
|
+
<Heading>{title}</Heading>
|
|
52
|
+
{/if}
|
|
53
|
+
<button class="group ml-auto flex justify-end" type="button" onclick={close}>
|
|
54
|
+
<X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
{@render children()}
|
|
58
|
+
</div>
|
|
59
|
+
</HiddenBackground>
|
|
60
|
+
{/if}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type DrawerPlacement = 'left' | 'right';
|
|
3
|
+
interface Props {
|
|
4
|
+
class?: string;
|
|
5
|
+
b_open: boolean;
|
|
6
|
+
title?: string;
|
|
7
|
+
children: Snippet;
|
|
8
|
+
placement?: DrawerPlacement;
|
|
9
|
+
}
|
|
10
|
+
declare const Drawer: import("svelte").Component<Props, {}, "b_open">;
|
|
11
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
12
|
+
export default Drawer;
|
|
@@ -103,7 +103,10 @@
|
|
|
103
103
|
</div>
|
|
104
104
|
<div
|
|
105
105
|
class={twMerge(
|
|
106
|
-
clsx(
|
|
106
|
+
clsx(
|
|
107
|
+
'flex grow flex-col gap-4 overflow-hidden bg-inherit p-4 pt-2',
|
|
108
|
+
innerClass
|
|
109
|
+
)
|
|
107
110
|
)}
|
|
108
111
|
>
|
|
109
112
|
{@render children?.()}
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { X } from '@lucide/svelte';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { fly } from 'svelte/transition';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import Heading from '../heading';
|
|
8
|
+
import HiddenBackground from '../hiddenBackground';
|
|
9
|
+
|
|
10
|
+
type DrawerPlacement = 'left' | 'right';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
class?: string;
|
|
14
|
+
b_open: boolean;
|
|
15
|
+
title?: string;
|
|
16
|
+
children: Snippet;
|
|
17
|
+
placement?: DrawerPlacement;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
class: clazz,
|
|
22
|
+
b_open = $bindable(false),
|
|
23
|
+
children,
|
|
24
|
+
title,
|
|
25
|
+
placement = 'right'
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
|
|
28
|
+
const close = () => {
|
|
29
|
+
b_open = false;
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if b_open}
|
|
34
|
+
<HiddenBackground onclose={close}>
|
|
35
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
36
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
37
|
+
<div
|
|
38
|
+
class={twMerge(
|
|
39
|
+
clsx([
|
|
40
|
+
'bg-surface-50-950 absolute top-0 flex h-full flex-col gap-4 p-4',
|
|
41
|
+
placement === 'left' && 'left-0',
|
|
42
|
+
placement === 'right' && 'right-0',
|
|
43
|
+
clazz
|
|
44
|
+
])
|
|
45
|
+
)}
|
|
46
|
+
transition:fly={{ x: placement === 'right' ? '100%' : '-100%', duration: 200 }}
|
|
47
|
+
onclick={(e) => e.stopPropagation()}
|
|
48
|
+
>
|
|
49
|
+
<div class="flex flex-row items-center justify-between gap-8">
|
|
50
|
+
{#if title}
|
|
51
|
+
<Heading>{title}</Heading>
|
|
52
|
+
{/if}
|
|
53
|
+
<button class="group ml-auto flex justify-end" type="button" onclick={close}>
|
|
54
|
+
<X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
{@render children()}
|
|
58
|
+
</div>
|
|
59
|
+
</HiddenBackground>
|
|
60
|
+
{/if}
|
|
@@ -103,7 +103,10 @@
|
|
|
103
103
|
</div>
|
|
104
104
|
<div
|
|
105
105
|
class={twMerge(
|
|
106
|
-
clsx(
|
|
106
|
+
clsx(
|
|
107
|
+
'flex grow flex-col gap-4 overflow-hidden bg-inherit p-4 pt-2',
|
|
108
|
+
innerClass
|
|
109
|
+
)
|
|
107
110
|
)}
|
|
108
111
|
>
|
|
109
112
|
{@render children?.()}
|