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