progress.tsx 600 B

123456789101112131415161718192021222324252627282930
  1. import styled from '@emotion/styled';
  2. /**
  3. * A simple progress bar.
  4. * ```
  5. * <Meter>
  6. * <Value percent={0.75} />
  7. * </Meter>
  8. * ```
  9. *
  10. * Extend the components to set a background color.
  11. *
  12. * Return multiple <Value /> components to render multiple bars directly on top
  13. * of each other with `position:absolute;`.
  14. */
  15. export const Meter = styled('div')`
  16. position: relative;
  17. height: 100%;
  18. width: 100%;
  19. pointer-events: none;
  20. `;
  21. export const Value = styled('span')<{
  22. percent: number;
  23. }>`
  24. position: absolute;
  25. height: 100%;
  26. width: ${p => p.percent * 100}%;
  27. pointer-events: none;
  28. `;