mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-16 05:03:11 +08:00
15 lines
482 B
JavaScript
15 lines
482 B
JavaScript
import { document } from 'global';
|
|
|
|
// HMR will cause this code to be invoked multiple times, so each warning should have a unique ID
|
|
export default function addHeadWarning(id, text) {
|
|
if (!document.getElementById(id)) {
|
|
const warning = document.createElement('h1');
|
|
warning.textContent = text;
|
|
warning.id = id;
|
|
warning.style.backgroundColor = 'tomato';
|
|
warning.style.padding = '10px';
|
|
|
|
document.body.insertBefore(warning, document.body.firstChild);
|
|
}
|
|
}
|