-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
157 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { useState } from "preact/hooks"; | ||
import SideBarItems from "./SideBarItems.tsx"; | ||
import type { Subscription } from "../types"; | ||
import ThemeToggle from "./ThemeToggle.tsx"; | ||
|
||
interface Props { | ||
userEmail?: string; | ||
apiUrl: string; | ||
subs: Subscription[]; | ||
} | ||
|
||
const Sidebar = ({ userEmail, apiUrl, subs }: Props) => { | ||
const [showSidebar, setShowSidebar] = useState(false); | ||
|
||
return ( | ||
<> | ||
<div class="lg:hidden"> | ||
{showSidebar ? ( | ||
<div> | ||
<div | ||
className="w-full h-full bg-zinc-500 dark:bg-zinc-700 fixed z-20 opacity-50" | ||
/> | ||
<button | ||
className="flex text-5xl items-center cursor-pointer fixed right-6 top-2 z-50" | ||
onClick={() => setShowSidebar(!showSidebar)} | ||
> | ||
x | ||
</button> | ||
</div> | ||
) : ( | ||
<svg | ||
onClick={() => setShowSidebar(!showSidebar)} | ||
className="fixed z-30 flex items-center cursor-pointer right-5 top-5 fill-black dark:fill-white" | ||
viewBox="0 0 100 80" | ||
width="40" | ||
height="40" | ||
> | ||
<rect width="100" height="10"></rect> | ||
<rect y="30" width="100" height="10"></rect> | ||
<rect y="60" width="100" height="10"></rect> | ||
</svg> | ||
)} | ||
</div> | ||
|
||
<div | ||
className={`top-0 right-0 w-2/3 lg:1/6 bg-zinc-300 dark:bg-zinc-500 p-1 fixed h-full z-40 | ||
ease-in-out duration-300 ${showSidebar ? "translate-x-0 " : "translate-x-full"} | ||
overflow-y-scroll`} | ||
> | ||
<SideBarItems | ||
userEmail={userEmail} | ||
apiUrl={apiUrl} | ||
subs={subs} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Sidebar; |
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,39 @@ | ||
--- | ||
import SideBarItems from "./SideBarItems.tsx"; | ||
import { SignOut } from "auth-astro/components"; | ||
import type { Subscription } from "../types"; | ||
import type { Session } from "@auth/core/types"; | ||
interface Props { | ||
session: Session | null; | ||
userEmail?: string; | ||
apiUrl: string; | ||
subs: Subscription[]; | ||
} | ||
const { session, userEmail, apiUrl, subs } = Astro.props; | ||
--- | ||
|
||
<nav | ||
class="bg-zinc-300 dark:bg-zinc-500 w-1/4 lg:w-1/6 | ||
text-center overflow-hidden overflow-y-scroll space-y-5 | ||
p-1 h-full fixed top-0 left-0 hidden lg:block" | ||
> | ||
<div> | ||
{ | ||
session ? ( | ||
<SignOut class="hover:bg-zinc-600 rounded-lg p-2 shadow-md transition:ease-in duration-100"> | ||
Sign out | ||
</SignOut> | ||
) : ( | ||
<a | ||
class="hover:bg-zinc-600 rounded-lg p-2 shadow-md transition:ease-in duration-100" | ||
href="/login" | ||
> | ||
Sign in | ||
</a> | ||
) | ||
} | ||
</div> | ||
<SideBarItems apiUrl={apiUrl} subs={subs} userEmail={userEmail} /> | ||
</nav> |
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,37 @@ | ||
import AllSubscriptionsList from "./allSubscriptions"; | ||
import type { Subscription } from "@/types"; | ||
|
||
interface Props { | ||
userEmail?: string; | ||
apiUrl: string; | ||
subs: Subscription[]; | ||
} | ||
|
||
const SideBarItems = ({ userEmail, apiUrl, subs }: Props) => { | ||
return ( | ||
|
||
<div class="w-7/8 lg:w-5/6 m-auto space-y-5 mt-20"> | ||
<a | ||
href="/posts/1" | ||
class="hover:bg-zinc-600 rounded-lg p-2 shadow-md transition:ease-in duration-100 | ||
text-center m-auto flex justify-center items-center " | ||
> | ||
Home | ||
</a> | ||
<ul> | ||
<details class="cursor-pointer"> | ||
<summary class="text-zinc-800 text-xs lg:text-lg" | ||
>Subscriptions</summary | ||
> | ||
<AllSubscriptionsList | ||
userEmail={userEmail} | ||
apiUrl={apiUrl} | ||
subs={subs} | ||
/> | ||
</details> | ||
</ul> | ||
</div > | ||
) | ||
} | ||
|
||
export default SideBarItems; |
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
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