Ringtone app
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

88 satır
1.5 KiB

  1. import {ChangeEventHandler, 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. onChange?: ChangeEventHandler<HTMLInputElement>,
  52. disabled?: boolean,
  53. }
  54. const NumericInput: FC<Props> = ({
  55. label,
  56. className,
  57. block,
  58. ...etcProps
  59. }) => {
  60. return (
  61. <Base
  62. className={className}
  63. style={{
  64. display: block ? 'block' : 'inline-block',
  65. width: block ? '100%' : undefined,
  66. }}
  67. >
  68. <ClickArea>
  69. <Label>
  70. {label}
  71. </Label>
  72. <Input
  73. {...etcProps}
  74. type="number"
  75. />
  76. </ClickArea>
  77. </Base>
  78. )
  79. }
  80. export default NumericInput