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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a74ce1c
[EuiPageTemplate Feature] [Docs] Create new section for “Templates” (…
cchaos Feb 11, 2022
087acb8
Merge remote-tracking branch 'upstream/main' into feature/page_templates
Mar 25, 2022
d185908
Merge remote-tracking branch 'upstream/main' into feature/page_templates
Mar 29, 2022
7d50eb0
Clean up
Mar 29, 2022
ab78a2a
`fullscreen`
Mar 29, 2022
356df99
one last link
Mar 29, 2022
d7689f0
Merge remote-tracking branch 'upstream/main' into feature/page_templates
Apr 2, 2022
fca27cc
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Apr 5, 2022
b659d6e
[Page Templates Feature] EuiPage docs & toggles (#5662)
cchaos Apr 6, 2022
f626ba9
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Apr 11, 2022
23b815a
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Apr 20, 2022
229fc99
[Page Templates Feature] Added EuiPageSection and updated EuiPage & E…
cchaos Apr 20, 2022
bd7dfe7
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Apr 29, 2022
c53c44b
Merge remote-tracking branch upstream/main into _upstream/feature_pag…
May 9, 2022
5301cc3
Change `usEuiPaddingCSS` to return css instead of string
May 9, 2022
9233976
[Page Template Feature] Updating EuiPageHeader to use the same paradi…
cchaos May 9, 2022
0b0b127
Merge remote-tracking branch upstream/main into _upstream/feature_pag…
May 16, 2022
fd69f57
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
May 17, 2022
2fdb83f
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
May 20, 2022
9e59dd3
Merge remote-tracking branch upstream/main into _upstream/feature_pag…
May 31, 2022
1cad3be
[Into Feature] New EuiPageTemplate as namespaced component for versat…
cchaos Jun 1, 2022
2c21eb5
[Final Feature PR] Convert to remaining page components to Emotion (#…
cchaos Jun 13, 2022
edf77d9
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Jun 13, 2022
1284cff
Snaps
Jun 13, 2022
e8eefdc
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Jun 13, 2022
f47547b
[Feature] Converting EuiPageTemplate to use ReactContext instead of c…
cchaos Jun 23, 2022
19d0b3f
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Jun 23, 2022
b99cef4
Merge remote-tracking branch upstream/main into _upstream/feature_pag…
Jul 26, 2022
cc1c6ed
[EuiPageTemplates] Some fixes for BWC (#6015)
cchaos Aug 2, 2022
b263d69
Merge remote-tracking branch 'upstream/main' into _upstream/feature_p…
Aug 2, 2022
5ae6ab8
Removed `euiPageRestrictWidthStyles()` in favor of style attribute
Aug 8, 2022
12a7373
Fixed EuiPageSection alignments and a few forgotten logical properties
Aug 8, 2022
6e33cf2
Some snapshot fixes
Aug 8, 2022
8d01543
Consolidate changelogs
Aug 8, 2022
1b719ec
Fix CL
Aug 8, 2022
169e352
Some fixes
Aug 9, 2022
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
3 changes: 2 additions & 1 deletion scripts/a11y-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const { AxePuppeteer } = require('@axe-core/puppeteer');
const docsPages = async (root, page) => {
const pagesToSkip = [
`${root}#/display/aspect-ratio`, // Has issues with the embedded audio player
`${root}#/layout/accordion` // Has an issue with ARIA attributes
`${root}#/layout/accordion`, // Has an issue with ARIA attributes
`${root}#/templates/page-template` // Has multiple `main` elements that we don't want to remove for bad copy/paste code
];

return [
Expand Down
19 changes: 4 additions & 15 deletions src-docs/src/components/guide_page/_guide_page.scss
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
@import '../../../../src/global_styling/mixins/helpers';

$guideSideNavWidth: 240px;

#guide { // sass-lint:disable-line no-ids
display: flex;
flex-direction: column;
min-height: 100vh;
@include euiHeaderAffordForFixed;

.euiBody--headerIsFixed & {
min-height: calc(100vh - #{$euiHeaderHeightCompensation});
}
.guideBody {
// Override euiHeaderAffordForFixed mixin since the page template handles this now
padding-top: 0 !important; // sass-lint:disable-line no-important
}

@include euiHeaderAffordForFixed;

.euiBody--headerIsFixed--double {
@include euiHeaderAffordForFixed($euiHeaderHeightCompensation * 2);

#guide { // sass-lint:disable-line no-ids
min-height: calc(100vh - #{$euiHeaderHeightCompensation * 2});
}

.euiHeader:not(.euiHeader--fixed) {
// Force headers below the fullscreen.
// This shouldn't be necessary in consuming applications because headers should always be at the top of the page
Expand Down
47 changes: 22 additions & 25 deletions src-docs/src/components/guide_page/guide_page_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiSideNav,
EuiPageSideBar,
EuiText,
} from '../../../../src/components';

Expand Down Expand Up @@ -252,31 +251,29 @@ export class GuidePageChrome extends Component {
}

return (
<EuiPageSideBar className="guideSideNav" sticky>
<EuiFlexGroup
style={{ height: '100%' }}
direction="column"
responsive={false}
gutterSize="none"
<EuiFlexGroup
style={{ height: '100%' }}
direction="column"
responsive={false}
gutterSize="none"
>
<EuiFlexItem
role="search"
grow={false}
className="guideSideNav__search"
>
<EuiFlexItem
role="search"
grow={false}
className="guideSideNav__search"
>
<EuiFieldSearch
fullWidth
placeholder="Search"
value={this.state.search}
onChange={this.onSearchChange}
aria-label="Search for a docs section"
/>
</EuiFlexItem>
<EuiFlexItem className="guideSideNav__content">
{sideNavContent}
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageSideBar>
<EuiFieldSearch
fullWidth
placeholder="Search"
value={this.state.search}
onChange={this.onSearchChange}
aria-label="Search for a docs section"
/>
</EuiFlexItem>
<EuiFlexItem className="guideSideNav__content">
{sideNavContent}
</EuiFlexItem>
</EuiFlexGroup>
);
}
}
Expand Down
32 changes: 16 additions & 16 deletions src-docs/src/components/guide_page/guide_page_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ export const GuidePageHeader: React.FunctionComponent<GuidePageHeaderProps> = ({
];

return (
<EuiHeader
role="region"
aria-label="EUI Docs app bar"
position="fixed"
theme="dark"
sections={[
{
items: [renderLogo(), renderVersion()],
borders: 'none',
},
{
items: rightSideItems,
borders: 'none',
},
]}
/>
<header aria-label="EUI Docs app bar">
<EuiHeader
position="fixed"
theme="dark"
sections={[
{
items: [renderLogo(), renderVersion()],
borders: 'none',
},
{
items: rightSideItems,
borders: 'none',
},
]}
/>
</header>
);
};
11 changes: 9 additions & 2 deletions src-docs/src/components/guide_section/_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ export const renderJsSourceCode = (code) => {
// [\r\n] - match end of line, so the extra new line is removed via the replace operation
/import {([^}]+)} from '@elastic\/eui';[\r\n]/g,
(match, imports) => {
// remove all characters that aren't letters, numbers, or underscores from the imports
const namedImports = imports.match(/[a-zA-Z0-9_]+/g);
// Finds any word (\b\w+\b) that
// (?<!as\s) - is not preceded by `as `
// (?!(\bas\b)) - and is not the word `as`
// (?!\sas) - and is not followed by ` as`
// | - or
// \w+\sas\s\w+ - find any group of words that conform to the alias import pattern (`Thing as OtherThing`)
const namedImports = imports.match(
/(?<!as\s)(?!(\bas\b))(\b\w+\b)(?!\sas)|\w+\sas\s\w+/g
);
elasticImports.push(...namedImports);
return '';
}
Expand Down
16 changes: 16 additions & 0 deletions src-docs/src/components/guide_section/_utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ describe('renderJsSourceCode', () => {
export default () => 'Hello world!';`)
);
});

it('handles aliased imports', () => {
expect(
renderJsSourceCode({
default: dedent(`
import { EuiPageTemplate_Deprecated as EuiPageTemplate } from '@elastic/eui';

export default () => 'Hello world!';`),
})
).toEqual(
dedent(`
import { EuiPageTemplate_Deprecated as EuiPageTemplate } from '@elastic/eui';

export default () => 'Hello world!';`)
);
});
});

describe('React import', () => {
Expand Down
126 changes: 66 additions & 60 deletions src-docs/src/components/guide_section/guide_section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
EuiButton,
EuiButtonEmpty,
EuiFlyout,
EuiPageContentBody,
EuiPanel,
EuiPanelProps,
EuiPageSection,
CommonProps,
useIsWithinBreakpoints,
} from '../../../../src';
Expand All @@ -27,7 +26,12 @@ import {
} from './guide_section_parts/guide_section_tabs';
import classNames from 'classnames';

export interface GuideSection extends CommonProps {
export interface GuideSectionProps
extends CommonProps,
Pick<
GuideSectionExample,
'exampleToggles' | 'demoPanelProps' | 'ghostBackground'
> {
id?: string;
title?: string;
text?: ReactNode;
Expand All @@ -36,15 +40,15 @@ export interface GuideSection extends CommonProps {
fullScreen?: {
slug: string;
demo: ReactNode;
showButton?: boolean;
};
demoPanelProps?: GuideSectionExample['demoPanelProps'];
props?: object;
playground?: any;
ghostBackground?: boolean;
wrapText?: boolean;
snippet?: string | string[];
color?: EuiPanelProps['color'];
children?: ReactNode;
nested?: boolean;
}

export const GuideSectionCodeTypesMap = {
Expand Down Expand Up @@ -74,7 +78,7 @@ export const GuideSectionCodeTypesMap = {
},
};

export const GuideSection: FunctionComponent<GuideSection> = ({
export const GuideSection: FunctionComponent<GuideSectionProps> = ({
id,
title,
text,
Expand All @@ -86,9 +90,11 @@ export const GuideSection: FunctionComponent<GuideSection> = ({
ghostBackground,
wrapText = true,
demoPanelProps,
exampleToggles,
snippet,
color,
children,
nested,
className,
}) => {
const { path } = useRouteMatch();
Expand Down Expand Up @@ -138,10 +144,12 @@ export const GuideSection: FunctionComponent<GuideSection> = ({
});
}

return tabs.length ? (
const playgroundToggle = renderPlaygroundToggle();

return tabs.length || playgroundToggle ? (
<GuideSectionExampleTabs
tabs={tabs}
rightSideControl={renderPlaygroundToggle()}
rightSideControl={playgroundToggle}
/>
) : undefined;
};
Expand Down Expand Up @@ -188,62 +196,60 @@ export const GuideSection: FunctionComponent<GuideSection> = ({
};

return (
<EuiPanel
<EuiPageSection
id={id}
className={classNames('guideSection', className)}
color={!isLargeBreakpoint ? 'transparent' : color || 'transparent'}
borderRadius="none"
paddingSize="l"
grow={false}
paddingSize={nested ? 'none' : 'l'}
restrictWidth
>
<EuiSpacer size={(color || title) && isLargeBreakpoint ? 'xxl' : 'xs'} />
<EuiPageContentBody restrictWidth>
<GuideSectionExampleText title={title} wrapText={wrapText}>
{text}
</GuideSectionExampleText>

{renderingPlayground && (
<EuiFlyout
onClose={() => setRenderingPlayground(false)}
size="l"
paddingSize="none"
closeButtonPosition="outside"
>
{renderPlayground()}
</EuiFlyout>
)}
{(demo || fullScreen) && (
<>
{text && <EuiSpacer />}
<GuideSectionExample
example={
<EuiErrorBoundary>
{/* eslint-disable-next-line no-nested-ternary */}
{fullScreen == null ? (
<div>{demo}</div>
) : demo == null ? (
<EuiButton
fill
iconType="fullScreen"
href={`#${path}/${fullScreen.slug}`}
>
Fullscreen demo
</EuiButton>
) : (
demo
)}
</EuiErrorBoundary>
}
tabs={renderTabs()}
ghostBackground={ghostBackground}
demoPanelProps={demoPanelProps}
/>
</>
)}

{children}
<EuiSpacer size={color && isLargeBreakpoint ? 'xxl' : 'xs'} />
</EuiPageContentBody>
</EuiPanel>
<GuideSectionExampleText title={title} wrapText={wrapText}>
{text}
</GuideSectionExampleText>

{renderingPlayground && (
<EuiFlyout
onClose={() => setRenderingPlayground(false)}
size="l"
paddingSize="none"
closeButtonPosition="outside"
>
{renderPlayground()}
</EuiFlyout>
)}
{(demo || (fullScreen && fullScreen.showButton !== false)) && (
<>
{(nested || text) && <EuiSpacer />}
<GuideSectionExample
example={
<EuiErrorBoundary>
{/* eslint-disable-next-line no-nested-ternary */}
{fullScreen == null ? (
<div>{demo}</div>
) : demo == null ? (
<EuiButton
fill
iconType="fullScreen"
href={`#${path}/${fullScreen.slug}`}
>
Fullscreen demo
</EuiButton>
) : (
demo
)}
</EuiErrorBoundary>
}
tabs={renderTabs()}
ghostBackground={ghostBackground}
demoPanelProps={demoPanelProps}
exampleToggles={exampleToggles}
/>
</>
)}

{children}
<EuiSpacer size={color && isLargeBreakpoint ? 'xxl' : 'xs'} />
</EuiPageSection>
);
};
Loading