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

feat: create dashboard servers #40

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
16 changes: 16 additions & 0 deletions apps/api/src/common/serialized-types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export class SerializedUser {
id: number;
name: string;
username: string;
email: string;

// biome-ignore lint/suspicious/noExplicitAny: <explanation>
constructor(user: any) {
// TODO: fix any

this.id = user.id;
this.name = user.name;
this.username = user.username;
this.email = user.email;
}
}

Check warning on line 16 in apps/api/src/common/serialized-types/user.ts

View check run for this annotation

Codecov / codecov/patch

apps/api/src/common/serialized-types/user.ts#L2-L16

Added lines #L2 - L16 were not covered by tests
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@tanstack/zod-form-adapter": "^0.33.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"framer-motion": "^11.9.0",
"gql.tada": "^1.8.9",
"graphql-request": "^7.1.0",
"lucide-react": "^0.445.0",
Expand Down
Binary file added apps/web/public/BotAvatar.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove image from public folder because it's not visible in the deployment.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/web/src/assets/discord-toggle-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions apps/web/src/components/layouts/servers.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't import Sidebar again it's already a layout in the path /app.

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { checkChannel } from "@/lib/utils";
import { useRouter } from "@tanstack/react-router";
import { Channels } from "../servers-layout/channels";
import Chat from "../servers-layout/chat";
import { Sidebar } from "./sidebar";

export const Servers = () => {
const user = {
id: 1,
username: "Amr",
profile_image_url: "https://placebear.com/200/200",
bio: "#AmrShoukry",
status: "online",
};

const server = {
id: 1,
name: "Active Courses",
image_url: "https://placebear.com/200/200",
channels: [
{
id: 1,
name: "HTML",
users: [
{
id: 1,
username: "Amr",
profile_image_url: "https://placebear.com/200/200",
status: "online",
},
{
id: 2,
username: "Moaz",
profile_image_url: "https://placebear.com/200/200",
status: "online",
},
{
id: 3,
username: "Ali",
profile_image_url: "https://placebear.com/200/200",
status: "offline",
},
],
messages: [
{
id: 1,
user_image: "https://placebear.com/200/200",
username: "Amr",
timestamp: "Yesterday at 2:13 PM",
content_string:
"Lorem ipsum dolor sit amet consectetur adipisicing.",
},
{
id: 2,
user_image: "https://placebear.com/200/200",
username: "Ali",
timestamp: "Yesterday at 2:15 PM",
content_string:
"Lorem ipsum dolor sit consectetur adipisicing.",
},
],
},
{
id: 2,
name: "CSS",
users: [
{
id: 1,
username: "Amr",
profile_image_url: "https://placebear.com/200/200",
status: "online",
},
{
id: 2,
username: "Moaz",
profile_image_url: "https://placebear.com/200/200",
status: "online",
},
{
id: 3,
username: "Ali",
profile_image_url: "https://placebear.com/200/200",
status: "offline",
},
],
messages: [
{
id: 1,
user_image: "https://placebear.com/200/200",
username: "Moaz",
timestamp: "Yesterday at 2:13 PM",
content_string:
"Lorem ipsum dolor sit amet consectetur adipisicing.",
},
{
id: 2,
user_image: "https://placebear.com/200/200",
username: "Ali",
timestamp: "Yesterday at 2:15 PM",
content_string:
"Lorem ipsum dolor sit consectetur adipisicing.",
},
],
},
],
};

const router = useRouter();
const currentUrl = router.state.location.pathname;
const isChannel = checkChannel(currentUrl);

// Listen for route changes and update state accordingly

return (
<div className="flex overflow-hidden">
<Sidebar />
<Channels server={server} user={user} />
{isChannel ? (
<Chat />
) : (
<p className="hidden w-full items-center justify-center bg-mainBlackHover md:flex">
Please Select A Channel To Continue
</p>
)}
</div>
);
};
107 changes: 57 additions & 50 deletions apps/web/src/components/layouts/sidebar.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a sever is active I don't need a hover effect, the white bar will be large if it's active and small if it's not.

Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,63 @@ export const Sidebar = () => {
const pathname = useLocation().pathname;

return (
!!isNavsOpen && (
<nav
className={`scrollbar-none scrollbar-hide w-24 overflow-y-auto bg-zinc-900 ${window.innerWidth < 1024 ? "slide-in-from-left animate-in duration-700" : ""}`}
>
{/* Dashboard */}
<TooltipProvider>
<Tooltip delayDuration={0}>
<TooltipTrigger className="w-full">
<Link
to="/app/channels/me"
className="group relative flex items-center justify-center py-2"
>
<Logo alt="Dashboard" />
<div
className={`absolute left-0 flex w-1 items-center justify-center overflow-hidden rounded-full bg-white duration-100 ${pathname.startsWith("/app/channels/me") && window.innerWidth > 1024 ? "top-3 h-2/3" : "top-1/2 h-2 group-hover:top-5 group-hover:h-6"}`}
></div>
</Link>
</TooltipTrigger>
<TooltipContent side="right">
Direct Messages
</TooltipContent>
</Tooltip>
</TooltipProvider>
{/* underline */}
<div className="mx-auto h-0.5 w-1/2 bg-zinc-600"></div>
{/* Servers */}
<div className="flex flex-col items-center justify-center gap-4 pt-4">
{Array.from({ length: 20 }).map((_, index) => (
<TooltipProvider key={index}>
<Tooltip delayDuration={0}>
<TooltipTrigger className="w-full">
<>
{isNavsOpen && (
<nav
className={`scrollbar-none scrollbar-hide h-[100vh] w-24 flex-shrink-0 overflow-y-auto bg-zinc-900 ${
window.innerWidth < 1024
? "slide-in-from-left animate-in duration-700"
: ""
}`}
>
{/* Dashboard Link */}
<TooltipProvider>
<Tooltip delayDuration={0}>
<TooltipTrigger className="w-full">
<Link
to="/app/channels/me"
className="group relative flex items-center justify-center py-2"
>
<Logo alt="Direct Messages" />
<div
key={index}
className="group relative flex w-full items-center justify-center"
>
<Logo alt="server" />
{/* Notifcation */}
<div
className={`absolute left-0 flex w-1 items-center justify-center overflow-hidden rounded-full bg-white duration-100 group-hover:top-3 group-hover:h-6 ${pathname === "/app/channels/" + index ? "top-0 h-full" : "top-1/3 h-2"}`}
></div>
</div>
</TooltipTrigger>
<TooltipContent side="right">
Server {index}
</TooltipContent>
</Tooltip>
</TooltipProvider>
))}
</div>
</nav>
)
className={`absolute left-0 flex w-1 items-center justify-center overflow-hidden rounded-full bg-white duration-100 ${pathname.startsWith("/app/channels/me") && window.innerWidth > 1024 ? "top-3 h-2/3" : "top-1/2 h-2 group-hover:top-5 group-hover:h-6"}`}
></div>
</Link>
</TooltipTrigger>
<TooltipContent side="right">
Direct Messages
</TooltipContent>
</Tooltip>
</TooltipProvider>

{/* Underline */}
<div className="mx-auto h-0.5 w-1/2 bg-zinc-600"></div>

{/* Servers */}
<div className="flex flex-col items-center justify-center gap-4 pt-4">
{Array.from({ length: 20 }).map((_, index) => (
<TooltipProvider key={index}>
<Tooltip delayDuration={0}>
<TooltipTrigger className="w-full">
<div className="group relative flex w-full items-center justify-center">
<Link to={`/app/channels/${index}`}>
<Logo alt={`server ${index}`} />
</Link>
{/* Notification */}
<div
className={`absolute left-0 flex w-1 items-center justify-center overflow-hidden rounded-full bg-white duration-100 group-hover:top-3 group-hover:h-6 ${pathname === `/app/channels/${index}` ? "top-0 h-full" : "top-1/3 h-2"}`}
></div>
</div>
</TooltipTrigger>
<TooltipContent side="right">
Server {index}
</TooltipContent>
</Tooltip>
</TooltipProvider>
))}
</div>
</nav>
)}
</>
);
};
44 changes: 44 additions & 0 deletions apps/web/src/components/servers-layout/channel-bar.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In small screens not all the content of the navbar is visible.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Link } from "@tanstack/react-router";
import React, { FC } from "react";
import BackSVG from "../svgs/back";
import BellMutedSVG from "../svgs/channel-bar/bell-muted";
import ChannelSVG from "../svgs/channel-bar/channel";
import HelpSVG from "../svgs/channel-bar/help";
import InboxSVG from "../svgs/channel-bar/inbox";
import PinSVG from "../svgs/channel-bar/pin";
import ThreadsSVG from "../svgs/channel-bar/threads";
import UsersSVG from "../svgs/channel-bar/users";

interface ChannelBarProps {
setIsExpanded: React.Dispatch<React.SetStateAction<boolean>>;
}

export const ChannelBar: FC<ChannelBarProps> = ({ setIsExpanded }) => {
const serverId = 1;
return (
<div className="custom-scrollbar flex h-[56px] items-center justify-between gap-[8px] overflow-x-auto border-b-[#000] border-b-[1px] border-b-solid bg-secondBlack px-[16px]">
<div className="flex items-center gap-[8px]">
<Link to={`/app/channels/${String(serverId)}`}>
<BackSVG />
</Link>
<ChannelSVG />
<p>Name</p>
</div>
<div className="flex items-center gap-[16px]">
<ThreadsSVG />
<BellMutedSVG />
<PinSVG />
<button onClick={() => setIsExpanded((old) => !old)}>
<UsersSVG />
</button>
<input
type="text"
className="h-[24px] rounded-sm bg-[#000] px-[4px] py-[8px] text-[12px]"
placeholder="Search"
/>
<InboxSVG />
<HelpSVG />
</div>
</div>
);
};
19 changes: 19 additions & 0 deletions apps/web/src/components/servers-layout/channel-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ChannelItemProps } from "@/types/servers";
import { Link } from "@tanstack/react-router";
import { FC } from "react";
import { DiscordChannelSVG } from "../svgs/discord-channel";

export const ChannelItem: FC<ChannelItemProps> = ({ channel, serverId }) => {
return (
<div className="relative flex items-center gap-[8px]">
<div className="flex h-2 w-1 items-center justify-center overflow-hidden rounded-full bg-white duration-100 group-hover:top-3 group-hover:h-6"></div>
<Link
to={`/app/channels/${serverId}/${channel.id}`}
className="mr-[8px] flex w-full items-center gap-[8px] rounded-sm px-[8px] py-[8px] hover:bg-mainBlackHover"
>
<DiscordChannelSVG />
<p>{channel.name}</p>
</Link>
</div>
);
};
Loading