Skip to content

Commit

Permalink
[Page Layouts] Adding content props to EuiPageHeader for pre-determin…
Browse files Browse the repository at this point in the history
…ed page layout patterns (#4451)

* Added content type props to EuiPageHeader

* Replaced example usages with props

* Setting up a new $`euiPageDefaultMaxWidth` sass token

* Updating playground & docs

* Fixin amsterdam small and reverse shadows

* ‘Fixing’ paddingSize prop on EuiPageContent

* Adding custom options for `restrictWidth`

* Starting the switch to a new component `EuiPageHeaderContent`

* middle; simulate node

* Update `useIsWithinBreakpoints` to be conditional

* Moving the content to a new component

* Cleaning up

* Playground fix

* more customProps

* prevent format errors

* Some cleanup and fixing of logic

* Added `stretch` to the align prop and fixed tests

* cl & comments

* Docs clarity

* words

* Apply suggestions from code review

* Render `<header>` element in EuiPageHeader

* Adding `iconProps` to optional icon

* Renaming `rightSideContent` to `rightSideItems` for better clarity of what the prop type is

* Replacing `rightSideResponsive` with a more generic `rightSideGroupProps`

Also had to change the EuiFlexGroupProps to include ALL props (like Common)

* Apply suggestions from code review

Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>

* Set deprecation notice for `panelPaddingSize`

Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
Co-authored-by: Dave Snider <dave.snider@gmail.com>
  • Loading branch information
3 people committed Feb 10, 2021
1 parent b4947c4 commit 0427fa5
Show file tree
Hide file tree
Showing 45 changed files with 2,108 additions and 97 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- Added `EuiOverlayMask` directly to `EuiModal` ([#4480](https://github.com/elastic/eui/pull/4480))
- Added `paddingSize` prop to `EuiFlyout` ([#4448](https://github.com/elastic/eui/pull/4448))
- Added `size='l'` prop to `EuiTabs` ([#4501](https://github.com/elastic/eui/pull/4501))
- Added content-specific props (`pageTitle`, `description`, `tabs`, `rightSideItems`) to `EuiPageHeader` by creating a new `EuiPageHeaderContent` component ([#4451](https://github.com/elastic/eui/pull/4451))
- Added `isActive` parameter to the `useIsWithinBreakpoints` hook ([#4451](https://github.com/elastic/eui/pull/4451))

**Bug fixes**

Expand All @@ -12,6 +14,11 @@
- Fixed `EuiCodeBlock` focus-state if content overflows [#4463](https://github.com/elastic/eui/pull/4463)
- Fixed issues in `EuiDataGrid` around unnecessary scroll bars and container heights not updating ([#4468](https://github.com/elastic/eui/pull/4468))

**Theme: Amsterdam**

- Increased `EuiPage`'s default `restrictWidth` size to `1200px` (extra large breakpoint) ([#4451](https://github.com/elastic/eui/pull/4451))
- Reduced size of `euiBottomShadowSmall` by one layer ([#4451](https://github.com/elastic/eui/pull/4451))

## [`31.5.0`](https://github.com/elastic/eui/tree/v31.5.0)

- Added `isLoading` prop and added `EuiOverlayMask` directly to `EuiConfirmModal` ([#4421](https://github.com/elastic/eui/pull/4421))
Expand Down
9 changes: 7 additions & 2 deletions 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 @@ -105,11 +105,16 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
min-height: 460px;
}

div {
> div,
> div > div {
background: transparentize($euiColorPrimary, .9);
}
}

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

.guideDemo__highlightSpacer {
.euiSpacer {
background: transparentize($euiColorPrimary, .9);
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/services/playground/_playground_compiler.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
@if (lightness($euiTextColor) < 50) {
background: $euiColorDarkestShade;
}
}
}
2 changes: 1 addition & 1 deletion src-docs/src/services/playground/createOptionalEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const createOptionalEnum = (prop = { options: {} }) => {
const newProp = {
...prop,
options: {
none: '-- No value selected --',
none: '',
...prop.options,
},
defaultValue: 'none',
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
1 change: 1 addition & 0 deletions src-docs/src/services/playground/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { iconValidator } from './iconValidator';
export { createOptionalEnum } from './createOptionalEnum';
export { dummyFunction } from './dummyFunction';
export { simulateFunction } from './simulateFunction';
export { generateAst, generateCustomProps } from './utils';
5 changes: 3 additions & 2 deletions src-docs/src/services/playground/knobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ const Knob = ({
isInvalid={error && error.length > 0}
compressed
fullWidth
hasNoInitialSelection={!valueKey && !defaultValue}
/>
</EuiFormRow>
);
Expand Down Expand Up @@ -241,11 +242,11 @@ const Knob = ({
<EuiSwitch
id={name}
label={custom.label || ''}
checked={typeof val !== 'undefined' && val}
checked={typeof val !== 'undefined' && Boolean(val)}
onChange={(e) => {
const value = e.target.checked;

set(value ? value : undefined);
set(value ? custom.value ?? e.target.checked : undefined);
}}
compressed
/>
Expand Down
10 changes: 9 additions & 1 deletion src-docs/src/services/playground/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ export default ({ config, setGhostBackground, playgroundClassName }) => {
newCode = newCode.replace(/(\);)$/m, '');
}

return format(newCode.trim(), ' '.repeat(4));
let formatted;
// TODO: Replace `html-format` with something better.
// Notably, something more jsx-friendly
try {
formatted = format(newCode.trim(), ' '.repeat(4));
} catch {
formatted = newCode.trim();
}
return formatted;
};

const Playground = () => {
Expand Down
16 changes: 16 additions & 0 deletions src-docs/src/services/playground/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import template from '@babel/template';

export const generateAst = (value) => {
return template.ast(String(value), { plugins: ['jsx'] }).expression;
};

export const generateCustomProps = (props) => {
return props.reduce((obj, item) => {
return {
...obj,
[item]: {
generate: generateAst,
},
};
}, {});
};
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
18 changes: 9 additions & 9 deletions src-docs/src/views/page/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import {
EuiPageContentHeader,
EuiPageContentHeaderSection,
EuiPageHeader,
EuiPageHeaderSection,
EuiPageSideBar,
EuiTitle,
EuiButton,
} from '../../../../src/components';

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
iconType="logoElastic"
pageTitle="Page title"
rightSideItems={[
<EuiButton fill>Add something</EuiButton>,
<EuiButton>Do something</EuiButton>,
]}
/>
<EuiPageContent>
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
Expand Down
14 changes: 5 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,11 @@ 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"
rightSideItems={['Page abilities']}
alignItems="center"
/>
<EuiPageContent verticalPosition="center" horizontalPosition="center">
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
Expand Down
Loading

0 comments on commit 0427fa5

Please sign in to comment.