UI - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: перенос Voice Tasker в нижний dock
This commit is contained in:
parent
6da9818826
commit
efa357c260
|
|
@ -69,6 +69,7 @@ export const AppHeader = observer(function AppHeader(props: AppHeaderProps) {
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<ExtendedAppHeader header={header} />
|
<ExtendedAppHeader header={header} />
|
||||||
|
<div className="nodedc-bottom-dock-voice-slot" data-nodedc-voice-task-dock-slot />
|
||||||
</Row>
|
</Row>
|
||||||
{mobileHeader && mobileHeader}
|
{mobileHeader && mobileHeader}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import type { ElementType, MouseEvent, ReactNode } from "react";
|
import type { ElementType, MouseEvent, ReactNode } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import {
|
import {
|
||||||
|
|
@ -760,6 +761,7 @@ export function VoiceTaskerGlobalControl({ workspaceSlug }: Props) {
|
||||||
const [commitResult, setCommitResult] = useState<TVoiceTaskCommitResult | null>(null);
|
const [commitResult, setCommitResult] = useState<TVoiceTaskCommitResult | null>(null);
|
||||||
const [hasDraftChanges, setHasDraftChanges] = useState(false);
|
const [hasDraftChanges, setHasDraftChanges] = useState(false);
|
||||||
const [selectedTargetIssue, setSelectedTargetIssue] = useState<TVoiceTaskTargetOption | null>(null);
|
const [selectedTargetIssue, setSelectedTargetIssue] = useState<TVoiceTaskTargetOption | null>(null);
|
||||||
|
const [dockSlot, setDockSlot] = useState<Element | null>(null);
|
||||||
|
|
||||||
const mediaRecorderRef = useRef<MediaRecorder | null>(null);
|
const mediaRecorderRef = useRef<MediaRecorder | null>(null);
|
||||||
const discardedRecorderRef = useRef<MediaRecorder | null>(null);
|
const discardedRecorderRef = useRef<MediaRecorder | null>(null);
|
||||||
|
|
@ -787,6 +789,22 @@ export function VoiceTaskerGlobalControl({ workspaceSlug }: Props) {
|
||||||
return UNAVAILABLE_LABELS[preflight.reason ?? "not_configured"];
|
return UNAVAILABLE_LABELS[preflight.reason ?? "not_configured"];
|
||||||
}, [preflight]);
|
}, [preflight]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof document === "undefined") return;
|
||||||
|
|
||||||
|
const updateDockSlot = () => {
|
||||||
|
setDockSlot(document.querySelector("[data-nodedc-voice-task-dock-slot]"));
|
||||||
|
};
|
||||||
|
|
||||||
|
updateDockSlot();
|
||||||
|
const observer = new MutationObserver(updateDockSlot);
|
||||||
|
observer.observe(document.body, { childList: true, subtree: true });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const clearTimer = useCallback(() => {
|
const clearTimer = useCallback(() => {
|
||||||
if (timerRef.current) {
|
if (timerRef.current) {
|
||||||
window.clearInterval(timerRef.current);
|
window.clearInterval(timerRef.current);
|
||||||
|
|
@ -1171,23 +1189,21 @@ export function VoiceTaskerGlobalControl({ workspaceSlug }: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="pointer-events-none fixed right-4 bottom-[calc(var(--nodedc-bottom-dock-offset,0px)+1rem)] z-[29]">
|
{isAvailable && dockSlot
|
||||||
<Tooltip tooltipContent={tooltipContent} position="left">
|
? createPortal(
|
||||||
|
<Tooltip tooltipContent={tooltipContent} position="top">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={cn(
|
className="nodedc-bottom-dock-voice-button"
|
||||||
"pointer-events-auto flex size-11 items-center justify-center border-0 bg-transparent p-0 shadow-none transition outline-none",
|
|
||||||
isAvailable
|
|
||||||
? "text-[rgb(var(--nodedc-accent-rgb))] hover:text-[rgb(var(--nodedc-card-active-rgb))]"
|
|
||||||
: "cursor-not-allowed text-tertiary"
|
|
||||||
)}
|
|
||||||
disabled={!isAvailable}
|
|
||||||
onClick={openVoiceTasker}
|
onClick={openVoiceTasker}
|
||||||
|
aria-label="Voice Tasker"
|
||||||
>
|
>
|
||||||
<Mic className="size-7" />
|
<Mic className="size-4" />
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>,
|
||||||
</div>
|
dockSlot
|
||||||
|
)
|
||||||
|
: null}
|
||||||
|
|
||||||
<ModalCore
|
<ModalCore
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,34 @@
|
||||||
backdrop-filter: blur(34px);
|
backdrop-filter: blur(34px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nodedc-bottom-dock-voice-slot {
|
||||||
|
display: flex;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nodedc-bottom-dock-voice-button {
|
||||||
|
display: grid;
|
||||||
|
height: 2rem;
|
||||||
|
width: 2rem;
|
||||||
|
place-items: center;
|
||||||
|
border: 0 !important;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: transparent;
|
||||||
|
color: rgb(var(--nodedc-accent-rgb));
|
||||||
|
outline: none !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
transition:
|
||||||
|
color 160ms ease,
|
||||||
|
transform 160ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nodedc-bottom-dock-voice-button:hover {
|
||||||
|
color: rgb(var(--nodedc-card-active-rgb));
|
||||||
|
}
|
||||||
|
|
||||||
.nodedc-bottom-dock-aware-padding {
|
.nodedc-bottom-dock-aware-padding {
|
||||||
padding-bottom: calc(var(--nodedc-quick-add-reserve, 2.5rem) + 0.5rem);
|
padding-bottom: calc(var(--nodedc-quick-add-reserve, 2.5rem) + 0.5rem);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue