Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added navigation bar component #74

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4f8e4a1
feat: added card component
Slartibartfass2 Nov 11, 2024
a6aaaff
feat: added avatar component
Slartibartfass2 Nov 11, 2024
c29a2ba
feat: added dropdown menu component
Slartibartfass2 Nov 11, 2024
f1c02d2
feat: added tabs component
Slartibartfass2 Nov 11, 2024
fff0bc5
feat: added navigation bar component
Slartibartfass2 Nov 11, 2024
a070f09
feat: corrected padding and behavior according to inputs
Slartibartfass2 Nov 12, 2024
8f1a571
feat: added project navigation bar component
Slartibartfass2 Nov 12, 2024
7de7b6d
feat: added navigation bar to pages
Slartibartfass2 Nov 12, 2024
16fbf75
refactor: used interface for navigation bar props
Slartibartfass2 Nov 13, 2024
884de98
feat: added simple navigation bar for bars with only a single title
Slartibartfass2 Nov 13, 2024
4185a87
chore: moved shadcn primitives to /components/primitives and composit…
Slartibartfass2 Nov 13, 2024
88fce1a
feat: added paper navigation bar
Slartibartfass2 Nov 14, 2024
15d5f9c
feat: added styles to primitives
Slartibartfass2 Nov 14, 2024
992af36
feat: wrapped navigation bar in header and back button + tabs in nav …
Slartibartfass2 Nov 14, 2024
f0a6743
feat: added paper navigation bar to paper create page
Slartibartfass2 Nov 14, 2024
45a2e1e
feat: children of navigation bar can also be undefined
Slartibartfass2 Nov 14, 2024
4d0efe8
test: added integration test for navigation bar
Slartibartfass2 Nov 14, 2024
312a938
feat: change type of projectId to number
Slartibartfass2 Nov 17, 2024
7b86fb0
test: added integration test for paper navigation bar
Slartibartfass2 Nov 17, 2024
9cf7be3
test: added integration test for project navigation bar
Slartibartfass2 Nov 17, 2024
c933259
feat: set all props directly instead of default values
Slartibartfass2 Nov 17, 2024
b5b2dec
test: added integration test for simple navigation bar
Slartibartfass2 Nov 17, 2024
cb1a06f
refactor: move drop down menu to separate component
Slartibartfass2 Nov 18, 2024
a0d94f3
feat: change navigation bar style
Slartibartfass2 Nov 18, 2024
78ff264
feat: add common interfaces and strongly type defaultTabValue
Slartibartfass2 Nov 18, 2024
f0cb8fc
test: remove duplicate tests and add another
Slartibartfass2 Nov 18, 2024
c8ec78c
feat: use correct properties for paper interface
Slartibartfass2 Nov 19, 2024
9634ac5
feat: when author list is empty 'unknown authors' is shown
Slartibartfass2 Nov 19, 2024
4420f83
feat: changed style of tabs
Slartibartfass2 Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@testing-library/svelte": "^5.2.4",
"@types/eslint": "^9.6.0",
"autoprefixer": "^10.4.20",
"bits-ui": "^1.0.0-next.51",
"clsx": "^2.1.1",
"@types/node": "^22.9.0",
"@vitest/coverage-v8": "^2.1.5",
Expand All @@ -34,6 +35,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.12.0",
"lucide-svelte": "^0.456.0",
"postcss": "^8.4.49",
"jsdom": "^25.0.1",
"prettier": "^3.3.2",
Expand Down
19 changes: 18 additions & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ declare global {
// interface PageData {}
// interface PageState {}
// interface Platform {}
interface Paper {
readonly id: number;
readonly data: PaperData;
}
interface PaperData {
readonly title: string;
readonly authors: string[];
readonly isBookmarked?: boolean;
}
interface Project {
readonly id: number;
readonly name: string;
}
interface User {
readonly firstName: string;
readonly lastName: string;
}
}
}

export {};
export { Paper, Project, User, PaperData };
51 changes: 51 additions & 0 deletions src/lib/components/composites/navigation-bar/NavigationBar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<script lang="ts">
import ArrowLeft from "lucide-svelte/icons/arrow-left";
import * as Card from "$lib/components/primitives/card/index.js";
import * as Tabs from "$lib/components/primitives/tabs/index.js";
import type { Snippet } from "svelte";
import UserMenu from "./UserMenu.svelte";
import type { Tab } from "$lib/components/composites/navigation-bar/navigation-bar";
import type { User } from "../../../../app";

interface Props {
user: User;
backRef?: string | undefined;
tabs: Tab[];
defaultTabValue: (typeof tabs)[number]["value"];
children?: Snippet | undefined;
}

const {
user,
backRef = undefined,
tabs,
defaultTabValue,
children = undefined,
}: Props = $props();
</script>

<header>
<Card.Root class="shadow-lg w-fit">
<nav class="grid grid-flow-col gap-3 items-center px-4 py-3">
<UserMenu {user} />
{#if backRef !== undefined}
<a href={backRef}><ArrowLeft class="w-6 h-6" /></a>
{/if}
<!-- Children can be e.g. a title element -->
{@render children?.()}
{#if tabs.length > 0}
<Tabs.Root value={defaultTabValue}>
<Tabs.List>
{#each tabs as tab}
<a href={tab.href}>
<Tabs.Trigger value={tab.value}>
<span>{tab.label}</span>
</Tabs.Trigger>
</a>
{/each}
</Tabs.List>
</Tabs.Root>
{/if}
</nav>
</Card.Root>
</header>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts">
import NavigationBar from "./NavigationBar.svelte";
import PaperInfo from "../paper-components/PaperInfo.svelte";
import type { PaperData, User } from "../../../../app";

interface Props {
user: User;
backRef?: string | undefined;
paper: { id: number | undefined; data: PaperData };
}

const { user, backRef, paper }: Props = $props();
</script>

<NavigationBar {user} {backRef} tabs={[]} defaultTabValue="">
<PaperInfo {paper} />
</NavigationBar>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script lang="ts">
import SimpleNavigationBar from "./SimpleNavigationBar.svelte";
import type { Tab } from "$lib/components/composites/navigation-bar/navigation-bar";
import type { Project, User } from "../../../../app";

type TabValue = (typeof tabs)[number]["value"];
interface Props {
user: User;
project: Project;
defaultTabValue: TabValue;
}

const { user, project, defaultTabValue }: Props = $props();
const tabs = [
{
value: "dashboard",
label: "Dashboard",
href: `/project/${project.id}/dashboard`,
},
{
value: "papers",
label: "Papers",
href: `/project/${project.id}/papers`,
},
{
value: "statistics",
label: "Statistics",
href: `/project/${project.id}/statistics`,
},
{
value: "settings",
label: "Settings",
href: `/project/${project.id}/settings/general`,
},
] as const;
</script>

<SimpleNavigationBar
{user}
backRef="/"
title={project.name}
tabs={tabs as unknown as Tab[]}
{defaultTabValue}
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script lang="ts">
import NavigationBar from "./NavigationBar.svelte";
import type { Tab } from "$lib/components/composites/navigation-bar/navigation-bar";
import type { User } from "../../../../app";

interface Props {
user: User;
backRef?: string | undefined;
title: string;
tabs: Tab[];
defaultTabValue: (typeof tabs)[number]["value"];
}

const { user, backRef = undefined, title, tabs, defaultTabValue }: Props = $props();
</script>

<NavigationBar {user} {backRef} {tabs} {defaultTabValue}>
<h2 class="place-content-center truncate">{title}</h2>
</NavigationBar>
Loading
Loading