-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89b1b81
commit 2ded65e
Showing
5 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<script lang="ts"> | ||
import { goto } from "$app/navigation"; | ||
import { page } from "$app/stores"; | ||
import MainLayout from "@/lib/components/MainLayout.svelte"; | ||
import Button from "@/lib/components/common/Button.svelte"; | ||
import SidebarItem from "@/lib/components/sidebar/SidebarItem.svelte"; | ||
import Search from "@/lib/components/inputs/Search.svelte"; | ||
import { FileDirectory24, People16, Person16 } from "svelte-octicons"; | ||
import ContentLayout from "@/lib/components/ContentLayout.svelte"; | ||
import PageToolbar from "@/lib/components/common/PageToolbar.svelte"; | ||
import Empty from "@/lib/components/common/Empty.svelte"; | ||
export let data; | ||
function search(event: SubmitEvent) { | ||
event.preventDefault(); | ||
const url = new URL($page.url); // make a copy | ||
const formData = new FormData(event.currentTarget as HTMLFormElement); | ||
const query = formData.get("query") ?? ""; | ||
if (!query) return; | ||
url.searchParams.set("query", query as string); | ||
goto(url); | ||
} | ||
$: query = ($page.url as URL).searchParams.get("query") ?? ""; | ||
</script> | ||
|
||
<MainLayout> | ||
<svelte:fragment slot="navigation"> | ||
<Button mode="primary" href="/create">Create Project</Button> | ||
<SidebarItem active={data.list === "owned"} href="?list=owned"> | ||
<Person16 /> | ||
Your Projects | ||
</SidebarItem> | ||
<SidebarItem active={data.list === "shared"} href="?list=shared"> | ||
<People16 /> | ||
Shared with you | ||
</SidebarItem> | ||
</svelte:fragment> | ||
|
||
<ContentLayout slot="content"> | ||
<PageToolbar slot="header"> | ||
<Search name="query" {query} on:submit={search} slot="center" /> | ||
</PageToolbar> | ||
|
||
{#each data.projects as project} | ||
<p>{project.title}</p> | ||
<p>{project.description}</p> | ||
{:else} | ||
<Empty icon={FileDirectory24}>No projects found</Empty> | ||
{/each} | ||
|
||
<PageToolbar slot="footer"></PageToolbar> | ||
</ContentLayout> | ||
</MainLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getOwned, getShared } from "$lib/api/projects"; | ||
import { breadcrumbTrail } from "$lib/utils/navigation"; | ||
import type { Project } from "@/api/types"; | ||
|
||
export async function load({ url, parent, fetch }) { | ||
const { me } = await parent(); | ||
const params = Object.fromEntries(url.searchParams.entries()); | ||
const list = params.list ?? "owned"; | ||
let projects: Project[]; | ||
if (list === "owned") { | ||
projects = await getOwned(me.id); | ||
} else if (list === "shared") { | ||
projects = await getShared(me.id); | ||
} | ||
const breadcrumbs = await breadcrumbTrail(parent, [ | ||
{ href: "/projects", title: "Projects" }, | ||
]); | ||
return { | ||
list, | ||
projects, | ||
breadcrumbs, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters