percentInput.tsx 820 B

123456789101112131415161718192021222324252627282930
  1. import type React from 'react';
  2. import {forwardRef} from 'react';
  3. import {css} from '@emotion/react';
  4. import styled from '@emotion/styled';
  5. import {InputGroup} from 'sentry/components/inputGroup';
  6. import {space} from 'sentry/styles/space';
  7. interface Props extends React.ComponentProps<typeof InputGroup.Input> {}
  8. export const PercentInput = forwardRef<HTMLInputElement, Props>(
  9. function PercentInput(props, ref) {
  10. return (
  11. <InputGroup
  12. css={css`
  13. width: 160px;
  14. `}
  15. >
  16. <InputGroup.Input ref={ref} type="number" min={0} max={100} {...props} />
  17. <InputGroup.TrailingItems>
  18. <TrailingPercent>%</TrailingPercent>
  19. </InputGroup.TrailingItems>
  20. </InputGroup>
  21. );
  22. }
  23. );
  24. const TrailingPercent = styled('strong')`
  25. padding: 0 ${space(0.25)};
  26. `;