Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Revisit updated header spacing #7759

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"dependencies": {
"@aws-crypto/client-node": "^3.1.1",
"@elastic/datemath": "5.0.3",
"@elastic/eui": "npm:@opensearch-project/oui@1.9.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.10.0",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/numeral": "npm:@amoo-miki/[email protected]",
"@elastic/request-crypto": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"enzyme-adapter-react-16": "^1.9.1"
},
"devDependencies": {
"@elastic/eui": "npm:@opensearch-project/oui@1.9.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.10.0",
"@osd/babel-preset": "1.0.0",
"@osd/optimizer": "1.0.0",
"comment-stripper": "^0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@elastic/charts": "31.1.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.9.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.10.0",
"@elastic/numeral": "npm:@amoo-miki/[email protected]",
"@opensearch/datemath": "5.0.3",
"@osd/i18n": "1.0.0",
Expand Down
306 changes: 134 additions & 172 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

Large diffs are not rendered by default.

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

58 changes: 50 additions & 8 deletions src/core/public/chrome/ui/header/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,70 @@

.newTopNavHeader {
z-index: 1000;
padding-left: $euiSizeXS;
padding: 0 $euiSizeL $euiSizeS;
box-shadow: none;
border-bottom: none;
background: none;
height: auto;
gap: $euiSizeS;

&.primaryHeader {
height: auto;
padding-top: $euiSizeM;
margin-top: $euiSizeM;
}

&.primaryApplicationHeader {
height: auto;
padding-top: $euiSizeM - $euiSizeXS;
border-bottom: 1px solid $euiColorLightShade;

&:last-child {
margin-bottom: 0;
}
}

.headerAppActionMenu {
// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
& > .euiFlexGroup {
gap: $euiSizeS;
}

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
& > .euiHeaderLinks > .euiHeaderLinks__list {
gap: $euiSizeS;

& > * {
margin: 0;
}
}
}

&:has(.headerDescriptionControl, .headerBottomControl) {
height: auto;
}

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
& > .euiHeaderSection {
gap: $euiSizeS;

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
& > .euiHeaderSectionItem:empty {
display: none;
}
}

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
&:not(:has(>:not(:empty))),
.euiHeaderSectionItem:not(:has(>:not(:empty))) {
display: none;
}
}

.headerGlobalNav:has(.newTopNavHeader:not(.primaryApplicationHeader)) {
margin-bottom: -1 * $euiSizeS;
}

.newTopNavHeaderTitle {
line-height: 1;
font-size: 2rem;
}

.primaryApplicationHeader {
Expand All @@ -40,10 +86,6 @@
}
}

.newTopNavApplicationTitle {
padding: 0 $euiSizeM;
}

.newAppTopNavExpander {
position: fixed;
left: 0;
Expand Down
12 changes: 5 additions & 7 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
EuiHideFor,
EuiIcon,
EuiShowFor,
EuiText,
EuiTitle,
htmlIdGenerator,
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
Expand Down Expand Up @@ -412,12 +412,10 @@ export function Header({
{/* Secondary header */}
<EuiHeader className="newTopNavHeader">
<EuiHeaderSection side="left">
<EuiHeaderSectionItem
border="none"
className="newTopNavApplicationTitle"
data-test-subj="headerApplicationTitle"
>
<EuiText>{breadcrumbs && <h2>{breadcrumbs[breadcrumbs.length - 1]?.text}</h2>}</EuiText>
<EuiHeaderSectionItem border="none" data-test-subj="headerApplicationTitle">
<EuiTitle size="l" className="newTopNavHeaderTitle">
{breadcrumbs && <h1>{breadcrumbs[breadcrumbs.length - 1]?.text}</h1>}
</EuiTitle>
</EuiHeaderSectionItem>

{renderBadge()}
Expand Down
22 changes: 12 additions & 10 deletions src/core/public/chrome/ui/header/header_controls_container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
*/

.headerControl {
// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
& > .euiHeaderSectionItem {
margin: 0 $euiSizeXS;
}
gap: $euiSizeS;

&.headerDescriptionControl {
padding: 0 $euiSizeM;
color: $euiTextSubduedColor;
}
.descriptionHeaderControl {
max-width: $euiLegibilityMaxWidth;
line-height: 1.5;
color: $euiTextSubduedColor;

&.headerBottomControl {
padding: $euiSizeM;
max-width: 725px;
// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
.euiHeaderLink {
vertical-align: unset;
border: 0;
height: auto;
}
}
}

&:empty {
Expand Down
16 changes: 2 additions & 14 deletions src/core/public/chrome/ui/header/recent_items.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@
*/

.headerRecentItemsButton {
margin-left: $euiSizeM;
margin-right: $euiSizeS;
min-width: $euiSizeL;
font-size: 0 !important;

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
.euiHeaderSectionItemButton__content,
.euiButtonEmpty__text {
line-height: 1;
}

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
.euiButtonEmpty__content {
padding: 0;
.primaryApplicationHeader & {
margin-top: $euiSizeXS;
}
}
45 changes: 30 additions & 15 deletions src/core/public/chrome/ui/header/recent_items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import React, { useMemo, useState } from 'react';
import * as Rx from 'rxjs';
import {
EuiPopover,
EuiHeaderSectionItemButton,
EuiTextColor,
EuiListGroup,
EuiListGroupItem,
EuiTitle,
EuiIcon,
EuiText,
EuiSpacer,
EuiHeaderSectionItemButtonProps,
EuiButtonIcon,
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import useObservable from 'react-use/lib/useObservable';
import { ChromeRecentlyAccessedHistoryItem } from '../..';
import { WorkspaceObject } from '../../../workspace';
Expand Down Expand Up @@ -67,21 +68,35 @@ export const RecentItems = ({
setIsPopoverOpen(false);
};

const button = (
<EuiToolTip
content={i18n.translate('core.ui.chrome.headerGlobalNav.viewRecentItemsTooltip', {
defaultMessage: 'Recents',
})}
delay="long"
position="bottom"
>
<EuiButtonIcon
iconType="recent"
color="text"
size="xs"
aria-expanded={isPopoverOpen}
aria-haspopup="true"
aria-label={i18n.translate('core.ui.chrome.headerGlobalNav.viewRecentItemsAriaLabel', {
defaultMessage: 'View recents',
})}
onClick={() => {
setIsPopoverOpen((prev) => !prev);
}}
data-test-subj="recentItemsSectionButton"
className="headerRecentItemsButton"
/>
</EuiToolTip>
);

return (
<EuiPopover
button={
<EuiHeaderSectionItemButton
onClick={() => {
setIsPopoverOpen((prev) => !prev);
}}
data-test-subj="recentItemsSectionButton"
size={buttonSize}
className="headerRecentItemsButton"
>
{/* TODO: replace this icon once there is a new icon added to OUI https://github.com/opensearch-project/OpenSearch-Dashboards/issues/7354 */}
<EuiIcon type="recentlyViewedApp" size="m" />
</EuiHeaderSectionItemButton>
}
button={button}
isOpen={isPopoverOpen}
closePopover={() => {
setIsPopoverOpen(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

.headerAppActionMenu .globalQueryBar,
.headerAppActionMenu .globalDatePicker {
padding-top: 0;
// The left-padding is a magic number just to add some space to the left that reduces with screen width
padding: 0 0 0 calc(100vw - 1600px);
}

.globalFilterGroup__filterBar {
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/navigation/public/top_nav_menu/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

.osdTopNavMenu {
margin-right: $euiSizeXS;

.newTopNavHeader & {
margin-right: 0;
}
}

.osdTopNavMenuGroupedActions {
background-color: $euiColorEmptyShade;

.newTopNavHeader & {
margin: 0;
}

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
& > .euiSwitch,
& > .euiButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
<EuiText className="descriptionHeaderControl" size="s">
{props.description}
{links?.map((linkProps) => (
<TopNavControlItem {...linkProps} />
<>

Check warning on line 55 in src/plugins/navigation/public/top_nav_menu/top_nav_control_item.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/navigation/public/top_nav_menu/top_nav_control_item.tsx#L55

Added line #L55 was not covered by tests
{/* @ts-ignore using an undefined property to prevent abuse */}
<TopNavControlItem {...linkProps} sizeOverride="xs" />
</>
))}
</EuiText>
);
Expand Down Expand Up @@ -102,7 +105,8 @@
case 'link':
component = (
<EuiHeaderLink
size="s"
// @ts-ignore using an undefined property to prevent abuse
size={props.sizeOverride || 's'}
iconType={props.iconType}
iconSide={props.iconSide}
iconSize={props.iconSize}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/navigation/public/top_nav_menu/top_nav_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
return (
<>
<MountPointPortal setMountPoint={setMenuMountPoint}>
<EuiFlexGroup alignItems="stretch" gutterSize="s">
<EuiFlexGroup alignItems="stretch" gutterSize="none">
<EuiFlexItem grow={false} className="osdTopNavMenuScreenTitle">
<EuiText size="s">{screenTitle}</EuiText>
</EuiFlexItem>
Expand All @@ -187,7 +187,7 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
case TopNavMenuItemRenderType.OMITTED:
return screenTitle ? (
<MountPointPortal setMountPoint={setMenuMountPoint}>
<EuiFlexGroup alignItems="stretch" gutterSize="s">
<EuiFlexGroup alignItems="stretch" gutterSize="none">
<EuiFlexItem grow={false} className="osdTopNavMenuScreenTitle">
<EuiText size="s">{screenTitle}</EuiText>
</EuiFlexItem>
Expand All @@ -206,7 +206,7 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
return (
<>
<MountPointPortal setMountPoint={setMenuMountPoint}>
<EuiFlexGroup alignItems="stretch" gutterSize="s">
<EuiFlexGroup alignItems="stretch" gutterSize="none">
<EuiFlexItem grow={false} className="osdTopNavMenuScreenTitle">
<EuiText size="s">{screenTitle}</EuiText>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "../../../../scripts/use_node ../../../../scripts/remove.js './target' && tsc"
},
"devDependencies": {
"@elastic/eui": "npm:@opensearch-project/oui@1.9.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.10.0",
"@osd/plugin-helpers": "1.0.0",
"react": "^16.14.0",
"react-dom": "^16.12.0",
Expand Down
Loading
Loading