Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

Collab ui tweaks (#913)

David Luzar2db2f3f5e416
diff --git a/src/components/App.tsx b/src/components/App.tsx
index cb8a41dcfc..2305488eaf 100644
--- a/src/components/App.tsx
+++ b/src/components/App.tsx
@@ -234,6 +234,8 @@ export class App extends React.Component<any, AppState> {
private destroySocketClient = () => {
this.setState({
isCollaborating: false,
+ remotePointers: {},
+ collaboratorCount: 0,
});
if (this.socket) {
this.socket.close();
diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx
index 58bfdcc170..e3efb0ccee 100644
--- a/src/components/LayerUI.tsx
+++ b/src/components/LayerUI.tsx
@@ -109,13 +109,14 @@ export const LayerUI = React.memo(
<Section className="App-right-menu" heading="canvasActions">
<Island padding={4}>
<Stack.Col gap={4}>
- <Stack.Row gap={2.25} justifyContent={"space-between"}>
+ <Stack.Row gap={1} justifyContent={"space-between"}>
{actionManager.renderAction("loadScene")}
{actionManager.renderAction("saveScene")}
{renderExportDialog()}
{actionManager.renderAction("clearCanvas")}
<RoomDialog
isCollaborating={appState.isCollaborating}
+ collaboratorCount={appState.collaboratorCount}
onRoomCreate={onRoomCreate}
onRoomDestroy={onRoomDestroy}
/>
diff --git a/src/components/MobileMenu.tsx b/src/components/MobileMenu.tsx
index 8dcf4b6f19..2b28186ffb 100644
--- a/src/components/MobileMenu.tsx
+++ b/src/components/MobileMenu.tsx
@@ -47,6 +47,7 @@ export function MobileMenu({
{actionManager.renderAction("clearCanvas")}
<RoomDialog
isCollaborating={appState.isCollaborating}
+ collaboratorCount={appState.collaboratorCount}
onRoomCreate={onRoomCreate}
onRoomDestroy={onRoomDestroy}
/>
diff --git a/src/components/RoomDialog.scss b/src/components/RoomDialog.scss
index 04a59c927d..54cfdc8902 100644
--- a/src/components/RoomDialog.scss
+++ b/src/components/RoomDialog.scss
@@ -3,6 +3,19 @@
color: #2b8a3e; // OC GREEN-9
}
+.RoomDialog-modalButton-collaborators {
+ min-width: 1em;
+ position: absolute;
+ bottom: -5px;
+ right: -5px;
+ padding: 3px;
+ border-radius: 50%;
+ background-color: #40c057; // OC GREEN-6
+ color: #fff;
+ font-size: 0.7em;
+ font-family: var(--ui-font);
+}
+
.RoomDialog-linkContainer {
display: flex;
margin: 1.5em 0;
@@ -11,7 +24,7 @@
.RoomDialog-link {
min-width: 0;
flex: 1 1 auto;
- margin-left: 1.5em;
+ margin-left: 1em;
display: inline-block;
cursor: pointer;
border: none;
diff --git a/src/components/RoomDialog.tsx b/src/components/RoomDialog.tsx
index c4392d1a07..f4720f2dc1 100644
--- a/src/components/RoomDialog.tsx
+++ b/src/components/RoomDialog.tsx
@@ -5,9 +5,9 @@ import { t } from "../i18n";
import useIsMobile from "../is-mobile";
import { users, clipboard, start, stop } from "./icons";
import { Modal } from "./Modal";
-
-import "./RoomDialog.scss";
import { copyTextToSystemClipboard } from "../clipboard";
+import { AppState } from "../types";
+import "./RoomDialog.scss";
function RoomModal({
onCloseRequest,
@@ -111,10 +111,12 @@ function RoomModal({
export function RoomDialog({
isCollaborating,
+ collaboratorCount,
onRoomCreate,
onRoomDestroy,
}: {
- isCollaborating: boolean;
+ isCollaborating: AppState["isCollaborating"];
+ collaboratorCount: AppState["collaboratorCount"];
onRoomCreate: () => void;
onRoomDestroy: () => void;
}) {
@@ -145,7 +147,13 @@ export function RoomDialog({
aria-label={t("buttons.roomDialog")}
showAriaLabel={useIsMobile()}
ref={triggerButton}
- />
+ >
+ {collaboratorCount > 0 && (
+ <div className="RoomDialog-modalButton-collaborators">
+ {collaboratorCount}
+ </div>
+ )}
+ </ToolButton>
{modalIsShown && (
<Modal
maxWidth={800}
diff --git a/src/components/ToolButton.tsx b/src/components/ToolButton.tsx
index ea4ea1c6b2..0b5a7a7e15 100644
--- a/src/components/ToolButton.tsx
+++ b/src/components/ToolButton.tsx
@@ -21,7 +21,11 @@ type ToolButtonBaseProps = {
};
type ToolButtonProps =
- | (ToolButtonBaseProps & { type: "button"; onClick?(): void })
+ | (ToolButtonBaseProps & {
+ type: "button";
+ children?: React.ReactNode;
+ onClick?(): void;
+ })
| (ToolButtonBaseProps & {
type: "radio";
@@ -61,6 +65,7 @@ export const ToolButton = React.forwardRef(function(
{props.showAriaLabel && (
<div className="ToolIcon__label">{props["aria-label"]}</div>
)}
+ {props.children}
</button>
);
}