|
@@ -1,25 +1,85 @@
|
|
1
|
+import { Theme } from '@mui/material';
|
1
|
2
|
import React, { ReactElement } from 'react';
|
2
|
3
|
import { connect } from 'react-redux';
|
|
4
|
+import { withStyles } from 'tss-react/mui';
|
3
|
5
|
|
4
|
6
|
import { IReduxState } from '../../../app/types';
|
5
|
7
|
import { getLocalParticipant } from '../../../base/participants/functions';
|
|
8
|
+import { getVideospaceFloatingElementsBottomSpacing } from '../../../base/ui/functions.web';
|
|
9
|
+import { getStageParticipantNameLabelHeight } from '../../../display-name/components/web/styles';
|
6
|
10
|
import { getLargeVideoParticipant } from '../../../large-video/functions';
|
7
|
11
|
import { isLayoutTileView } from '../../../video-layout/functions.web';
|
|
12
|
+import { calculateSubtitlesFontSize } from '../../functions.web';
|
8
|
13
|
import {
|
9
|
14
|
AbstractCaptions,
|
10
|
15
|
type IAbstractCaptionsProps,
|
11
|
16
|
_abstractMapStateToProps
|
12
|
17
|
} from '../AbstractCaptions';
|
13
|
18
|
|
14
|
|
-
|
15
|
19
|
interface IProps extends IAbstractCaptionsProps {
|
16
|
20
|
|
|
21
|
+ /**
|
|
22
|
+ * The height of the visible area.
|
|
23
|
+ */
|
|
24
|
+ _clientHeight?: number;
|
|
25
|
+
|
17
|
26
|
/**
|
18
|
27
|
* Whether the subtitles container is lifted above the invite box.
|
19
|
28
|
*/
|
20
|
29
|
_isLifted: boolean | undefined;
|
|
30
|
+
|
|
31
|
+ /**
|
|
32
|
+ * An object containing the CSS classes.
|
|
33
|
+ */
|
|
34
|
+ classes?: Partial<Record<keyof ReturnType<typeof styles>, string>>;
|
21
|
35
|
}
|
22
|
36
|
|
|
37
|
+
|
|
38
|
+const styles = (theme: Theme, props: IProps) => {
|
|
39
|
+ const { _isLifted = false, _clientHeight } = props;
|
|
40
|
+ const fontSize = calculateSubtitlesFontSize(_clientHeight);
|
|
41
|
+ const padding = Math.ceil(0.2 * fontSize);
|
|
42
|
+
|
|
43
|
+ // Currently the subtitles position are not affected by the toolbar visibility.
|
|
44
|
+ let bottom = getVideospaceFloatingElementsBottomSpacing(theme, true);
|
|
45
|
+
|
|
46
|
+ // This is the case where we display the onstage participant display name
|
|
47
|
+ // below the subtitles.
|
|
48
|
+ if (_isLifted) {
|
|
49
|
+ // 10px is the space between the onstage participant display name label and subtitles. We also need
|
|
50
|
+ // to add the padding of the subtitles because it will decrease the gap between the label and subtitles.
|
|
51
|
+ bottom += getStageParticipantNameLabelHeight(theme) + 10 + padding;
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ return {
|
|
55
|
+ transcriptionSubtitles: {
|
|
56
|
+ bottom,
|
|
57
|
+ fontSize: `${fontSize}px`,
|
|
58
|
+ left: '50%',
|
|
59
|
+ maxWidth: '50vw',
|
|
60
|
+ overflowWrap: 'break-word' as const,
|
|
61
|
+ pointerEvents: 'none' as const,
|
|
62
|
+ position: 'absolute' as const,
|
|
63
|
+ textShadow: `
|
|
64
|
+ 0px 0px 1px rgba(0,0,0,0.3),
|
|
65
|
+ 0px 1px 1px rgba(0,0,0,0.3),
|
|
66
|
+ 1px 0px 1px rgba(0,0,0,0.3),
|
|
67
|
+ 0px 0px 1px rgba(0,0,0,0.3)`,
|
|
68
|
+ transform: 'translateX(-50%)',
|
|
69
|
+ zIndex: 7, // The popups are with z-index 8. This z-index has to be lower.
|
|
70
|
+ lineHeight: 1.2,
|
|
71
|
+
|
|
72
|
+ span: {
|
|
73
|
+ color: '#fff',
|
|
74
|
+ background: 'black',
|
|
75
|
+
|
|
76
|
+ // without this when the text is wrapped on 2+ lines there will be a gap in the background:
|
|
77
|
+ padding: `${padding}px 0px`
|
|
78
|
+ }
|
|
79
|
+ }
|
|
80
|
+ };
|
|
81
|
+};
|
|
82
|
+
|
23
|
83
|
/**
|
24
|
84
|
* React {@code Component} which can display speech-to-text results from
|
25
|
85
|
* Jigasi as subtitles.
|
|
@@ -53,12 +113,10 @@ class Captions extends AbstractCaptions<IProps> {
|
53
|
113
|
* @returns {ReactElement} - The subtitles container.
|
54
|
114
|
*/
|
55
|
115
|
_renderSubtitlesContainer(paragraphs: Array<ReactElement>): ReactElement {
|
56
|
|
- const className = this.props._isLifted
|
57
|
|
- ? 'transcription-subtitles lifted'
|
58
|
|
- : 'transcription-subtitles';
|
|
116
|
+ const classes = withStyles.getClasses(this.props);
|
59
|
117
|
|
60
|
118
|
return (
|
61
|
|
- <div className = { className } >
|
|
119
|
+ <div className = { classes.transcriptionSubtitles } >
|
62
|
120
|
{ paragraphs }
|
63
|
121
|
</div>
|
64
|
122
|
);
|
|
@@ -77,11 +135,13 @@ function mapStateToProps(state: IReduxState) {
|
77
|
135
|
const isTileView = isLayoutTileView(state);
|
78
|
136
|
const largeVideoParticipant = getLargeVideoParticipant(state);
|
79
|
137
|
const localParticipant = getLocalParticipant(state);
|
|
138
|
+ const { clientHeight } = state['features/base/responsive-ui'];
|
80
|
139
|
|
81
|
140
|
return {
|
82
|
141
|
..._abstractMapStateToProps(state),
|
83
|
|
- _isLifted: Boolean(largeVideoParticipant && largeVideoParticipant?.id !== localParticipant?.id && !isTileView)
|
|
142
|
+ _isLifted: Boolean(largeVideoParticipant && largeVideoParticipant?.id !== localParticipant?.id && !isTileView),
|
|
143
|
+ _clientHeight: clientHeight
|
84
|
144
|
};
|
85
|
145
|
}
|
86
|
146
|
|
87
|
|
-export default connect(mapStateToProps)(Captions);
|
|
147
|
+export default connect(mapStateToProps)(withStyles(Captions, styles));
|