@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
38 lines (37 loc) • 1.14 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({
baseFontSize,
children
}) {
const memoizedTheme = useMemo(() => ({
baseFontSize: baseFontSize || 14,
layoutMaxWidth: akEditorDefaultLayoutWidth
}), [baseFontSize]);
return /*#__PURE__*/React.createElement(ThemeProvider, {
theme: memoizedTheme
}, children);
}
export function BaseTheme({
children,
baseFontSize
}) {
return /*#__PURE__*/React.createElement(WidthConsumer, null, ({
breakpoint
}) => /*#__PURE__*/React.createElement(BaseThemeWrapper, {
breakpoint: breakpoint,
baseFontSize: baseFontSize
}, /*#__PURE__*/React.createElement(React.Fragment, null, children)));
}