performanceBadge.tsx 973 B

123456789101112131415161718192021222324252627282930313233
  1. import styled from '@emotion/styled';
  2. import {space} from 'sentry/styles/space';
  3. import {PERFORMANCE_SCORE_COLORS} from 'sentry/views/insights/browser/webVitals/utils/performanceScoreColors';
  4. import {
  5. scoreToStatus,
  6. STATUS_TEXT,
  7. } from 'sentry/views/insights/browser/webVitals/utils/scoreToStatus';
  8. type Props = {
  9. score: number;
  10. };
  11. export function PerformanceBadge({score}: Props) {
  12. const status = scoreToStatus(score);
  13. return (
  14. <Badge status={status}>
  15. {STATUS_TEXT[status]} {score}
  16. </Badge>
  17. );
  18. }
  19. export const Badge = styled('div')<{status: string}>`
  20. white-space: nowrap;
  21. border-radius: 12px;
  22. color: ${p => p.theme[PERFORMANCE_SCORE_COLORS[p.status].normal]};
  23. background-color: ${p => p.theme[PERFORMANCE_SCORE_COLORS[p.status].light]};
  24. border: solid 1px ${p => p.theme[PERFORMANCE_SCORE_COLORS[p.status].light]};
  25. font-size: ${p => p.theme.fontSizeExtraSmall};
  26. padding: 0 ${space(1)};
  27. display: inline-block;
  28. height: 17px;
  29. `;