@masa-dev/react-signage
Version:
This is a react library for signage.
30 lines (29 loc) • 813 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { toast } from "react-hot-toast";
import { DebugContext } from "./DebugContext";
const backgrounds = {
info: 'white',
warning: 'yellow',
error: 'red'
};
const colors = {
info: 'black',
warning: 'black',
error: 'white'
};
export function DebugProvider(props) {
const { debug, children } = props;
function debugMessage(data) {
if (!debug || !data.message)
return;
console.log(data);
toast(data.message, {
duration: 5000,
style: {
backgroundColor: backgrounds[data.severity],
color: colors[data.severity],
}
});
}
return _jsx(DebugContext.Provider, { value: { debug, debugMessage }, children: children });
}