Ringtone app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

85 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. },
  21. })
  22. const ClickArea = styled('label')({
  23. position: 'relative',
  24. height: '100%',
  25. })
  26. const Label = styled('span')({
  27. position: 'absolute',
  28. left: -999999,
  29. })
  30. const Input = styled('input')({
  31. display: 'block',
  32. width: '100%',
  33. height: '100%',
  34. margin: 0,
  35. padding: '0 1rem',
  36. boxSizing: 'border-box',
  37. font: 'inherit',
  38. border: 0,
  39. backgroundColor: 'transparent',
  40. color: 'inherit',
  41. outline: 0,
  42. })
  43. type Props = {
  44. label: string,
  45. name: string,
  46. className?: string,
  47. block?: boolean,
  48. placeholder?: string,
  49. defaultValue?: string | number | readonly string[],
  50. type?: 'email' | 'url' | 'text' | 'tel',
  51. }
  52. const TextInput: FC<Props> = ({
  53. label,
  54. className,
  55. block,
  56. ...etcProps
  57. }) => {
  58. return (
  59. <Base
  60. className={className}
  61. style={{
  62. display: block ? 'block' : 'inline-block',
  63. width: block ? '100%' : undefined,
  64. }}
  65. >
  66. <ClickArea>
  67. <Label>
  68. {label}
  69. </Label>
  70. <Input
  71. {...etcProps}
  72. />
  73. </ClickArea>
  74. </Base>
  75. )
  76. }
  77. export default TextInput