Skip to content
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
1 change: 1 addition & 0 deletions packages/eui-theme-borealis/changelogs/upcoming/9049.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added `tabsSize` theme override to size `m` for `EuiPageHeader`
2 changes: 2 additions & 0 deletions packages/eui-theme-borealis/src/variables/_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { border_colors } from './colors/_colors_light';
import { buttons } from './_buttons';
import { forms } from './_forms';
import { emptyPrompt } from './_empty_prompt';
import { pageHeader } from './_page_header';

const component_colors: _EuiThemeComponentColors = {
badgeBackground: computed(
Expand Down Expand Up @@ -372,6 +373,7 @@ export const components: _EuiThemeComponents = {
buttons,
forms,
emptyPrompt,
pageHeader,
LIGHT: component_colors,
DARK: {
...component_colors,
Expand Down
13 changes: 13 additions & 0 deletions packages/eui-theme-borealis/src/variables/_page_header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import { _EuiThemePageHeader } from '@elastic/eui-theme-common';

export const pageHeader: _EuiThemePageHeader = {
tabsSize: 'm', // Reduced from default 'l'
};
1 change: 1 addition & 0 deletions packages/eui-theme-common/changelogs/upcoming/9049.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added `_EuiThemePageHeader` type and `pageHeader` component token
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { _EuiThemeButton } from './buttons';
import { _EuiThemeForm, _EuiThemeFormColors } from './forms';
import { _EuiThemeEmptyPrompt } from './empty_prompt';
import { _EuiThemePageHeader } from './page_header';

export type _EuiThemeComponentColors = {
badgeBackground: ColorModeSwitch;
Expand Down Expand Up @@ -159,6 +160,7 @@ export type _EuiThemeComponents = {
buttons: _EuiThemeButton;
forms: _EuiThemeForm & StrictColorModeSwitch<_EuiThemeFormColors>;
emptyPrompt: _EuiThemeEmptyPrompt;
pageHeader: _EuiThemePageHeader;
/**
* internal-only key that holds temporary tokens used while migrating themes
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export * from './typography';
export * from './buttons';
export * from './forms';
export * from './empty_prompt';
export * from './page_header';
export * from './components';
export * from './flags';
export * from './overrides';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

export type _EuiThemePageHeader = {
tabsSize: string;
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/eui/changelogs/upcoming/9049.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Changed `EuiPageHeader` tabs to `m` size for Borealis theme
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ exports[`EuiPageHeader props page content props are passed down is rendered 1`]
/>
<div
aria-label="aria-label"
class="euiTabs testClass1 testClass2 emotion-euiTabs-l-euiTestCss"
class="euiTabs testClass1 testClass2 emotion-euiTabs-m-euiTestCss"
data-test-subj="test subject string"
role="tablist"
>
Expand All @@ -346,7 +346,7 @@ exports[`EuiPageHeader props page content props are passed down is rendered 1`]
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 1
</span>
Expand All @@ -359,7 +359,7 @@ exports[`EuiPageHeader props page content props are passed down is rendered 1`]
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 2
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ exports[`EuiPageHeaderContent props children is rendered even if content props a
class="euiSpacer euiSpacer--l emotion-euiSpacer-l"
/>
<div
class="euiTabs emotion-euiTabs-l"
class="euiTabs emotion-euiTabs-m"
role="tablist"
>
<button
Expand All @@ -304,7 +304,7 @@ exports[`EuiPageHeaderContent props children is rendered even if content props a
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 1
</span>
Expand All @@ -317,7 +317,7 @@ exports[`EuiPageHeaderContent props children is rendered even if content props a
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 2
</span>
Expand Down Expand Up @@ -552,7 +552,7 @@ exports[`EuiPageHeaderContent props tabs is rendered 1`] = `
Tab 1
</h1>
<div
class="euiTabs emotion-euiTabs-l"
class="euiTabs emotion-euiTabs-m"
role="tablist"
>
<button
Expand All @@ -563,7 +563,7 @@ exports[`EuiPageHeaderContent props tabs is rendered 1`] = `
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 1
</span>
Expand All @@ -576,7 +576,7 @@ exports[`EuiPageHeaderContent props tabs is rendered 1`] = `
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 2
</span>
Expand Down Expand Up @@ -604,7 +604,7 @@ exports[`EuiPageHeaderContent props tabs is rendered with tabsProps 1`] = `
</h1>
<div
aria-label="aria-label"
class="euiTabs testClass1 testClass2 emotion-euiTabs-l-euiTestCss"
class="euiTabs testClass1 testClass2 emotion-euiTabs-m-euiTestCss"
data-test-subj="test subject string"
role="tablist"
>
Expand All @@ -616,7 +616,7 @@ exports[`EuiPageHeaderContent props tabs is rendered with tabsProps 1`] = `
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 1
</span>
Expand All @@ -629,7 +629,7 @@ exports[`EuiPageHeaderContent props tabs is rendered with tabsProps 1`] = `
type="button"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-l"
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
>
Tab 2
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React, { FunctionComponent, ReactNode, HTMLAttributes } from 'react';
import classNames from 'classnames';
import { CommonProps } from '../../common';
import { EuiIcon, EuiIconProps, IconType } from '../../icon';
import { EuiTab, EuiTabs, EuiTabsProps } from '../../tabs';
import { EuiTab, EuiTabs, EuiTabsProps, EuiTabsSizes } from '../../tabs';
import { Props as EuiTabProps } from '../../tabs/tab';
import { EuiFlexGroup, EuiFlexItem, EuiFlexGroupProps } from '../../flex';
import { EuiSpacer } from '../../spacer';
Expand All @@ -19,6 +19,7 @@ import { EuiText } from '../../text';
import {
useIsWithinBreakpoints,
useEuiMemoizedStyles,
useEuiTheme,
} from '../../../services';
import { EuiScreenReaderOnly } from '../../accessibility';
import { EuiBreadcrumbs, EuiBreadcrumbsProps } from '../../breadcrumbs';
Expand Down Expand Up @@ -174,11 +175,17 @@ export const EuiPageHeaderContent: FunctionComponent<
!!responsive
);

const { euiTheme } = useEuiTheme();

const classes = classNames('euiPageHeaderContent', className);
const pageHeaderStyles = useEuiMemoizedStyles(euiPageHeaderStyles);
const contentStyles = useEuiMemoizedStyles(euiPageHeaderContentStyles);
const styles = setStyleForRestrictedPageWidth(restrictWidth, style);

// Get tabs size from theme, fallback to 'l' for other themes
const themeTabsSize = (euiTheme.components.pageHeader?.tabsSize ??
'l') as EuiTabsSizes;

let paddingSides: LogicalSides = 'vertical';
let paddingSize = _paddingSize;
let bottomBorder = _bottom_border;
Expand Down Expand Up @@ -300,7 +307,7 @@ export const EuiPageHeaderContent: FunctionComponent<
<>
{pageTitleNode && <EuiSpacer />}
{screenReaderPageTitle}
<EuiTabs {...tabsProps} bottomBorder={false} size="l">
<EuiTabs {...tabsProps} bottomBorder={false} size={themeTabsSize}>
{renderTabs()}
</EuiTabs>
</>
Expand Down
2 changes: 1 addition & 1 deletion packages/eui/src/components/tabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

export type { EuiTabProps } from './tab';
export { EuiTab } from './tab';
export type { EuiTabsProps } from './tabs';
export type { EuiTabsProps, EuiTabsSizes } from './tabs';
export { EuiTabs } from './tabs';
export type {
EuiTabbedContentTab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
_EuiThemeComponentColors,
_EuiThemeComponents,
_EuiThemePageHeader,
} from '@elastic/eui-theme-common';

import { computed } from '../../../../services/theme/utils';
Expand Down Expand Up @@ -475,10 +476,16 @@ const component_colors: _EuiThemeComponentColors = {
),
};

// Amsterdam theme uses default tab size for pageHeader
const pageHeader: _EuiThemePageHeader = {
tabsSize: 'l',
};

export const components: _EuiThemeComponents = {
buttons,
forms,
emptyPrompt,
pageHeader,
LIGHT: component_colors,
DARK: {
...component_colors,
Expand Down
7 changes: 6 additions & 1 deletion packages/eui/src/themes/json/eui_theme_borealis_dark.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,10 @@
"euiColorBorderStrongWarning": "#FACB3D",
"euiColorBorderStrongRisk": "#FC8544",
"euiColorBorderStrongDanger": "#F6726A",
"euiColorBorderStrongText": "#8E9FBC"
"euiColorBorderStrongText": "#8E9FBC",
"page": {
"pageHeader": {
"tabsSize": "m"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,10 @@
"euiColorBorderStrongWarning": "#966B03",
"euiColorBorderStrongRisk": "#C24411",
"euiColorBorderStrongDanger": "#C61E25",
"euiColorBorderStrongText": "#5A6D8C"
"euiColorBorderStrongText": "#5A6D8C",
"page": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 I'm not sure that this is really that useful on the JSON export (it's not a value to use as a token).

That being said, if we add these for Borealis we should add them for Amsterdam as well (example file), otherwise switching themes would break if these are used somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I realize, we still have these files duplicated in packages/eui/src/themes/json and packages/eui-theme-borealis/src.

Originally it was duplicated when introducing Borealis as there were issues loading the file from the theme package. But that is not the case anymore and Kibana was updated (file) to use the eui-theme-borealis file.
That means this change is not actually available in Kibana as the packages/eui-theme-borealis/src files were not updated.

"pageHeader": {
"tabsSize": "m"
}
}
}
86 changes: 52 additions & 34 deletions packages/website/docs/components/layout/page-header.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,49 +34,67 @@ export default () => (
A set of `tabs` can be displayed inside the page header by passing an array of [EuiTab](../containers/tabs/index.mdx) objects using the `label` key for the tab content. When displaying tabs, the `bottomBorder` prop will be enforced to create separation of the header and content. You'll still need to manage the page content and selected tab in your own instance.

```tsx interactive
import React from 'react';
import React, { useState } from 'react';
import { EuiPageHeader, EuiButton } from '@elastic/eui';

export default () => (
<EuiPageHeader
pageTitle="Page title"
tabs={[
{
label: 'Tab 1',
isSelected: true,
},
{
label: 'Tab 2',
},
]}
rightSideItems={[
<EuiButton fill>Add something</EuiButton>,
<EuiButton>Do something</EuiButton>,
]}
/>
);
export default () => {
const [selectedTabId, setSelectedTabId] = useState('tab1');

const tabs = [
{
label: 'Tab 1',
isSelected: selectedTabId === 'tab1',
onClick: () => setSelectedTabId('tab1'),
},
{
label: 'Tab 2',
isSelected: selectedTabId === 'tab2',
onClick: () => setSelectedTabId('tab2'),
},
];

return (
<EuiPageHeader
pageTitle="Page title"
tabs={tabs}
rightSideItems={[
<EuiButton fill>Add something</EuiButton>,
<EuiButton>Do something</EuiButton>,
]}
/>
);
};
```

When supplying `tabs` without a `pageTitle`, **EuiPageHeader** will promote those tabs as if they are the page title. This means that any `description` or `children` will sit **below** the tabs and should used to describe the currently selected tab.

```tsx interactive
import React from 'react';
import React, { useState } from 'react';
import { EuiPageHeader } from '@elastic/eui';

export default () => (
<EuiPageHeader
tabs={[
{
label: 'Tab 1',
isSelected: true,
},
{
label: 'Tab 2',
},
]}
description="This description should be describing the current page as depicted by the current tab. It has grow set to false to ensure a readable line-length."
/>
);
export default () => {
const [selectedTabId, setSelectedTabId] = useState('tab1');

const tabs = [
{
label: 'Tab 1',
isSelected: selectedTabId === 'tab1',
onClick: () => setSelectedTabId('tab1'),
},
{
label: 'Tab 2',
isSelected: selectedTabId === 'tab2',
onClick: () => setSelectedTabId('tab2'),
},
];

return (
<EuiPageHeader
tabs={tabs}
description="This description should be describing the current page as depicted by the current tab. It has grow set to false to ensure a readable line-length."
/>
);
};
```

## Breadcrumbs in the page header
Expand Down
Loading