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

[Feature] EuiPage and EuiPageTemplate Updates #5768

Merged
merged 36 commits into from
Aug 9, 2022
Merged

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Apr 6, 2022

Justification for new template structure

While implementing the original EuiPageTemplate in Kibana, we realized that it is very rigid and doesn't allow for certain configurations like:

  • Prepending page contents before the page header
  • Allowing full-width content areas
  • Providing page header and other prop-based content outside of an actual propagated prop on the template component

This new template is based on React context to pass through unified props like paddingSize and restrictWidth while still be configurable at every level. It also removes the necessity to provide page header contents through props. It is also built as a namespaced component and therefore the context will only be passed to those that are namespaced in case of complete custom layouts.

The best way to justify is to showcase the new capabilities. Take the following layout which couldn't be achieved by the previous version of EuiPageTemplate and would need to be completely custom contents that would then no longer be tied to cascading props:

Screen Shot 2022-08-11 at 15 45 20 PM

Now you can easily achieve this with the following setup:

<EuiPageTemplate bottomBorder="extended">
  {/* Sidebar content can now be instantiated anywhere and it will always be placed in the correct spot */}
  <EuiPageTemplate.Sidebar>{sidebar}</EuiPageTemplate.Sidebar>
  {/* This non-namespaced section will not be tied to the template ensuring it's display is always custom */}
  <EuiPageSection color="subdued">
    Some content before the page header
  </EuiPageSection>
  {/* Display a page header anywhere in the stack of contents */}
  <EuiPageTemplate.Header {...header} />
  {/* This template section overrides some default template props */}
  <EuiPageTemplate.Section grow={false} bottomBorder="extended">
    Some content after the page header
  </EuiPageTemplate.Section>
  {/* Empty prompts can be placed anywhere in the stack and not replace the entire page contents */}
  <EuiPageTemplate.EmptyPrompt title={<span>No spice</span>}>
    {emptyPrompt}
  </EuiPageTemplate.EmptyPrompt>
</EuiPageTemplate>

Based solely on the presence of a fixed EuiHeader, the template will also ensure the layout affords for this offset without needing to apply custom styles and use of a Sass mixin.

More example conversions to the new EuiPageTemplate

`template = default` with sidebar and a bottom bar Screen Shot 2022-08-08 at 16 37 40 PM
<EuiPageTemplate>
  <EuiPageTemplate.Sidebar>{sidebar}</EuiPageTemplate.Sidebar>
  <EuiPageTemplate.Header {...header} />
  <EuiPageTemplate.Section>{content}</EuiPageTemplate.Section>
  <EuiPageTemplate.BottomBar>{bottomBar}</EuiPageTemplate.BottomBar>
</EuiPageTemplate>
`template = centeredBody` Screen Shot 2022-08-08 at 16 44 18 PM
<EuiPageTemplate>
  <EuiPageTemplate.EmptyPrompt title={<span>No spice</span>}>
    {emptyPrompt}
  </EuiPageTemplate.EmptyPrompt>
</EuiPageTemplate>
`template = centeredContent` with sidebar Screen Shot 2022-08-08 at 16 46 24 PM
<EuiPageTemplate>
  <EuiPageTemplate.Sidebar>{sidebar}</EuiPageTemplate.Sidebar>
  <EuiPageTemplate.Header {...header} />
  <EuiPageTemplate.EmptyPrompt title={<span>No spice</span>}>
    {emptyPrompt}
  </EuiPageTemplate.EmptyPrompt>
</EuiPageTemplate>
`template = empty` (no content panelling) Screen Shot 2022-08-08 at 17 09 33 PM
{/* The default for `bottomBorder` is `extended` */}
<EuiPageTemplate panelled={false} bottomBorder={true}>
  <EuiPageTemplate.Header {...header} rightSideItems={[button]} />
  <EuiPageTemplate.Section>
    <EuiFlexGrid columns={2}>
      <EuiFlexItem>
        <EuiPanel style={{ height: 200 }} />
      </EuiFlexItem>
      <EuiFlexItem>
        <EuiPanel style={{ height: 200 }} />
      </EuiFlexItem>
      <EuiFlexItem>
        <EuiPanel style={{ height: 200 }} />
      </EuiFlexItem>
      <EuiFlexItem>
        <EuiPanel style={{ height: 200 }} />
      </EuiFlexItem>
    </EuiFlexGrid>
  </EuiPageTemplate.Section>
</EuiPageTemplate>

PR Summaries:

Checklist

  • Checked 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 any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

cchaos and others added 9 commits February 11, 2022 13:34
…5625)

* [Docs] Create new section for “Templates”
- Moves Page Template, SuperDatePicker, and Searchable Sitewide Template
- Stubs in placeholder page for in lower level page components
- Fixes routes
# Conflicts:
#	scripts/a11y-testing.js
#	src-docs/src/views/page/page_example.js
* Added `exampleToggles` to GuideSectionExample for easily passing through custom controls
@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

…uiPageBody padding defaults (#5769)

* Removed nested page header styles when within EuiPageBody (improved way of doing this coming later)
* [NEW] EuiPageSection to replace EuiPageContent & EuiPageContentBody
* Added `exampleToggles` to GuideSectionExample for easily passing through custom controls
* Added `euiPaddingStyles` and `euiBackgroundColorStyles` global styling functions
* Added deprecation comments to EuiPageContent and EuiPageContentBody
@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

cchaos added 2 commits May 9, 2022 10:11
This gets the className output to render the key name. Same with `useEuiBackgroundColorCSS`.

Also fixed usage in `EuiPageSection`.

Also fixed docs `exampleToggles` pass through from GuideSection to example
@kibanamachine
Copy link

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

…gm as EuiPageSection (#5857)

* [EuiPageHeader] Refactoring to support same `bottomBorder`, `restrictWidth` and `paddingSize` props as EuiPageSection
* Converted EuiPageHeaderContent to Emotion
* Consolidate more styles including ensuring max-width is applied as `style` tag
@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

🚀

@cchaos
Copy link
Contributor Author

cchaos commented Aug 9, 2022

@kibanamachine
Copy link

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

@thompsongl thompsongl deleted the feature/page_templates branch August 23, 2022 20:39
This was referenced Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change deprecations Contains deprecations. Add them to the deprecations meta ticket after merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants