-
Notifications
You must be signed in to change notification settings - Fork 330
Expand file tree
/
Copy pathBottomNav.svelte
More file actions
70 lines (59 loc) · 1.92 KB
/
Copy pathBottomNav.svelte
File metadata and controls
70 lines (59 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<script lang="ts">
import type { BottomNavContextType, BottomNavProps } from "$lib/types";
import { cn } from "$lib/utils";
import { getTheme, warnThemeDeprecation } from "$lib/theme/themeUtils";
import clsx from "clsx";
import { setBottomNavContext } from "$lib/context";
import { bottomNav } from "./theme";
import { untrack } from "svelte";
let { children, header, position = "fixed", navType = "default", class: className, classes, outerClass, innerClass, activeClass, activeUrl = "", ...restProps }: BottomNavProps = $props();
warnThemeDeprecation(
"BottomNav",
untrack(() => ({ innerClass, outerClass })),
{ innerClass: "inner", outerClass: "class" }
);
const styling = $derived(classes ?? { inner: innerClass });
// Theme context
const theme = $derived(getTheme("bottomNav"));
const activeCls = $derived(cn("text-primary-700 dark:text-primary-700 hover:text-primary-900 dark:hover:text-primary-900", activeClass));
// Create reactive context using getters
const reactiveCtx: BottomNavContextType = {
get activeClass() {
return activeCls;
},
get activeUrl() {
return activeUrl;
},
get navType() {
return navType;
}
};
setBottomNavContext(reactiveCtx);
const { base, inner } = $derived(bottomNav({ position, navType }));
</script>
<div {...restProps} class={base({ class: clsx(theme?.base, className ?? outerClass) })}>
{#if header}
{@render header()}
{/if}
<div class={inner({ class: clsx(theme?.inner, styling.inner) })}>
{@render children()}
</div>
</div>
<!--
@component
[Go to docs](https://flowbite-svelte.com/)
## Type
[BottomNavProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L271)
## Props
@prop children
@prop header
@prop position = "fixed"
@prop navType = "default"
@prop class: className
@prop classes
@prop outerClass
@prop innerClass
@prop activeClass
@prop activeUrl = ""
@prop ...restProps
-->