diff --git a/packages/grafana-ui/src/components/DragHandle/DragHandle.tsx b/packages/grafana-ui/src/components/DragHandle/DragHandle.tsx index 1c48a33992a..cf63b6626e5 100644 --- a/packages/grafana-ui/src/components/DragHandle/DragHandle.tsx +++ b/packages/grafana-ui/src/components/DragHandle/DragHandle.tsx @@ -58,6 +58,19 @@ export const getDragStyles = (theme: GrafanaTheme2, handlePosition?: DragHandleP }, }); + const beforeVertical = { + borderRight: '1px solid transparent', + height: '100%', + left: verticalOffset, + transform: 'translateX(-50%)', + }; + + const beforeHorizontal = { + borderTop: '1px solid transparent', + top: horizontalOffset, + transform: 'translateY(-50%)', + }; + return { dragHandleVertical: cx( dragHandleBase, @@ -65,12 +78,7 @@ export const getDragStyles = (theme: GrafanaTheme2, handlePosition?: DragHandleP cursor: 'col-resize', width: clickTargetSize, - '&:before': { - borderRight: '1px solid transparent', - height: '100%', - left: verticalOffset, - transform: 'translateX(-50%)', - }, + '&:before': beforeVertical, '&:after': { left: verticalOffset, @@ -86,12 +94,7 @@ export const getDragStyles = (theme: GrafanaTheme2, handlePosition?: DragHandleP height: clickTargetSize, cursor: 'row-resize', - '&:before': { - borderTop: '1px solid transparent', - top: horizontalOffset, - transform: 'translateY(-50%)', - width: '100%', - }, + '&:before': beforeHorizontal, '&:after': { left: '50%', @@ -101,5 +104,23 @@ export const getDragStyles = (theme: GrafanaTheme2, handlePosition?: DragHandleP }, }) ), + dragHandleBaseVertical: cx( + dragHandleBase, + css({ + cursor: 'col-resize', + width: clickTargetSize, + + '&:before': beforeVertical, + }) + ), + dragHandleBaseHorizontal: cx( + dragHandleBase, + css({ + cursor: 'row-resize', + height: clickTargetSize, + + '&:before': beforeHorizontal, + }) + ), }; }; diff --git a/public/app/core/components/AppChrome/AppChrome.tsx b/public/app/core/components/AppChrome/AppChrome.tsx index 4cd95dd8d4e..c8b49ab0520 100644 --- a/public/app/core/components/AppChrome/AppChrome.tsx +++ b/public/app/core/components/AppChrome/AppChrome.tsx @@ -1,10 +1,11 @@ import { css, cx } from '@emotion/css'; import classNames from 'classnames'; +import { Resizable } from 're-resizable'; import { PropsWithChildren, useEffect } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { locationSearchToObject, locationService, useScopes } from '@grafana/runtime'; -import { LinkButton, useStyles2 } from '@grafana/ui'; +import { getDragStyles, LinkButton, useStyles2 } from '@grafana/ui'; import { useGrafana } from 'app/core/context/GrafanaContext'; import { useMediaQueryMinWidth } from 'app/core/hooks/useMediaQueryMinWidth'; import { Trans } from 'app/core/internationalization'; @@ -14,7 +15,11 @@ import { ScopesDashboards } from 'app/features/scopes/dashboards/ScopesDashboard import { AppChromeMenu } from './AppChromeMenu'; import { AppChromeService, DOCKED_LOCAL_STORAGE_KEY } from './AppChromeService'; -import { EXTENSION_SIDEBAR_WIDTH, ExtensionSidebar } from './ExtensionSidebar/ExtensionSidebar'; +import { + ExtensionSidebar, + MAX_EXTENSION_SIDEBAR_WIDTH, + MIN_EXTENSION_SIDEBAR_WIDTH, +} from './ExtensionSidebar/ExtensionSidebar'; import { useExtensionSidebarContext } from './ExtensionSidebar/ExtensionSidebarProvider'; import { MegaMenu, MENU_WIDTH } from './MegaMenu/MegaMenu'; import { useMegaMenuFocusHelper } from './MegaMenu/utils'; @@ -26,7 +31,12 @@ export interface Props extends PropsWithChildren<{}> {} export function AppChrome({ children }: Props) { const { chrome } = useGrafana(); - const { isOpen: isExtensionSidebarOpen, isEnabled: isExtensionSidebarEnabled } = useExtensionSidebarContext(); + const { + isOpen: isExtensionSidebarOpen, + isEnabled: isExtensionSidebarEnabled, + extensionSidebarWidth, + setExtensionSidebarWidth, + } = useExtensionSidebarContext(); const state = chrome.useState(); const scopes = useScopes(); @@ -36,7 +46,10 @@ export function AppChrome({ children }: Props) { ); const headerLevels = useChromeHeaderLevels(); - const styles = useStyles2(getStyles, headerLevels * getChromeHeaderLevelHeight()); + const headerHeight = headerLevels * getChromeHeaderLevelHeight(); + const styles = useStyles2(getStyles, headerHeight); + const contentSizeStyles = useStyles2(getContentSizeStyles, extensionSidebarWidth); + const dragStyles = useStyles2(getDragStyles); useResponsiveDockedMegaMenu(chrome); useMegaMenuFocusHelper(state.megaMenuOpen, state.megaMenuDocked); @@ -117,15 +130,24 @@ export function AppChrome({ children }: Props) { [styles.pageContainerMenuDocked]: menuDockedAndOpen || isScopesDashboardsOpen, [styles.pageContainerMenuDockedScopes]: menuDockedAndOpen && isScopesDashboardsOpen, [styles.pageContainerWithSidebar]: !state.chromeless && isExtensionSidebarOpen, + [contentSizeStyles.contentWidth]: !state.chromeless && isExtensionSidebarOpen, })} id="pageContent" > {children} {!state.chromeless && isExtensionSidebarEnabled && isExtensionSidebarOpen && ( -