You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FaceExpressionsSwitch.js 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // @flow
  2. import { makeStyles } from '@material-ui/core/styles';
  3. import React from 'react';
  4. import { useTranslation } from 'react-i18next';
  5. import { Switch } from '../../../base/react';
  6. const useStyles = makeStyles(theme => {
  7. return {
  8. switchContainer: {
  9. display: 'flex',
  10. alignItems: 'center',
  11. '& svg': {
  12. display: 'none'
  13. },
  14. '& div': {
  15. width: 38,
  16. '& > label': {
  17. width: 32,
  18. height: 20,
  19. backgroundColor: theme.palette.ui05,
  20. '&:not([data-checked]):hover': {
  21. backgroundColor: theme.palette.ui05
  22. },
  23. '&[data-checked]': {
  24. backgroundColor: theme.palette.action01,
  25. '&:hover': {
  26. backgroundColor: theme.palette.action01
  27. },
  28. '&::before': {
  29. margin: '0 0 1.5px -3px',
  30. backgroundColor: theme.palette.text01
  31. }
  32. },
  33. '&:focus-within': {
  34. borderColor: 'transparent'
  35. },
  36. '&::before': {
  37. width: 14,
  38. height: 14,
  39. margin: '0 0 1.5px 1.5px',
  40. backgroundColor: theme.palette.text01
  41. }
  42. }
  43. }
  44. },
  45. switchLabel: {
  46. marginRight: 10,
  47. ...theme.typography.bodyShortRegular,
  48. lineHeight: `${theme.typography.bodyShortRegular.lineHeight}px`
  49. }
  50. };
  51. });
  52. /**
  53. * The type of the React {@code Component} props of {@link ToggleFaceExpressionsButton}.
  54. */
  55. type Props = {
  56. /**
  57. * The function to initiate the change in the speaker stats table.
  58. */
  59. onChange: Function,
  60. /**
  61. * The state of the button.
  62. */
  63. showFaceExpressions: boolean,
  64. };
  65. /**
  66. * React component for toggling face expressions grid.
  67. *
  68. * @returns {React$Element<any>}
  69. */
  70. export default function FaceExpressionsSwitch({ onChange, showFaceExpressions }: Props) {
  71. const classes = useStyles();
  72. const { t } = useTranslation();
  73. return (
  74. <div className = { classes.switchContainer } >
  75. <label
  76. className = { classes.switchLabel }
  77. htmlFor = 'face-expressions-switch'>
  78. { t('speakerStats.displayEmotions')}
  79. </label>
  80. <Switch
  81. id = 'face-expressions-switch'
  82. onValueChange = { onChange }
  83. trackColor = {{ false: 'blue' }}
  84. value = { showFaceExpressions } />
  85. </div>
  86. );
  87. }