@chayns-components/core
Version:
A set of beautiful React components for developing your own applications with chayns.
47 lines • 1.59 kB
JavaScript
import { RuntimeEnviroment, useEnvironment } from 'chayns-api';
import React from 'react';
import { createGlobalStyle } from 'styled-components';
import { useUsableHeight } from '../../utils/pageProvider';
import ColorSchemeProvider from '../color-scheme-provider/ColorSchemeProvider';
import { StyledPageProvider } from './PageProvider.styles';
const GlobalStyle = createGlobalStyle`
*, *::before, *::after {
box-sizing: border-box;
}
`;
const PageProvider = _ref => {
let {
children,
color,
colorMode,
secondaryColor,
siteId,
style = {},
shouldRemovePadding,
shouldUseUsableHeight,
customVariables
} = _ref;
const {
runtimeEnvironment
} = useEnvironment();
const usableHeight = useUsableHeight();
const shouldUsePadding = !shouldRemovePadding && ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(runtimeEnvironment);
return /*#__PURE__*/React.createElement(StyledPageProvider, {
className: "page-provider",
$shouldUsePadding: shouldUsePadding,
$usableHeight: shouldUseUsableHeight ? usableHeight : undefined
}, /*#__PURE__*/React.createElement(ColorSchemeProvider, {
color: color,
secondaryColor: secondaryColor,
colorMode: colorMode,
siteId: siteId,
style: shouldUseUsableHeight ? {
...style,
height: '100%'
} : style,
customVariables: customVariables
}, children), /*#__PURE__*/React.createElement(GlobalStyle, null));
};
PageProvider.displayName = 'PageProvider';
export default PageProvider;
//# sourceMappingURL=PageProvider.js.map