listItem.tsx 794 B

12345678910111213141516171819202122232425262728293031323334
  1. import {forwardRef} from 'react';
  2. import styled from '@emotion/styled';
  3. import space from 'sentry/styles/space';
  4. interface ListeItemProps extends React.HTMLAttributes<HTMLLIElement> {
  5. padding?: string;
  6. symbol?: React.ReactElement;
  7. }
  8. const ListItem = styled(
  9. forwardRef<HTMLLIElement, ListeItemProps>(
  10. ({symbol, children, padding: _padding, ...props}, ref) => (
  11. <li ref={ref} role={props.onClick ? 'button' : undefined} {...props}>
  12. {symbol && <Symbol>{symbol}</Symbol>}
  13. {children}
  14. </li>
  15. )
  16. )
  17. )`
  18. position: relative;
  19. ${p => p.symbol && `padding-left: ${p.padding ?? space(4)};`}
  20. `;
  21. const Symbol = styled('div')`
  22. display: flex;
  23. align-items: center;
  24. position: absolute;
  25. top: 0;
  26. left: 0;
  27. min-height: 22.5px;
  28. `;
  29. export default ListItem;