Skip to content

Commit

Permalink
[EuiSideNav] Remove Sass mixin and replace with hasEmbellish prop
Browse files Browse the repository at this point in the history
- for the medium breakpoint/collapsed EuiFlyout usage, this requires nesting an `EuiPageSidebar` in the flyout

- also requires some extra Security CSS selector tweaks
  • Loading branch information
cee-chen committed Feb 21, 2024
1 parent 564faa8 commit 6d55aa3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions packages/shared-ux/page/solution_nav/src/solution_nav.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
$euiSideNavEmphasizedBackgroundColor: transparentize($euiColorLightShade, .7);
@import '@elastic/eui/src/components/side_nav/mixins';
@import 'variables';

// Put the page background color in the flyout version too
.kbnSolutionNav__flyout {
background-color: $euiPageBackgroundColor;

.kbnSolutionNav {
flex: auto; // Override default EuiPageSideBar flex CSS when in a flyout
}
}

.kbnSolutionNav {
@include euiSideNavEmbellish;
@include euiYScroll;

display: flex;
Expand Down
8 changes: 5 additions & 3 deletions packages/shared-ux/page/solution_nav/src/solution_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
useIsWithinMinBreakpoint,
useEuiTheme,
useEuiThemeCSSVariables,
EuiPageSidebar,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -102,6 +103,7 @@ export const SolutionNav: FC<SolutionNavProps> = ({
canBeCollapsed = true,
...rest
}) => {
const euiThemeContext = useEuiTheme();
const isSmallerBreakpoint = useIsWithinBreakpoints(mobileBreakpoints);
const isMediumBreakpoint = useIsWithinBreakpoints(['m']);
const isLargerBreakpoint = useIsWithinMinBreakpoint('l');
Expand Down Expand Up @@ -177,7 +179,7 @@ export const SolutionNav: FC<SolutionNavProps> = ({
);
}, [children, headingID, isCustomSideNav, isHidden, items, rest]);

const { euiTheme } = useEuiTheme();
const { euiTheme } = euiThemeContext;
const navWidth = useMemo(() => {
if (isLargerBreakpoint) {
return isOpenOnDesktop ? FLYOUT_SIZE_CSS : euiTheme.size.xxl;
Expand Down Expand Up @@ -234,11 +236,11 @@ export const SolutionNav: FC<SolutionNavProps> = ({
className="kbnSolutionNav__flyout"
hideCloseButton={!canBeCollapsed}
>
<div className={sideNavClasses}>
<EuiPageSidebar className={sideNavClasses} hasEmbellish={true}>
{titleText}
<EuiSpacer size="l" />
{sideNavContent}
</div>
</EuiPageSidebar>
</EuiFlyout>
)}
{canBeCollapsed && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const withSolutionNav = <P extends TemplateProps>(WrappedComponent: Compo
...props.pageSideBarProps,
minWidth: isSidebarShrunk ? euiTheme.size.xxl : undefined,
className: sideBarClasses,
hasEmbellish: !isSidebarShrunk,
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
$euiSideNavEmphasizedBackgroundColor: transparentize($euiColorLightShade, .7);
@import '@elastic/eui/src/components/side_nav/mixins';

// Put the page background color in the flyout version too
.kbnPageTemplateSolutionNav__flyout {
background-color: $euiPageBackgroundColor;
}

.kbnPageTemplateSolutionNav {
@include euiSideNavEmbellish;
@include euiYScroll;

@include euiBreakpoint('m' ,'l', 'xl') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const StyledKibanaPageTemplate = styled(KibanaPageTemplate)<
theme: EuiThemeComputed; // using computed EUI theme to be consistent with user profile theming
}
>`
.kbnSolutionNav {
.kbnSolutionNav__sidebar:not(.kbnSolutionNav__sidebar--shrink) {
background-color: ${({ theme }) => theme.colors.emptyShade};
}
Expand Down

0 comments on commit 6d55aa3

Please sign in to comment.