mirror of https://github.com/jitsi/jitsi-meet
parent
abe2fa4dd4
commit
3c69645169
@ -0,0 +1,43 @@ |
||||
import React from 'react'; |
||||
import { useSelector } from 'react-redux'; |
||||
|
||||
import { IReduxState } from '../../../app/types'; |
||||
import { IconUsers } from '../../../base/icons/svg'; |
||||
// eslint-disable-next-line lines-around-comment
|
||||
// @ts-ignore
|
||||
import Label from '../../../base/label/components/native/Label'; |
||||
import BaseTheme from '../../../base/ui/components/BaseTheme.native'; |
||||
import { getVisitorsShortText } from '../../functions'; |
||||
|
||||
const styles = { |
||||
raisedHandsCountLabel: { |
||||
alignItems: 'center', |
||||
backgroundColor: BaseTheme.palette.warning02, |
||||
borderRadius: BaseTheme.shape.borderRadius, |
||||
flexDirection: 'row', |
||||
marginLeft: BaseTheme.spacing[0], |
||||
marginBottom: BaseTheme.spacing[0] |
||||
}, |
||||
|
||||
raisedHandsCountLabelText: { |
||||
color: BaseTheme.palette.uiBackground, |
||||
paddingLeft: BaseTheme.spacing[2] |
||||
} |
||||
}; |
||||
|
||||
const VisitorsCountLabel = () => { |
||||
const visitorsMode = useSelector((state: IReduxState) => state['features/visitors'].enabled); |
||||
const visitorsCount = useSelector((state: IReduxState) => |
||||
state['features/visitors'].count || 0); |
||||
|
||||
return visitorsMode && ( |
||||
<Label |
||||
icon = { IconUsers } |
||||
iconColor = { BaseTheme.palette.uiBackground } |
||||
style = { styles.raisedHandsCountLabel } |
||||
text = { `${getVisitorsShortText(visitorsCount)}` } |
||||
textStyle = { styles.raisedHandsCountLabelText } /> |
||||
); |
||||
}; |
||||
|
||||
export default VisitorsCountLabel; |
@ -0,0 +1,11 @@ |
||||
/** |
||||
* A short string to represent the number of visitors. |
||||
* Over 100 we show numbers like 0.2 K or 9.5 K. |
||||
* |
||||
* @param {number} visitorsCount - The number of visitors to shorten. |
||||
* |
||||
* @returns {string} Short string representing the number of visitors. |
||||
*/ |
||||
export function getVisitorsShortText(visitorsCount: number) { |
||||
return visitorsCount > 100 ? `${Math.round(visitorsCount / 100) / 10} K` : String(visitorsCount); |
||||
} |
Loading…
Reference in new issue