TBodyShortUrl.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, { FC } from 'react';
  2. import styled from 'styled-components';
  3. import { CopyToClipboard } from 'react-copy-to-clipboard';
  4. import { Flex } from 'reflexbox/styled-components';
  5. import TBodyButton from './TBodyButton';
  6. interface Props {
  7. copiedIndex: number;
  8. handleCopy: any; // TODO: types
  9. index: number;
  10. url: {
  11. id: string;
  12. shortLink: string;
  13. };
  14. }
  15. const CopyText = styled.div`
  16. position: absolute;
  17. top: 0;
  18. left: 40px;
  19. font-size: 11px;
  20. color: green;
  21. `;
  22. const Icon = styled.img`
  23. width: 12px;
  24. height: 12px;
  25. `;
  26. const TBodyShortUrl: FC<Props> = ({ index, copiedIndex, handleCopy, url }) => (
  27. <Flex alignItems="center">
  28. {copiedIndex === index && <CopyText>Copied to clipboard!</CopyText>}
  29. <CopyToClipboard onCopy={() => handleCopy(index)} text={`${url.shortLink}`}>
  30. <TBodyButton>
  31. <Icon src="/images/copy.svg" />
  32. </TBodyButton>
  33. </CopyToClipboard>
  34. <a href={`${url.shortLink}`}>{`${url.shortLink.replace(
  35. /^https?:\/\//,
  36. ''
  37. )}`}</a>
  38. </Flex>
  39. );
  40. export default TBodyShortUrl;