fluid-ui-svelte 0.1.4 → 0.1.6
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.
|
@@ -2,28 +2,39 @@
|
|
|
2
2
|
import Container from "../primitives/Container.svelte";
|
|
3
3
|
import Button from "../primitives/Button.svelte";
|
|
4
4
|
import type { Snippet } from "svelte";
|
|
5
|
-
|
|
5
|
+
let {
|
|
6
6
|
class: className,
|
|
7
|
+
triggerClass,
|
|
7
8
|
contentClass,
|
|
8
9
|
overrideDefaultStyling = false,
|
|
10
|
+
isOpen = $bindable(false),
|
|
9
11
|
dropdownTrigger,
|
|
10
|
-
|
|
12
|
+
dropdownContent,
|
|
11
13
|
}: {
|
|
12
14
|
class?: string;
|
|
15
|
+
triggerClass?: string;
|
|
13
16
|
contentClass?: string;
|
|
14
17
|
overrideDefaultStyling?: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
isOpen?: boolean;
|
|
19
|
+
dropdownTrigger: Snippet<[options: { isOpen: boolean; toggleDropdown: Function }]>;
|
|
20
|
+
dropdownContent: Snippet<[options: { isOpen: boolean; toggleDropdown: Function }]>;
|
|
17
21
|
} = $props();
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
const componentOptions = {
|
|
24
|
+
isOpen,
|
|
25
|
+
toggleDropdown: () => {
|
|
26
|
+
isOpen = !isOpen;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
20
29
|
</script>
|
|
21
30
|
|
|
22
31
|
<Container class={(overrideDefaultStyling ? "" : "fluid-dropdown") + (className ? ` ${className}` : "")} overrideDefaultStyling={true}>
|
|
23
|
-
{
|
|
32
|
+
<Container class={(overrideDefaultStyling ? "" : "fluid-dropdown-trigger") + (triggerClass ? ` ${triggerClass}` : "")} overrideDefaultStyling>
|
|
33
|
+
{@render dropdownTrigger(componentOptions)}
|
|
34
|
+
</Container>
|
|
24
35
|
<Container overrideDefaultStyling class={(overrideDefaultStyling ? "" : "fluid-dropdown-content") + (contentClass ? ` ${contentClass}` : "")}>
|
|
25
36
|
{#if isOpen}
|
|
26
|
-
{@render
|
|
37
|
+
{@render dropdownContent(componentOptions)}
|
|
27
38
|
{/if}
|
|
28
39
|
</Container>
|
|
29
40
|
</Container>
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
2
|
declare const Dropdown: import("svelte").Component<{
|
|
3
3
|
class?: string;
|
|
4
|
+
triggerClass?: string;
|
|
4
5
|
contentClass?: string;
|
|
5
6
|
overrideDefaultStyling?: boolean;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
dropdownTrigger: Snippet<[options: {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
toggleDropdown: Function;
|
|
11
|
+
}]>;
|
|
12
|
+
dropdownContent: Snippet<[options: {
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
toggleDropdown: Function;
|
|
15
|
+
}]>;
|
|
16
|
+
}, {}, "isOpen">;
|
|
9
17
|
export default Dropdown;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
3
|
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
let {
|
|
6
6
|
class: className = "",
|
|
7
7
|
buttonType = "solid",
|
|
8
8
|
buttonStyle = "primary",
|
|
9
9
|
onclick,
|
|
10
10
|
overrideDefaultStyling = false,
|
|
11
|
+
isActive = $bindable(false),
|
|
12
|
+
activeChildren,
|
|
11
13
|
children,
|
|
12
14
|
...restProps
|
|
13
15
|
}: {
|
|
@@ -16,9 +18,10 @@
|
|
|
16
18
|
buttonStyle?: "primary" | "secondary" | "tetriary" | "neutral";
|
|
17
19
|
onclick: (e: Event) => any;
|
|
18
20
|
overrideDefaultStyling?: boolean;
|
|
21
|
+
isActive?: boolean;
|
|
22
|
+
activeChildren?: Snippet;
|
|
19
23
|
children: Snippet;
|
|
20
24
|
} & Omit<HTMLButtonAttributes, "onclick"> = $props();
|
|
21
|
-
let isActive = $state(false);
|
|
22
25
|
</script>
|
|
23
26
|
|
|
24
27
|
<button
|
|
@@ -38,5 +41,13 @@
|
|
|
38
41
|
(overrideDefaultStyling ? "" : " fluid-" + buttonStyle + "-button")}
|
|
39
42
|
{...restProps}
|
|
40
43
|
>
|
|
41
|
-
{
|
|
44
|
+
{#if activeChildren}
|
|
45
|
+
{#if isActive}
|
|
46
|
+
{@render activeChildren()}
|
|
47
|
+
{:else}
|
|
48
|
+
{@render children()}
|
|
49
|
+
{/if}
|
|
50
|
+
{:else}
|
|
51
|
+
{@render children()}
|
|
52
|
+
{/if}
|
|
42
53
|
</button>
|
|
@@ -6,6 +6,8 @@ declare const Button: import("svelte").Component<{
|
|
|
6
6
|
buttonStyle?: "primary" | "secondary" | "tetriary" | "neutral";
|
|
7
7
|
onclick: (e: Event) => any;
|
|
8
8
|
overrideDefaultStyling?: boolean;
|
|
9
|
+
isActive?: boolean;
|
|
10
|
+
activeChildren?: Snippet;
|
|
9
11
|
children: Snippet;
|
|
10
|
-
} & Omit<HTMLButtonAttributes, "onclick">, {}, "">;
|
|
12
|
+
} & Omit<HTMLButtonAttributes, "onclick">, {}, "isActive">;
|
|
11
13
|
export default Button;
|