mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* adjust positioning and switch icon * hide collapse button unless collapsed/focused * use Button instead of IconButton
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import classnames from 'classnames';
|
|
import React from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { Button, useTheme2 } from '@grafana/ui';
|
|
|
|
export interface Props {
|
|
className?: string;
|
|
isExpanded: boolean;
|
|
onClick: () => void;
|
|
}
|
|
|
|
export const SectionNavToggle = ({ className, isExpanded, onClick }: Props) => {
|
|
const theme = useTheme2();
|
|
const styles = getStyles(theme);
|
|
|
|
return (
|
|
<Button
|
|
title={'Toggle section navigation'}
|
|
aria-label={isExpanded ? 'Close section navigation' : 'Open section navigation'}
|
|
icon="arrow-to-right"
|
|
className={classnames(className, styles.icon, {
|
|
[styles.iconExpanded]: isExpanded,
|
|
})}
|
|
variant="secondary"
|
|
fill="text"
|
|
size="md"
|
|
onClick={onClick}
|
|
/>
|
|
);
|
|
};
|
|
|
|
SectionNavToggle.displayName = 'SectionNavToggle';
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({
|
|
icon: css({
|
|
color: theme.colors.text.secondary,
|
|
marginRight: 0,
|
|
zIndex: 1,
|
|
}),
|
|
iconExpanded: css({
|
|
rotate: '180deg',
|
|
}),
|
|
});
|