public inbox for [email protected]
 help / color / mirror / Atom feed
From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	Dwiky Rizky Ananditya <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH v1 11/17] feat(components): add app-sidebar component
Date: Sun, 19 Jan 2025 08:11:28 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

this component will dispaly its sidebar like menu navigations.

Signed-off-by: Muhammad Rizki <[email protected]>
---
 src/lib/components/customs/app-sidebar.svelte | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 src/lib/components/customs/app-sidebar.svelte

diff --git a/src/lib/components/customs/app-sidebar.svelte b/src/lib/components/customs/app-sidebar.svelte
new file mode 100644
index 0000000..9291b94
--- /dev/null
+++ b/src/lib/components/customs/app-sidebar.svelte
@@ -0,0 +1,74 @@
+<script lang="ts">
+  import { navigations } from "$constants";
+  import Separator from "$components/ui/separator/separator.svelte";
+  import * as Sidebar from "$lib/components/ui/sidebar";
+  import { useAuth } from "$lib/hooks/auth.svelte";
+  import { LogOut, Mails } from "lucide-svelte";
+  import type { ComponentProps } from "svelte";
+  import { goto } from "$app/navigation";
+    import Button from "$components/ui/button/button.svelte";
+
+  let { ref = $bindable(null), ...restProps }: ComponentProps<typeof Sidebar.Root> = $props();
+
+  const auth = useAuth();
+  const sidebar = Sidebar.useSidebar();
+
+  const handleNavigationMobile = () => {
+    if (!sidebar.isMobile) return;
+    sidebar.toggle();
+  };
+
+  const handleLogout = () => {
+    auth.clear();
+    goto("/");
+  };
+</script>
+
+<Sidebar.Root bind:ref variant="inset" collapsible="icon" {...restProps}>
+  <Sidebar.Content>
+    <Sidebar.Group>
+      <Sidebar.Header>
+        <Sidebar.Menu>
+          <Sidebar.MenuItem>
+            <Sidebar.MenuButton onclick={() => sidebar.toggle()} size="lg">
+              <div
+                class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground"
+              >
+                <Mails class="size-4" />
+              </div>
+              <div class="grid flex-1 text-left text-sm leading-tight">
+                <span class="truncate font-semibold">{auth.user?.full_name}</span>
+                <span class="truncate text-xs">@{auth.user?.username}</span>
+              </div>
+            </Sidebar.MenuButton>
+          </Sidebar.MenuItem>
+        </Sidebar.Menu>
+      </Sidebar.Header>
+      <Separator class="mb-3" />
+      <Sidebar.GroupContent>
+        <Sidebar.Menu>
+          {#each navigations as item (item.name)}
+            <Sidebar.MenuItem>
+              <Sidebar.MenuButton>
+                {#snippet child({ props })}
+                  <a href={item.url} onclick={handleNavigationMobile} {...props}>
+                    <item.icon />
+                    <span>{item.name}</span>
+                  </a>
+                {/snippet}
+              </Sidebar.MenuButton>
+            </Sidebar.MenuItem>
+          {/each}
+        </Sidebar.Menu>
+      </Sidebar.GroupContent>
+    </Sidebar.Group>
+  </Sidebar.Content>
+  <Sidebar.Footer>
+    <Sidebar.Menu>
+      <Button variant="destructive" onclick={handleLogout} class="flex justify-start items-center w-full">
+        <LogOut />
+        <span>Logout</span>
+      </Button>
+    </Sidebar.Menu>
+  </Sidebar.Footer>
+</Sidebar.Root>
-- 
Muhammad Rizki


  parent reply	other threads:[~2025-01-19  1:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-19  1:11 [PATCH RESEND v1 00/17] Refactor GNU/Weeb Mail Site Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 01/17] feat: initial front-end Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 02/17] feat(routes): configure page layout options Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 03/17] feat(fonts): add Google fonts Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 04/17] feat(components): add shadcn-svelte components Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 05/17] feat(deps): add `axios` as HTTP client Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 06/17] feat(deps): add `svelte-copy` dependency Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 07/17] feat(constants): add navigations and mail-config constant Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 08/17] feat(components): add loading spinner component Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 09/17] feat(components): add header component Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 10/17] feat: initial hooks, schemas, typings for the login functions Muhammad Rizki
2025-01-19  1:11 ` Muhammad Rizki [this message]
2025-01-19  1:11 ` [PATCH v1 12/17] feat(routes): create initial settings page Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 13/17] feat(routes): add home page Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 14/17] feat(routes): add main layout for the protected routes Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 15/17] feat(routes): add login page Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 16/17] chore(.gitignore): add patch files ignore Muhammad Rizki
2025-01-19  1:11 ` [PATCH v1 17/17] chore: update README.md Muhammad Rizki
2025-01-19 19:53 ` [PATCH RESEND v1 00/17] Refactor GNU/Weeb Mail Site Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox