mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* initial wip * Progress on new threshold design * Testing radio button group for mode option * Starting to come together * Fixed percent mode * Full width radio groups * Minor tweaks, cursor to trash icon and hover state * fixed unit tests * Fixed storybook * re-ordering fields * Updated snapshot * Make it consistent, add vs create
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import React, { useState, FC } from 'react';
|
|
import { css, cx } from 'emotion';
|
|
import { GrafanaTheme } from '@grafana/data';
|
|
import { useTheme, Icon, stylesFactory } from '@grafana/ui';
|
|
|
|
interface Props {
|
|
title: string;
|
|
}
|
|
|
|
export const OptionsGroup: FC<Props> = ({ title, children }) => {
|
|
const [isExpanded, toggleExpand] = useState(true);
|
|
const theme = useTheme();
|
|
const styles = getStyles(theme);
|
|
|
|
return (
|
|
<div className={styles.box}>
|
|
<div className={styles.header} onClick={() => toggleExpand(!isExpanded)}>
|
|
{title}
|
|
<div className={cx(styles.toggle, 'editor-options-group-toggle')}>
|
|
<Icon name={isExpanded ? 'chevron-down' : 'chevron-left'} />
|
|
</div>
|
|
</div>
|
|
{isExpanded && <div className={styles.body}>{children}</div>}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
|
return {
|
|
box: css`
|
|
border-bottom: 1px solid ${theme.colors.pageHeaderBorder};
|
|
`,
|
|
toggle: css`
|
|
color: ${theme.colors.textWeak};
|
|
font-size: ${theme.typography.size.lg};
|
|
`,
|
|
header: css`
|
|
display: flex;
|
|
cursor: pointer;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: ${theme.spacing.sm} ${theme.spacing.md};
|
|
font-weight: ${theme.typography.weight.semibold};
|
|
|
|
&:hover {
|
|
.editor-options-group-toggle {
|
|
color: ${theme.colors.text};
|
|
}
|
|
}
|
|
`,
|
|
body: css`
|
|
padding: 0 ${theme.spacing.md} ${theme.spacing.md} ${theme.spacing.md};
|
|
`,
|
|
};
|
|
});
|