Ringtone app
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

86 lines
1.4 KiB

  1. import {FC} from 'react'
  2. import styled from 'styled-components'
  3. const Base = styled('div')({
  4. height: '3rem',
  5. borderRadius: '0.25rem',
  6. overflow: 'hidden',
  7. position: 'relative',
  8. backgroundColor: 'var(--color-bg, white)',
  9. '::before': {
  10. content: "''",
  11. borderWidth: 1,
  12. borderStyle: 'solid',
  13. position: 'absolute',
  14. top: 0,
  15. left: 0,
  16. width: '100%',
  17. height: '100%',
  18. borderRadius: 'inherit',
  19. boxSizing: 'border-box',
  20. opacity: 0.5,
  21. },
  22. })
  23. const ClickArea = styled('label')({
  24. position: 'relative',
  25. height: '100%',
  26. })
  27. const Label = styled('span')({
  28. position: 'absolute',
  29. left: -999999,
  30. })
  31. const Input = styled('input')({
  32. display: 'block',
  33. width: '100%',
  34. height: '100%',
  35. margin: 0,
  36. padding: '0 1rem',
  37. boxSizing: 'border-box',
  38. font: 'inherit',
  39. border: 0,
  40. backgroundColor: 'transparent',
  41. color: 'inherit',
  42. outline: 0,
  43. })
  44. type Props = {
  45. label: string,
  46. name: string,
  47. className?: string,
  48. block?: boolean,
  49. placeholder?: string,
  50. defaultValue?: string | number | readonly string[],
  51. type?: 'email' | 'url' | 'text' | 'tel',
  52. }
  53. const TextInput: FC<Props> = ({
  54. label,
  55. className,
  56. block,
  57. ...etcProps
  58. }) => {
  59. return (
  60. <Base
  61. className={className}
  62. style={{
  63. display: block ? 'block' : 'inline-block',
  64. width: block ? '100%' : undefined,
  65. }}
  66. >
  67. <ClickArea>
  68. <Label>
  69. {label}
  70. </Label>
  71. <Input
  72. {...etcProps}
  73. />
  74. </ClickArea>
  75. </Base>
  76. )
  77. }
  78. export default TextInput