diff --git a/packages/core/chrome/core-chrome-browser-internal/src/ui/header/collapsible_nav.scss b/packages/core/chrome/core-chrome-browser-internal/src/ui/header/collapsible_nav.scss deleted file mode 100644 index 1086e30ebec0..000000000000 --- a/packages/core/chrome/core-chrome-browser-internal/src/ui/header/collapsible_nav.scss +++ /dev/null @@ -1,46 +0,0 @@ -$screenHeightBreakpoint: $euiSize * 15; - -.kbnCollapsibleNav { - @media (max-height: $screenHeightBreakpoint) { - overflow-y: auto; - } -} - -.kbnCollapsibleNav__recentsListGroup { - max-height: $euiSize * 10; - margin-right: -$euiSizeS; - @include euiYScroll; -} - -.kbnCollapsibleNav__solutions { - @include euiYScroll; - - /** - * Allows the solutions nav group to be viewed on - * very small screen sizes and when the browser Zoom is high - */ - @media (max-height: $screenHeightBreakpoint) { - flex: 1 0 auto; - } -} - -/** - * 1. Increase the hit area of the link (anchor) - * 2. Only show the text underline when hovering on the text/anchor portion - */ - -.kbnCollapsibleNav__solutionGroupButton { - display: block; /* 1 */ - - &:hover { - text-decoration: none; /* 2 */ - } -} - -.kbnCollapsibleNav__solutionGroupLink { - display: block; /* 1 */ - - &:hover { - text-decoration: underline; /* 2 */ - } -} diff --git a/packages/core/chrome/core-chrome-browser-internal/src/ui/header/collapsible_nav.tsx b/packages/core/chrome/core-chrome-browser-internal/src/ui/header/collapsible_nav.tsx index 2ad507a95838..cd13d3f22872 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/ui/header/collapsible_nav.tsx +++ b/packages/core/chrome/core-chrome-browser-internal/src/ui/header/collapsible_nav.tsx @@ -7,7 +7,6 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import './collapsible_nav.scss'; import { EuiThemeProvider, EuiCollapsibleNav, @@ -18,6 +17,7 @@ import { EuiListGroupItem, EuiCollapsibleNavProps, EuiButton, + useEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { groupBy, sortBy } from 'lodash'; @@ -36,6 +36,7 @@ import { createEuiButtonItem, createOverviewLink, } from './nav_link'; +import { getCollapsibleNavStyles } from './get_collapsible_nav_styles'; function getAllCategories(allCategorizedLinks: Record) { const allCategories = {} as Record; @@ -149,6 +150,7 @@ export function CollapsibleNav({ ...(needsIcon && { basePath }), }); }; + const styles = getCollapsibleNavStyles(useEuiTheme()); return ( {customNavLink && ( <> @@ -275,14 +277,14 @@ export function CollapsibleNav({ color="subdued" gutterSize="none" size="s" - className="kbnCollapsibleNav__recentsListGroup" + css={styles.navRecentsListGroupCss} /> )} - + {/* Kibana, Observability, Security, and Management sections */} {orderedCategories.map((categoryName) => { const category = categoryDictionary[categoryName]!; @@ -294,11 +296,12 @@ export function CollapsibleNav({ iconType={category.euiIconType} iconSize="m" buttonElement={overviewLink ? 'div' : 'button'} - buttonClassName="kbnCollapsibleNav__solutionGroupButton" + css={styles.navSolutionGroupButton} title={ overviewLink ? ( { + const { euiTheme } = euiThemeContext; + const screenHeightBreakpoint = mathWithUnits(euiTheme.size.base, (x) => x * 15); + const _euiYScroll = euiYScroll(euiThemeContext); + + const navCss = css` + @media (max-height: ${screenHeightBreakpoint}) { + overflow-y: auto; + } + `; + const navRecentsListGroupCss = [ + css` + max-height: calc(${euiTheme.size.base} * 10); + margin-right: -${euiTheme.size.s}; + `, + _euiYScroll, + ]; + const navSolutions = [ + _euiYScroll, + css` + /** + * Allows the solutions nav group to be viewed on + * very small screen sizes and when the browser Zoom is high + */ + @media (max-height: ${screenHeightBreakpoint}) { + flex: 1 0 auto; + } + `, + ]; + const navSolutionGroupButton = css` + display: block; /* Increase the hit area of the link (anchor) */ + + &:hover { + text-decoration: none; /* Only show the text underline when hovering on the text/anchor portion */ + } + `; + const navSolutionGroupLink = css` + display: block; /* Increase the hit area of the link (anchor) */ + + &:hover { + text-decoration: underline; /* Only show the text underline when hovering on the text/anchor portion */ + } + `; + + return { + navCss, + navRecentsListGroupCss, + navSolutions, + navSolutionGroupButton, + navSolutionGroupLink, + }; +};