@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
39 lines (38 loc) • 1.31 kB
JavaScript
import React, { useMemo } from 'react';
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
import { ThemeProvider } from '@emotion/react';
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
import { WidthConsumer } from '../WidthProvider';
export function mapBreakpointToLayoutMaxWidth(breakpoint) {
switch (breakpoint) {
case 'M':
case 'L':
return 760;
default:
return 680;
}
}
export function BaseThemeWrapper(_ref) {
var baseFontSize = _ref.baseFontSize,
children = _ref.children;
var memoizedTheme = useMemo(function () {
return {
baseFontSize: baseFontSize || 14,
layoutMaxWidth: akEditorDefaultLayoutWidth
};
}, [baseFontSize]);
return /*#__PURE__*/React.createElement(ThemeProvider, {
theme: memoizedTheme
}, children);
}
export function BaseTheme(_ref2) {
var children = _ref2.children,
baseFontSize = _ref2.baseFontSize;
return /*#__PURE__*/React.createElement(WidthConsumer, null, function (_ref3) {
var breakpoint = _ref3.breakpoint;
return /*#__PURE__*/React.createElement(BaseThemeWrapper, {
breakpoint: breakpoint,
baseFontSize: baseFontSize
}, /*#__PURE__*/React.createElement(React.Fragment, null, children));
});
}