Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(stage-participant-badge): Scale size based on the screen height
Hristo Terezov7718c393191c
diff --git a/css/filmstrip/_tile_view_overrides.scss b/css/filmstrip/_tile_view_overrides.scssindex 8c53dffa47..e24376b522 100644--- a/css/filmstrip/_tile_view_overrides.scss+++ b/css/filmstrip/_tile_view_overrides.scss@@ -18,8 +18,7 @@*/#dominantSpeaker,#largeVideoElementsContainer,- #sharedVideo,- .stage-participant-label {+ #sharedVideo {display: none;}diff --git a/react/features/base/ui/Tokens.ts b/react/features/base/ui/Tokens.tsindex 159707becb..87d19ba12f 100644--- a/react/features/base/ui/Tokens.ts+++ b/react/features/base/ui/Tokens.ts@@ -189,6 +189,13 @@ export const typography = {letterSpacing: 0.16},+ bodyShortRegularSmall: {+ fontSize: 10,+ lineHeight: 16,+ fontWeight: font.weightRegular,+ letterSpacing: 0+ },+bodyShortRegular: {fontSize: 14,lineHeight: 20,diff --git a/react/features/base/ui/types.ts b/react/features/base/ui/types.tsindex d1bd1c90b4..8a3bd8857c 100644--- a/react/features/base/ui/types.ts+++ b/react/features/base/ui/types.ts@@ -69,6 +69,7 @@ export interface ITypography {bodyShortBoldLarge: ITypographyType;bodyShortRegular: ITypographyType;bodyShortRegularLarge: ITypographyType;+ bodyShortRegularSmall: ITypographyType;heading1: ITypographyType;heading2: ITypographyType;heading3: ITypographyType;diff --git a/react/features/display-name/components/web/StageParticipantNameLabel.tsx b/react/features/display-name/components/web/StageParticipantNameLabel.tsxindex 365c78be7d..c42d36be74 100644--- a/react/features/display-name/components/web/StageParticipantNameLabel.tsx+++ b/react/features/display-name/components/web/StageParticipantNameLabel.tsx@@ -16,12 +16,35 @@ import { getTransitionParamsForElementsAboveToolbox, isToolboxVisible } from '..import { isLayoutTileView } from '../../../video-layout/functions.web';import DisplayNameBadge from './DisplayNameBadge';-import { getStageParticipantTypography } from './styles';+import {+ getStageParticipantFontSizeRange,+ getStageParticipantNameLabelLineHeight,+ getStageParticipantTypography,+ scaleFontProperty+} from './styles';++interface IOptions {+ clientHeight?: number;+}++const useStyles = makeStyles<IOptions>()((theme, options: IOptions = {}) => {+ const typography = {+ ...getStageParticipantTypography(theme)+ };+ const { clientHeight } = options;++ if (typeof clientHeight === 'number' && clientHeight > 0) {+ // We want to show the fontSize and lineHeight configured in theme on a screen with height 1080px. In this case+ // the clientHeight will be 960px if there are some titlebars, toolbars, addressbars, etc visible.For any other+ // screen size we will decrease/increase the font size based on the screen size.++ typography.fontSize = scaleFontProperty(clientHeight, getStageParticipantFontSizeRange(theme));+ typography.lineHeight = getStageParticipantNameLabelLineHeight(theme, clientHeight);+ }-const useStyles = makeStyles()(theme => {return {badgeContainer: {- ...withPixelLineHeight(getStageParticipantTypography(theme)),+ ...withPixelLineHeight(typography),alignItems: 'center',display: 'inline-flex',justifyContent: 'center',@@ -47,7 +70,8 @@ const useStyles = makeStyles()(theme => {* @returns {ReactElement|null}*/const StageParticipantNameLabel = () => {- const { classes, cx } = useStyles();+ const clientHeight = useSelector((state: IReduxState) => state['features/base/responsive-ui'].clientHeight);+ const { classes, cx } = useStyles({ clientHeight });const largeVideoParticipant = useSelector(getLargeVideoParticipant);const selectedId = largeVideoParticipant?.id;const nameToDisplay = useSelector((state: IReduxState) => getParticipantDisplayName(state, selectedId ?? ''));@@ -68,7 +92,6 @@ const StageParticipantNameLabel = () => {return (<divclassName = { cx(- 'stage-participant-label',classes.badgeContainer,toolboxVisible && classes.containerElevated) }>diff --git a/react/features/display-name/components/web/styles.ts b/react/features/display-name/components/web/styles.tsindex 7b15779013..734a4a2603 100644--- a/react/features/display-name/components/web/styles.ts+++ b/react/features/display-name/components/web/styles.ts@@ -15,12 +15,92 @@ export function getStageParticipantTypography(theme: Theme) {return theme.typography.bodyShortRegularLarge;}+/**+ * Returns the range of possible values for the font size for the stage participant display name badge.+ *+ * @param {Theme} theme - The current theme.+ * @returns {ILimits}+ */+export function getStageParticipantFontSizeRange(theme: Theme) {+ return {+ max: theme.typography.bodyShortRegularLarge.fontSize,+ min: theme.typography.bodyShortRegularSmall.fontSize+ };+}++/**+ * Returns the range of possible values for the line height for the stage participant display name badge.+ *+ * @param {Theme} theme - The current theme.+ * @returns {ILimits}+ */+export function getStageParticipantLineHeightRange(theme: Theme) {+ return {+ max: theme.typography.bodyShortRegularLarge.lineHeight,+ min: theme.typography.bodyShortRegularSmall.lineHeight+ };+}+/*** Returns the height + padding for stage participant display name badge.** @param {Theme} theme - The current theme.+ * @param {number} clientHeight - The height of the visible area.* @returns {number}*/-export function getStageParticipantNameLabelHeight(theme: Theme) {- return getStageParticipantTypography(theme).lineHeight ?? 0 + DISPLAY_NAME_VERTICAL_PADDING;+export function getStageParticipantNameLabelHeight(theme: Theme, clientHeight?: number) {+ const lineHeight = getStageParticipantNameLabelLineHeight(theme, clientHeight);++ return lineHeight + DISPLAY_NAME_VERTICAL_PADDING;+}++/**+ * Returns the height + padding for stage participant display name badge.+ *+ * @param {Theme} theme - The current theme.+ * @param {number} clientHeight - The height of the visible area.+ * @returns {number}+ */+export function getStageParticipantNameLabelLineHeight(theme: Theme, clientHeight?: number) {+ return scaleFontProperty(clientHeight, getStageParticipantLineHeightRange(theme));+}++interface ILimits {+ max: number;+ min: number;+}++/**+ * The default clint height limits used by scaleFontProperty.+ */+const DEFAULT_CLIENT_HEIGHT_LIMITS = {+ min: 300,+ max: 960+};++/**+ * Scales a css font property depending on the passed screen size.+ * Note: The result will be in the range of the specified propValueLimits. Also if the current screen height is+ * more/less than the values in screenLimits parameter the result will be the max/min of the propValuesLimits.+ *+ * @param {number|undefined} screenHeight - The current screen height.+ * @param {ILimits} propValuesLimits - The max and min value for the font property that we are scaling.+ * @param {ILimits} screenHeightLimits - The max and min value for screen height.+ * @returns {number} - The scaled prop value.+ */+export function scaleFontProperty(+ screenHeight: number | undefined,+ propValuesLimits: ILimits,+ screenHeightLimits: ILimits = DEFAULT_CLIENT_HEIGHT_LIMITS) {+ if (typeof screenHeight !== 'number') {+ return propValuesLimits.max;+ }++ const { max: maxPropSize, min: minPropSize } = propValuesLimits;+ const { max: maxHeight, min: minHeight } = screenHeightLimits;+ const propSizePerPxHeight = (maxPropSize - minPropSize) / (maxHeight - minHeight);++ return Math.round(+ (Math.max(Math.min(screenHeight, maxHeight), minHeight) - minHeight) * propSizePerPxHeight+ ) + minPropSize;}diff --git a/react/features/subtitles/components/web/Captions.tsx b/react/features/subtitles/components/web/Captions.tsxindex e33b26be03..d019c40aa6 100644--- a/react/features/subtitles/components/web/Captions.tsx+++ b/react/features/subtitles/components/web/Captions.tsx@@ -61,7 +61,7 @@ const styles = (theme: Theme, props: IProps) => {if (_isLifted) {// 10px is the space between the onstage participant display name label and subtitles. We also need// to add the padding of the subtitles because it will decrease the gap between the label and subtitles.- marginBottom += getStageParticipantNameLabelHeight(theme) + 10 + padding;+ marginBottom += getStageParticipantNameLabelHeight(theme, _clientHeight) + 10 + padding;}if (_shiftUp) {