Compare commits
3 changed files with 22 additions and 61 deletions
|
|
@ -1,11 +1,13 @@
|
||||||
|
import { Button, Popover, PopoverContent, PopoverTrigger } from "@tensamin/ui";
|
||||||
import {
|
import {
|
||||||
Button,
|
ArrowLeft,
|
||||||
Popover,
|
ChevronDown,
|
||||||
PopoverContent,
|
ChevronUp,
|
||||||
PopoverTrigger,
|
House,
|
||||||
useIsMobile,
|
Phone,
|
||||||
} from "@tensamin/ui";
|
Settings,
|
||||||
import { ArrowLeft, House, Phone, Settings, User } from "lucide-react";
|
User,
|
||||||
|
} from "lucide-react";
|
||||||
import { useLocation, useNavigate, useSearch } from "@tanstack/react-router";
|
import { useLocation, useNavigate, useSearch } from "@tanstack/react-router";
|
||||||
import { joinCall, useCall } from "@tensamin/call/store";
|
import { joinCall, useCall } from "@tensamin/call/store";
|
||||||
import Wrapper from "@tensamin/user/wrapper";
|
import Wrapper from "@tensamin/user/wrapper";
|
||||||
|
|
@ -31,8 +33,6 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) {
|
||||||
call.call_members.some((member) => member === id),
|
call.call_members.some((member) => member === id),
|
||||||
);
|
);
|
||||||
|
|
||||||
const isMobile = useIsMobile();
|
|
||||||
|
|
||||||
const [selectOpen, setSelectOpen] = useState(false);
|
const [selectOpen, setSelectOpen] = useState(false);
|
||||||
|
|
||||||
const [userInfoOpen, setUserInfoOpen] = useState(false);
|
const [userInfoOpen, setUserInfoOpen] = useState(false);
|
||||||
|
|
@ -72,10 +72,8 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) {
|
||||||
{pathname === "/chat" && id && (
|
{pathname === "/chat" && id && (
|
||||||
<Wrapper
|
<Wrapper
|
||||||
userId={id}
|
userId={id}
|
||||||
component={(user) =>
|
component={(user) => (
|
||||||
isMobile ? (
|
<>
|
||||||
<p className="font-medium text-md">{user?.display}</p>
|
|
||||||
) : (
|
|
||||||
<Popover open={userInfoOpen} onOpenChange={setUserInfoOpen}>
|
<Popover open={userInfoOpen} onOpenChange={setUserInfoOpen}>
|
||||||
<PopoverTrigger
|
<PopoverTrigger
|
||||||
render={
|
render={
|
||||||
|
|
@ -87,6 +85,7 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p className="font-medium text-md">{user?.display}</p>
|
<p className="font-medium text-md">{user?.display}</p>
|
||||||
|
{userInfoOpen ? <ChevronUp /> : <ChevronDown />}
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
@ -94,8 +93,8 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) {
|
||||||
<Profile user={user} />
|
<Profile user={user} />
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
)
|
</>
|
||||||
}
|
)}
|
||||||
loading={<Skeleton className="ml-3 w-40 h-5" />}
|
loading={<Skeleton className="ml-3 w-40 h-5" />}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tensamin",
|
"name": "tensamin",
|
||||||
"version": "0.0.8",
|
"version": "0.0.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ import {
|
||||||
ContextMenuTrigger,
|
ContextMenuTrigger,
|
||||||
Drawer,
|
Drawer,
|
||||||
DrawerContent,
|
DrawerContent,
|
||||||
DrawerDescription,
|
|
||||||
DrawerTitle,
|
|
||||||
DrawerTrigger,
|
DrawerTrigger,
|
||||||
useIsMobile,
|
useIsMobile,
|
||||||
} from "@tensamin/ui";
|
} from "@tensamin/ui";
|
||||||
|
|
@ -43,12 +41,6 @@ type MenuComponents = {
|
||||||
SubContent: (props: { children: ReactNode }) => ReactElement;
|
SubContent: (props: { children: ReactNode }) => ReactElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
function blurActiveElement() {
|
|
||||||
if (document.activeElement instanceof HTMLElement) {
|
|
||||||
document.activeElement.blur();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const desktopMenuComponents: MenuComponents = {
|
const desktopMenuComponents: MenuComponents = {
|
||||||
Content: ContextMenuContent,
|
Content: ContextMenuContent,
|
||||||
Group: ContextMenuGroup,
|
Group: ContextMenuGroup,
|
||||||
|
|
@ -59,20 +51,10 @@ const desktopMenuComponents: MenuComponents = {
|
||||||
SubContent: ContextMenuSubContent,
|
SubContent: ContextMenuSubContent,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getMobileMenuComponents({
|
function getMobileMenuComponents(onClose: () => void): MenuComponents {
|
||||||
description,
|
|
||||||
onClose,
|
|
||||||
title,
|
|
||||||
}: {
|
|
||||||
description: string;
|
|
||||||
onClose: () => void;
|
|
||||||
title: string;
|
|
||||||
}): MenuComponents {
|
|
||||||
return {
|
return {
|
||||||
Content: ({ className, children }) => (
|
Content: ({ className, children }) => (
|
||||||
<DrawerContent>
|
<DrawerContent>
|
||||||
<DrawerTitle className="sr-only">{title}</DrawerTitle>
|
|
||||||
<DrawerDescription className="sr-only">{description}</DrawerDescription>
|
|
||||||
<div className={cn("p-3!", className)}>{children}</div>
|
<div className={cn("p-3!", className)}>{children}</div>
|
||||||
</DrawerContent>
|
</DrawerContent>
|
||||||
),
|
),
|
||||||
|
|
@ -80,7 +62,6 @@ function getMobileMenuComponents({
|
||||||
Item: ({ children, className, disabled, onClick, variant = "default" }) => {
|
Item: ({ children, className, disabled, onClick, variant = "default" }) => {
|
||||||
async function handleClick() {
|
async function handleClick() {
|
||||||
await onClick?.();
|
await onClick?.();
|
||||||
blurActiveElement();
|
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,9 +86,8 @@ function getMobileMenuComponents({
|
||||||
Sub: ({ children }) => <div>{children}</div>,
|
Sub: ({ children }) => <div>{children}</div>,
|
||||||
SubTrigger: ({ children, onClick }) => {
|
SubTrigger: ({ children, onClick }) => {
|
||||||
async function handleClick() {
|
async function handleClick() {
|
||||||
blurActiveElement();
|
|
||||||
onClose();
|
|
||||||
await onClick?.();
|
await onClick?.();
|
||||||
|
onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -218,23 +198,11 @@ export default function MessageContextMenu({
|
||||||
);
|
);
|
||||||
const [mainDrawerOpen, setMainDrawerOpen] = useState(false);
|
const [mainDrawerOpen, setMainDrawerOpen] = useState(false);
|
||||||
const [reactionDrawerOpen, setReactionDrawerOpen] = useState(false);
|
const [reactionDrawerOpen, setReactionDrawerOpen] = useState(false);
|
||||||
const mainDrawerComponents = useMemo(
|
const mainDrawerComponents = getMobileMenuComponents(() =>
|
||||||
() =>
|
setMainDrawerOpen(false),
|
||||||
getMobileMenuComponents({
|
|
||||||
description: "Actions available for this message.",
|
|
||||||
onClose: () => setMainDrawerOpen(false),
|
|
||||||
title: "Message actions",
|
|
||||||
}),
|
|
||||||
[],
|
|
||||||
);
|
);
|
||||||
const reactionDrawerComponents = useMemo(
|
const reactionDrawerComponents = getMobileMenuComponents(() =>
|
||||||
() =>
|
setReactionDrawerOpen(false),
|
||||||
getMobileMenuComponents({
|
|
||||||
description: "Choose a reaction to add to this message.",
|
|
||||||
onClose: () => setReactionDrawerOpen(false),
|
|
||||||
title: "Add reaction",
|
|
||||||
}),
|
|
||||||
[],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
|
|
@ -253,13 +221,7 @@ export default function MessageContextMenu({
|
||||||
</Drawer>
|
</Drawer>
|
||||||
<Drawer open={reactionDrawerOpen} onOpenChange={setReactionDrawerOpen}>
|
<Drawer open={reactionDrawerOpen} onOpenChange={setReactionDrawerOpen}>
|
||||||
<DrawerContent>
|
<DrawerContent>
|
||||||
<DrawerTitle className="sr-only">Add reaction</DrawerTitle>
|
<ReactionItems Item={reactionDrawerComponents.Item} />
|
||||||
<DrawerDescription className="sr-only">
|
|
||||||
Choose a reaction to add to this message.
|
|
||||||
</DrawerDescription>
|
|
||||||
<div className="p-3!">
|
|
||||||
<ReactionItems Item={reactionDrawerComponents.Item} />
|
|
||||||
</div>
|
|
||||||
</DrawerContent>
|
</DrawerContent>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue