Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dc22ad9
Highlight/Hover color updates
tsullivan Apr 16, 2025
ea72190
Icon stuff
tsullivan Apr 16, 2025
0414cb8
New folder for navigation_section components
tsullivan Apr 17, 2025
4feb1a3
Color stuff
tsullivan Apr 17, 2025
88c3194
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 18, 2025
96d456a
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 18, 2025
da3c57e
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 21, 2025
761db31
Merge branch 'sidenav/fix-icons-for-panelopeners' of github.com:tsull…
tsullivan Apr 21, 2025
b09cc51
fix "expanded" panel opener bg color style
tsullivan Apr 22, 2025
900c3f6
fix selected color in nav panel
tsullivan Apr 22, 2025
83cd8fe
Minor cleanup
tsullivan Apr 22, 2025
67a63c4
Fix tests
tsullivan Apr 22, 2025
65f248d
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 22, 2025
e289d13
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 23, 2025
657fee6
fix padding of panel opener w/out icon
tsullivan Apr 23, 2025
5e02ae8
fix tests ii
tsullivan Apr 23, 2025
bc34955
Fix gap issue 2: for items with icons
tsullivan Apr 24, 2025
f2a5c52
Fix spacing of button and divider
tsullivan Apr 24, 2025
3780748
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 25, 2025
e4dcf84
Optimize emotion code
tsullivan Apr 25, 2025
debc4f6
naming tweak
tsullivan Apr 25, 2025
51fa5b8
simplify css rules, fix euiCollapsibleNavLink
tsullivan Apr 28, 2025
28af8d4
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 28, 2025
e111318
refine spacing of panel opener button and icon
tsullivan Apr 28, 2025
b578ed6
Merge branch 'main' into sidenav/fix-icons-for-panelopeners
tsullivan Apr 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ export type { Props as RecentlyAccessedProps } from './recently_accessed';
export { FeedbackBtn } from './feedback_btn';

export type { PanelContent, PanelComponentProps } from './panel';

export { NavigationSectionUI } from './navigation_section';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { NavigationSectionUI } from './navigation_section_ui';
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { Theme, css } from '@emotion/react';
import classNames from 'classnames';
import React, { useCallback, type FC } from 'react';

import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui';
import type { ChromeProjectNavigationNode } from '@kbn/core-chrome-browser';
import type { NavigateToUrlFn } from '../../../types';
import { isActiveFromUrl } from '../../../utils';
import { usePanel } from '../panel';
import { SubItemBadge } from '../subitem_badge';

interface Props {
item: ChromeProjectNavigationNode;
navigateToUrl: NavigateToUrlFn;
activeNodes: ChromeProjectNavigationNode[][];
}

const panelOpenerStyles = {
button: ({ euiTheme }: Theme) =>
css`
color: inherit;
font-weight: inherit;
transform: none !important; /* don't translateY 1px */
padding-inline: calc(${euiTheme.size.xs} * 2);
background-color: inherit;

&:hover {
background-color: ${euiTheme.colors.backgroundBaseInteractiveHover};
}

&.isSelected {
background-color: ${euiTheme.colors.backgroundLightPrimary};
&:hover {
background-color: ${euiTheme.colors.backgroundLightPrimary};
}
}

&.isExpanded {
background-color: ${euiTheme.colors.backgroundBaseInteractiveHover};
}

/* get the spacing of panel opener's title and icons to match the spacing from other nav subitems */
.panelIcon {
margin-left: -${euiTheme.size.xxs};
}
.hasIcon {
padding-left: calc(${euiTheme.size.xxs} / 2);
}
`,
flexGroup: ({ euiTheme }: Theme) => css`
gap: calc(${euiTheme.size.s} / 1.5);
`,
};

export const NavigationItemOpenPanel: FC<Props> = ({ item, activeNodes }: Props) => {
const { open: openPanel, close: closePanel, selectedNode } = usePanel();
const { title, deepLink, icon, withBadge, badgeOptions } = item;
const { id, path } = item;
const isExpanded = selectedNode?.path === path;
const isSelected = isActiveFromUrl(item.path, activeNodes);

const dataTestSubj = classNames(`nav-item`, `nav-item-${path}`, {
[`nav-item-deepLinkId-${deepLink?.id}`]: !!deepLink,
[`nav-item-id-${id}`]: id,
[`nav-item-isActive`]: isSelected || isExpanded,
});

const togglePanel = useCallback(
(target: EventTarget) => {
if (selectedNode?.id === item.id) {
closePanel();
} else {
openPanel(item, target as Element);
}
},
[selectedNode?.id, item, closePanel, openPanel]
);

const onLinkClick = useCallback(
(e: React.MouseEvent) => {
e.preventDefault();
togglePanel(e.target);
},
[togglePanel]
);

return (
<EuiButton
onClick={onLinkClick}
iconSide="right"
iconSize="s"
iconType="arrowRight"
size="s"
fullWidth
className={classNames([isSelected ? 'isSelected' : isExpanded ? 'isExpanded' : undefined])}
css={panelOpenerStyles.button}
data-test-subj={dataTestSubj}
>
<EuiFlexGroup gutterSize="none" alignItems="center" css={panelOpenerStyles.flexGroup}>
{icon && (
<EuiFlexItem grow={false} className="panelIcon">
<EuiIcon type={icon} />
</EuiFlexItem>
)}
<EuiFlexItem grow={false} className={classNames([icon && 'hasIcon'])}>
{title}
</EuiFlexItem>
{withBadge && (
<EuiFlexItem grow={false}>
<SubItemBadge icon={badgeOptions?.icon} tooltip={badgeOptions?.tooltip} />
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiButton>
);
};
Loading