diff --git a/public/app/features/alerting/unified/components/CollapseToggle.tsx b/public/app/features/alerting/unified/components/CollapseToggle.tsx index 0fa7a8556c6..3c73a4779cd 100644 --- a/public/app/features/alerting/unified/components/CollapseToggle.tsx +++ b/public/app/features/alerting/unified/components/CollapseToggle.tsx @@ -1,43 +1,45 @@ import React, { FC, HTMLAttributes } from 'react'; import { css, cx } from '@emotion/css'; -import { IconSize, useStyles, Icon } from '@grafana/ui'; +import { GrafanaTheme2 } from '@grafana/data'; +import { IconSize, useStyles2, Button } from '@grafana/ui'; interface Props extends HTMLAttributes { isCollapsed: boolean; onToggle: (isCollapsed: boolean) => void; + // Todo: this should be made compulsory for a11y purposes + idControlled?: string; size?: IconSize; className?: string; text?: string; } -export const CollapseToggle: FC = ({ isCollapsed, onToggle, className, text, size = 'xl', ...restOfProps }) => { - const styles = useStyles(getStyles); +export const CollapseToggle: FC = ({ + isCollapsed, + onToggle, + idControlled, + className, + text, + size = 'xl', + ...restOfProps +}) => { + const styles = useStyles2(getStyles); return ( - + /> ); }; -export const getStyles = () => ({ +export const getStyles = (theme: GrafanaTheme2) => ({ expandButton: css` - background: none; - border: none; - - outline: none !important; - - display: inline-flex; - align-items: center; - - svg { - margin-bottom: 0; - } + color: ${theme.colors.text.secondary}; + margin-right: ${theme.spacing(1)}; `, }); diff --git a/public/app/features/dashboard/components/PanelEditor/OptionsPaneCategory.tsx b/public/app/features/dashboard/components/PanelEditor/OptionsPaneCategory.tsx index c94902dd4c5..4c57d945ef4 100644 --- a/public/app/features/dashboard/components/PanelEditor/OptionsPaneCategory.tsx +++ b/public/app/features/dashboard/components/PanelEditor/OptionsPaneCategory.tsx @@ -1,11 +1,12 @@ import React, { FC, ReactNode, useCallback, useEffect, useState, useRef } from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; -import { Counter, Icon, useStyles2 } from '@grafana/ui'; +import { Counter, useStyles2 } from '@grafana/ui'; import { PANEL_EDITOR_UI_STATE_STORAGE_KEY } from './state/reducers'; import { useLocalStorage } from 'react-use'; import { selectors } from '@grafana/e2e-selectors'; import { useQueryParams } from 'app/core/hooks/useQueryParams'; +import { CollapseToggle } from 'app/features/alerting/unified/components/CollapseToggle'; export interface OptionsPaneCategoryProps { id: string; @@ -101,12 +102,16 @@ export const OptionsPaneCategory: FC = React.memo( ref={ref} >
-
- -
-
{renderTitle(isExpanded)}
+ +
+ {renderTitle(isExpanded)} +
- {isExpanded &&
{children}
} + {isExpanded && ( +
+ {children} +
+ )} ); } @@ -122,10 +127,6 @@ const getStyles = (theme: GrafanaTheme2) => { boxNestedExpanded: css` margin-bottom: ${theme.spacing(2)}; `, - toggle: css` - color: ${theme.colors.text.secondary}; - margin-right: ${theme.spacing(1)}; - `, title: css` flex-grow: 1; overflow: hidden; @@ -138,7 +139,7 @@ const getStyles = (theme: GrafanaTheme2) => { display: flex; cursor: pointer; align-items: baseline; - padding: ${theme.spacing(1)}; + padding: ${theme.spacing(0.5)}; color: ${theme.colors.text.primary}; font-weight: ${theme.typography.fontWeightMedium};