ChatToggle.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { ChatComposers } from '@andyet/simplewebrtc';
  2. import KeyboardArrowUpIcon from 'material-icons-svg/components/baseline/KeyboardArrowUp';
  3. import MoreHorizIcon from 'material-icons-svg/components/baseline/MoreHoriz';
  4. import React from 'react';
  5. import styled from 'styled-components';
  6. interface Props {
  7. roomAddress: string;
  8. onClick: () => void;
  9. }
  10. interface ContainerProps {
  11. isTyping: boolean;
  12. }
  13. const Container = styled.button((props: ContainerProps) => ({
  14. position: 'absolute',
  15. bottom: 0,
  16. right: 0,
  17. width: '16.6667%',
  18. textAlign: 'left',
  19. zIndex: 300,
  20. fontSize: '18px',
  21. border: '1px #e9ecec solid',
  22. background: 'white',
  23. padding: '5px 15px',
  24. '&:focus': {
  25. outline: 0
  26. },
  27. '& svg': {
  28. fill: 'rgb(77, 86, 89)',
  29. fontSize: '24px',
  30. verticalAlign: 'middle',
  31. '&:last-of-type': {
  32. marginLeft: '8px',
  33. opacity: props.isTyping ? 1 : 0
  34. }
  35. }
  36. }));
  37. const ChatToggle: React.SFC<Props> = ({ roomAddress, onClick }) => (
  38. <ChatComposers
  39. room={roomAddress}
  40. render={({ composers }) => (
  41. <Container onClick={onClick} isTyping={composers.length > 0}>
  42. <KeyboardArrowUpIcon />
  43. <span>Chat</span>
  44. <MoreHorizIcon />
  45. </Container>
  46. )}
  47. />
  48. );
  49. export default ChatToggle;