Skip to content

Commit

Permalink
✨ Add space for video below document content
Browse files Browse the repository at this point in the history
  • Loading branch information
phlmn committed Dec 9, 2023
1 parent be467fa commit dd56e5c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 15 additions & 1 deletion frontend/src/editor/player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ const SKIP_SHORTCUT_SEC = 3;

let lastTabPressTs = 0;

export function PlayerBar({ documentId, editor }: { documentId: string; editor: Editor }) {
export function PlayerBar({
documentId,
editor,
onShowVideo,
}: {
documentId: string;
editor: Editor;
onShowVideo?: (show: boolean) => void;
}) {
const { data } = useGetDocument(
{ document_id: documentId },
{
Expand Down Expand Up @@ -61,6 +69,12 @@ export function PlayerBar({ documentId, editor }: { documentId: string; editor:
videoPreview: hasVideo,
});

useEffect(() => {
if (onShowVideo) {
onShowVideo(hasVideo);
}
}, [hasVideo]);

// calculate the start of the current element to color it
const [currentElementStartTime, setCurrentElementStartTime] = useState(0.0);

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/editor/transcription_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,14 @@ export function TranscriptionEditor({
documentId,
readOnly,
initialValue,
onShowVideo,
...props
}: {
editor?: Editor;
documentId: string;
readOnly: boolean;
initialValue?: Paragraph[];
onShowVideo?: (show: boolean) => void;
} & ComponentProps<'div'>) {
const systemPrefersDark = useMediaQuery('(prefers-color-scheme: dark)');
// prevent ctrl+s
Expand Down Expand Up @@ -312,7 +314,7 @@ export function TranscriptionEditor({
className={clsx('2xl:-ml-20')}
/>
</ErrorBoundary>
<PlayerBar documentId={documentId} editor={editor} />
<PlayerBar documentId={documentId} editor={editor} onShowVideo={onShowVideo} />
</LoadingContext.Provider>
</SpeakerColorsProvider>
</Slate>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/pages/document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export function DocumentPage({
const [_location, navigate] = useLocation();
const debugMode = useDebugMode();
const { isLoggedIn } = useAuthData();
const [videoVisible, setVideoVisible] = useState(false);

const url = getDocumentWsUrl(documentId);

Expand Down Expand Up @@ -188,13 +189,17 @@ export function DocumentPage({
</TopBar>

<TranscriptionEditor
onShowVideo={setVideoVisible}
editor={editor}
documentId={documentId}
initialValue={initialValue}
className={'grow flex flex-col'}
readOnly={!data || !data.can_write}
/>

{/* Spacer to prevent video preview from hiding text */}
{videoVisible && <div className="h-36"></div>}

{editor && debugMode && <Suspense>{<LazyDebugPanel editor={editor} />}</Suspense>}
</AppContainer>
);
Expand Down

0 comments on commit dd56e5c

Please sign in to comment.