TextInput.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import styled, { css } from "styled-components";
  2. import { ifProp, withProp } from "styled-tools";
  3. import { Flex } from "reflexbox/styled-components";
  4. import { fadeIn } from "../helpers/animations";
  5. interface Props {
  6. autoFocus?: boolean;
  7. name?: string;
  8. id?: string;
  9. type?: string;
  10. value?: string;
  11. required?: boolean;
  12. small?: boolean;
  13. onChange?: any;
  14. tiny?: boolean;
  15. placeholderSize?: number[];
  16. }
  17. const TextInput = styled(Flex).attrs({
  18. as: "input"
  19. })<Props>`
  20. position: relative;
  21. box-sizing: border-box;
  22. letter-spacing: 0.05em;
  23. color: #444;
  24. background-color: white;
  25. box-shadow: 0 10px 35px rgba(50, 50, 50, 0.1);
  26. border-radius: 100px;
  27. border: none;
  28. border-bottom: 5px solid #f5f5f5;
  29. animation: ${fadeIn} 0.5s ease-out;
  30. transition: all 0.5s ease-out;
  31. :focus {
  32. outline: none;
  33. box-shadow: 0 20px 35px rgba(50, 50, 50, 0.2);
  34. }
  35. ::placeholder {
  36. font-size: ${withProp("placeholderSize", s => s[0] || 14)};
  37. letter-spacing: 0.05em;
  38. color: #888;
  39. }
  40. @media screen and (min-width: 64em) {
  41. ::placeholder {
  42. font-size: ${withProp("placeholderSize", s => s[3] || 16)}px;
  43. }
  44. }
  45. @media screen and (min-width: 52em) {
  46. letter-spacing: 0.1em;
  47. border-bottom-width: 6px;
  48. ::placeholder {
  49. font-size: ${withProp("placeholderSize", s => s[2] || 15)}px;
  50. }
  51. }
  52. @media screen and (min-width: 40em) {
  53. ::placeholder {
  54. font-size: ${withProp("placeholderSize", s => s[1] || 15)}px;
  55. }
  56. }
  57. /* ${ifProp(
  58. "small",
  59. css`
  60. width: 240px;
  61. height: 54px;
  62. margin-right: 32px;
  63. padding: 0 24px 2px;
  64. font-size: 18px;
  65. border-bottom: 4px solid #f5f5f5;
  66. ::placeholder {
  67. font-size: 13px;
  68. }
  69. @media only screen and (max-width: 448px) {
  70. width: 200px;
  71. height: 40px;
  72. padding: 0 16px 2px;
  73. font-size: 13px;
  74. border-bottom-width: 3px;
  75. }
  76. `
  77. )}
  78. ${ifProp(
  79. "tiny",
  80. css`
  81. flex: 0 0 auto;
  82. width: 280px;
  83. height: 32px;
  84. margin: 0;
  85. padding: 0 16px 1px;
  86. font-size: 13px;
  87. border-bottom-width: 1px;
  88. border-radius: 4px;
  89. box-shadow: 0 4px 10px rgba(100, 100, 100, 0.1);
  90. :focus {
  91. box-shadow: 0 10px 25px rgba(50, 50, 50, 0.1);
  92. }
  93. ::placeholder {
  94. font-size: 12px;
  95. letter-spacing: 0;
  96. }
  97. @media only screen and (max-width: 768px) {
  98. width: 240px;
  99. height: 28px;
  100. }
  101. @media only screen and (max-width: 510px) {
  102. width: 180px;
  103. height: 24px;
  104. padding: 0 8px 1px;
  105. font-size: 12px;
  106. border-bottom-width: 3px;
  107. }
  108. `
  109. )} */
  110. `;
  111. TextInput.defaultProps = {
  112. value: "",
  113. small: false,
  114. tiny: false,
  115. height: [56, 72],
  116. py: 0,
  117. pr: [48, 84],
  118. pl: [32, 40],
  119. fontSize: [14, 16],
  120. placeholderSize: []
  121. };
  122. export default TextInput;