The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/features/explore/ExploreDrawer.tsx

89 lines
2.3 KiB

// Libraries
import { css, cx, keyframes } from '@emotion/css';
import { Resizable, ResizeCallback } from 're-resizable';
import React from 'react';
// Services & Utils
import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2, useTheme2 } from '@grafana/ui';
export interface Props {
width: number;
children: React.ReactNode;
onResize?: ResizeCallback;
}
export function ExploreDrawer(props: Props) {
const { width, children, onResize } = props;
const theme = useTheme2();
const styles = useStyles2(getStyles);
const drawerWidth = `${width + 31.5}px`;
return (
<Resizable
className={cx(styles.fixed, styles.container, styles.drawerActive)}
defaultSize={{ width: drawerWidth, height: `${theme.components.horizontalDrawer.defaultHeight}px` }}
handleClasses={{ top: styles.rzHandle }}
enable={{
top: true,
right: false,
bottom: false,
left: false,
topRight: false,
bottomRight: false,
bottomLeft: false,
topLeft: false,
}}
maxHeight="100vh"
maxWidth={drawerWidth}
minWidth={drawerWidth}
onResize={onResize}
>
{children}
</Resizable>
);
}
const drawerSlide = (theme: GrafanaTheme2) => keyframes`
0% {
transform: translateY(${theme.components.horizontalDrawer.defaultHeight}px);
}
100% {
transform: translateY(0px);
}
`;
const getStyles = (theme: GrafanaTheme2) => ({
// @ts-expect-error csstype doesn't allow !important. see https://github.com/frenic/csstype/issues/114
fixed: css({
position: 'fixed !important',
}),
container: css({
bottom: 0,
background: theme.colors.background.primary,
borderTop: `1px solid ${theme.colors.border.weak}`,
margin: theme.spacing(0, -2, 0, -2),
boxShadow: theme.shadows.z3,
zIndex: theme.zIndex.navbarFixed,
}),
drawerActive: css({
opacity: 1,
animation: `0.5s ease-out ${drawerSlide(theme)}`,
}),
rzHandle: css({
background: theme.colors.secondary.main,
transition: '0.3s background ease-in-out',
position: 'relative',
width: '200px !important',
height: '7px !important',
left: 'calc(50% - 100px) !important',
top: '-4px !important',
cursor: 'grab',
borderRadius: theme.shape.radius.pill,
['&:hover']: {
background: theme.colors.secondary.shade,
},
}),
});