UNPKG

948 BJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5exports.__esModule = true;
6exports.useTheme = exports["default"] = void 0;
7
8var _core = require("@emotion/core");
9
10var _emotionTheming = require("emotion-theming");
11
12var _react = require("react");
13
14var _theme = _interopRequireDefault(require("../theme"));
15
16/** @jsx jsx */
17var ThemeProvider = function ThemeProvider(_ref) {
18 var theme = _ref.theme,
19 children = _ref.children;
20 return (0, _core.jsx)(_emotionTheming.ThemeProvider, {
21 theme: theme
22 }, children);
23};
24
25ThemeProvider.defaultProps = {
26 theme: _theme["default"]
27};
28
29var useTheme = function useTheme() {
30 var theme = (0, _react.useContext)(_core.ThemeContext);
31
32 if (theme === undefined) {
33 throw new Error("useTheme must be used within a ThemeProvider");
34 }
35
36 return theme;
37};
38
39exports.useTheme = useTheme;
40var _default = ThemeProvider;
41exports["default"] = _default;
\No newline at end of file