Skip to content

Commit

Permalink
feat(navbar): highlight selected category
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Oct 24, 2023
1 parent da942a2 commit de64637
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 125 deletions.
10 changes: 10 additions & 0 deletions src/lib/components/NavSidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Profile from "$lib/components/sidebar/Profile.svelte"
import SideButton from "$lib/components/sidebar/SideButton.svelte"
import Icon from "@iconify/svelte"
import { PageType } from "$lib/stores/StateStore"
</script>

<div class="side-container dark:bg-dark bg-lightdark">
Expand All @@ -21,9 +22,18 @@
</button>
</div>
<ul class="side-buttons">
<!-- Buttons Here -->
<SideButton
iconSrc="/chat.svg"
href="/chat"
name="Chat with AI"
category={PageType.Chat}
/>
<SideButton
iconSrc="/document.svg"
name="Docs Organizer"
category={PageType.Docs}
href="/docs"
/>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/chat/ChatPage.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>1231233313123</h1>
Empty file.
114 changes: 0 additions & 114 deletions src/lib/components/share/Input.svelte

This file was deleted.

25 changes: 22 additions & 3 deletions src/lib/components/sidebar/SideButton.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
<script lang="ts">
import type { PageType } from "$lib/stores/StateStore"
import { stateStore } from "$lib/stores/StateStore"
export let iconSrc: string
export let name = "None"
export let category: PageType | undefined
export let href: string
const applyCategory = () => {
if (category) $stateStore.pageType = category
}
</script>

<li class="side-btn">
<a class="side-btn-wrap side-btn" href="/test">
<a class="side-btn-wrap side-btn"
on:click={applyCategory}
class:selected={$stateStore.pageType === category}
href={href}
>
<div class="side-btn-content">
<img alt="icon"
class="vertical-center"
src={iconSrc}
width="24px"
width="28px"
/>
<h5 class="text-2xl text-right">{name}</h5>
<h5 class="text-2xl">{name}</h5>
</div>
</a>
</li>
Expand Down Expand Up @@ -43,9 +57,14 @@
background-color: #474749;
}
.selected {
background-color: #474749 !important;
}
.side-btn .side-btn-wrap .side-btn-content {
display: flex;
align-items: center;
justify-content: center;
}
.side-btn .side-btn-wrap .side-btn-content h5 {
Expand Down
14 changes: 10 additions & 4 deletions src/lib/stores/StateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ export enum Appearance {
Dark
}

/**
* @desc First value is must be two over.
* If not, it will be confusing to use comparison operators.
* @example $stateStore.pageType === PageType.Chat
* If chat is 0, it will be true even if it is not chat.
*/
export enum PageType {
Chat,
Document,
Chat = 2,
Docs,
}

export interface StateStore {
showSettings: boolean
appearance: Appearance
chatType: PageType
pageType: PageType
}


export const stateStore = writable<StateStore>({
showSettings: false,
appearance: Appearance.Dark,
chatType: PageType.Chat
pageType: PageType.Chat
})
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Sidebar from "$lib/components/NavSidebar.svelte"
import ChatInput from "$lib/components/share/Input.svelte"
import ChatInput from "$lib/components/share/ChatInput.svelte"
import Settings from "$lib/components/sidebar/settings/Settings.svelte"
import { DarkMode } from "$lib/utils/DarkMode"
import { onMount } from "svelte"
Expand Down
6 changes: 6 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<script lang="ts">
import { onMount } from "svelte"
onMount(() => {
// TODO if not settings about first page
location.href = "/chat"
})
</script>

<svelte:head>
Expand Down
3 changes: 3 additions & 0 deletions src/routes/chat/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
Chat here
</div>
3 changes: 3 additions & 0 deletions src/routes/docs/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
Docs here
</div>
6 changes: 3 additions & 3 deletions static/document.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de64637

Please sign in to comment.