equationSymbol copy.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {forwardRef} from 'react';
  2. import styled from '@emotion/styled';
  3. import {space} from 'sentry/styles/space';
  4. const Symbol = styled('span')<{isHidden?: boolean; isSelected?: boolean}>`
  5. display: flex;
  6. width: 16px;
  7. height: 16px;
  8. line-height: 16px;
  9. padding: ${space(0.5)};
  10. justify-content: center;
  11. align-items: center;
  12. flex-shrink: 0;
  13. border-radius: ${p => p.theme.borderRadius};
  14. font-weight: 500;
  15. color: ${p => p.theme.black};
  16. font-size: 11px;
  17. background: ${p => p.theme.yellow300};
  18. margin-top: -2px;
  19. ${p =>
  20. p.isSelected &&
  21. !p.isHidden &&
  22. `
  23. background: ${p.theme.purple300};
  24. color: ${p.theme.white};
  25. `}
  26. ${p =>
  27. p.isHidden &&
  28. `
  29. background: ${p.theme.gray300};
  30. color: ${p.theme.white};
  31. `}
  32. `;
  33. interface EquationSymbolProps extends React.ComponentProps<typeof Symbol> {
  34. equationId: number;
  35. }
  36. export function getEquationSymbol(equationId: number) {
  37. return `ƒ${equationId + 1}`;
  38. }
  39. export const EquationSymbol = forwardRef<HTMLSpanElement, EquationSymbolProps>(
  40. function EquationSymbol({equationId, ...props}, ref) {
  41. return (
  42. <Symbol ref={ref} {...props}>
  43. <span>
  44. ƒ<sub>{equationId + 1}</sub>
  45. </span>
  46. </Symbol>
  47. );
  48. }
  49. );