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

(Trying to) Fix z-indexes with header and flyouts & adding more EuiHeader docs #3655

Merged
merged 23 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
aa75d10
[EuiOverlayMask] Added `headerAdjacent` prop for altering z-index bas…
Jun 18, 2020
86b8440
[EuiFlyout] Adjusts mask for header and add `maskProps`
Jun 18, 2020
594fc74
Fix demo page setup script with folder location
Jun 18, 2020
0cdbe16
[EuiCollapsibleNav] Applying `headerAdjacent="below”` to mask and add…
Jun 18, 2020
bf49a59
[Docs] Fixing header examples (esp Alerts)
Jun 18, 2020
0e77bd9
Tweak to Amsterdam EuiHeaderBreadcrumb sizing
Jun 18, 2020
3eb4793
Fix demo page setup script with folder location (pt 2)
Jun 24, 2020
846a99b
[EuiBreadcrumbs] Fix for allowing `onClick`
Jun 24, 2020
9371948
[SASS] Fix flyout vs collapsible nav clip-path
Jun 24, 2020
3ac309c
[EuiBreadcrumbs] Fix for allowing `onClick` (SNAPS)
Jun 24, 2020
bd9b1a3
[Docs] Elastic Header Pattern (as TSX)
Jun 24, 2020
199a701
Convert example to JS and optimize for codesandbox
Jun 24, 2020
9baca91
[EuiBadge] Allow any valid chroma.js color string
Jun 24, 2020
fbe7d84
[EuiHeaderLinks] Fix margins for any children
Jun 24, 2020
90e173b
Cleanup
Jun 24, 2020
3744e44
Update src-docs/src/views/header/header_example.js
cchaos Jun 30, 2020
c61245d
Update src-docs/src/views/overlay_mask/overlay_mask_example.js
cchaos Jun 30, 2020
ba35c78
Change `headerAdjacent` to `headerZindexLocation`
Jul 1, 2020
6a342ce
Merge branch 'fix/z-indexes' of https://github.com/cchaos/eui into fi…
Jul 1, 2020
8e78c12
cl
Jul 1, 2020
75e63ca
cl
Jul 1, 2020
e99dca9
Merge branch 'master' into fix/z-indexes
cchaos Jul 1, 2020
6bac69a
Merge branch 'master' into fix/z-indexes
cchaos Jul 1, 2020
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
132 changes: 85 additions & 47 deletions generator-eui/documentation/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const chalk = require('chalk');
const Generator = require('yeoman-generator');
const utils = require('../utils');
Expand All @@ -12,24 +31,29 @@ module.exports = class extends Generator {
}

prompting() {
let prompts = [{
message: 'What\'s the name of the component you\'re documenting? Use snake_case, please.',
name: 'name',
type: 'input',
store: true,
}];
const prompts = [
{
message:
"What's the name of the component you're documenting? Use snake_case, please.",
name: 'name',
type: 'input',
store: true,
},
];

if (this.fileType === 'demo') {
prompts.push({
message: `What's the name of the directory this demo should go in? (Within src-docs/src/views). Use snake_case, please.`,
message:
"What's the name of the directory this demo should go in? (Within src-docs/src/views). Use snake_case, please.",
name: 'folderName',
type: 'input',
store: true,
default: answers => answers.name,
});

prompts.push({
message: 'What would you like to name this demo? Use snake_case, please.',
message:
'What would you like to name this demo? Use snake_case, please.',
name: 'demoName',
type: 'input',
store: true,
Expand All @@ -46,22 +70,24 @@ module.exports = class extends Generator {

const writeDocumentationPage = () => {
const componentExampleName = utils.makeComponentName(config.name, false);
const componentExamplePrefix = utils.lowerCaseFirstLetter(componentExampleName);
const componentExamplePrefix = utils.lowerCaseFirstLetter(
componentExampleName
);
const componentName = utils.makeComponentName(config.name);
const fileName = config.name;

const path = DOCUMENTATION_PAGE_PATH;

const vars = config.documentationVars = {
const vars = (config.documentationVars = {
componentExampleName,
componentExamplePrefix,
componentName,
fileName,
};
});

const documentationPagePath
= config.documentationPagePath
= `${path}/${config.name}/${config.name}_example.js`;
const documentationPagePath = (config.documentationPagePath = `${path}/${
config.name
}/${config.name}_example.js`);

this.fs.copyTpl(
this.templatePath('documentation_page.js'),
Expand All @@ -72,21 +98,22 @@ module.exports = class extends Generator {

const writeDocumentationPageDemo = (fileName, folderName) => {
const componentExampleName = utils.makeComponentName(fileName, false);
const componentExamplePrefix = utils.lowerCaseFirstLetter(componentExampleName);
const componentExamplePrefix = utils.lowerCaseFirstLetter(
componentExampleName
);
const componentName = utils.makeComponentName(config.name);

const path = DOCUMENTATION_PAGE_PATH;

const vars = config.documentationVars = {
const vars = (config.documentationVars = {
componentExampleName,
componentExamplePrefix,
componentName,
fileName,
};
folderName,
});

const documentationPageDemoPath
= config.documentationPageDemoPath
= `${path}/${folderName}/${fileName}.tsx`;
const documentationPageDemoPath = (config.documentationPageDemoPath = `${path}/${folderName}/${fileName}.tsx`);

this.fs.copyTpl(
this.templatePath('documentation_page_demo.tsx'),
Expand Down Expand Up @@ -117,44 +144,55 @@ module.exports = class extends Generator {

this.log(chalk.white('\n// Import demo into example.'));
this.log(
`${chalk.magenta('import')} ${componentExampleName} from ${chalk.cyan(`'./${fileName}'`)};\n` +
`${chalk.magenta('const')} ${componentExamplePrefix}Source = require(${chalk.cyan(`'!!raw-loader!./${fileName}'`)});\n` +
`${chalk.magenta('const')} ${componentExamplePrefix}Html = renderToHtml(${componentExampleName});`
`${chalk.magenta('import')} ${componentExampleName} from ${chalk.cyan(
`'./${fileName}'`
)};\n` +
`${chalk.magenta(
'const'
)} ${componentExamplePrefix}Source = require(${chalk.cyan(
`'!!raw-loader!./${fileName}'`
)});\n` +
`${chalk.magenta(
'const'
)} ${componentExamplePrefix}Html = renderToHtml(${componentExampleName});`
);

this.log(chalk.white('\n// Render demo.'));
this.log(
`<GuideSection\n` +
` title="${componentExampleName}"\n` +
` source={[{\n` +
` type: GuideSectionTypes.JS,\n` +
` code: ${componentExamplePrefix}Source,\n` +
` }, {\n` +
` type: GuideSectionTypes.HTML,\n` +
` code: ${componentExamplePrefix}Html,\n` +
` }]}\n` +
` text={\n` +
` <p>Description needed: how to use the ${componentExampleName} component.</p>\n` +
` }\n` +
` demo={\n` +
` <${componentExampleName} />\n` +
` }\n` +
`/>\n`
'<GuideSection\n' +
` title="${componentExampleName}"\n` +
' source={[{\n' +
' type: GuideSectionTypes.JS,\n' +
` code: ${componentExamplePrefix}Source,\n` +
' }, {\n' +
' type: GuideSectionTypes.HTML,\n' +
` code: ${componentExamplePrefix}Html,\n` +
' }]}\n' +
' text={\n' +
` <p>Description needed: how to use the ${componentExampleName} component.</p>\n` +
' }\n' +
' demo={\n' +
` <${componentExampleName} />\n` +
' }\n' +
'/>\n'
);
};

const showImportRouteSnippet = (suffix, appendToRoute) => {
const {
componentExampleName,
fileName,
} = this.config.documentationVars;
const { componentExampleName, fileName } = this.config.documentationVars;

this.log(chalk.white('\n// Import example into routes.js and then add it to the "components" array.'));
this.log(
chalk.white(
'\n// Import example into routes.js and then add it to the "components" array.'
)
);
this.log(
`${chalk.magenta('import')} { ${componentExampleName}${suffix} }\n` +
` ${chalk.magenta('from')} ${chalk.cyan(`'./views/${fileName}/${fileName}_${suffix.toLowerCase()}'`)};`
` ${chalk.magenta('from')} ${chalk.cyan(
`'./views/${fileName}/${fileName}_${suffix.toLowerCase()}'`
)};`
);
}
};

this.log('------------------------------------------------');
this.log(chalk.bold('Import snippets:'));
Expand All @@ -170,4 +208,4 @@ module.exports = class extends Generator {
}
this.log('------------------------------------------------');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {
<%= componentName %>,
} from '../../../../src/components/<%= fileName %>';
} from '../../../../src/components/<%= folderName %>';

export default () => (
<<%= componentName %>>
Expand Down
6 changes: 6 additions & 0 deletions src-docs/src/components/guide_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
.guideSideNav {
top: $euiHeaderHeightCompensation * 2;
}

.euiHeader:not(.euiHeader--fixed) {
// Force headers below the full screen.
// This shouldn't be necessary in consuming applications because headers should always be at the top of the page
z-index: 0;
}
}

.guidePage {
Expand Down
107 changes: 36 additions & 71 deletions src-docs/src/views/header/header_alert.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
import React from 'react';
import { GuideFullScreen } from '../../services/full_screen/full_screen';
import React, { useState } from 'react';

import {
EuiButton,
EuiHeader,
EuiHeaderSection,
EuiHeaderSectionItem,
EuiHeaderLogo,
EuiHeaderLink,
EuiHeaderLinks,
EuiIcon,
EuiPage,
EuiPageBody,
EuiPageHeader,
EuiPageHeaderSection,
EuiPageContent,
EuiPageContentHeader,
EuiPageContentHeaderSection,
EuiPageContentBody,
EuiTitle,
EuiSpacer,
EuiSwitch,
} from '../../../../src/components';

import HeaderUserMenu from './header_user_menu';
import HeaderSpacesMenu from './header_spaces_menu';
import HeaderUpdates from './header_updates';

export default () => {
const [position, setPosition] = useState('static');

const renderLogo = () => {
return (
<EuiHeaderLogo
Expand All @@ -37,64 +29,37 @@ export default () => {
};

return (
<GuideFullScreen>
{setIsFullScreen => (
<div className="guideFullScreenOverlay" style={{ zIndex: 9000 }}>
<EuiHeader>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right">
{renderLogo()}
</EuiHeaderSectionItem>
<EuiHeaderSectionItem border="right">
<HeaderSpacesMenu />
</EuiHeaderSectionItem>
<EuiHeaderLinks>
<EuiHeaderLink href="#">Home</EuiHeaderLink>
</EuiHeaderLinks>
</EuiHeaderSection>

<EuiHeaderSection side="right">
<EuiHeaderSectionItem>
<HeaderUpdates />
</EuiHeaderSectionItem>
<EuiHeaderSectionItem>
<HeaderUserMenu />
</EuiHeaderSectionItem>
</EuiHeaderSection>
</EuiHeader>
<>
<EuiSwitch
label={'Make header fixed position and put alerts in flyout'}
checked={position === 'fixed'}
onChange={e => setPosition(e.target.checked ? 'fixed' : 'static')}
/>
<EuiSpacer />
<EuiHeader position={position}>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right">
{renderLogo()}
</EuiHeaderSectionItem>
<EuiHeaderSectionItem border="right">
<HeaderSpacesMenu />
</EuiHeaderSectionItem>
<EuiHeaderLinks>
<EuiHeaderLink href="#">Home</EuiHeaderLink>
</EuiHeaderLinks>
</EuiHeaderSection>

<EuiPage style={{ height: '100%' }}>
<EuiPageBody>
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="m">
<h2>Kibana news feed demo</h2>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageContent>
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
<p>
Click the <EuiIcon type="cheer" size="m" /> button to see
‘What’s new?’
</p>
</EuiPageContentHeaderSection>
</EuiPageContentHeader>
<EuiPageContentBody>
<EuiButton
fill
onClick={() => setIsFullScreen(false)}
iconType="exit"
aria-label="Exit fullscreen demo">
Exit fullscreen demo
</EuiButton>
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
</EuiPage>
</div>
)}
</GuideFullScreen>
<EuiHeaderSection side="right">
<EuiHeaderSectionItem>
<HeaderUpdates
flyoutOrPopover={position === 'fixed' ? 'flyout' : 'popover'}
/>
</EuiHeaderSectionItem>
<EuiHeaderSectionItem>
<HeaderUserMenu />
</EuiHeaderSectionItem>
</EuiHeaderSection>
</EuiHeader>
</>
);
};
Loading