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] Created EuiPageTemplate to facilitate the new design patterns for page layouts #4525

Merged
merged 70 commits into from
Feb 26, 2021

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Feb 15, 2021

... And updated the EUI docs to use the new pattern.

Component updates/additions

EuiPage

  • grow: To easily facilitate allowing the whole page to stretch to fit vertically.
  • direction: Changes the flex-direction property. Originally added because I wanted to remove the EuiPageBody dependency, but found the EuiPageBody to be a better solution. Leaving it in, just as a nice solution for others.

EuiPageBody

  • panelled: Uses an EuiPanel as the main component instead of a plain div
  • panelProps: Extends any extra EuiPanel props if panelled=true
  • paddingSize: For changes to overall padding for both EuiPanel and plain div

EuiPageContent

Fix: I'm pretty sure I fixed the overflowing of content when the EuiPageContent component is a flex item next to EuiSideBar by adding min-width: 0.

EuiPageContentBody

  • restrictWidth: Aligns with all other EuiPage component restrictWidth props
  • paddingSize: Also to align with all other EuiPage component padding sizes

EuiPageHeader

EuiPageHeaderContent

  • Updated the EuiTabs component to render the large size.

EuiPageSideBar

  • Added $euiPageSidebarMinWidth global token for updating the hard-coded min-width
  • Added the prop sticky for easily allowing the sidebar to scroll independently of the page contents. The euiHeaderAffordForFixed() Sass mixin now also applies any extra styling to .euiSideBar--sticky to afford for any fixed headers.

[NEW] EuiPageTemplate

Similar to the EuiSelectableSitewideTemplate component this new EuiPageTemplate component is a shortcut for creating the different types of page layout patterns described in the docs. It is somewhat opinionated, but still with the ability to customize most of the inner components with props like sideBarProps and pageContentProps.

This template may not be complete at this time, but provides solutions with a quick way to opt in to the new layout patterns. And fixes #3743

Example. This simple React usage:

<EuiPageTemplate
  pageSideBar={sideNav}
  pageHeader={{
    iconType: 'logoElastic',
    pageTitle: 'Page title',
    rightSideItems: [button],
    tabs: [{ label: 'Tab 1', isSelected: true }, { label: 'Tab 2' }],
  }}>
    {content}
</EuiPageTemplate>

Will render as:

Screen Shot 2021-02-15 at 16 08 59 PM

Four types of templates

As of right now there are 4 template types, all with/without sideBars: 'default' | 'centeredBody' | 'centeredContent' | 'empty'. The example above is the default. The centered options allow for either the whole body or just the content to be centered depending, usually, on which part is the "empty" state.

centeredBody
Screen Shot 2021-02-15 at 16 11 48 PM

centeredContent
Screen Shot 2021-02-15 at 16 11 54 PM

empty
Good for more free-form body content like dashboards.
Screen Shot 2021-02-17 at 12 38 56 PM

Padding size and max-widths

Both the restrictWidth and paddingSize props can be applied as this top layer and will apply them to all the appropriate inner components. It also defaults the restrictWidth to true so that most layouts are automatically maxed.

Screen Shot 2021-02-15 at 16 13 50 PM

Other component fixes

EuiBreadcrumbs truncation

Since I re-discovered the min-width: 0 trick for flex items and noticed that long header breadcrumbs were breaking the header layouts, I added this directly to the EuiBreadcrumb component.

EuiHeaderSectionItemButton only rendered a <button>

These buttons weren't accepting href's like I needed for the docs updates with putting the github and design library links in the header. Now the component just extends EuiButtonEmpty to easily get all the states and types necessary for allowing both onClick and href.

This also removed the specific :hover states to be more inline with our empty button behavior which has none.

Docs updates/additions

Added an EuiHeader to house the theme switcher and other links that previously only existed on the home page

I've also made the design library and codesandbox links theme aware. Meaning, depending on the currently selected theme, it will update these library links to point to that theme's library and the codesandbox link will import the corresponding CSS file.

Screen Recording 2021-02-15 at 03 19 04 PM

Added the ability to create custom demo tabs

For these new EuiPage docs, I really wanted to show both how to use the template version and how to create the same layout manually with the corresponding components. I could have used the Demo JS and Snippet tabs for this, but I wanted to be more explicit than that. I also wanted to be able to have all the import statements for both (which Snippets do not automatically come with).

So now you can pass something like the following into the source key of the guide section, and it will render similar to our current Demo JS tab but with a custom tab displayName.

{
  type: GuideSectionTypes.JS,
  code: PageCustomContentTemplateSource,
  displayName: 'Template JS',
}

The tabs will also now render in the order they're given in the source.

Screen Recording 2021-02-15 at 03 29 16 PM

Updated the home page 😸

Screen Shot 2021-02-15 at 15 32 06 PM

Follow-ups

There are still a few minor things to work out like:

  • More EuiHeader z-index issues
  • Figure out how to allow EuiPanel to render any component like <main>

Checklist (Still working on most of these)

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • [ ] Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

cchaos added 30 commits February 11, 2021 12:16
# Conflicts:
#	src-docs/src/components/guide_page/guide_page.js
#	src-docs/src/views/home/home_view.js
# Conflicts:
#	src-docs/src/images/button_popover.svg
# Conflicts:
#	src-docs/src/components/guide_components.scss
# Conflicts:
#	src-docs/src/components/guide_section/_guide_section.scss
#	src-docs/src/components/guide_section/guide_section_parts/guide_section_code.tsx
But sticky isn’t working inside the page
And created template versions of all the doc examples
cchaos and others added 3 commits February 22, 2021 15:10
Co-authored-by: Dave Snider <dave.snider@gmail.com>
@cchaos
Copy link
Contributor Author

cchaos commented Feb 22, 2021

Dynamically set number of cards on the homepage

I think it's odd to hide cards at certain page sizes. I think we just need to add more at some point 😄

Colors page sticky margins are off

Actually this failure from negative margins of the lower gray box ...

Screen Shot 2021-02-22 at 15 24 01 PM

EDIT: And I know how to fix now actually

Tabs on example pages

I'm hoping NOT to wait on the other PR for long. So I'd like to stick with this usage as it's using the inherent tabs prop of EuiPageHeader to showcase specifically how that works.

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

LGTM. Reasons to stick with with these decisions make sense to me knowing we have another PR coming soon. Nice work. Huge change!

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4525/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4525/

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

I didn't look too closely at the docs changes, but the new component changes look ready to go
Just a couple changes for TS and CL

CHANGELOG.md Outdated
@@ -23,9 +23,26 @@

- Removed letter-spacing from `euiFont` Sass mixin ([#4488](https://github.com/elastic/eui/pull/4488))

### Feature: EuiPageTemplate ([#4517](https://github.com/elastic/eui/pull/4517))
Copy link
Contributor

Choose a reason for hiding this comment

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

Had a release in the meantime. Need to update the location.

Comment on lines 93 to 94
const onMenuButtonClick: MouseEventHandler<HTMLButtonElement> = (e) => {
// @ts-ignore HELP
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const onMenuButtonClick: MouseEventHandler<HTMLButtonElement> = (e) => {
// @ts-ignore HELP
const onMenuButtonClick: MouseEventHandler<
HTMLButtonElement & HTMLAnchorElement
> = (e) => {

src/components/header/header_links/header_links.tsx Outdated Show resolved Hide resolved
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4525/

@cchaos
Copy link
Contributor Author

cchaos commented Feb 25, 2021

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4525/

@cchaos
Copy link
Contributor Author

cchaos commented Feb 25, 2021

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4525/

@cchaos
Copy link
Contributor Author

cchaos commented Feb 26, 2021

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4525/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for common layout pattern often used in Kibana
5 participants