Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 27 additions & 9 deletions code/components/room-components/context-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { cn } from "@/lib/utils";

type ContextMenuButtonProps = {
label: React.ReactNode;
icon?: React.ReactNode;
disabled?: boolean;
onClick: () => void;
};
Expand All @@ -16,6 +17,7 @@ export type ContextMenuOption = {
| {
type: "button";
label: string;
icon?: React.ReactNode;
disabled?: boolean;
onClick: () => void;
}
Expand All @@ -31,22 +33,35 @@ type ContextMenuProps = {
options: ContextMenuOption[];
};

function ContextMenuButton({ label, disabled, onClick }: Readonly<ContextMenuButtonProps>) {
function ContextMenuButton({
label,
icon,
disabled,
onClick,
}: Readonly<ContextMenuButtonProps>) {
return (
<button
className={cn("!cursor-pointer font-body-m-light w-full bg-transparent text-left px-3 py-2", {
["hover:bg-light-background-hover"]: !disabled,
["!cursor-default"]: disabled,
})}
className={cn(
"!cursor-pointer w-[calc(100%-8px)] flex justify-start items-center gap-2 font-noto-sans-mono text-sm text-left whitespace-nowrap m-1 text-foreground px-2 py-1.5",
{
["hover:bg-accent"]: !disabled,
["!cursor-default hover:bg-white text-muted-foreground"]: disabled,
}
)}
disabled={disabled}
onClick={onClick}
>
{label}
{icon} {label}
</button>
);
}

export const ContextMenu = ({ show, onChanged, position, options }: Readonly<ContextMenuProps>) => {
export const ContextMenuRender = ({
show,
onChanged,
position,
options,
}: Readonly<ContextMenuProps>) => {
const ref = React.useRef<HTMLDivElement>(null);

React.useEffect(() => {
Expand All @@ -68,7 +83,7 @@ export const ContextMenu = ({ show, onChanged, position, options }: Readonly<Con
return (
<div
ref={ref}
className="fixed w-[200px] bg-light-background-1 flex flex-col border border-light-border-1"
className="fixed w-[200px] bg-white flex flex-col border border-zinc-200 shadow-xs"
style={{
display: show ? "block" : "none",
top: `${position.y}px`,
Expand All @@ -81,13 +96,16 @@ export const ContextMenu = ({ show, onChanged, position, options }: Readonly<Con
<ContextMenuButton
key={option.id}
label={option.label}
icon={option.icon}
disabled={option.disabled ?? false}
onClick={option.onClick}
/>
);
}
if (option.type === "divider") {
return <div key={option.id} className="w-full h-[1px] bg-light-background-3"></div>;
return (
<div key={option.id} className="w-full h-[1px] bg-zinc-200"></div>
);
}
})}
</div>
Expand Down
16 changes: 7 additions & 9 deletions code/components/room/room.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import { Hourglass } from "lucide-react";
import React from "react";
import { ContextMenu } from "@/components/room-components/context-menu";
import { ContextMenuRender } from "@/components/room-components/context-menu";
import { useCollaborationRoom } from "@/store/store";
import { RoomInformationOverlay } from "@/components/room-components/overlay/room-information-overlay";
import { RoomStatusOverlay } from "@/components/room-components/overlay/room-status-overlay";
import { ToolsOverlay } from "@/components/room-components/overlay/tools-overlay";
import { MultiuseOverlay } from "@/components/room-components/overlay/multiuse-overlay";
// import { OperationsOverlay } from "@/components/room-components/overlay/operations-overlay";
import { useWeave } from "@inditextech/weavejs-react";
import { RoomLoader } from "../room-components/room-loader";
import { WEAVE_INSTANCE_STATUS } from "@inditextech/weavejs-sdk";
Expand Down Expand Up @@ -92,20 +91,19 @@ export const RoomLayout = () => {
)}
{status === WEAVE_INSTANCE_STATUS.RUNNING && roomLoaded && (
<>
<RoomInformationOverlay />
<RoomStatusOverlay />
<ToolsOverlay />
<ZoomHandlerOverlay />
{/* <OperationsOverlay /> */}
<MultiuseOverlay />
<ContextMenu
<ContextMenuRender
show={contextMenuShow}
onChanged={(show: boolean) => {
setContextMenuShow(show);
}}
position={contextMenuPosition}
options={contextMenuOptions}
/>
<RoomInformationOverlay />
<RoomStatusOverlay />
<ToolsOverlay />
<ZoomHandlerOverlay />
<MultiuseOverlay />
{uploadingImage && (
<div className="w-full h-full bg-light-background-inverse/25 flex justify-center items-center absolute top-0 left-0">
<div className="flex flex-col gap-2 bg-light-background-1 p-8 justify-center items-center">
Expand Down
37 changes: 32 additions & 5 deletions code/components/room/room.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import {
WeaveSelection,
} from "@inditextech/weavejs-sdk";
// import { WeaveStoreWebsocketsConnectionStatus, WeaveStoreWebsockets } from "@inditextech/weavejs-store-websockets";
import { WeaveStoreAzureWebPubsubConnectionStatus, WeaveStoreAzureWebPubsub } from "@inditextech/weavejs-store-azure-web-pubsub";
import {
WeaveStoreAzureWebPubsubConnectionStatus,
WeaveStoreAzureWebPubsub,
} from "@inditextech/weavejs-store-azure-web-pubsub";
import { PantoneNode } from "@/components/nodes/pantone/pantone";
import { PantoneToolAction } from "@/components/actions/pantone-tool/pantone-tool";
import { WorkspaceNode } from "@/components/nodes/workspace/workspace";
Expand All @@ -39,6 +42,17 @@ import { useWeave, WeaveProvider } from "@inditextech/weavejs-react";
import { RoomLayout } from "./room.layout";
import { AlignElementsToolAction } from "@/components/actions/align-elements-tool/align-elements-tool";
import { RoomLoader } from "../room-components/room-loader";
import {
Copy,
Clipboard,
Group,
Ungroup,
Trash,
SendToBack,
BringToFront,
ArrowUp,
ArrowDown,
} from "lucide-react";

export const Room = () => {
const params = useParams<{ roomId: string }>();
Expand All @@ -52,8 +66,12 @@ export const Room = () => {
const user = useCollaborationRoom((state) => state.user);
const setRoom = useCollaborationRoom((state) => state.setRoom);
const setUser = useCollaborationRoom((state) => state.setUser);
const setFetchConnectionUrlLoading = useCollaborationRoom((state) => state.setFetchConnectionUrlLoading);
const setFetchConnectionUrlError = useCollaborationRoom((state) => state.setFetchConnectionUrlError);
const setFetchConnectionUrlLoading = useCollaborationRoom(
(state) => state.setFetchConnectionUrlLoading
);
const setFetchConnectionUrlError = useCollaborationRoom(
(state) => state.setFetchConnectionUrlError
);

const setContextMenuShow = useCollaborationRoom(
(state) => state.setContextMenuShow
Expand Down Expand Up @@ -94,15 +112,15 @@ export const Room = () => {
setFetchConnectionUrlError(error);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[],
[]
);

const onConnectionStatusChangeHandler = React.useCallback(
(status: WeaveStoreAzureWebPubsubConnectionStatus) => {
setConnectionStatus(status);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[],
[]
);

// const onConnectionStatusChangeHandler = React.useCallback(
Expand Down Expand Up @@ -235,6 +253,7 @@ export const Room = () => {
id: "copy",
type: "button",
label: "Copy",
icon: <Copy size={16} />,
disabled: actIsActionActive || !actCanCopy,
onClick: () => {
const weaveCopyPasteNodesPlugin =
Expand All @@ -250,6 +269,7 @@ export const Room = () => {
id: "paste",
type: "button",
label: "Paste",
icon: <Clipboard size={16} />,
disabled: actIsActionActive || !actCanPaste,
onClick: () => {
const weaveCopyPasteNodesPlugin =
Expand All @@ -269,6 +289,7 @@ export const Room = () => {
id: "bring-to-front",
type: "button",
label: "Bring to front",
icon: <BringToFront size={16} />,
disabled: nodes.length !== 1,
onClick: () => {
actInstance.bringToFront(nodes[0].instance);
Expand All @@ -278,6 +299,7 @@ export const Room = () => {
id: "move-up",
type: "button",
label: "Move up",
icon: <ArrowUp size={16} />,
disabled: nodes.length !== 1,
onClick: () => {
actInstance.moveUp(nodes[0].instance);
Expand All @@ -287,6 +309,7 @@ export const Room = () => {
id: "move-down",
type: "button",
label: "Move down",
icon: <ArrowDown size={16} />,
disabled: nodes.length !== 1,
onClick: () => {
actInstance.moveDown(nodes[0].instance);
Expand All @@ -296,6 +319,7 @@ export const Room = () => {
id: "send-to-back",
type: "button",
label: "Send to back",
icon: <SendToBack size={16} />,
disabled: nodes.length !== 1,
onClick: () => {
actInstance.sendToBack(nodes[0].instance);
Expand All @@ -309,6 +333,7 @@ export const Room = () => {
id: "group",
type: "button",
label: "Group",
icon: <Group size={16} />,
disabled: !canGroup,
onClick: () => {
actInstance.group(nodes.map((n) => n.node));
Expand All @@ -318,6 +343,7 @@ export const Room = () => {
id: "ungroup",
type: "button",
label: "Ungroup",
icon: <Ungroup size={16} />,
disabled: !canUnGroup,
onClick: () => {
actInstance.unGroup(nodes[0].node);
Expand All @@ -331,6 +357,7 @@ export const Room = () => {
id: "delete",
type: "button",
label: "Delete",
icon: <Trash size={16} />,
onClick: () => {
for (const node of nodes) {
actInstance.removeNode(node.node);
Expand Down
32 changes: 16 additions & 16 deletions code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading