ShortenerInput.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. <Error type="shortener" />
  56. <ShortenerOptions
  57. isAuthenticated={isAuthenticated}
  58. setShortenerFormError={setShortenerFormError}
  59. />
  60. </ShortenerForm>
  61. );
  62. ShortenerInput.propTypes = {
  63. handleSubmit: PropTypes.func.isRequired,
  64. isAuthenticated: PropTypes.bool.isRequired,
  65. setShortenerFormError: PropTypes.func.isRequired,
  66. };
  67. export default ShortenerInput;