ShortenerInput.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import styled from 'styled-components';
  4. import SVG from 'react-inlinesvg';
  5. import ShortenerOptions from './ShortenerOptions';
  6. import TextInput from '../TextInput';
  7. import Error from '../Error';
  8. const ShortenerForm = styled.form`
  9. position: relative;
  10. display: flex;
  11. justify-content: center;
  12. align-items: center;
  13. width: 800px;
  14. max-width: 100%;
  15. `;
  16. const Submit = styled.div`
  17. content: '';
  18. position: absolute;
  19. top: 0;
  20. right: 12px;
  21. width: 64px;
  22. height: 100%;
  23. display: flex;
  24. justify-content: center;
  25. align-items: center;
  26. cursor: pointer;
  27. :hover svg {
  28. fill: #673ab7;
  29. }
  30. @media only screen and (max-width: 448px) {
  31. right: 8px;
  32. width: 40px;
  33. }
  34. `;
  35. const Icon = styled(SVG)`
  36. svg {
  37. width: 28px;
  38. height: 28px;
  39. margin-right: 8px;
  40. margin-top: 2px;
  41. fill: #aaa;
  42. transition: all 0.2s ease-out;
  43. @media only screen and (max-width: 448px) {
  44. height: 22px;
  45. width: 22px;
  46. }
  47. }
  48. `;
  49. const ShortenerInput = ({ isAuthenticated, handleSubmit, setShortenerFormError }) => (
  50. <ShortenerForm id="shortenerform" onSubmit={handleSubmit}>
  51. <TextInput id="target" name="target" placeholder="Paste your long URL" autoFocus />
  52. <Submit onClick={handleSubmit}>
  53. <Icon src="/images/send.svg" />
  54. </Submit>
  55. <input type="hidden" id="g-recaptcha-input" name="g-recaptcha-input" />
  56. <Error type="shortener" />
  57. <ShortenerOptions
  58. isAuthenticated={isAuthenticated}
  59. setShortenerFormError={setShortenerFormError}
  60. />
  61. </ShortenerForm>
  62. );
  63. ShortenerInput.propTypes = {
  64. handleSubmit: PropTypes.func.isRequired,
  65. isAuthenticated: PropTypes.bool.isRequired,
  66. setShortenerFormError: PropTypes.func.isRequired,
  67. };
  68. export default ShortenerInput;