diff --git a/src-docs/src/views/flyout/flyout_example.js b/src-docs/src/views/flyout/flyout_example.js index 550c29cf22c..d6e42bea87d 100644 --- a/src-docs/src/views/flyout/flyout_example.js +++ b/src-docs/src/views/flyout/flyout_example.js @@ -29,6 +29,10 @@ import FlyoutLarge from './flyout_large'; const flyoutLargeSource = require('!!raw-loader!./flyout_large'); const flyoutLargeHtml = renderToHtml(FlyoutLarge); +import FlyoutPaddingMedium from './flyout_padding_medium'; +const FlyoutPaddingMediumSource = require('!!raw-loader!./flyout_padding_medium'); +const FlyoutPaddingMediumHtml = renderToHtml(FlyoutPaddingMedium); + import FlyoutMaxWidth from './flyout_max_width'; const flyoutMaxWidthSource = require('!!raw-loader!./flyout_max_width'); const flyoutMaxWidthHtml = renderToHtml(FlyoutMaxWidth); @@ -79,6 +83,20 @@ const flyoutSmallSnippet = ` `; +const flyoutMediumPaddingSnippet = ` + + +

+ +

+
+
+ + + +
+`; + const flyoutMaxWidthSnippet = ` @@ -245,6 +263,32 @@ export const FlyoutExample = { snippet: flyoutLargeSnippet, demo: , }, + { + title: 'Flyout padding', + source: [ + { + type: GuideSectionTypes.JS, + code: FlyoutPaddingMediumSource, + }, + { + type: GuideSectionTypes.HTML, + code: FlyoutPaddingMediumHtml, + }, + ], + text: ( +

+ All the inner flyout components inherit their{' '} + padding from the wrapping{' '} + EuiFlyout component. This ensures that all the + horizontal edges line up no matter the paddingSize. + When using the {'"none"'} size, you will need to + accomodate your content with some other way of creating distance to + the edges of the flyout. +

+ ), + snippet: flyoutMediumPaddingSnippet, + demo: , + }, { title: 'Max width', source: [ diff --git a/src-docs/src/views/flyout/flyout_padding_medium.js b/src-docs/src/views/flyout/flyout_padding_medium.js new file mode 100644 index 00000000000..5739ccc26ba --- /dev/null +++ b/src-docs/src/views/flyout/flyout_padding_medium.js @@ -0,0 +1,119 @@ +import React, { useState } from 'react'; + +import { + EuiButtonEmpty, + EuiCallOut, + EuiFlexGroup, + EuiFlexItem, + EuiFlyout, + EuiFlyoutHeader, + EuiFlyoutBody, + EuiFlyoutFooter, + EuiButtonGroup, + EuiButton, + EuiFormRow, + EuiTitle, +} from '../../../../src/components'; + +export default () => { + const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); + const [paddingSize, setPaddingSize] = useState('l'); + const [paddingSizeName, setPaddingSizeName] = useState('large'); + + const sizes = [ + { + id: 'none', + label: 'None', + }, + { + id: 's', + label: 'Small', + }, + { + id: 'm', + label: 'Medium', + }, + { + id: 'l', + label: 'Large', + }, + ]; + + const closeFlyout = () => setIsFlyoutVisible(false); + + const showFlyout = () => setIsFlyoutVisible(true); + + const callOut = ( + + ); + + let flyout; + if (isFlyoutVisible) { + flyout = ( + + + +

+ A flyout with a {paddingSizeName} padding +

+
+
+ + + { + const newName = sizes + .find((size) => size.id === id) + .label.toLowerCase(); + setPaddingSize(id); + setPaddingSizeName(newName); + }} + /> + + + + + + + Close + + + + + Save + + + + +
+ ); + } + return ( + <> + + Show flyout to test padding sizes + + {flyout} + + ); +}; diff --git a/src/components/flyout/__snapshots__/flyout.test.tsx.snap b/src/components/flyout/__snapshots__/flyout.test.tsx.snap index 5b527d18e08..871ce19ff98 100644 --- a/src/components/flyout/__snapshots__/flyout.test.tsx.snap +++ b/src/components/flyout/__snapshots__/flyout.test.tsx.snap @@ -17,7 +17,7 @@ Array [ >