ScreenshareControls.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { RequestDisplayMedia } from '@andyet/simplewebrtc';
  2. import ShareScreenIcon from 'material-icons-svg/components/baseline/ScreenShare';
  3. import React from 'react';
  4. import styled from 'styled-components';
  5. import { TalkyButton } from '../styles/button';
  6. import mq from '../styles/media-queries';
  7. const Button = styled(TalkyButton)({
  8. display: 'none',
  9. [mq.SMALL_DESKTOP]: {
  10. display: 'block'
  11. }
  12. });
  13. const EmptySpacer = styled.span({
  14. width: '120px'
  15. });
  16. // ScreenshareControls displays a button that activates the screenshare flow.
  17. // It also provides a link to install the screenshare extension if it is
  18. // required by the user's browser.
  19. const ScreenshareControls: React.SFC = () => (
  20. <RequestDisplayMedia
  21. render={(getDisplayMedia, sharing) => {
  22. if (!sharing.available) {
  23. return <EmptySpacer />;
  24. }
  25. return (
  26. <Button title="Screen Share" onClick={getDisplayMedia}>
  27. <ShareScreenIcon fill="#505658" />
  28. <span>Share screen</span>
  29. </Button>
  30. );
  31. }}
  32. />
  33. );
  34. export default ScreenshareControls;