Skip to content

Commit 8436329

Browse files
authored
Merge pull request #822 from AppQuality/fix-transcript-obs-button
Fix-transcript-obs-button
2 parents ab095e3 + 64cb205 commit 8436329

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

src/pages/Video/components/ObservationTooltip.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ import { getColorWithAlpha } from 'src/common/utils';
44
import styled from 'styled-components';
55
import { useVideoContext } from '../context/VideoContext';
66

7-
const StyledTag = styled(Tag)`
7+
const StyledTag = styled(Tag)<{
8+
isSelecting?: boolean;
9+
}>`
10+
${({ isSelecting }) =>
11+
isSelecting &&
12+
`
13+
display: none;
14+
`}
815
box-shadow: ${({ theme }) => theme.shadows.boxShadow(theme)};
916
background: white;
1017
position: relative;
18+
user-select: none;
1119
1220
&:hover {
1321
cursor: pointer;
@@ -35,17 +43,20 @@ export const ObservationTooltip = ({
3543
observationId,
3644
color,
3745
label,
46+
isSelecting,
3847
}: {
3948
observationId: number;
4049
color?: string;
4150
label?: string;
51+
isSelecting?: boolean;
4252
}) => {
4353
const { setOpenAccordion } = useVideoContext();
4454
return (
4555
<StyledTag
4656
size="large"
4757
color={color}
4858
onClick={() => setOpenAccordion({ id: observationId })}
59+
isSelecting={isSelecting}
4960
>
5061
<TagIcon />
5162
{label}

src/pages/Video/components/Transcript.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ const HighlightContainer = styled.div``;
4949
const ChipsWrap = styled.div`
5050
line-height: ${({ theme }) => theme.lineHeights.xxl};
5151
position: relative;
52-
53-
[observation] {
54-
display: inline-block;
55-
padding: 0 2px;
56-
}
5752
`;
5853

5954
export const TitleWrapper = styled.div`
@@ -63,6 +58,20 @@ export const TitleWrapper = styled.div`
6358
gap: ${({ theme }) => theme.space.xs};
6459
`;
6560

61+
const CreateObservationButton = styled(Button)<{
62+
position: {
63+
x: number;
64+
y: number;
65+
};
66+
}>`
67+
user-select: none;
68+
position: absolute;
69+
left: ${({ position }) => position.x}px;
70+
top: ${({ position }) => position.y}px;
71+
transform: translate(-50%, 0);
72+
z-index: ${({ theme }) => theme.levels.front};
73+
`;
74+
6675
const Transcript = ({
6776
currentTime,
6877
isSearchable,
@@ -179,10 +188,11 @@ const Transcript = ({
179188
lastRect.right - containerRect.left + wrapperRef.current.scrollLeft;
180189

181190
setPosition({
182-
x: relativeX + 30,
183-
y: relativeY - 60,
191+
x: relativeX,
192+
y: relativeY + 15,
184193
});
185194
} else {
195+
setPosition(undefined);
186196
setIsSelecting(false);
187197
}
188198
};
@@ -263,29 +273,25 @@ const Transcript = ({
263273
color={observation.color}
264274
observationId={observation.id}
265275
label={observation.label}
276+
isSelecting={isSelecting}
266277
/>
267278
)}
268279
/>
269280
))}
270281
{isSelecting && (
271-
<Button
282+
<CreateObservationButton
272283
size="small"
273284
id="add-observation-button"
274285
isAccent
275286
isPrimary
276287
onClick={handleAddObservation}
277-
style={{
278-
position: 'absolute',
279-
left: position?.x,
280-
top: position?.y,
281-
transform: 'translate(-50%, 0)',
282-
}}
288+
position={position || { x: 0, y: 0 }}
283289
>
284290
<Button.StartIcon>
285291
<TagIcon />
286292
</Button.StartIcon>
287293
{t('__VIDEO_PAGE_ADD_OBSERVATION')}
288-
</Button>
294+
</CreateObservationButton>
289295
)}
290296
</ChipsWrap>
291297
</Highlight>

0 commit comments

Comments
 (0)