Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

Dev - freemocap v2 onboarding tooltips plus styles (#801)

Pooya Moradi M.bbd5071482b1
diff --git a/app-design-v2/src/App.css b/app-design-v2/src/App.css
index 678aa68f..14626dbe 100644
--- a/app-design-v2/src/App.css
+++ b/app-design-v2/src/App.css
@@ -39,11 +39,11 @@
--import-icon: url("./assets/icons/import_icon.svg");
--externallink-icon: url("./assets/icons/externallink_icon.svg");
--dropdown-icon: url("./assets/icons/dropdown_icon.svg");
- --stream-icon: url("./assets/icons/stream_icon.svg");
- --streaming-icon: url("./assets/icons/streaming_icon.svg");
- --calibrate-icon: url("./assets/icons/calibrate_icon.svg");
- --calibrated-icon: url("./assets/icons/calibrated_icon.svg");
- --camera-icon: url("./assets/icons/camera_icon.svg");
+ --stream-icon: url("./assets/icons/stream_icon.svg");
+ --streaming-icon: url("./assets/icons/streaming_icon.svg");
+ --calibrate-icon: url("./assets/icons/calibrate_icon.svg");
+ --calibrated-icon: url("./assets/icons/calibrated_icon.svg");
+ --camera-icon: url("./assets/icons/camera_icon.svg");
--record-icon: url("./assets/icons/record_icon.svg");
--calibrate-icon: url("./assets/icons/calibrate_icon.svg");
@@ -224,11 +224,12 @@ q::after {
/* BUTTON STYLES AND SHAPES */
/* Activate button */
-.activated > p {
- color: var(--green-100);
+.activated>p {
+ color: var(--green-100);
}
+
.button.activated:hover {
- background-color: var(--green-900);
+ background-color: var(--green-900);
}
/* Primary fullwidth button */
@@ -268,7 +269,12 @@ q::after {
}
.button.sm.externallink:after {
- content: var(--externallink-icon);
+ content: "";
+ background-image: var(--externallink-icon);
+ transform-origin: center center;
+ background-repeat: no-repeat;
+ background-position: center;
+ background-size: contain;
}
.button.sm.dropdown:after {
@@ -290,36 +296,39 @@ q::after {
transition: background-color var(--speed-1) ease-in-out;
}
-.button:not(
- p,
- .button.checkbox,
- button.text-sm,
- input,
- button.active,
- .toggle-button
- ):active {
+.button:not(p,
+ .button.checkbox,
+ button.text-sm,
+ input,
+ button.active,
+ .toggle-button):active {
transform: scale(96%);
}
+
/* video tiles */
.video-tile {
- flex: 1 1 200px;
-
- height: auto;
- aspect-ratio: 1 / 1;
- }
+ flex: 1 1 200px;
+
+ height: auto;
+ aspect-ratio: 1 / 1;
+}
+
.video-tile.size-1 {
- min-width: 300px
+ min-width: 300px
}
+
.video-tile.empty:before {
- content: var(--camera-icon);
- margin: 8px;
- display: block;
+ content: var(--camera-icon);
+ margin: 8px;
+ display: block;
}
+
.video-tile.empty {
- border: 1.5px dashed var(--gray-500);
+ border: 1.5px dashed var(--gray-500);
- background: transparent;
+ background: transparent;
}
+
/* segmented-control design */
.segmented-control-container {
max-width: max-content;
@@ -332,17 +341,17 @@ q::after {
transition: color var(--speed-1) ease-in-out;
}
-.segmented-control-button > p.text.md {
+.segmented-control-button>p.text.md {
/* medium size */
min-height: 25px;
}
-.segmented-control-button > p.text.sm {
+.segmented-control-button>p.text.sm {
/* small size */
min-height: 22px;
}
-.segmented-control-button:hover > p {
+.segmented-control-button:hover>p {
color: var(--gray-100);
transition: color var(--speed-1) ease-in-out;
}
@@ -518,6 +527,7 @@ a:after {
.z-10 {
z-index: 10;
}
+
/* order */
.order-1 {
order: 1;
@@ -558,6 +568,7 @@ a:after {
.order-10 {
order: 10;
}
+
/* positions */
.pos-abs {
position: absolute;
@@ -608,9 +619,11 @@ a:after {
.flex-col {
flex-direction: column;
}
+
.flex-wrap {
flex-wrap: wrap;
}
+
.items-center {
align-items: center;
}
@@ -618,6 +631,7 @@ a:after {
.justify-center {
justify-content: center;
}
+
.flex-start {
align-items: flex-start;
}
@@ -868,7 +882,7 @@ a:after {
justify-content: center;
}
-.icon-button:hover > .icon {
+.icon-button:hover>.icon {
filter: brightness(2);
/* filter animation out */
transition: filter var(--speed-1) ease-in-out;
@@ -892,15 +906,19 @@ a:after {
.close-icon {
background-image: var(--close-icon);
}
+
.stream-icon {
background-image: var(--stream-icon);
}
+
.streaming-icon {
background-image: var(--streaming-icon);
}
+
.calibrate-icon {
background-image: var(--calibrate-icon);
}
+
.calibrated-icon {
background-image: var(--calibrated-icon);
}
@@ -1085,17 +1103,19 @@ body,
/* animation: scaleIn 0.3s ease forwards; */
animation: fadeIn, scaleIn;
}
+
.conection-container {
width: 255px;
}
-.disabled > * {
+
+.disabled>* {
opacity: 0.3;
transition: opacity var(--speed-2) ease-in-out;
}
.disabled,
-.disabled > * {
+.disabled>* {
pointer-events: none;
/* prevents clicking */
}
@@ -1148,7 +1168,7 @@ body,
gap: 0.5em;
}
-.form-control + .form-control {
+.form-control+.form-control {
margin-top: 1em;
}
@@ -1365,4 +1385,4 @@ input[type="checkbox"]:disabled {
transform: scale(1);
opacity: 1;
}
-} */
+} */
\ No newline at end of file
diff --git a/freemocap-ui/public/images/charuco_board.webp b/freemocap-ui/public/images/charuco_board.webp
new file mode 100644
index 00000000..513fc410
Binary files /dev/null and b/freemocap-ui/public/images/charuco_board.webp differ
diff --git a/freemocap-ui/public/images/charuco_settings.webp b/freemocap-ui/public/images/charuco_settings.webp
new file mode 100644
index 00000000..d8b78d3d
Binary files /dev/null and b/freemocap-ui/public/images/charuco_settings.webp differ
diff --git a/freemocap-ui/src/app/AppContent.tsx b/freemocap-ui/src/app/AppContent.tsx
index 7e367512..295d94bc 100644
--- a/freemocap-ui/src/app/AppContent.tsx
+++ b/freemocap-ui/src/app/AppContent.tsx
@@ -11,6 +11,8 @@ import { useTranslation } from "react-i18next";
import { getLocaleDirection } from "@/i18n";
import { fetchAllRecordings } from "@/store/slices/recording-status/recording-status-thunks";
import { WelcomeModal } from "@/components/ui-components/WelcomeModal";
+import {FloatingOnboarding} from "@/hooks/floatingOnboarding.tsx";
+import PromptTooltip from "@/components/ui-components/promptTooltip";
export const AppContent = function () {
const { i18n } = useTranslation();
diff --git a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeView.tsx b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeView.tsx
index 955290f1..1c6d47d7 100644
--- a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeView.tsx
+++ b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeView.tsx
@@ -44,7 +44,7 @@ export const CameraConfigTreeView: React.FC = () => {
</span>
)}
<div className="flex-1" />
- <div className="button-group flex items-center gap-1 pos-rel">
+ <div data-onboarding="camera:connect-camera" className="button-group flex items-center gap-1 pos-rel">
<CameraHeaderActions />
</div>
</div>
diff --git a/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-module.tsx b/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-module.tsx
index 381c2ccd..d3329c0a 100644
--- a/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-module.tsx
+++ b/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-module.tsx
@@ -1,14 +1,17 @@
-import React, { useCallback, useMemo, useState, useEffect } from "react";
+import React, { useCallback, useMemo, useState, useEffect, useRef } from "react";
import { useLocation } from "react-router-dom";
import SubactionHeader from "@/components/ui-components/SubactionHeader";
import ToggleComponent from "@/components/ui-components/ToggleComponent";
import IconButton from "@/components/ui-components/IconButton";
import DropdownButton from "@/components/ui-components/DropdownButton.tsx";
import CalibrationSettings from "./calibration-settings";
+import { FloatingOnboarding } from "@/hooks/floatingOnboarding";
+import PromptTooltip from "@/components/ui-components/promptTooltip";
import ButtonSm from "@/components/ui-components/ButtonSm";
import { useCalibration } from "@/hooks/useCalibration";
import { useElectronIPC, useServer } from "@/services";
import { useAppDispatch, useAppSelector } from "@/store";
+import { loadFromStorage, saveToStorage } from "@/store/persistence";
import {
calibrationAutoLoadDismissed,
calibrationLoadedFromBundle,
@@ -17,18 +20,6 @@ import {
} from "@/store/slices/calibration";
type CalibrationSource = "record" | "import-videos" | "import-toml";
-
-/**
- * Represents the current operating mode of the application.
- * - "streaming": real-time camera capture mode (all calibration options available, including "Record and Calibrate")
- * - "playback": video playback mode ("Record and Calibrate" option should be hidden from the dropdown)
- *
- * TODO[INTEGRATION]: Replace this dummy state with the actual mode from the app's
- * global state or server. For example, you might fetch this from:
- * - A Redux selector like `useAppSelector(selectAppMode)`
- * - An IPC call to the backend
- * - A context provider
- */
type AppMode = "streaming" | "playback";
const SOURCE_ICONS: Record<CalibrationSource, string> = {
@@ -73,9 +64,27 @@ const CalibrationModule = ({
} = useCalibration();
const [showCalibrationSettings, setShowCalibrationSettings] = useState(false);
+ const [showCharucoInfo, setShowCharucoInfo] = useState(false);
const [calibrationSource, setCalibrationSource] =
useState<CalibrationSource>("record");
+ const hasAutoOpened = useRef(false);
+
+ useEffect(() => {
+ if (hasAutoOpened.current) return;
+ if (connectedCameraIds.length < 2) return;
+ const dismissed = loadFromStorage<boolean>("calibration-tooltip-dismissed", false);
+ if (!dismissed) {
+ setShowCharucoInfo(true);
+ }
+ hasAutoOpened.current = true;
+ }, [connectedCameraIds.length]);
+
+ const handleCloseCharucoInfo = useCallback(() => {
+ setShowCharucoInfo(false);
+ saveToStorage("calibration-tooltip-dismissed", true);
+ }, []);
+
// Derive app mode from the current route, unless overridden by props
const location = useLocation();
const appMode: AppMode = appModeOverride ?? (location.pathname === "/playback" ? "playback" : "streaming");
@@ -401,15 +410,38 @@ const CalibrationModule = ({
<div className="flex flex-row items-center">
<div className="flex flex-row flex-1 justify-content-space-between items-center w-100">
<SubactionHeader text="Calibration" />
- <div className="flex flex-row gap-1 items-center">
+ <div data-onboarding="calibration:what-is-calibration" className="flex flex-row pos-rel gap-1 items-center">
<IconButton
icon="explainer-icon"
className="button sm"
- onClick={() => {}} // shows onboarding tooltips
+ onClick={() => setShowCharucoInfo(prev => !prev)}
tooltip
tooltipText="How to calibrate"
tooltipPosition="pos-left"
/>
+ <FloatingOnboarding
+ target='[data-onboarding="calibration:what-is-calibration"]'
+ className=""
+ >
+ <PromptTooltip
+ show={showCharucoInfo}
+ title="How to Calibrate your cameras"
+ text="Print a ChArUco board and show it to each camera while recording, pan and rotate it so it can be captured from different angles for accurate 3D tracking."
+ image={true}
+ imageSrc="/images/charuco_board.webp"
+ position="pos-right"
+ variant="default"
+ button={true}
+ buttonText="Download ChArUco Board"
+ onButtonClick={() =>
+ window.open(
+ "https://docs.freemocap.org/documentation/multi-camera-calibration.html",
+ "_blank",
+ )
+ }
+ onClose={handleCloseCharucoInfo}
+ />
+ </FloatingOnboarding>
</div>
</div>
</div>
diff --git a/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-settings.tsx b/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-settings.tsx
index de7c8e09..20f77c66 100644
--- a/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-settings.tsx
+++ b/freemocap-ui/src/components/pipeline-progress/calibration-progress/calibration-settings.tsx
@@ -1,4 +1,10 @@
-import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import React, {
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import SubactionHeader from "@/components/ui-components/SubactionHeader";
import ValueSelector from "@/components/ui-components/ValueSelector";
import IconButton from "@/components/ui-components/IconButton";
@@ -6,6 +12,9 @@ import NameDropdownSelector from "@/components/ui-components/NameDropdownSelecto
import { useCalibration } from "@/hooks/useCalibration";
import { CalibrationSolverMethod } from "@/store/slices/calibration";
+import { FloatingOnboarding } from "@/hooks/floatingOnboarding";
+import PromptTooltip from "@/components/ui-components/promptTooltip";
+
type BoardPreset = "5 x 3" | "7 x 5" | "Custom";
interface BoardPresetDims {
@@ -24,7 +33,7 @@ const PRESET_OPTIONS_SOLVER = ["Anipose legacy", "Accurate"];
const solverLabelToMethod: Record<string, CalibrationSolverMethod> = {
"Anipose legacy": "anipose",
- "Accurate": "pyceres",
+ Accurate: "pyceres",
};
const solverMethodToLabel: Record<CalibrationSolverMethod, string> = {
@@ -47,7 +56,10 @@ const CalibrationSettings = ({ onClose }: CalibrationSettingsProps) => {
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
- if (modalRef.current && !modalRef.current.contains(event.target as Node)) {
+ if (
+ modalRef.current &&
+ !modalRef.current.contains(event.target as Node)
+ ) {
handleClose();
}
};
@@ -66,7 +78,10 @@ const CalibrationSettings = ({ onClose }: CalibrationSettingsProps) => {
const currentPreset = useMemo<BoardPreset>(() => {
for (const [preset, dims] of Object.entries(BOARD_PRESETS)) {
- if (dims.squares_x === board.squares_x && dims.squares_y === board.squares_y) {
+ if (
+ dims.squares_x === board.squares_x &&
+ dims.squares_y === board.squares_y
+ ) {
return preset as BoardPreset;
}
}
@@ -74,6 +89,7 @@ const CalibrationSettings = ({ onClose }: CalibrationSettingsProps) => {
}, [board.squares_x, board.squares_y]);
const [forcedCustom, setForcedCustom] = useState(false);
+ const [showTooltip, setShowTooltip] = useState(true);
const displayedPreset: BoardPreset = forcedCustom ? "Custom" : currentPreset;
@@ -101,23 +117,43 @@ const CalibrationSettings = ({ onClose }: CalibrationSettingsProps) => {
);
return (
- <div
- className="z-10 calibration-settings-flyout pos-fixed draggable border-1 border-black elevated-sharp flex flex-col p-1 bg-dark br-2 reveal fadeIn gap-1"
- >
- <div className="gap-1 flex flex-col right-0 p-2 bg-middark br-1 z-1" ref={modalRef} onClick={(e) => e.stopPropagation()}>
+ <div className="z-10 calibration-settings-flyout pos-fixed draggable border-1 border-black elevated-sharp flex flex-col p-1 bg-dark br-2 reveal fadeIn gap-1">
+ <div
+ className="gap-1 flex flex-col right-0 p-2 bg-middark br-1 z-1"
+ ref={modalRef}
+ onClick={(e) => e.stopPropagation()}
+ >
{/* Header */}
+
<div className="flex flex-row justify-content-space-between items-center">
<div className="flex flex-row flex-1 justify-content-space-between items-center w-100">
<SubactionHeader text="Charuco board settings" />
- <div className="flex flex-row gap-1 items-center">
+ <div
+ data-onboarding="calibration:charuco-settings"
+ className="flex flex-row pos-rel gap-1 items-center"
+ >
<IconButton
icon="explainer-icon"
className="button sm"
- onClick={() => {}} // Does nothing but clicks
+ onClick={() => setShowTooltip(prev => !prev)}
tooltip
- tooltipText="Learn about calibration"
+ tooltipText="Learn about ChArUco"
tooltipPosition="pos-left"
/>
+ <PromptTooltip
+ show={showTooltip}
+ title="Understand board settings"
+ text={
+ "Preset: The type of tile-based charuco board, either 3Γ—5 or 7Γ—5.\n" +
+ "Square length: The exact dimension of each black square. Measure this square precisely in millimeters.\n" +
+ "Solver method: There are two options. Select the appropriate one depending on the use case."
+ }
+ image={true}
+ imageSrc="/images/charuco_settings.webp"
+ position="pos-right"
+ variant="default"
+ onClose={() => setShowTooltip(false)}
+ />
</div>
</div>
</div>
@@ -144,7 +180,11 @@ const CalibrationSettings = ({ onClose }: CalibrationSettingsProps) => {
step={1}
unit=""
disabled={displayedPreset !== "Custom"}
- onChange={(v) => updateCalibrationConfig({ charucoBoard: { ...board, squares_x: v } })}
+ onChange={(v) =>
+ updateCalibrationConfig({
+ charucoBoard: { ...board, squares_x: v },
+ })
+ }
/>
</div>
@@ -158,7 +198,11 @@ const CalibrationSettings = ({ onClose }: CalibrationSettingsProps) => {
step={1}
unit=""
disabled={displayedPreset !== "Custom"}
- onChange={(v) => updateCalibrationConfig({ charucoBoard: { ...board, squares_y: v } })}
+ onChange={(v) =>
+ updateCalibrationConfig({
+ charucoBoard: { ...board, squares_y: v },
+ })
+ }
/>
</div>
@@ -173,7 +217,11 @@ const CalibrationSettings = ({ onClose }: CalibrationSettingsProps) => {
max={9999999}
step={0.1}
unit="mm"
- onChange={(v) => updateCalibrationConfig({ charucoBoard: { ...board, square_length_mm: v } })}
+ onChange={(v) =>
+ updateCalibrationConfig({
+ charucoBoard: { ...board, square_length_mm: v },
+ })
+ }
/>
</div>
diff --git a/freemocap-ui/src/components/ui-components/MainNavTabs.tsx b/freemocap-ui/src/components/ui-components/MainNavTabs.tsx
index 30e95058..ade9d990 100644
--- a/freemocap-ui/src/components/ui-components/MainNavTabs.tsx
+++ b/freemocap-ui/src/components/ui-components/MainNavTabs.tsx
@@ -82,16 +82,16 @@ export const MainNavTabs = () => {
{NAV_TABS.map((tab, idx) => {
const isActive = idx === activeIdx;
return (
- <button
+ <div
key={tab.path}
- className={`segmented-control-button justify-center button pl-2 pr-2 gap-1 br-1 flex-inline items-center${isActive ? ' bg-dark' : ''}`}
+ className={`segmented-control-button justify-center button pl-2 pr-2 gap-1 br-1 flex-inline items-center cursor-pointer${isActive ? ' bg-dark' : ''}`}
onClick={() => handleClick(tab.path)}
>
{tab.path === '/active-recording'
? <ActiveRecordingLabel />
: <p className={`text md text-center p-1 ${isActive ? ' text-white' : ' text-gray'}`}>{tab.label}</p>
}
- </button>
+ </div>
);
})}
</div>
diff --git a/freemocap-ui/src/components/ui-components/PromptTooltip.tsx b/freemocap-ui/src/components/ui-components/PromptTooltip.tsx
index 4ad1e505..911d15d4 100644
--- a/freemocap-ui/src/components/ui-components/PromptTooltip.tsx
+++ b/freemocap-ui/src/components/ui-components/PromptTooltip.tsx
@@ -74,7 +74,7 @@ const PromptTooltip: React.FC<PromptTooltipProps> = ({
>
<div
className={clsx(
- "tooltip-inner",
+ "floating-tooltip-inner",
"gap-2",
"flex",
"flex-col",
@@ -109,7 +109,7 @@ const PromptTooltip: React.FC<PromptTooltipProps> = ({
)}
<div className="tooltip-description-holder flex flex-row pos-rel">
- <p className="text-white text md">{text}</p>
+ <p className="text-white text md" style={{ whiteSpace: "pre-line" }}>{text}</p>
</div>
{button && (
@@ -119,7 +119,7 @@ const PromptTooltip: React.FC<PromptTooltipProps> = ({
iconClass={buttonIcon}
buttonType={buttonType}
onClick={onButtonClick}
- className="flex-1 externallink tertiary full-width flex-inline text-left items-center full-width justify-center"
+ className="flex-1 bg-primary externallink tertiary full-width flex-inline text-left items-center full-width justify-center"
/>
</div>
)}
diff --git a/freemocap-ui/src/hooks/floatingOnboarding.tsx b/freemocap-ui/src/hooks/floatingOnboarding.tsx
new file mode 100644
index 00000000..ab8ccabe
--- /dev/null
+++ b/freemocap-ui/src/hooks/floatingOnboarding.tsx
@@ -0,0 +1,511 @@
+ // FloatingOnboarding.tsx ::::: Pooya Moradi M. 2026 <[email protected]> :::::
+ /*
+ EXAMPLE USAGE: WITH PROMPTTOOLTIP
+
+ IMPORT BOTH
+ import {FloatingOnboarding} from "@/hooks/floatingOnboarding";
+ import PromptTooltip from "@/components/ui-components/promptTooltip";
+ ADD [data-onboarding="XXXXXX"] TO THE REFERENCE DOM DELEMENT TO ANCHOR TO
+
+
+
+ <FloatingOnboarding
+ target='[data-onboarding="connect-cameras"]'
+
+ offset={16}
+ >
+ <PromptTooltip
+ show={true} // add condition when to show the prompt tooltip
+ title="Connect Cameras"
+ text="Make sure you have at least one camera plugged in, then hit Connect to start streaming."
+ position="pos-right"
+ variant="boarding"
+ onClose={() => {
+ // console.log("Tooltip closed");
+ }}
+ />
+ </FloatingOnboarding>
+
+ */
+
+ import React, {
+ ReactNode,
+ useEffect,
+ useLayoutEffect,
+ useRef,
+ useState,
+ isValidElement,
+ cloneElement,
+ } from "react";
+
+ import { createPortal } from "react-dom";
+
+ interface FloatingOnboardingProps {
+ // CSS selector of target element
+ target: string;
+
+ offsetTop?: number;
+ offsetLeft?: number;
+
+ // Tooltip / overlay content
+ children: ReactNode;
+
+ // Show / hide onboarding
+ show?: boolean;
+
+ // Additional CSS classes
+ className?: string;
+ }
+
+ type Position = {
+ top: number;
+ left: number;
+ };
+
+ export function FloatingOnboarding({
+ target,
+ children,
+ show = true,
+className,
+ offsetTop = 0,
+ offsetLeft = 0,
+ }: FloatingOnboardingProps) {
+ // =========================================================
+ // REFS
+ // =========================================================
+
+ const tooltipRef =
+ useRef<HTMLDivElement | null>(null);
+
+ // =========================================================
+ // STATE
+ // =========================================================
+
+ const [mounted, setMounted] =
+ useState(false);
+
+ const [targetElement, setTargetElement] =
+ useState<HTMLElement | null>(null);
+
+ const [position, setPosition] =
+ useState<Position>({
+ top: 0,
+ left: 0,
+ });
+
+
+ // =========================================================
+// CHILD VISIBILITY DETECTION
+// =========================================================
+
+const childShouldRender =
+ isValidElement(children)
+ ? (children.props as { show?: boolean }).show !== false
+ : true;
+
+
+ // Internal auto-unmount state
+ const [isActive, setIsActive] =
+ useState(true);
+ useEffect(() => {
+ if (childShouldRender) {
+ setIsActive(true);
+ }
+}, [childShouldRender]);
+
+ // =========================================================
+ // CONFIG AREA
+ // =========================================================
+
+ const VIEWPORT_PADDING = 12;
+
+ // const OFFSET_X = 0;
+
+ // const OFFSET_Y = 0;
+
+ const Z_INDEX = 99;
+
+ const POSITION_TRANSITION =
+ "top 0.01s linear, left 0.01s linear";
+
+ // =========================================================
+ // FIND / TRACK TARGET ELEMENT
+ // =========================================================
+
+ useEffect(() => {
+ let observer: MutationObserver | null =
+ null;
+
+ const syncTarget = () => {
+ const el = document.querySelector(
+ target
+ ) as HTMLElement | null;
+
+ // -----------------------------------
+ // target missing
+ // -----------------------------------
+
+ if (!el || !document.body.contains(el)) {
+ setTargetElement(null);
+ return;
+ }
+
+ // -----------------------------------
+ // hidden element
+ // -----------------------------------
+
+ const rect = el.getBoundingClientRect();
+
+ const style =
+ window.getComputedStyle(el);
+
+ const isHidden =
+ style.display === "none" ||
+ style.visibility === "hidden" ||
+ style.opacity === "0" ||
+ rect.width === 0 ||
+ rect.height === 0;
+
+ if (isHidden) {
+ setTargetElement(null);
+ return;
+ }
+
+ // -----------------------------------
+ // visible + valid
+ // -----------------------------------
+
+ setTargetElement(el);
+ };
+
+ // initial sync
+ syncTarget();
+
+ // dynamic app watcher
+ observer = new MutationObserver(() => {
+ syncTarget();
+ });
+
+ observer.observe(document.body, {
+ childList: true,
+ subtree: true,
+ attributes: true,
+ attributeFilter: [
+ "style",
+ "class",
+ "hidden",
+ ],
+ });
+
+ // viewport/activity updates
+ window.addEventListener(
+ "resize",
+ syncTarget
+ );
+
+ window.addEventListener(
+ "scroll",
+ syncTarget,
+ true
+ );
+
+ return () => {
+ observer?.disconnect();
+
+ window.removeEventListener(
+ "resize",
+ syncTarget
+ );
+
+ window.removeEventListener(
+ "scroll",
+ syncTarget,
+ true
+ );
+ };
+ }, [target]);
+
+ // =========================================================
+ // MOUNTED STATE
+ // =========================================================
+
+ useEffect(() => {
+ setMounted(true);
+ }, []);
+
+ // =========================================================
+ // POSITION ENGINE
+ // =========================================================
+
+ const updatePosition = () => {
+ if (!targetElement) return;
+
+ // target got removed dynamically
+ if (!document.body.contains(targetElement)) {
+ setTargetElement(null);
+ return;
+ }
+
+ if (!tooltipRef.current) return;
+
+ // =====================================================
+ // GET TARGET POSITION
+ // =====================================================
+
+ const targetRect =
+ targetElement.getBoundingClientRect();
+
+ // =====================================================
+ // MATCH TARGET SIZE
+ // =====================================================
+
+ const targetWidth = targetRect.width;
+ const targetHeight = targetRect.height;
+
+ tooltipRef.current.style.width =
+ `${targetWidth}px`;
+
+ tooltipRef.current.style.height =
+ `${targetHeight}px`;
+
+ tooltipRef.current.style.minWidth =
+ `${targetWidth}px`;
+
+ tooltipRef.current.style.minHeight =
+ `${targetHeight}px`;
+
+ // =====================================================
+ // GET TOOLTIP SIZE
+ // =====================================================
+
+ const tooltipRect =
+ tooltipRef.current.getBoundingClientRect();
+
+ // =====================================================
+ // CENTER ALIGNMENT
+ // =====================================================
+
+ let left =
+ targetRect.left +
+ targetRect.width / 2 -
+ tooltipRect.width / 2;
+
+ let top =
+ targetRect.top +
+ targetRect.height / 2 -
+ tooltipRect.height / 2;
+
+ // =====================================================
+ // OPTIONAL CUSTOM OFFSETS
+ // =====================================================
+
+ left += offsetLeft;
+ top += offsetTop;
+
+ // =====================================================
+ // EDGE DETECTION
+ // =====================================================
+
+ // if (left < VIEWPORT_PADDING) {
+ // left = VIEWPORT_PADDING;
+ // }
+
+ // if (
+ // left + tooltipRect.width >
+ // window.innerWidth - VIEWPORT_PADDING
+ // ) {
+ // left =
+ // window.innerWidth -
+ // tooltipRect.width -
+ // VIEWPORT_PADDING;
+ // }
+
+ // if (top < VIEWPORT_PADDING) {
+ // top = VIEWPORT_PADDING;
+ // }
+
+ // if (
+ // top + tooltipRect.height >
+ // window.innerHeight -
+ // VIEWPORT_PADDING
+ // ) {
+ // top =
+ // window.innerHeight -
+ // tooltipRect.height -
+ // VIEWPORT_PADDING;
+ // }
+
+ // =====================================================
+ // APPLY POSITION
+ // =====================================================
+
+ setPosition({
+ top,
+ left,
+ });
+ };
+
+ // =========================================================
+ // INITIAL POSITION
+ // =========================================================
+
+ useLayoutEffect(() => {
+ updatePosition();
+ }, [targetElement]);
+
+ // =========================================================
+ // AUTO UPDATE ENGINE
+ // =========================================================
+
+ useEffect(() => {
+ if (!targetElement) return;
+
+ updatePosition();
+
+ const handleUpdate = () => {
+ updatePosition();
+ };
+
+ // =====================================================
+ // SCROLL LISTENER
+ // =====================================================
+
+ window.addEventListener(
+ "scroll",
+ handleUpdate,
+ true
+ );
+
+ // =====================================================
+ // WINDOW RESIZE
+ // =====================================================
+
+ window.addEventListener(
+ "resize",
+ handleUpdate
+ );
+
+ // =====================================================
+ // RESIZE OBSERVER
+ // =====================================================
+
+ const resizeObserver =
+ new ResizeObserver(() => {
+ updatePosition();
+ });
+
+ resizeObserver.observe(targetElement);
+
+ if (tooltipRef.current) {
+ resizeObserver.observe(
+ tooltipRef.current
+ );
+ }
+
+ // =====================================================
+ // RAF LOOP
+ // =====================================================
+
+ let frame = 0;
+
+ const loop = () => {
+ updatePosition();
+
+ frame = requestAnimationFrame(loop);
+ };
+
+ frame = requestAnimationFrame(loop);
+
+ // =====================================================
+ // CLEANUP
+ // =====================================================
+
+ return () => {
+ window.removeEventListener(
+ "scroll",
+ handleUpdate,
+ true
+ );
+
+ window.removeEventListener(
+ "resize",
+ handleUpdate
+ );
+
+ resizeObserver.disconnect();
+
+ cancelAnimationFrame(frame);
+ };
+ }, [targetElement]);
+
+
+
+ // =========================================================
+ // AUTO-INJECT UNMOUNT CALLBACK
+ // =========================================================
+
+ let content = children;
+
+ if (isValidElement(children)) {
+ content = cloneElement(
+ children as React.ReactElement<any>,
+ {
+ __floatingOnboardingUnmount:
+ () => {
+ setIsActive(false);
+ },
+ }
+ );
+ }
+
+ // =========================================================
+ // RENDER GUARDS
+ // =========================================================
+
+ if (!mounted) return null;
+
+ if (!show || !childShouldRender)
+ return null;
+
+ if (!targetElement) return null;
+
+
+ // Auto-remove container
+ if (!isActive) return null;
+
+ // =========================================================
+ // PORTAL RENDER
+ // =========================================================
+
+ return createPortal(
+ <div
+ className={`prompt-tooltip-reference-container${className ? ` ${className}` : ''}`}
+ ref={tooltipRef}
+ style={{
+ position: "fixed",
+
+ top: position.top,
+ left: position.left,
+
+ zIndex: Z_INDEX,
+
+ boxSizing: "border-box",
+
+ transition:
+ POSITION_TRANSITION,
+
+ pointerEvents: "none",
+
+ userSelect: "none",
+ WebkitUserSelect: "none",
+
+ touchAction: "none",
+
+ WebkitTouchCallout: "none",
+ }}
+ >
+ {content}
+ </div>,
+ document.body
+ );
+ }
\ No newline at end of file
diff --git a/freemocap-ui/src/hooks/useDraggableTooltips.tsx b/freemocap-ui/src/hooks/useDraggableTooltips.tsx
index eb0e0cfa..2947354f 100644
--- a/freemocap-ui/src/hooks/useDraggableTooltips.tsx
+++ b/freemocap-ui/src/hooks/useDraggableTooltips.tsx
@@ -144,7 +144,7 @@ export default function useDraggableTooltips(): void {
if (!dragging && Math.abs(dx) + Math.abs(dy) > DRAG_THRESHOLD) {
dragging = true;
toggleUserSelect(false);
- el.style.zIndex = "9999";
+ el.style.zIndex = "";
// Ensure parent has position context for nested elements
if (window.getComputedStyle(el).position === "static") {
diff --git a/freemocap-ui/src/layout/BasePanelLayout.tsx b/freemocap-ui/src/layout/BasePanelLayout.tsx
index 4a7ac18d..c6807e7b 100644
--- a/freemocap-ui/src/layout/BasePanelLayout.tsx
+++ b/freemocap-ui/src/layout/BasePanelLayout.tsx
@@ -1,100 +1,168 @@
-import React, {useCallback, useEffect, useRef, useState} from "react";
-import {ImperativePanelHandle, Panel, PanelGroup, PanelResizeHandle} from "react-resizable-panels";
-import {SidePanelContent} from "@/layout/content/SidePanelContent";
+import React, { useCallback, useEffect, useRef, useState } from "react";
+import {
+ ImperativePanelHandle,
+ Panel,
+ PanelGroup,
+ PanelResizeHandle,
+} from "react-resizable-panels";
+import { useLocation } from "react-router-dom";
+import { SidePanelContent } from "@/layout/content/SidePanelContent";
import BottomPanelContent from "@/layout/content/BottomPanelContent";
-import {useMenuActions} from "@/hooks/useMenuActions";
-import {useKeyboardShortcuts} from "@/hooks/useKeyboardShortcuts";
-import {RecordingCompleteDialog} from "@/components/control-panels/recording-info-panel/RecordingCompleteDialog";
-import {MainNavTabs} from "@/components/ui-components/MainNavTabs";
+import { useMenuActions } from "@/hooks/useMenuActions";
+import { useKeyboardShortcuts } from "@/hooks/useKeyboardShortcuts";
+import { RecordingCompleteDialog } from "@/components/control-panels/recording-info-panel/RecordingCompleteDialog";
+import { MainNavTabs } from "@/components/ui-components/MainNavTabs";
+import { FloatingOnboarding } from "@/hooks/floatingOnboarding";
+import PromptTooltip from "@/components/ui-components/promptTooltip";
+import { useServer } from "@/services/server/ServerContextProvider";
+import { useAppSelector } from "@/store";
+import { selectIsLoading } from "@/store/slices/cameras/cameras-selectors";
-export const BasePanelLayout = ({children, onOpenWelcome}: { children?: React.ReactNode; onOpenWelcome?: () => void }) => {
- const leftPanelRef = useRef<ImperativePanelHandle>(null);
- const bottomPanelRef = useRef<ImperativePanelHandle>(null);
- const [isCollapsed, setIsCollapsed] = useState(false);
-const [isBottomCollapsed, setIsBottomCollapsed] = useState(true);
+export const BasePanelLayout = ({
+ children,
+ onOpenWelcome,
+}: {
+ children?: React.ReactNode;
+ onOpenWelcome?: () => void;
+}) => {
+ const leftPanelRef = useRef<ImperativePanelHandle>(null);
+ const bottomPanelRef = useRef<ImperativePanelHandle>(null);
+ const [isCollapsed, setIsCollapsed] = useState(false);
+ const [isBottomCollapsed, setIsBottomCollapsed] = useState(true);
- useEffect(() => {
- bottomPanelRef.current?.collapse();
- }, []);
+ const { isConnected, isFailed, connectedCameraIds } = useServer();
+ const location = useLocation();
+ const isCamerasLoading = useAppSelector(selectIsLoading);
- const handleToggleCollapse = useCallback(() => {
- const panel = leftPanelRef.current;
- if (!panel) return;
- if (panel.isCollapsed()) {
- panel.expand();
- } else {
- panel.collapse();
- }
- }, []);
+ useEffect(() => {
+ bottomPanelRef.current?.collapse();
+ }, []);
- const handlePanelCollapse = useCallback(() => setIsCollapsed(true), []);
- const handlePanelExpand = useCallback(() => setIsCollapsed(false), []);
- const handleBottomPanelCollapse = useCallback(() => setIsBottomCollapsed(true), []);
- const handleBottomPanelExpand = useCallback(() => setIsBottomCollapsed(false), []);
+ const handleToggleCollapse = useCallback(() => {
+ const panel = leftPanelRef.current;
+ if (!panel) return;
+ if (panel.isCollapsed()) {
+ panel.expand();
+ } else {
+ panel.collapse();
+ }
+ }, []);
- useMenuActions({ onToggleSidebar: handleToggleCollapse });
- useKeyboardShortcuts();
+ const handlePanelCollapse = useCallback(() => setIsCollapsed(true), []);
+ const handlePanelExpand = useCallback(() => setIsCollapsed(false), []);
+ const handleBottomPanelCollapse = useCallback(
+ () => setIsBottomCollapsed(true),
+ [],
+ );
+ const handleBottomPanelExpand = useCallback(
+ () => setIsBottomCollapsed(false),
+ [],
+ );
- return (
- <div className="main-app-container flex flex-col" style={{ height: '100vh' }}>
- <PanelGroup className="app-container flex-1" direction="vertical">
- {/* Top section (horizontal panels) */}
- <Panel className="app-container-inner" defaultSize={87} minSize={20}>
- <PanelGroup
- className="pos-rel app-container-sub pr-1 pl-1 pt-1 pb-0"
- direction="horizontal"
- style={{ direction: "ltr" }}
- >
- <Panel
- className="left-side-panel p-1 action-container bg-darkgray br-2 border-mid-black border-1"
- ref={leftPanelRef}
- collapsible
- defaultSize={24}
- minSize={10}
- collapsedSize={3}
- onCollapse={handlePanelCollapse}
- onExpand={handlePanelExpand}
- >
- <SidePanelContent
- isCollapsed={isCollapsed}
- onToggleCollapse={handleToggleCollapse}
- onOpenWelcome={onOpenWelcome}
- />
- </Panel>
- <PanelResizeHandle
- className="resizable-component"
- style={{ width: "4px", cursor: "col-resize", backgroundColor: "var(--color-surface-active)" }}
- />
- <Panel className="right-side-panel" defaultSize={76} minSize={10}>
- <div className="flex flex-col h-full pos-rel bg-darkgray br-2">
- <MainNavTabs />
- <div className="flex-1 min-h-0 mt-45">
- {children}
- </div>
- </div>
- <RecordingCompleteDialog />
- </Panel>
- </PanelGroup>
- </Panel>
+ useMenuActions({ onToggleSidebar: handleToggleCollapse });
+ useKeyboardShortcuts();
- <PanelResizeHandle
- className="resizable-component"
- style={{ height: "4px", cursor: "row-resize", backgroundColor: "var(--color-surface-active)" }}
- />
+ return (
+ <div
+ className="main-app-container flex flex-col"
+ style={{ height: "100vh" }}
+ >
+ <FloatingOnboarding
+ target='[data-onboarding="connection:server-connection"]'
+ className="z-110i"
+ >
+ <PromptTooltip
+ className={isFailed ? "" : "loading"}
+ show={!isConnected}
+ title={isFailed ? "Service Unavailable" : "Connecting..."}
+ text={isFailed
+ ? "Make sure you have the service running"
+ : "Websocket connecting, app functions will be available once connection is made"}
+ position="pos-bottom"
+ variant={isFailed ? "warning" : "default"}
+ onClose={() => {}}
+ />
+ </FloatingOnboarding>
- <Panel
- className="console-area pr-1 pl-1 pb-1"
- ref={bottomPanelRef}
- collapsible
- defaultSize={13}
- minSize={10}
- collapsedSize={4}
- onCollapse={handleBottomPanelCollapse}
- onExpand={handleBottomPanelExpand}
- >
- <BottomPanelContent isCollapsed={isBottomCollapsed} />
- </Panel>
- </PanelGroup>
- </div>
- );
+ <FloatingOnboarding target='[data-onboarding="camera:connect-camera"]'>
+ <PromptTooltip
+ show={
+ location.pathname === '/streaming' &&
+ connectedCameraIds.length === 0 &&
+ !isCamerasLoading
+ }
+ title="Connect Cameras"
+ text="Make sure you have at least one camera plugged in, then hit Connect to start streaming."
+ position="pos-right"
+ variant="boarding"
+ onClose={() => {}}
+ />
+ </FloatingOnboarding>
+
+ <PanelGroup className="app-container flex-1" direction="vertical">
+ {/* Top section (horizontal panels) */}
+ <Panel className="app-container-inner" defaultSize={87} minSize={20}>
+ <PanelGroup
+ className="pos-rel app-container-sub pr-1 pl-1 pt-1 pb-0"
+ direction="horizontal"
+ style={{ direction: "ltr" }}
+ >
+ <Panel
+ className="left-side-panel p-1 action-container bg-darkgray br-2 border-mid-black border-1"
+ ref={leftPanelRef}
+ collapsible
+ defaultSize={24}
+ minSize={10}
+ collapsedSize={3}
+ onCollapse={handlePanelCollapse}
+ onExpand={handlePanelExpand}
+ >
+ <SidePanelContent
+ isCollapsed={isCollapsed}
+ onToggleCollapse={handleToggleCollapse}
+ onOpenWelcome={onOpenWelcome}
+ />
+ </Panel>
+ <PanelResizeHandle
+ className="resizable-component"
+ style={{
+ width: "4px",
+ cursor: "col-resize",
+ backgroundColor: "var(--color-surface-active)",
+ }}
+ />
+ <Panel className="right-side-panel" defaultSize={76} minSize={10}>
+ <div className="flex flex-col h-full pos-rel bg-darkgray br-2">
+ <MainNavTabs />
+ <div className="flex-1 min-h-0 mt-45">{children}</div>
+ </div>
+ <RecordingCompleteDialog />
+ </Panel>
+ </PanelGroup>
+ </Panel>
+
+ <PanelResizeHandle
+ className="resizable-component"
+ style={{
+ height: "4px",
+ cursor: "row-resize",
+ backgroundColor: "var(--color-surface-active)",
+ }}
+ />
+
+ <Panel
+ className="console-area pr-1 pl-1 pb-1"
+ ref={bottomPanelRef}
+ collapsible
+ defaultSize={13}
+ minSize={10}
+ collapsedSize={4}
+ onCollapse={handleBottomPanelCollapse}
+ onExpand={handleBottomPanelExpand}
+ >
+ <BottomPanelContent isCollapsed={isBottomCollapsed} />
+ </Panel>
+ </PanelGroup>
+ </div>
+ );
};
diff --git a/freemocap-ui/src/layout/content/SidePanelContent.tsx b/freemocap-ui/src/layout/content/SidePanelContent.tsx
index 25692888..c6ac9102 100644
--- a/freemocap-ui/src/layout/content/SidePanelContent.tsx
+++ b/freemocap-ui/src/layout/content/SidePanelContent.tsx
@@ -96,7 +96,7 @@ export const SidePanelContent = ({ isCollapsed = false, onToggleCollapse, onOpen
/>
)}
<div
- data-warning="service-unavailable"
+ data-onboarding="connection:server-connection"
className="flex-1 overflow-hidden min-w-0"
>
<ServerConnectionStatus />
diff --git a/freemocap-ui/src/services/server/ServerContextProvider.tsx b/freemocap-ui/src/services/server/ServerContextProvider.tsx
index 9af97037..49f50c24 100644
--- a/freemocap-ui/src/services/server/ServerContextProvider.tsx
+++ b/freemocap-ui/src/services/server/ServerContextProvider.tsx
@@ -48,6 +48,7 @@ function sortedArraysEqual(a: string[], b: string[]): boolean {
export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({children}) => {
// Reactive state - only updates when camera list actually changes
const [isConnected, setIsConnected] = useState<boolean>(false);
+ const [isFailed, setIsFailed] = useState<boolean>(false);
const [connectedCameraIds, setConnectedCameraIds] = useState<string[]>([]);
// Tracker schemas β€” shipped by the backend on WS connect/reconfigure. Held
@@ -174,6 +175,7 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr
const handleStateChange = (newState: ConnectionState): void => {
const connected = newState === ConnectionState.CONNECTED;
setIsConnected(connected);
+ setIsFailed(newState === ConnectionState.FAILED);
if (newState === ConnectionState.DISCONNECTED || newState === ConnectionState.FAILED) {
canvasManagerRef.current?.terminateAllWorkers();
@@ -710,6 +712,7 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr
const contextValue = useMemo(() => ({
isConnected,
+ isFailed,
connect,
disconnect,
sendWebsocketMessage,
@@ -728,7 +731,7 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr
trackerSchemas,
activeTrackerId,
getActiveSchema,
- }), [isConnected, connectedCameraIds, trackerSchemas, activeTrackerId, connect, disconnect, sendWebsocketMessage, setCanvasForCamera, getFps, getServerFps, getFramerateStore, getLogStore, updateServerConnection, subscribeToKeypointsRaw, subscribeToKeypointsFiltered, subscribeToRigidBodies, getLatestKeypointsRaw, setOverlayVisibility, getActiveSchema]);
+ }), [isConnected, isFailed, connectedCameraIds, trackerSchemas, activeTrackerId, connect, disconnect, sendWebsocketMessage, setCanvasForCamera, getFps, getServerFps, getFramerateStore, getLogStore, updateServerConnection, subscribeToKeypointsRaw, subscribeToKeypointsFiltered, subscribeToRigidBodies, getLatestKeypointsRaw, setOverlayVisibility, getActiveSchema]);
return (
<ServerContext.Provider value={contextValue}>
diff --git a/freemocap-ui/src/services/server/server-context.ts b/freemocap-ui/src/services/server/server-context.ts
index 8ba4f003..3983d931 100644
--- a/freemocap-ui/src/services/server/server-context.ts
+++ b/freemocap-ui/src/services/server/server-context.ts
@@ -7,6 +7,7 @@ import type { KeypointsCallback, KeypointsFrame } from '@/components/viewport3d/
export interface ServerContextValue {
isConnected: boolean;
+ isFailed: boolean;
connect: () => void;
disconnect: () => void;
sendWebsocketMessage: (data: string | object) => void;
diff --git a/freemocap-ui/src/styles/button-sm.css b/freemocap-ui/src/styles/button-sm.css
index 384cd35f..2be685eb 100644
--- a/freemocap-ui/src/styles/button-sm.css
+++ b/freemocap-ui/src/styles/button-sm.css
@@ -116,7 +116,12 @@ button.quaternary {
}
.button.sm.externallink:after {
- content: var(--externallink-icon);
+ content: "";
+ background-image: var(--externallink-icon);
+ transform-origin: center center;
+ background-repeat: no-repeat;
+ background-position: center;
+ background-size: contain;
}
.button.sm.dropdown:after {
diff --git a/freemocap-ui/src/styles/tooltips.css b/freemocap-ui/src/styles/tooltips.css
index 6e1c3968..ae06a227 100644
--- a/freemocap-ui/src/styles/tooltips.css
+++ b/freemocap-ui/src/styles/tooltips.css
@@ -82,6 +82,11 @@
background: var(--color-bg-primary);
will-change: transform, opacity;
}
+.floating-tooltip-inner {
+
+ background: var(--color-bg-primary);
+
+}
/* =========================================
POSITION : BOTTOM