RuntimeErrorHeader.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const theme = require('../theme');
  2. const Spacer = require('./Spacer');
  3. /**
  4. * @typedef {Object} RuntimeErrorHeaderProps
  5. * @property {number} currentErrorIndex
  6. * @property {number} totalErrors
  7. */
  8. /**
  9. * A fixed header that shows the total runtime error count.
  10. * @param {Document} document
  11. * @param {HTMLElement} root
  12. * @param {RuntimeErrorHeaderProps} props
  13. * @returns {void}
  14. */
  15. function RuntimeErrorHeader(document, root, props) {
  16. const header = document.createElement('div');
  17. header.innerText = 'Error ' + (props.currentErrorIndex + 1) + ' of ' + props.totalErrors;
  18. header.style.backgroundColor = '#' + theme.red;
  19. header.style.color = '#' + theme.white;
  20. header.style.fontWeight = '500';
  21. header.style.height = '2.5rem';
  22. header.style.left = '0';
  23. header.style.lineHeight = '2.5rem';
  24. header.style.position = 'fixed';
  25. header.style.textAlign = 'center';
  26. header.style.top = '0';
  27. header.style.width = '100vw';
  28. header.style.zIndex = '2';
  29. root.appendChild(header);
  30. Spacer(document, root, { space: '2.5rem' });
  31. }
  32. module.exports = RuntimeErrorHeader;