Skip to content

Commit 170ce0f

Browse files
committed
Sidebar cleanup
1 parent 5748a61 commit 170ce0f

File tree

6 files changed

+57
-37
lines changed

6 files changed

+57
-37
lines changed

src/lib/components/sidebar/AppSidebar.svelte

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
<script lang="ts" module>
2-
import type { UserResource } from '@clerk/types';
3-
import { data } from '@/lib/components/sidebar/sampleData';
4-
</script>
5-
61
<script lang="ts">
72
import NavMain from '@/lib/components/sidebar/NavMain.svelte';
83
import NavProjects from '@/lib/components/sidebar/NavProjects.svelte';
@@ -11,6 +6,9 @@
116
import * as Sidebar from '@/lib/components/ui/sidebar/index.js';
127
import type { ComponentProps } from 'svelte';
138
9+
import type { UserResource } from '@clerk/types';
10+
import { data } from '@/lib/components/sidebar/sampleData';
11+
1412
let {
1513
ref = $bindable(null),
1614
collapsible = 'icon',

src/lib/components/sidebar/NavMain.svelte

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1+
<script lang="ts" module>
2+
export type NavItems = {
3+
title: string;
4+
url: string;
5+
icon?: any;
6+
isActive?: boolean;
7+
items?: {
8+
title: string;
9+
url: string;
10+
}[];
11+
};
12+
</script>
13+
114
<script lang="ts">
215
import * as Collapsible from '@/lib/components/ui/collapsible/index.js';
316
import * as Sidebar from '@/lib/components/ui/sidebar/index.js';
417
import ChevronRight from '@lucide/svelte/icons/chevron-right';
518
6-
let {
7-
items
8-
}: {
9-
items: {
10-
title: string;
11-
url: string;
12-
// this should be `Component` after @lucide/svelte updates types
13-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
14-
icon?: any;
15-
isActive?: boolean;
16-
items?: {
17-
title: string;
18-
url: string;
19-
}[];
20-
}[];
21-
} = $props();
19+
type Props = {
20+
items: NavItems[];
21+
};
22+
23+
let { items }: Props = $props();
2224
</script>
2325

2426
<Sidebar.Group>

src/lib/components/sidebar/NavProjects.svelte

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<script lang="ts" module>
2+
export type NavProject = {
3+
name: string;
4+
url: string;
5+
icon: any;
6+
};
7+
</script>
8+
19
<script lang="ts">
210
import * as DropdownMenu from '@/lib/components/ui/dropdown-menu/index.js';
311
import { useSidebar } from '@/lib/components/ui/sidebar/context.svelte.js';
@@ -7,17 +15,11 @@
715
import Forward from '@lucide/svelte/icons/forward';
816
import Trash2 from '@lucide/svelte/icons/trash-2';
917
10-
let {
11-
projects
12-
}: {
13-
projects: {
14-
name: string;
15-
url: string;
16-
// This should be `Component` after @lucide/svelte updates types
17-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18-
icon: any;
19-
}[];
20-
} = $props();
18+
type Props = {
19+
projects: NavProject[];
20+
};
21+
22+
let { projects }: Props = $props();
2123
2224
const sidebar = useSidebar();
2325
</script>

src/lib/components/sidebar/NavUser.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script lang="ts" module>
2+
export type NavUser = { name: string; email: string; avatar: string };
3+
</script>
4+
15
<script lang="ts">
26
import * as Avatar from '@/lib/components/ui/avatar/index.js';
37
import * as DropdownMenu from '@/lib/components/ui/dropdown-menu/index.js';
@@ -10,7 +14,11 @@
1014
import LogOut from '@lucide/svelte/icons/log-out';
1115
import Sparkles from '@lucide/svelte/icons/sparkles';
1216
13-
let { user }: { user: { name: string; email: string; avatar: string } } = $props();
17+
type Props = {
18+
user: NavUser;
19+
};
20+
21+
let { user }: Props = $props();
1422
const sidebar = useSidebar();
1523
</script>
1624

src/lib/components/sidebar/TeamSwitcher.svelte

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1+
<script lang="ts" module>
2+
export type Team = {
3+
name: string;
4+
logo: any;
5+
plan: string;
6+
};
7+
</script>
8+
19
<script lang="ts">
210
import * as DropdownMenu from '@/lib/components/ui/dropdown-menu/index.js';
311
import * as Sidebar from '@/lib/components/ui/sidebar/index.js';
412
import { useSidebar } from '@/lib/components/ui/sidebar/index.js';
513
import ChevronsUpDown from '@lucide/svelte/icons/chevrons-up-down';
614
import Plus from '@lucide/svelte/icons/plus';
715
8-
// This should be `Component` after @lucide/svelte updates types
9-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10-
let { teams }: { teams: { name: string; logo: any; plan: string }[] } = $props();
16+
type Props = {
17+
teams: Team[];
18+
};
19+
20+
let { teams }: Props = $props();
1121
const sidebar = useSidebar();
1222
1323
let activeTeam = $state(teams[0]);

src/lib/components/sidebar/sampleData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const data = {
124124
{
125125
name: 'Travel',
126126
url: '#',
127-
icon: Map
127+
icon: icons.Map
128128
}
129129
]
130130
};

0 commit comments

Comments
 (0)