-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigation: Collapsible section nav implementation (#55995)
* initial collapsible section nav implementation * fix unit tests * automatically collapse sectionnav when below lg size * fix unit tests * only register 1 event listener each time * fix display name for SectionNavToggle
- Loading branch information
1 parent
4087ad4
commit 317b353
Showing
5 changed files
with
108 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { css } from '@emotion/css'; | ||
import classnames from 'classnames'; | ||
import React from 'react'; | ||
|
||
import { GrafanaTheme2 } from '@grafana/data'; | ||
import { IconButton, 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 ( | ||
<IconButton | ||
aria-label={isExpanded ? 'Close section navigation' : 'Open section navigation'} | ||
name={isExpanded ? 'angle-left' : 'angle-right'} | ||
className={classnames(className, styles.icon)} | ||
size="xl" | ||
onClick={onClick} | ||
/> | ||
); | ||
}; | ||
|
||
SectionNavToggle.displayName = 'SectionNavToggle'; | ||
|
||
const getStyles = (theme: GrafanaTheme2) => ({ | ||
icon: css({ | ||
backgroundColor: theme.colors.background.secondary, | ||
border: `1px solid ${theme.colors.border.weak}`, | ||
borderRadius: '50%', | ||
marginRight: 0, | ||
zIndex: 1, | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters