TextArea.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React, { Component } from "react";
  2. import styled from "styled-components";
  3. type PropsType = {
  4. label?: string;
  5. value: string;
  6. setValue: (x: string) => void;
  7. placeholder?: string;
  8. width?: string;
  9. disabled?: boolean;
  10. };
  11. type StateType = {};
  12. export default class TextArea extends Component<PropsType, StateType> {
  13. handleChange = (e: any) => {
  14. this.props.setValue(e.target.value);
  15. };
  16. render() {
  17. let { label, value, placeholder, width } = this.props;
  18. return (
  19. <StyledTextArea>
  20. <Label>{label}</Label>
  21. <InputArea
  22. disabled={this.props.disabled}
  23. placeholder={placeholder}
  24. width={width}
  25. value={value || ""}
  26. onChange={this.handleChange}
  27. />
  28. </StyledTextArea>
  29. );
  30. }
  31. }
  32. const InputArea = styled.textarea`
  33. outline: none;
  34. border: none;
  35. resize: none;
  36. font-size: 13px;
  37. background: #ffffff11;
  38. border: 1px solid #ffffff55;
  39. border-radius: 3px;
  40. width: ${(props: { disabled: boolean; width: string }) =>
  41. props.width ? props.width : "270px"};
  42. color: ${(props: { disabled: boolean; width: string }) =>
  43. props.disabled ? "#ffffff44" : "white"};
  44. padding: 5px 10px;
  45. margin-right: 8px;
  46. height: 8em;
  47. line-height: 1.6em;
  48. `;
  49. const Label = styled.div`
  50. color: #ffffff;
  51. margin-bottom: 10px;
  52. font-size: 13px;
  53. font-family: "Work Sans", sans-serif;
  54. `;
  55. const StyledTextArea = styled.div`
  56. margin-bottom: 15px;
  57. margin-top: 20px;
  58. `;