spanRectangle.tsx 812 B

12345678910111213141516171819202122232425262728293031
  1. import {useTheme} from '@emotion/react';
  2. import {
  3. getSpanBarColours,
  4. SpanBarType,
  5. } from 'sentry/components/performance/waterfall/constants';
  6. import {RowRectangle} from 'sentry/components/performance/waterfall/rowBar';
  7. import toPercent from 'sentry/utils/number/toPercent';
  8. import {EnhancedSpan} from './types';
  9. import {SpanViewBoundsType} from './utils';
  10. export default function SpanRectangle({
  11. bounds,
  12. spanBarType,
  13. }: {
  14. bounds: SpanViewBoundsType;
  15. spanGrouping: EnhancedSpan[];
  16. spanBarType?: SpanBarType;
  17. }) {
  18. const theme = useTheme();
  19. return (
  20. <RowRectangle
  21. style={{
  22. backgroundColor: getSpanBarColours(spanBarType, theme).primary,
  23. left: `min(${toPercent(bounds.left || 0)}, calc(100% - 1px))`,
  24. width: toPercent(bounds.width || 0),
  25. }}
  26. />
  27. );
  28. }