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

[Page Layouts] Adding content props to EuiPageHeader for pre-determined page layout patterns #4451

Merged
merged 35 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cb8817a
Added content type props to EuiPageHeader
Jan 26, 2021
b54aae4
Replaced example usages with props
Jan 26, 2021
06afe85
Setting up a new $`euiPageDefaultMaxWidth` sass token
Jan 26, 2021
a2b0e6f
Updating playground & docs
Jan 26, 2021
c19d038
Fixin amsterdam small and reverse shadows
Jan 26, 2021
eff79dc
‘Fixing’ paddingSize prop on EuiPageContent
Jan 26, 2021
206351c
Adding custom options for `restrictWidth`
Jan 28, 2021
6413fb4
Starting the switch to a new component `EuiPageHeaderContent`
Jan 28, 2021
59643df
middle; simulate node
thompsongl Jan 29, 2021
517542d
Update `useIsWithinBreakpoints` to be conditional
Jan 29, 2021
ea27ca0
Moving the content to a new component
Jan 29, 2021
20f3bb9
Cleaning up
Jan 29, 2021
09285bf
Playground fix
Jan 29, 2021
a3051f2
more customProps
thompsongl Feb 1, 2021
eb08a9d
Merge branch 'props/page_header' into props/page_header
cchaos Feb 2, 2021
b4df1a7
Merge pull request #39 from thompsongl/props/page_header
cchaos Feb 2, 2021
a5b6eb5
prevent format errors
thompsongl Feb 3, 2021
199ade3
Merge pull request #40 from thompsongl/props/page_header
cchaos Feb 3, 2021
373fa5e
Some cleanup and fixing of logic
Feb 3, 2021
2a59f32
Added `stretch` to the align prop and fixed tests
Feb 3, 2021
46929e1
Merge remote-tracking branch 'upstream/master' into props/page_header
Feb 3, 2021
27d7815
cl & comments
Feb 3, 2021
18a429b
Docs clarity
snide Feb 4, 2021
5d1ea82
words
snide Feb 4, 2021
f6108ef
Apply suggestions from code review
cchaos Feb 4, 2021
7dec3f6
Merge pull request #41 from snide/docs/pageheader
cchaos Feb 4, 2021
fb2c6b9
Render `<header>` element in EuiPageHeader
Feb 8, 2021
fc50d95
Adding `iconProps` to optional icon
Feb 8, 2021
e3f1ce1
Renaming `rightSideContent` to `rightSideItems` for better clarity of…
Feb 8, 2021
f0964c0
Replacing `rightSideResponsive` with a more generic `rightSideGroupPr…
Feb 8, 2021
df17134
Merge branch 'master' into props/page_header
cchaos Feb 8, 2021
7d557fc
Apply suggestions from code review
cchaos Feb 10, 2021
f573ebb
Merge branch 'master' into props/page_header
cchaos Feb 10, 2021
e97d3b8
Set deprecation notice for `panelPaddingSize`
Feb 10, 2021
9615bcc
Merge branch 'master' into props/page_header
cchaos Feb 10, 2021
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
6 changes: 5 additions & 1 deletion src-docs/src/components/guide_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
min-height: 100vh;
background-color: $euiColorEmptyShade;
border-left: $euiBorderThin;
max-width: 1000px;
max-width: $euiPageDefaultMaxWidth;
margin-left: 240px;
}

Expand All @@ -110,6 +110,10 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
}
}

.guideDemo__highlightLayout--single {
background: transparentize($euiColorPrimary, .9);
}

.guideDemo__highlightSpacer {
.euiSpacer {
background: transparentize($euiColorPrimary, .9);
Expand Down
3 changes: 2 additions & 1 deletion src-docs/src/services/playground/iconValidator.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { iconTypes } from '../../views/icon/icons';
import { iconTypes as logoTypes } from '../../views/icon/logos';
import { mapOptions } from './mapOptions';
import { PropTypes } from 'react-view';

const iconOptions = mapOptions(iconTypes);
const iconOptions = mapOptions(iconTypes.concat(logoTypes));

export const iconValidator = (prop = { custom: {} }) => {
const newProp = {
Expand Down
10 changes: 10 additions & 0 deletions src-docs/src/services/playground/knobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ const Knob = ({
/>
</>
);
case 'textarea':
return (
<EuiTextArea
placeholder={placeholder}
value={val}
onChange={(e) => {
set(e.target.value);
}}
/>
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/icon/logos.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
EuiCopy,
} from '../../../../src/components';

const iconTypes = [
export const iconTypes = [
'logoAppSearch',
'logoBeats',
'logoBusinessAnalytics',
Expand Down
10 changes: 1 addition & 9 deletions src-docs/src/views/page/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
EuiPageContentHeader,
EuiPageContentHeaderSection,
EuiPageHeader,
EuiPageHeaderSection,
EuiPageSideBar,
EuiTitle,
} from '../../../../src/components';
Expand All @@ -17,14 +16,7 @@ export default () => (
<EuiPage>
<EuiPageSideBar>SideBar nav</EuiPageSideBar>
<EuiPageBody component="div">
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>Page title</h1>
</EuiTitle>
</EuiPageHeaderSection>
<EuiPageHeaderSection>Page abilities</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageHeader pageTitle="Page title" />
<EuiPageContent>
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
Expand Down
13 changes: 4 additions & 9 deletions src-docs/src/views/page/page_content_center_with_side_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
EuiPageContentHeader,
EuiPageContentHeaderSection,
EuiPageHeader,
EuiPageHeaderSection,
EuiPageSideBar,
EuiTitle,
} from '../../../../src/components';
Expand All @@ -18,14 +17,10 @@ export default () => (
<EuiPageSideBar>SideBar nav</EuiPageSideBar>
{/* The EUI docs site already has a wrapping <main> tag, so we've changed this example to a <div> for accessibility. You likely don't need to copy the `component` prop for your own usage. */}
<EuiPageBody component="div">
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>Page title</h1>
</EuiTitle>
</EuiPageHeaderSection>
<EuiPageHeaderSection>Page abilities</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageHeader
pageTitle="Page title"
rightSideContent={['Page abilities']}
/>
<EuiPageContent verticalPosition="center" horizontalPosition="center">
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
Expand Down
93 changes: 93 additions & 0 deletions src-docs/src/views/page/page_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';
import Playground from './playground';

import {
EuiCode,
Expand All @@ -27,6 +28,14 @@ import PageSimple from './page_simple';
const pageSimpleSource = require('!!raw-loader!./page_simple');
const pageSimpleHtml = renderToHtml(PageSimple);

import PageHeader from './page_header';
const pageHeaderSource = require('!!raw-loader!./page_header');
const pageHeaderHtml = renderToHtml(PageHeader);

import PageHeaderCustom from './page_header_custom';
const pageHeaderCustomSource = require('!!raw-loader!./page_header_custom');
const pageHeaderCustomHtml = renderToHtml(PageHeaderCustom);

import PageContentOnly from './page_content_only';
const pageContentOnlySource = require('!!raw-loader!./page_content_only');
const pageContentOnlyHtml = renderToHtml(Page);
Expand All @@ -40,6 +49,7 @@ const PageContentCenterWithSideBarSource = require('!!raw-loader!./page_content_
const PageContentCenterWithSideBarHtml = renderToHtml(Page);

export const PageExample = {
playground: Playground,
title: 'Page',
intro: (
<EuiText>
Expand Down Expand Up @@ -117,6 +127,89 @@ export const PageExample = {
</div>
),
},
{
title: 'Page header',
source: [
{
type: GuideSectionTypes.JS,
code: pageHeaderSource,
},
{
type: GuideSectionTypes.HTML,
code: pageHeaderHtml,
},
],
text: (
<>
<p>
<strong>EuiPageHeader</strong> comes with some pre-determined
content that you can apply to the left and right sides of the
component.
</p>
<p>
The left side allows you to pass any combination of{' '}
<EuiCode>pageTitle</EuiCode>, <EuiCode>description</EuiCode>,{' '}
<EuiCode>tabs</EuiCode>, or any <EuiCode>leftSideContent</EuiCode>.
The order of which are determined by the particular combination.
</p>
<p>
The right side, <EuiCode>rightSideContent</EuiCode>, allows for just
a simple <strong>array of nodes</strong> which are placed within a
flexbox row. This is usually in the form of multiple buttons, of
which, at least one is primary (or{' '}
<EuiCode language="ts">{'fill="true"'}</EuiCode>). These items are
also display in <strong>reverse order</strong> so that the first and
primary action should be first in the list.
</p>
<p>
You can further adjust the display of these content types with an
optional <EuiCode>iconType</EuiCode> placed to the left of the
title, <EuiCode>alignItems</EuiCode> for adjusting the vertical
alignment of the two sides, and <EuiCode>responsiveOrder</EuiCode>
to determine which content to display first on smaller screens.
</p>
</>
),
demo: (
<div className="guideDemo__highlightLayout--single">
<PageHeader />
</div>
),
props: { EuiPageHeader },
},
{
source: [
{
type: GuideSectionTypes.JS,
code: pageHeaderCustomSource,
},
{
type: GuideSectionTypes.HTML,
code: pageHeaderCustomHtml,
},
],
text: (
<>
<p>
The page header content props mainly are helpful props to push
content into established Elastic page layout patterns. They are
completely optional and by nature, inflexible. If you need a layout
that does not match these patterns you can simply pass in your own{' '}
<EuiCode>children</EuiCode> utilizing the{' '}
<strong>EuiPageHeaderSection</strong> components. Do note, that when
supplying <EuiCode>children</EuiCode>,{' '}
<strong>EuiPageHeader</strong> will completely ignore any other
content props and only render the children.
</p>
</>
),
demo: (
<div className="guideDemo__highlightLayout">
<PageHeaderCustom />
</div>
),
props: { EuiPageHeader },
},
{
title: 'Page with content only',
source: [
Expand Down
30 changes: 30 additions & 0 deletions src-docs/src/views/page/page_header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';

import { EuiPageHeader, EuiText, EuiButton } from '../../../../src/components';

export default () => (
<EuiPageHeader
pageTitle="Page title"
iconType="logoKibana"
tabs={[
{
label: 'Tab 1',
isSelected: true,
},
{
label: 'Tab 2',
},
]}
description="Page description goes here."
leftSideContent={
<EuiText>
<p>And some custom content</p>
</EuiText>
}
rightSideContent={[
<EuiButton fill>Add something</EuiButton>,
<EuiButton>Do something</EuiButton>,
]}
alignItems="top"
/>
);
18 changes: 18 additions & 0 deletions src-docs/src/views/page/page_header_custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

import {
EuiPageHeader,
EuiPageHeaderSection,
EuiTitle,
} from '../../../../src/components';

export default () => (
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>Page title</h1>
</EuiTitle>
</EuiPageHeaderSection>
<EuiPageHeaderSection>Page abilities</EuiPageHeaderSection>
</EuiPageHeader>
);
9 changes: 1 addition & 8 deletions src-docs/src/views/page/page_simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ import {
EuiPageContentHeader,
EuiPageContentHeaderSection,
EuiPageHeader,
EuiPageHeaderSection,
EuiTitle,
} from '../../../../src/components';

export default () => (
<EuiPage>
<EuiPageBody component="div">
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>Page title</h1>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageHeader pageTitle="Page title" />
<EuiPageContent>
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
Expand Down
76 changes: 76 additions & 0 deletions src-docs/src/views/page/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import React from 'react';
import { PropTypes } from 'react-view';
import { EuiPageHeader, EuiButton } from '../../../../src/components/';
import {
propUtilityForPlayground,
iconValidator,
} from '../../services/playground';

// HELP: Can we get a "simulate" toggle and pass ReactNodes?
cchaos marked this conversation as resolved.
Show resolved Hide resolved
const tabs = [
{
label: 'Tab 1',
isSelected: true,
},
{
label: 'Tab 2',
},
];

const rightSideContent = [
<EuiButton fill>Button 1</EuiButton>,
<EuiButton>Button 2</EuiButton>,
];

export default () => {
const docgenInfo = Array.isArray(EuiPageHeader.__docgenInfo)
? EuiPageHeader.__docgenInfo[0]
: EuiPageHeader.__docgenInfo;
const propsToUse = propUtilityForPlayground(docgenInfo.props);

propsToUse.iconType = iconValidator(propsToUse.iconType);

propsToUse.pageTitle = {
...propsToUse.pageTitle,
type: PropTypes.String,
value: 'Page title',
};

propsToUse.leftSideContent = {
...propsToUse.leftSideContent,
type: PropTypes.String,
};

// HELP: NOT WORKING
propsToUse.alignItems = {
...propsToUse.alignItems,
defaultValue: 'center',
};
cchaos marked this conversation as resolved.
Show resolved Hide resolved

propsToUse.description = {
...propsToUse.description,
type: PropTypes.String,
};

propsToUse.rightSideContent = {
...propsToUse.rightSideContent,
type: PropTypes.Array,
};

return {
config: {
componentName: 'EuiPageHeader',
props: propsToUse,
scope: {
EuiPageHeader,
},
imports: {
'@elastic/eui': {
named: ['EuiPageHeader'],
},
},
},
};
};
Loading