source: frontend/node_modules/@pmmmwh/react-refresh-webpack-plugin/overlay/components/PageHeader.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.8 KB
Line 
1const Spacer = require('./Spacer.js');
2const theme = require('../theme.js');
3
4/**
5 * @typedef {Object} PageHeaderProps
6 * @property {string} [message]
7 * @property {string} title
8 * @property {string} [topOffset]
9 */
10
11/**
12 * The header of the overlay.
13 * @param {Document} document
14 * @param {HTMLElement} root
15 * @param {PageHeaderProps} props
16 * @returns {void}
17 */
18function PageHeader(document, root, props) {
19 const pageHeaderContainer = document.createElement('div');
20 pageHeaderContainer.style.background = '#' + theme.dimgrey;
21 pageHeaderContainer.style.boxShadow = '0 1px 4px rgba(0, 0, 0, 0.3)';
22 pageHeaderContainer.style.color = '#' + theme.white;
23 pageHeaderContainer.style.left = '0';
24 pageHeaderContainer.style.right = '0';
25 pageHeaderContainer.style.padding = '1rem 1.5rem';
26 pageHeaderContainer.style.paddingLeft = 'max(1.5rem, env(safe-area-inset-left))';
27 pageHeaderContainer.style.paddingRight = 'max(1.5rem, env(safe-area-inset-right))';
28 pageHeaderContainer.style.position = 'fixed';
29 pageHeaderContainer.style.top = props.topOffset || '0';
30
31 const title = document.createElement('h3');
32 title.innerText = props.title;
33 title.style.color = '#' + theme.red;
34 title.style.fontSize = '1.125rem';
35 title.style.lineHeight = '1.3';
36 title.style.margin = '0';
37 pageHeaderContainer.appendChild(title);
38
39 if (props.message) {
40 title.style.margin = '0 0 0.5rem';
41
42 const message = document.createElement('span');
43 message.innerText = props.message;
44 message.style.color = '#' + theme.white;
45 message.style.wordBreak = 'break-word';
46 pageHeaderContainer.appendChild(message);
47 }
48
49 root.appendChild(pageHeaderContainer);
50
51 // This has to run after appending elements to root
52 // because we need to actual mounted height.
53 Spacer(document, root, {
54 space: pageHeaderContainer.offsetHeight.toString(10),
55 });
56}
57
58module.exports = PageHeader;
Note: See TracBrowser for help on using the repository browser.