import { css } from '@emotion/css'; import React from 'react'; import { useToggle } from 'react-use'; import { GrafanaTheme2 } from '@grafana/data'; import { Collapse, useStyles2, Stack } from '@grafana/ui'; export interface Props { title: string; collapsedInfo: string[]; children: React.ReactNode; } export function QueryOptionGroup({ title, children, collapsedInfo }: Props) { const [isOpen, toggleOpen] = useToggle(false); const styles = useStyles2(getStyles); return (
{title}
{!isOpen && (
{collapsedInfo.map((x, i) => ( {x} ))}
)} } >
{children}
); } const getStyles = (theme: GrafanaTheme2) => { return { collapse: css({ backgroundColor: 'unset', border: 'unset', marginBottom: 0, ['> button']: { padding: theme.spacing(0, 1), }, }), wrapper: css({ width: '100%', display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', }), title: css({ flexGrow: 1, overflow: 'hidden', fontSize: theme.typography.bodySmall.fontSize, fontWeight: theme.typography.fontWeightMedium, margin: 0, }), description: css({ color: theme.colors.text.secondary, fontSize: theme.typography.bodySmall.fontSize, fontWeight: theme.typography.bodySmall.fontWeight, paddingLeft: theme.spacing(2), gap: theme.spacing(2), display: 'flex', }), body: css({ display: 'flex', gap: theme.spacing(2), flexWrap: 'wrap', }), }; };