All files / src/components/Fundraisers/PublicPaymentForm CustomDonationDigitInput.tsx

0% Statements 0/5
100% Branches 0/0
0% Functions 0/2
0% Lines 0/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                                                                                                       
import React, { memo, useRef } from "react";
import { styled } from "@mui/material";
import { palette } from "@palette";
 
type CustomDonationDigitInputProps = {
  min?: number;
  max?: number;
  amount: number | string;
  handleKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
  handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
  handleBlur: () => void;
};
 
const CustomDonationDigitInput = ({
  amount,
  handleChange,
  handleKeyDown,
  handleBlur,
}: CustomDonationDigitInputProps) => {
  const ref = useRef(null);
  return (
    <StyledInput
      autoFocus
      ref={ref}
      min={1}
      value={`${amount}`}
      onChange={handleChange}
      onKeyDown={handleKeyDown}
      onBlur={() => handleBlur()}
      size={`${amount}`.length + 2}
      style={{
        padding: 0,
      }}
    />
  );
};
 
const StyledInput = styled("input")({
  color: palette.neutral[80],
  border: "none",
  outline: "none",
  width: "fit-content",
  fontSize: "32px",
  fontWeight: 350,
  fontFamily: "Give Whyte,sans-serif",
  margin: 0,
  padding: 0,
  background: "inherit",
});
 
export default memo(CustomDonationDigitInput);