diff --git a/CHANGELOG.md b/CHANGELOG.md index 932a368fbfd..e8255121914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Fixed `EuiComboBox`'s padding on the right ([#2135](https://github.com/elastic/eui/pull/2135)) - Fixed `EuiAccordion` to correctly account for changing computed height of child elements ([#2136](https://github.com/elastic/eui/pull/2136)) +- Fixed some `EuiFlyout` sizing ([#2125](https://github.com/elastic/eui/pull/2125)) **Breaking changes** diff --git a/src-docs/src/views/flyout/flyout_example.js b/src-docs/src/views/flyout/flyout_example.js index cf9d3c0d5d6..c4f43923011 100644 --- a/src-docs/src/views/flyout/flyout_example.js +++ b/src-docs/src/views/flyout/flyout_example.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { renderToHtml } from '../../services'; @@ -9,6 +9,7 @@ import { EuiFlyout, EuiFlyoutHeader, EuiFlyoutFooter, + EuiCallOut, } from '../../../../src/components'; import { Flyout } from './flyout'; @@ -216,7 +217,7 @@ export const FlyoutExample = { demo: , }, { - title: 'maxWidth', + title: 'Max width', source: [ { type: GuideSectionTypes.JS, @@ -228,14 +229,22 @@ export const FlyoutExample = { }, ], text: ( -

- In this example, we set maxWidth to{' '} - 448px, to set the width of the flyout at the ideal - width for a form. -

+ +

+ By default, flyouts will continue to grow with the width of the + window. To stop this growth at an ideal width, set{' '} + maxWidth to true, or pass your + own custom size. +

+ +
), snippet: flyoutMaxWidthSnippet, demo: , + props: { EuiFlyout }, }, ], }; diff --git a/src-docs/src/views/flyout/flyout_max_width.js b/src-docs/src/views/flyout/flyout_max_width.js index aab2260b11f..1537c1194a1 100644 --- a/src-docs/src/views/flyout/flyout_max_width.js +++ b/src-docs/src/views/flyout/flyout_max_width.js @@ -4,7 +4,7 @@ import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader, - EuiButton, + EuiLink, EuiText, EuiTitle, EuiFieldText, @@ -22,39 +22,52 @@ export class FlyoutMaxWidth extends Component { this.state = { isFlyoutVisible: false, - isSwitchChecked: true, + flyoutSize: 'm', + flyoutMaxWidth: false, }; this.closeFlyout = this.closeFlyout.bind(this); this.showFlyout = this.showFlyout.bind(this); } - onSwitchChange = () => { - this.setState({ - isSwitchChecked: !this.state.isSwitchChecked, - }); - }; - closeFlyout() { this.setState({ isFlyoutVisible: false }); } - showFlyout() { - this.setState({ isFlyoutVisible: true }); - } + showFlyout = (size = 'm', maxWidth = false) => { + this.setState({ + flyoutSize: size, + flyoutMaxWidth: maxWidth, + isFlyoutVisible: true, + }); + }; render() { let flyout; if (this.state.isFlyoutVisible) { + let maxWidthTitle; + switch (this.state.flyoutMaxWidth) { + case true: + maxWidthTitle = 'Default'; + break; + case false: + maxWidthTitle = 'No'; + break; + default: + maxWidthTitle = `${this.state.flyoutMaxWidth}px`; + break; + } + flyout = ( + size={this.state.flyoutSize} + maxWidth={this.state.flyoutMaxWidth}> -

448px wide flyout

+

{maxWidthTitle} maxWidth

@@ -101,7 +114,77 @@ export class FlyoutMaxWidth extends Component { return (
- Show max-width flyout + this.showFlyout('s')}> + Show small flyout with no max-width + + + this.showFlyout('s', true)}> + Show small flyout with{' '} + default max-width + + + this.showFlyout('s', 200)}> + Show small flyout with{' '} + smaller custom max-width -- minWidth wins except for + on small screens + + + this.showFlyout('s', 448)}> + Show small flyout with{' '} + larger custom max-width -- minWidth wins except for + on small screens + + + + + this.showFlyout('m')}> + Show medium flyout with no max-width + + + this.showFlyout('m', true)}> + Show medium flyout with{' '} + default max-width + + + this.showFlyout('m', 448)}> + Show medium flyout with{' '} + smaller custom max-width -- minWidth wins and full + 100vw wins on small screens + + + this.showFlyout('m', 900)}> + Show medium flyout with{' '} + larger custom max-width + + + + + this.showFlyout('l')}> + Show large flyout with no max-width + + + this.showFlyout('l', true)}> + Show large flyout with{' '} + default max-width + + + this.showFlyout('l', 448)}> + Show large flyout with{' '} + smaller custom max-width -- minWidth wins and full + 100vw wins on small screens + + + this.showFlyout('l', 1600)}> + Show large flyout with{' '} + larger custom max-width + + + + + this.showFlyout('m', 0)}> + Trick for forms: Medium flyout with{' '} + 0 as max-width + {flyout}
diff --git a/src-docs/src/views/not_found/not_found_view.js b/src-docs/src/views/not_found/not_found_view.js index d9400e71eb3..d17729d6477 100644 --- a/src-docs/src/views/not_found/not_found_view.js +++ b/src-docs/src/views/not_found/not_found_view.js @@ -1,26 +1,27 @@ import React from 'react'; import { Link } from 'react-router'; +import { EuiText } from '../../../../src/components/text'; export const NotFoundView = () => (
-

- Wow, a 404! You just created something from nothing. -

+ +

404

-

- You visited a page which doesn’t exist, causing this page - to exist. This page thanks you for summoning it into existence from the - raw fabric of reality, but it thinks you may find another page more - interesting. Might it suggest the{' '} - { - - home page - - } - ? -

+

+ You visited a page which doesn’t exist, causing this{' '} + page to exist. This page thanks you for summoning it into existence + from the raw fabric of reality, but it thinks you may find another + page more interesting. Might it suggest the{' '} + { + + home page + + } + ? +

+
); diff --git a/src/components/flyout/_flyout.scss b/src/components/flyout/_flyout.scss index 226c6f6a741..cda11c8a26b 100644 --- a/src/components/flyout/_flyout.scss +++ b/src/components/flyout/_flyout.scss @@ -1,3 +1,5 @@ +@import '../form/variables'; + .euiFlyout { border-left: $euiBorderThin; // The mixin augments the above @@ -31,17 +33,18 @@ */ $flyoutSizes: ( 'small': ( - min: map-get($euiBreakpoints, 'm') * .5, /* 1 */ + min: round(map-get($euiBreakpoints, 'm') * .5), /* 1 */ width: 25vw, - max: map-get($euiBreakpoints, 's'), + max: round(map-get($euiBreakpoints, 's') * .7), ), 'medium': ( - min: map-get($euiBreakpoints, 'm') * .7, /* 1 */ + // Calculated for forms plus padding + min: $euiFormMaxWidth + ($euiSizeM * 2), width: 50vw, max: map-get($euiBreakpoints, 'm'), ), 'large': ( - min: map-get($euiBreakpoints, 'm') * .9, /* 1 */ + min: round(map-get($euiBreakpoints, 'm') * .9), /* 1 */ width: 75vw, max: map-get($euiBreakpoints, 'l'), ) @@ -85,8 +88,8 @@ $flyoutSizes: ( } .euiFlyout--small { - width: 80vw; // ensure that it's only partially showing the main content + width: 90vw; // ensure that it's only partially showing the main content min-width: 0; /* 1 */ - max-width: 80vw !important; /* 2 */ + max-width: map-get(map-get($flyoutSizes, 'small'), 'max'); } } diff --git a/src/components/flyout/flyout.js b/src/components/flyout/flyout.js index 96da9206d38..17f3e88b43a 100644 --- a/src/components/flyout/flyout.js +++ b/src/components/flyout/flyout.js @@ -123,8 +123,8 @@ EuiFlyout.propTypes = { * Sets the max-width of the page, * set to `true` to use the default size, * set to `false` to not restrict the width, - * set to a number for a custom width in px, - * set to a string for a custom width in custom measurement. + * set to a `number` for a custom width in `px`, + * set to a `string` for a custom width in a custom measurement. */ maxWidth: PropTypes.oneOfType([ PropTypes.bool,