/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the "Elastic License * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side * Public License v 1"; you may not use this file except in compliance with, at * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; import type { AppMountParameters, CoreStart } from '@kbn/core/public'; import { I18nProvider } from '@kbn/i18n-react'; import React, { ReactNode, useState } from 'react'; import ReactDOM from 'react-dom'; import { useIsWithinBreakpoints } from '@elastic/eui'; import { css } from '@emotion/react'; import { ResizableLayout, ResizableLayoutDirection, ResizableLayoutMode, } from '@kbn/resizable-layout'; import { createHtmlPortalNode, InPortal, OutPortal } from 'react-reverse-portal'; const ResizableSection = ({ direction, initialFixedPanelSize, minFixedPanelSize, minFlexPanelSize, fixedPanelColor, flexPanelColor, fixedPanelContent, flexPanelContent, }: { direction: ResizableLayoutDirection; initialFixedPanelSize: number; minFixedPanelSize: number; minFlexPanelSize: number; fixedPanelColor: string; flexPanelColor: string; fixedPanelContent: ReactNode; flexPanelContent: ReactNode; }) => { const [fixedPanelSize, setFixedPanelSize] = useState(initialFixedPanelSize); const [container, setContainer] = useState(null); const [fixedPanelNode] = useState(() => createHtmlPortalNode({ attributes: { class: 'eui-fullHeight' } }) ); const [flexPanelNode] = useState(() => createHtmlPortalNode({ attributes: { class: 'eui-fullHeight' } }) ); const isMobile = useIsWithinBreakpoints(['xs', 's']); const layoutMode = isMobile ? ResizableLayoutMode.Static : ResizableLayoutMode.Resizable; const layoutDirection = isMobile ? ResizableLayoutDirection.Vertical : direction; const fullWidthAndHeightCss = css` position: relative; width: 100%; height: 100%; `; const panelBaseCss = css` ${fullWidthAndHeightCss} padding: 20px; font-size: 20px; display: flex; align-items: center; justify-content: center; `; const fixedPanelCss = css` ${panelBaseCss} background-color: ${fixedPanelColor}; `; const flexPanelCss = css` ${panelBaseCss} background-color: ${flexPanelColor}; `; return (
{fixedPanelContent}
{flexPanelContent}
} flexPanel={} onFixedPanelSizeChange={setFixedPanelSize} />
); }; export const renderApp = (coreStart: CoreStart, { element }: AppMountParameters) => { ReactDOM.render(
} flexPanelContent={ } /> } />
, element ); return () => { ReactDOM.unmountComponentAtNode(element); }; };