openreplay/frontend/app/components/Highlights/HighlightPlayer.tsx
Delirium 2cd96b0df0
Highlight UI (#2951)
* ui: start highlight ui

* ui: tag items

* ui: connecting highlights to notes api...

* Highlight feature refinements (#2948)

* ui: move clips player to foss, connect notes api to hl

* ui: tune note/hl editing, prevent zoom slider body from jumping around

* ui: safe check for tag

* ui: fix thumbnail gen

* ui: fix thumbnail gen

* ui: make player modal wider, add shadow

* ui: custom warn barge for clips

* ui: swap icon for note event wrapper

* ui: rm other, fix cancel

* ui: moving around creation modal

* ui: bg tint

* ui: rm disabled for text btn

* ui: fix ownership sorting

* ui: close player on bg click

* ui: fix query, fix min distance for default range

* ui: move hl list header out of list comp

* ui: spot list header segmented size

* Various improvements in highlights (#2955)

* ui: update hl in hlPanel comp

* ui: rm debug

* ui: fix icons file

---------

Co-authored-by: Sudheer Salavadi <connect.uxmaster@gmail.com>
2025-01-24 09:59:54 +01:00

79 lines
1.7 KiB
TypeScript

import React from 'react';
import cn from 'classnames';
import ClipsPlayer from '../Session/ClipsPlayer';
import { useStore } from 'App/mstore';
import { Loader } from 'UI';
import { observer } from 'mobx-react-lite';
interface Clip {
sessionId: string | undefined;
range: [number, number];
message: string;
}
function HighlightPlayer({
hlId,
onClose,
}: {
hlId: string;
onClose: () => void;
}) {
const { notesStore } = useStore();
const [clip, setClip] = React.useState<Clip>({
sessionId: undefined,
range: [],
message: '',
});
React.useEffect(() => {
if (hlId) {
notesStore.fetchNoteById(hlId).then((hl) => {
if (!hl) {
onClose();
} else {
setClip({
range: [hl.startAt ?? 0, hl.endAt ?? 99999],
sessionId: hl.sessionId,
message: hl.message,
});
}
});
}
}, [hlId]);
const onBgClick = (e: React.MouseEvent) => {
if (e.target === e.currentTarget) {
onClose();
}
}
return (
<div
className={
'w-screen h-screen fixed top-0 left-0 flex items-center justify-center'
}
style={{ zIndex: 100, background: 'rgba(0,0,0, 0.15)' }}
onClick={onBgClick}
>
<div
className={cn(
'rounded-lg overflow-hidden',
'rounded shadow boarder bg-white'
)}
style={{ width: 960 }}
>
<Loader loading={notesStore.loading}>
<ClipsPlayer
isHighlight
onClose={onClose}
clip={clip}
currentIndex={0}
isCurrent={true}
autoplay={false}
/>
</Loader>
</div>
</div>
);
}
export default observer(HighlightPlayer);