refactor(connection-stats): use jss instead of sass in ConnectionStatsTable (#11156)

This commit is contained in:
Shahab 2022-03-29 13:53:40 +04:30 committed by GitHub
parent 70efa31c16
commit d2f70b0006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 67 deletions

View File

@ -1,50 +0,0 @@
%connection-info {
font-size: 12px;
font-weight: 400;
td {
padding: 2px 0;
}
}
.connection-info
{
@extend %connection-info;
> table {
white-space: nowrap;
@extend %connection-info;
}
td:nth-child(n-1) {
padding-left: 5px;
}
&__icon {
margin-right: 2px;
}
&__download
{
@extend .connection-info__icon;
}
&__status
{
font-weight: bold;
}
&__upload
{
@extend .connection-info__icon;
}
&__mobile {
margin: 15px;
}
.connection-actions {
margin: 10px auto;
text-align: center;
}
}

View File

@ -59,7 +59,6 @@ $flagsImagePath: "../images/";
@import 'components/button-control'; @import 'components/button-control';
@import 'components/input-control'; @import 'components/input-control';
@import 'components/input-slider'; @import 'components/input-slider';
@import "connection-info";
@import '404'; @import '404';
@import 'policy'; @import 'policy';
@import 'popover'; @import 'popover';

View File

@ -1,6 +1,7 @@
/* @flow */ /* @flow */
import { withStyles } from '@material-ui/styles'; import { withStyles } from '@material-ui/styles';
import clsx from 'clsx';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { isMobileBrowser } from '../../../features/base/environment/utils'; import { isMobileBrowser } from '../../../features/base/environment/utils';
@ -172,15 +173,48 @@ function onClick(event) {
const styles = theme => { const styles = theme => {
return { return {
actions: {
margin: '10px auto',
textAlign: 'center'
},
connectionStatsTable: {
'&, & > table': {
fontSize: '12px',
fontWeight: '400',
'& td': {
padding: '2px 0'
}
},
'& > table': {
whiteSpace: 'nowrap'
},
'& td:nth-child(n-1)': {
paddingLeft: '5px'
},
'& $upload, & $download': {
marginRight: '2px'
}
},
contextMenu: { contextMenu: {
position: 'relative', position: 'relative',
marginTop: 0, marginTop: 0,
right: 'auto', right: 'auto',
padding: `${theme.spacing(2)}px ${theme.spacing(1)}px`, padding: `${theme.spacing(2)}px ${theme.spacing(1)}px`,
marginLeft: '4px', marginLeft: `${theme.spacing(1)}px`,
marginRight: '4px', marginRight: `${theme.spacing(1)}px`,
marginBottom: '4px' marginBottom: `${theme.spacing(1)}px`
} },
download: {},
mobile: {
margin: `${theme.spacing(3)}px`
},
status: {
fontWeight: 'bold'
},
upload: {}
}; };
}; };
@ -198,7 +232,7 @@ class ConnectionStatsTable extends Component<Props> {
*/ */
render() { render() {
const { isLocalVideo, enableSaveLogs, disableShowMoreStats, classes } = this.props; const { isLocalVideo, enableSaveLogs, disableShowMoreStats, classes } = this.props;
const className = isMobileBrowser() ? 'connection-info connection-info__mobile' : 'connection-info'; const className = clsx(classes.connectionStatsTable, { [classes.mobile]: isMobileBrowser() });
return ( return (
<ContextMenu <ContextMenu
@ -209,7 +243,7 @@ class ConnectionStatsTable extends Component<Props> {
className = { className } className = { className }
onClick = { onClick }> onClick = { onClick }>
{ this._renderStatistics() } { this._renderStatistics() }
<div className = 'connection-actions'> <div className = { classes.actions }>
{ isLocalVideo && enableSaveLogs ? this._renderSaveLogs() : null} { isLocalVideo && enableSaveLogs ? this._renderSaveLogs() : null}
{ !disableShowMoreStats && this._renderShowMoreLink() } { !disableShowMoreStats && this._renderShowMoreLink() }
</div> </div>
@ -230,7 +264,7 @@ class ConnectionStatsTable extends Component<Props> {
const { isLocalVideo } = this.props; const { isLocalVideo } = this.props;
return ( return (
<table className = 'connection-info__container'> <table>
<tbody> <tbody>
{ isLocalVideo ? this._renderBandwidth() : null } { isLocalVideo ? this._renderBandwidth() : null }
{ isLocalVideo ? this._renderTransport() : null } { isLocalVideo ? this._renderTransport() : null }
@ -251,6 +285,7 @@ class ConnectionStatsTable extends Component<Props> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
_renderBandwidth() { _renderBandwidth() {
const { classes } = this.props;
const { download, upload } = this.props.bandwidth || {}; const { download, upload } = this.props.bandwidth || {};
return ( return (
@ -259,11 +294,11 @@ class ConnectionStatsTable extends Component<Props> {
{ this.props.t('connectionindicator.bandwidth') } { this.props.t('connectionindicator.bandwidth') }
</td> </td>
<td> <td>
<span className = 'connection-info__download'> <span className = { classes.download }>
&darr; &darr;
</span> </span>
{ download ? `${download} Kbps` : 'N/A' } { download ? `${download} Kbps` : 'N/A' }
<span className = 'connection-info__upload'> <span className = { classes.upload }>
&uarr; &uarr;
</span> </span>
{ upload ? `${upload} Kbps` : 'N/A' } { upload ? `${upload} Kbps` : 'N/A' }
@ -280,6 +315,7 @@ class ConnectionStatsTable extends Component<Props> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
_renderBitrate() { _renderBitrate() {
const { classes } = this.props;
const { download, upload } = this.props.bitrate || {}; const { download, upload } = this.props.bitrate || {};
return ( return (
@ -290,11 +326,11 @@ class ConnectionStatsTable extends Component<Props> {
</span> </span>
</td> </td>
<td> <td>
<span className = 'connection-info__download'> <span className = { classes.download }>
&darr; &darr;
</span> </span>
{ download ? `${download} Kbps` : 'N/A' } { download ? `${download} Kbps` : 'N/A' }
<span className = 'connection-info__upload'> <span className = { classes.upload }>
&uarr; &uarr;
</span> </span>
{ upload ? `${upload} Kbps` : 'N/A' } { upload ? `${upload} Kbps` : 'N/A' }
@ -410,8 +446,10 @@ class ConnectionStatsTable extends Component<Props> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
_renderConnectionSummary() { _renderConnectionSummary() {
const { classes } = this.props;
return ( return (
<tr className = 'connection-info__status'> <tr className = { classes.status }>
<td> <td>
<span>{ this.props.t('connectionindicator.status') }</span> <span>{ this.props.t('connectionindicator.status') }</span>
</td> </td>
@ -527,7 +565,7 @@ class ConnectionStatsTable extends Component<Props> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
_renderPacketLoss() { _renderPacketLoss() {
const { packetLoss, t } = this.props; const { classes, packetLoss, t } = this.props;
let packetLossTableData; let packetLossTableData;
if (packetLoss) { if (packetLoss) {
@ -535,11 +573,11 @@ class ConnectionStatsTable extends Component<Props> {
packetLossTableData = ( packetLossTableData = (
<td> <td>
<span className = 'connection-info__download'> <span className = { classes.download }>
&darr; &darr;
</span> </span>
{ download === null ? 'N/A' : `${download}%` } { download === null ? 'N/A' : `${download}%` }
<span className = 'connection-info__upload'> <span className = { classes.upload }>
&uarr; &uarr;
</span> </span>
{ upload === null ? 'N/A' : `${upload}%` } { upload === null ? 'N/A' : `${upload}%` }
@ -650,7 +688,7 @@ class ConnectionStatsTable extends Component<Props> {
const isRemoteVideo = !this.props.isLocalVideo; const isRemoteVideo = !this.props.isLocalVideo;
return ( return (
<table className = 'connection-info__container'> <table>
<tbody> <tbody>
{ this._renderConnectionSummary() } { this._renderConnectionSummary() }
{ this._renderBitrate() } { this._renderBitrate() }