mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
SectionNav: Simplify section toggle styling (#63653)
This commit is contained in:
parent
0c36b247af
commit
2023203045
@ -33,13 +33,7 @@ export function SectionNav({ model }: Props) {
|
||||
</div>
|
||||
</CustomScrollbar>
|
||||
</nav>
|
||||
<SectionNavToggle
|
||||
className={cx(styles.collapseIcon, {
|
||||
[styles.collapseIconExpanded]: isExpanded,
|
||||
})}
|
||||
isExpanded={Boolean(isExpanded)}
|
||||
onClick={onToggleSectionNav}
|
||||
/>
|
||||
<SectionNavToggle isExpanded={isExpanded} onClick={onToggleSectionNav} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -109,30 +103,5 @@ const getStyles = (theme: GrafanaTheme2) => {
|
||||
padding: theme.spacing(4.5, 1, 2, 2),
|
||||
},
|
||||
}),
|
||||
collapseIcon: css({
|
||||
alignSelf: 'center',
|
||||
margin: theme.spacing(1, 0),
|
||||
position: 'relative',
|
||||
top: theme.spacing(0),
|
||||
transform: 'rotate(90deg)',
|
||||
transition: theme.transitions.create('opacity'),
|
||||
|
||||
[theme.breakpoints.up('md')]: {
|
||||
alignSelf: 'flex-start',
|
||||
left: 0,
|
||||
margin: theme.spacing(0, 0, 0, 1),
|
||||
top: theme.spacing(2),
|
||||
transform: 'none',
|
||||
},
|
||||
|
||||
'div:hover > &, &:focus': {
|
||||
opacity: 1,
|
||||
},
|
||||
}),
|
||||
collapseIconExpanded: css({
|
||||
[theme.breakpoints.up('md')]: {
|
||||
opacity: 0,
|
||||
},
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
@ -6,12 +6,11 @@ import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Button, useTheme2 } from '@grafana/ui';
|
||||
|
||||
export interface Props {
|
||||
className?: string;
|
||||
isExpanded: boolean;
|
||||
isExpanded?: boolean;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export const SectionNavToggle = ({ className, isExpanded, onClick }: Props) => {
|
||||
export const SectionNavToggle = ({ isExpanded, onClick }: Props) => {
|
||||
const theme = useTheme2();
|
||||
const styles = getStyles(theme);
|
||||
|
||||
@ -20,7 +19,7 @@ export const SectionNavToggle = ({ className, isExpanded, onClick }: Props) => {
|
||||
title={'Toggle section navigation'}
|
||||
aria-label={isExpanded ? 'Close section navigation' : 'Open section navigation'}
|
||||
icon="arrow-to-right"
|
||||
className={classnames(className, styles.icon, {
|
||||
className={classnames(styles.icon, {
|
||||
[styles.iconExpanded]: isExpanded,
|
||||
})}
|
||||
variant="secondary"
|
||||
@ -35,11 +34,33 @@ SectionNavToggle.displayName = 'SectionNavToggle';
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => ({
|
||||
icon: css({
|
||||
alignSelf: 'center',
|
||||
margin: theme.spacing(1, 0),
|
||||
top: theme.spacing(0),
|
||||
transform: 'rotate(90deg)',
|
||||
transition: theme.transitions.create('opacity'),
|
||||
color: theme.colors.text.secondary,
|
||||
marginRight: 0,
|
||||
zIndex: 1,
|
||||
|
||||
[theme.breakpoints.up('md')]: {
|
||||
alignSelf: 'flex-start',
|
||||
position: 'relative',
|
||||
left: 0,
|
||||
margin: theme.spacing(0, 0, 0, 1),
|
||||
top: theme.spacing(2),
|
||||
transform: 'none',
|
||||
},
|
||||
|
||||
'div:hover > &, &:focus': {
|
||||
opacity: 1,
|
||||
},
|
||||
}),
|
||||
iconExpanded: css({
|
||||
rotate: '180deg',
|
||||
|
||||
[theme.breakpoints.up('md')]: {
|
||||
opacity: 0,
|
||||
margin: 0,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user