Skip to content

Commit

Permalink
feat: Add profile on mobile top nav (unkeyed#2236)
Browse files Browse the repository at this point in the history
* Feature/Add profile on mobile top nav

* Update mobile-sidebar.tsx

* Update user-button.tsx

* [autofix.ci] apply automated fixes

* Update user-button.tsx

* Update user-button.tsx

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
pragyananda and autofix-ci[bot] authored Oct 10, 2024
1 parent 3ef2cc7 commit c948512
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
15 changes: 9 additions & 6 deletions apps/dashboard/app/(app)/mobile-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Menu } from "lucide-react";
import Link from "next/link";
import { useSelectedLayoutSegments } from "next/navigation";
import { WorkspaceSwitcher } from "./team-switcher";
import { UserButton } from "./user-button";

type Props = {
className?: string;
Expand All @@ -23,17 +24,19 @@ type Props = {

export const MobileSideBar = ({ className, workspace }: Props) => {
const segments = useSelectedLayoutSegments() ?? [];

const workspaceNavigation = createWorkspaceNavigation(workspace, segments);

return (
<div className={cn(className, "w-96")}>
<div className={cn(className, "w-full")}>
<Sheet>
<div className="flex items-center justify-between w-full p-4 gap-6">
<SheetTrigger>
<Menu className="w-6 h-6 " />
</SheetTrigger>
<WorkspaceSwitcher />
<div className={cn(className, "w-96 flex items-center justify-between py-4 gap-6")}>
<SheetTrigger>
<Menu className="w-6 h-6 " />
</SheetTrigger>
<WorkspaceSwitcher />
</div>
<UserButton />
</div>
<SheetHeader>
<SheetClose />
Expand Down
33 changes: 26 additions & 7 deletions apps/dashboard/app/(app)/user-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Book, ChevronRight, LogOut, Rocket, Settings } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import type React from "react";

export const UserButton: React.FC = () => {
const { user } = useUser();
const router = useRouter();
Expand All @@ -25,17 +26,35 @@ export const UserButton: React.FC = () => {

return (
<DropdownMenu>
<DropdownMenuTrigger className="flex items-center justify-between gap-2 p-2 w-full h-12 rounded-[0.625rem] hover:bg-background-subtle hover:cursor-pointer text-content">
<div className="flex items-center gap-2 whitespace-nowrap overflow-hidden">
<Avatar className="w-5 h-5">
<DropdownMenuTrigger className="flex items-center justify-between gap-2 p-2 w-auto lg:w-full h-12 rounded-lg hover:bg-background-subtle hover:cursor-pointer text-content ">
<div className="flex items-center gap-2 overflow-hidden whitespace-nowrap">
<Tooltip>
<TooltipTrigger
className="w-full overflow-hidden text-ellipsis hidden sm:inline lg:hidden"
asChild
>
<span className="overflow-hidden text-ellipsis text-sm font-medium">
{user.username ?? user.fullName ?? user.primaryEmailAddress?.emailAddress}
</span>
</TooltipTrigger>
<TooltipContent>
<span className="text-sm font-medium">
{user.username ?? user.fullName ?? user.primaryEmailAddress?.emailAddress}
</span>
</TooltipContent>
</Tooltip>
<Avatar className="w-8 h-8 lg:w-5 lg:h-5">
{user.imageUrl ? <AvatarImage src={user.imageUrl} alt="Profile picture" /> : null}
<AvatarFallback className=" w-5 h-5 overflow-hidden text-gray-700 bg-gray-100 border border-gray-500 rounded-md">
<AvatarFallback className="w-8 h-8 lg:w-5 lg:h-5 bg-gray-100 border border-gray-500 rounded-md">
{(user?.fullName ?? "U").slice(0, 2).toUpperCase()}
</AvatarFallback>
</Avatar>

<Tooltip>
<TooltipTrigger asChild>
<TooltipTrigger
className="hidden lg:inline w-full overflow-hidden text-ellipsis"
asChild
>
<span className="overflow-hidden text-ellipsis text-sm font-medium">
{user.username ?? user.fullName ?? user.primaryEmailAddress?.emailAddress}
</span>
Expand All @@ -47,9 +66,9 @@ export const UserButton: React.FC = () => {
</TooltipContent>
</Tooltip>
</div>
<ChevronRight className="w-4 h-4" />
<ChevronRight className="hidden lg:inline w-4 h-4" />
</DropdownMenuTrigger>
<DropdownMenuContent side="right" className="w-96">
<DropdownMenuContent side="bottom" className="w-full max-w-xs md:w-96">
<DropdownMenuGroup>
<Link href="/new">
<DropdownMenuItem className="cursor-pointer">
Expand Down

0 comments on commit c948512

Please sign in to comment.