-
Notifications
You must be signed in to change notification settings - Fork 1
/
MysticalProvider.mjs
42 lines (37 loc) · 1.03 KB
/
MysticalProvider.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { ThemeProvider } from "@emotion/react";
import PropTypes from "prop-types";
import React from "react";
import Global from "./Global.mjs";
import customProperties from "./private/customProperties.mjs";
import useMystical from "./useMystical.mjs";
function MysticalGlobalStyles() {
const { theme = {} } = useMystical();
return React.createElement(Global, {
styles: [
{
["*, *::before,*::after"]: {
boxSizing: "border-box",
},
},
theme.colors && { ":root": customProperties(theme.colors, "colors") },
theme.global,
],
});
}
function MysticalProvider({ theme, options = {}, children }) {
return React.createElement(
ThemeProvider,
{ theme: { theme, options } },
React.createElement(MysticalGlobalStyles),
children,
);
}
MysticalProvider.propTypes = {
theme: PropTypes.object,
options: PropTypes.shape({
darkModeOff: PropTypes.bool,
darkModeForcedBoundary: PropTypes.bool,
}),
children: PropTypes.node.isRequired,
};
export default MysticalProvider;