diff --git a/src-docs/src/components/guide_section/guide_section.tsx b/src-docs/src/components/guide_section/guide_section.tsx
index 6a1ea6407a1..2e479d14013 100644
--- a/src-docs/src/components/guide_section/guide_section.tsx
+++ b/src-docs/src/components/guide_section/guide_section.tsx
@@ -185,6 +185,7 @@ export const GuideSection: FunctionComponent = ({
config,
setGhostBackground,
playgroundClassName,
+ playgroundCssStyles,
playgroundPanelProps,
} = playground();
@@ -192,6 +193,7 @@ export const GuideSection: FunctionComponent = ({
config,
setGhostBackground,
playgroundClassName,
+ playgroundCssStyles,
playgroundPanelProps,
playgroundToggle: renderPlaygroundToggle(),
tabs: renderTabs(),
diff --git a/src-docs/src/services/playground/playground.js b/src-docs/src/services/playground/playground.js
index 2f12d0d623e..4422d135181 100644
--- a/src-docs/src/services/playground/playground.js
+++ b/src-docs/src/services/playground/playground.js
@@ -9,7 +9,8 @@ import {
EuiFlyoutBody,
EuiFlyoutHeader,
EuiPanel,
-} from '../../../../src/components';
+ useEuiTheme,
+} from '../../../../src';
import Knobs from './knobs';
import { GuideSectionPropsDescription } from '../../components/guide_section/guide_section_parts/guide_section_props_description';
@@ -17,6 +18,7 @@ export default ({
config,
setGhostBackground,
playgroundClassName,
+ playgroundCssStyles,
playgroundPanelProps,
}) => {
const getSnippet = (code) => {
@@ -50,6 +52,7 @@ export default ({
};
const Playground = () => {
+ const euiTheme = useEuiTheme();
const [isGhost, setGhost] = useState(false);
const params = useView(config);
@@ -87,6 +90,7 @@ export default ({
diff --git a/src-docs/src/views/_index.scss b/src-docs/src/views/_index.scss
index d2d7e586ba0..1648b306b84 100644
--- a/src-docs/src/views/_index.scss
+++ b/src-docs/src/views/_index.scss
@@ -7,7 +7,6 @@ $guideDemoHighlightColor: transparentize($euiColorPrimary, .9);
@import './date_picker/date_picker';
@import './elastic_charts/index';
@import './empty_prompt/empty_prompt';
-@import './flex/flex';
@import './horizontal_rule/horizontal_rule';
@import './page_template/page';
@import './notification_event/notification_event';
diff --git a/src-docs/src/views/flex/_flex.scss b/src-docs/src/views/flex/_flex.scss
deleted file mode 100644
index ef069da0157..00000000000
--- a/src-docs/src/views/flex/_flex.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-.guideDemo__highlightGrid .euiFlexItem,
-.guideDemo__highlightGridWrap .euiFlexItem div {
- background: $guideDemoHighlightColor;
- padding: $euiSize;
-}
diff --git a/src-docs/src/views/flex/component_span.tsx b/src-docs/src/views/flex/component_span.tsx
index 878ee751e71..078a000f685 100644
--- a/src-docs/src/views/flex/component_span.tsx
+++ b/src-docs/src/views/flex/component_span.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
+import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/direction.tsx b/src-docs/src/views/flex/direction.tsx
index 663b50a36e0..3d98a36135f 100644
--- a/src-docs/src/views/flex/direction.tsx
+++ b/src-docs/src/views/flex/direction.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
+import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/flex_align_center.js b/src-docs/src/views/flex/flex_align_center.tsx
similarity index 100%
rename from src-docs/src/views/flex/flex_align_center.js
rename to src-docs/src/views/flex/flex_align_center.tsx
diff --git a/src-docs/src/views/flex/flex_example.js b/src-docs/src/views/flex/flex_example.js
index c99fe92a0a2..30dbde0c4ec 100644
--- a/src-docs/src/views/flex/flex_example.js
+++ b/src-docs/src/views/flex/flex_example.js
@@ -15,6 +15,8 @@ import {
import { flexGroupConfig, flexGridConfig } from './playground';
+import { FlexItemHighlightWrapper } from './wrapper_styles';
+
import FlexGroup from './flex_group';
const flexGroupSource = require('!!raw-loader!./flex_group');
@@ -54,6 +56,9 @@ const flexGridColumnsSource = require('!!raw-loader!./flex_grid_columns');
import FlexGridColumnFirst from './flex_grid_column_first';
const flexGridColumnFirstSource = require('!!raw-loader!./flex_grid_column_first');
+import FlexGridResponsive from './flex_grid_responsive';
+const flexGridResponsiveSource = require('!!raw-loader!./flex_grid_responsive');
+
import FlexNest from './flex_nest';
const flexNestSource = require('!!raw-loader!./flex_nest');
@@ -126,6 +131,15 @@ const flexGridColumnFirstSnippet = `
`;
+const flexGridResponsiveSnippet = `
+
+
+
+
+
+
+ `;
+
const flexNestSnippet = `
@@ -183,9 +197,9 @@ export const FlexExample = {
),
demo: (
-
+
-
+
),
playground: flexGroupConfig,
props: { EuiFlexGroup, EuiFlexItem },
@@ -226,9 +240,9 @@ export const FlexExample = {
`,
demo: (
-
+
-
+
),
},
{
@@ -248,9 +262,9 @@ export const FlexExample = {
),
snippet: componentSpanSnippet,
demo: (
-
+
-
+
),
},
{
@@ -290,9 +304,9 @@ export const FlexExample = {
),
snippet: flexGrowZeroSnippet,
demo: (
-
+
-
+
),
},
{
@@ -312,9 +326,9 @@ export const FlexExample = {
),
snippet: flexGrowNumericSnippet,
demo: (
-
+
-
+
),
},
{
@@ -343,9 +357,9 @@ export const FlexExample = {
`,
demo: (
-
+
-
+
),
},
{
@@ -365,9 +379,9 @@ export const FlexExample = {
),
snippet: flexGroupWrap,
demo: (
-
+
-
+
),
},
{
@@ -378,9 +392,9 @@ export const FlexExample = {
},
],
demo: (
-
+
-
+
),
snippet: `
@@ -395,9 +409,9 @@ export const FlexExample = {
},
],
demo: (
-
+
-
+
),
snippet: `
@@ -412,9 +426,9 @@ export const FlexExample = {
},
],
demo: (
-
+
-
+
),
snippet: `
@@ -436,9 +450,33 @@ export const FlexExample = {
),
snippet: directionSnippet,
demo: (
-
+
-
+
+ ),
+ },
+ {
+ title: 'Responsive flex groups',
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: flexGroupResponsiveSource,
+ },
+ ],
+ text: (
+
+ By default EuiFlexGroup is responsive by always
+ stacking the items on smaller screens. However, often you only want to
+ use groups for alignment and margins, rather than layouts. Simply
+ apply the responsive={'{false}'} prop to retain a
+ single row layout for the group.
+
+ ),
+ snippet: flexGroupResponsiveSnippet,
+ demo: (
+
+
+
),
},
{
@@ -461,9 +499,9 @@ export const FlexExample = {
playground: flexGridConfig,
snippet: flexGridColumnsSnippet,
demo: (
-
+
-
+
),
},
@@ -484,9 +522,34 @@ export const FlexExample = {
),
snippet: flexGridColumnFirstSnippet,
demo: (
-
+
-
+
+ ),
+ },
+ {
+ title: 'Responsive flex grids',
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: flexGridResponsiveSource,
+ },
+ ],
+ text: (
+
+ EuiFlexGrid is also similarly responsive by default,
+ responsive by always stacking the items vertically on smaller screens.
+ However, should you want to customize the number of items on small or
+ large screens, we recommend applying the{' '}
+ responsive={'{false}'} prop and then conditionally
+ pass a column number based on the current breakpoint.
+
+ ),
+ snippet: flexGridResponsiveSnippet,
+ demo: (
+
+
+
),
},
{
@@ -518,9 +581,9 @@ export const FlexExample = {
),
snippet: flexNestSnippet,
demo: (
-
+
-
+
),
},
{
@@ -531,54 +594,18 @@ export const FlexExample = {
code: flexGutterSource,
},
],
- text: (
- <>
-
- The gutterSize prop can be applied to either a{' '}
- EuiFlexGroup or a EuiFlexGrid to
- adjust the spacing between EuiFlexItems .
-
-
-
- If the parent container of a flex group or grid doesn't have
- sufficient padding to account for the negative margins, it may
- cause overflow scrolling.
-
-
- >
- ),
- snippet: flexGutterSnippet,
- demo: (
-
-
-
- ),
- },
- {
- title: 'Responsive layouts',
- source: [
- {
- type: GuideSectionTypes.JS,
- code: flexGroupResponsiveSource,
- },
- ],
text: (
- By default EuiFlexGroup is responsive by always
- stacking the items on smaller screens. However, often you only want to
- use groups for alignment and margins, rather than layouts. Simply
- apply the responsive={'{false}'} prop to retain a
- single row layout for the group.
+ The gutterSize prop can be applied to either a{' '}
+ EuiFlexGroup or a EuiFlexGrid to
+ adjust the spacing between EuiFlexItems .
),
- snippet: flexGroupResponsiveSnippet,
+ snippet: flexGutterSnippet,
demo: (
-
-
-
+
+
+
),
},
],
diff --git a/src-docs/src/views/flex/flex_grid_column_first.tsx b/src-docs/src/views/flex/flex_grid_column_first.tsx
index 2960e0958fc..9a962b0dcff 100644
--- a/src-docs/src/views/flex/flex_grid_column_first.tsx
+++ b/src-docs/src/views/flex/flex_grid_column_first.tsx
@@ -1,31 +1,15 @@
import React from 'react';
-import { EuiFlexGrid, EuiFlexItem } from '../../../../src/components/flex';
+import { EuiFlexGrid, EuiFlexItem } from '../../../../src/components';
export default () => (
-
-
-
- One
-
-
- Two
-
-
- Three
-
-
- Four
-
-
- Five
-
-
- Six
-
-
- Seven
-
-
-
+
+ One
+ Two
+ Three
+ Four
+ Five
+ Six
+ Seven
+
);
diff --git a/src-docs/src/views/flex/flex_grid_columns.tsx b/src-docs/src/views/flex/flex_grid_columns.tsx
index 349b1644f33..f29f8ec1012 100644
--- a/src-docs/src/views/flex/flex_grid_columns.tsx
+++ b/src-docs/src/views/flex/flex_grid_columns.tsx
@@ -1,31 +1,15 @@
import React from 'react';
-import { EuiFlexGrid, EuiFlexItem } from '../../../../src/components/flex';
+import { EuiFlexGrid, EuiFlexItem } from '../../../../src/components';
export default () => (
-
-
-
- One
-
-
- Two
-
-
- Three
-
-
- Four
-
-
- Five
-
-
- Six
-
-
- Seven
-
-
-
+
+ One
+ Two
+ Three
+ Four
+ Five
+ Six
+ Seven
+
);
diff --git a/src-docs/src/views/flex/flex_grid_responsive.tsx b/src-docs/src/views/flex/flex_grid_responsive.tsx
new file mode 100644
index 00000000000..b4f6e71e4f2
--- /dev/null
+++ b/src-docs/src/views/flex/flex_grid_responsive.tsx
@@ -0,0 +1,21 @@
+import React from 'react';
+import {
+ EuiFlexGrid,
+ EuiFlexItem,
+ useIsWithinBreakpoints,
+} from '../../../../src';
+
+export default () => {
+ const isMobile = useIsWithinBreakpoints(['xs', 's']);
+
+ return (
+
+ One
+ Two
+ Three
+ Four
+ Five
+ Six
+
+ );
+};
diff --git a/src-docs/src/views/flex/flex_group.tsx b/src-docs/src/views/flex/flex_group.tsx
index df45792d634..4293c7a7508 100644
--- a/src-docs/src/views/flex/flex_group.tsx
+++ b/src-docs/src/views/flex/flex_group.tsx
@@ -1,7 +1,10 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
-import { EuiSpacer } from '../../../../src/components/spacer';
+import {
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+} from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/flex_group_wrap.tsx b/src-docs/src/views/flex/flex_group_wrap.tsx
index 7c71a96a43a..f3889e41199 100644
--- a/src-docs/src/views/flex/flex_group_wrap.tsx
+++ b/src-docs/src/views/flex/flex_group_wrap.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
+import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/flex_grow_numeric.tsx b/src-docs/src/views/flex/flex_grow_numeric.tsx
index 143e959694b..59e291af0d9 100644
--- a/src-docs/src/views/flex/flex_grow_numeric.tsx
+++ b/src-docs/src/views/flex/flex_grow_numeric.tsx
@@ -1,7 +1,10 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
-import { EuiSpacer } from '../../../../src/components/spacer';
+import {
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+} from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/flex_grow_zero.tsx b/src-docs/src/views/flex/flex_grow_zero.tsx
index abb3e6b5008..86686de1d45 100644
--- a/src-docs/src/views/flex/flex_grow_zero.tsx
+++ b/src-docs/src/views/flex/flex_grow_zero.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
+import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/flex_gutter.tsx b/src-docs/src/views/flex/flex_gutter.tsx
index ccaf2ba83ed..27035f34bd3 100644
--- a/src-docs/src/views/flex/flex_gutter.tsx
+++ b/src-docs/src/views/flex/flex_gutter.tsx
@@ -1,7 +1,10 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
-import { EuiSpacer } from '../../../../src/components/spacer';
+import {
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+} from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/flex_item.tsx b/src-docs/src/views/flex/flex_item.tsx
index 8aff4ff0d1e..62854063d2a 100644
--- a/src-docs/src/views/flex/flex_item.tsx
+++ b/src-docs/src/views/flex/flex_item.tsx
@@ -1,6 +1,9 @@
import React from 'react';
-import { EuiButton } from '../../../../src/components/button';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
+import {
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiButton,
+} from '../../../../src/components';
export default () => (
diff --git a/src-docs/src/views/flex/flex_item_panel.js b/src-docs/src/views/flex/flex_item_panel.tsx
similarity index 100%
rename from src-docs/src/views/flex/flex_item_panel.js
rename to src-docs/src/views/flex/flex_item_panel.tsx
diff --git a/src-docs/src/views/flex/flex_justify.js b/src-docs/src/views/flex/flex_justify.tsx
similarity index 100%
rename from src-docs/src/views/flex/flex_justify.js
rename to src-docs/src/views/flex/flex_justify.tsx
diff --git a/src-docs/src/views/flex/flex_justify_between.js b/src-docs/src/views/flex/flex_justify_between.tsx
similarity index 100%
rename from src-docs/src/views/flex/flex_justify_between.js
rename to src-docs/src/views/flex/flex_justify_between.tsx
diff --git a/src-docs/src/views/flex/flex_justify_evenly.js b/src-docs/src/views/flex/flex_justify_evenly.tsx
similarity index 100%
rename from src-docs/src/views/flex/flex_justify_evenly.js
rename to src-docs/src/views/flex/flex_justify_evenly.tsx
diff --git a/src-docs/src/views/flex/flex_nest.tsx b/src-docs/src/views/flex/flex_nest.tsx
index bba6715afe8..44564f2b45c 100644
--- a/src-docs/src/views/flex/flex_nest.tsx
+++ b/src-docs/src/views/flex/flex_nest.tsx
@@ -4,11 +4,11 @@ import {
EuiFlexGrid,
EuiFlexGroup,
EuiFlexItem,
-} from '../../../../src/components/flex';
-import { EuiSpacer } from '../../../../src/components/spacer';
+ EuiSpacer,
+} from '../../../../src/components';
export default () => (
-
+ <>
Flex Group
@@ -29,5 +29,5 @@ export default () => (
-
+ >
);
diff --git a/src-docs/src/views/flex/flex_responsive.tsx b/src-docs/src/views/flex/flex_responsive.tsx
index 52ef66133bb..02c764926bf 100644
--- a/src-docs/src/views/flex/flex_responsive.tsx
+++ b/src-docs/src/views/flex/flex_responsive.tsx
@@ -1,10 +1,13 @@
import React from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
-import { EuiSpacer } from '../../../../src/components/spacer';
-import { EuiIcon } from '../../../../src/components/icon';
+import {
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+ EuiIcon,
+} from '../../../../src/components';
export default () => (
-
+ <>
@@ -24,5 +27,5 @@ export default () => (
On mobile, the icon will stay to the left of this text.
-
+ >
);
diff --git a/src-docs/src/views/flex/playground.js b/src-docs/src/views/flex/playground.js
index c69dee8c1e6..7d9443c9f35 100644
--- a/src-docs/src/views/flex/playground.js
+++ b/src-docs/src/views/flex/playground.js
@@ -6,6 +6,8 @@ import {
} from '../../../../src/components/';
import { propUtilityForPlayground } from '../../services/playground';
+import { flexItemHiglightStyles } from './wrapper_styles';
+
export const flexGroupConfig = () => {
const docgenInfo = Array.isArray(EuiFlexGroup.__docgenInfo)
? EuiFlexGroup.__docgenInfo[0]
@@ -42,7 +44,7 @@ export const flexGroupConfig = () => {
},
},
},
- playgroundClassName: 'guideDemo__highlightGrid',
+ playgroundCssStyles: flexItemHiglightStyles,
};
};
@@ -84,6 +86,6 @@ export const flexGridConfig = () => {
},
},
},
- playgroundClassName: 'guideDemo__highlightGrid',
+ playgroundCssStyles: flexItemHiglightStyles,
};
};
diff --git a/src-docs/src/views/flex/wrapper_styles.tsx b/src-docs/src/views/flex/wrapper_styles.tsx
new file mode 100644
index 00000000000..c5ca6efc815
--- /dev/null
+++ b/src-docs/src/views/flex/wrapper_styles.tsx
@@ -0,0 +1,24 @@
+import React from 'react';
+import { css } from '@emotion/react';
+import {
+ useEuiTheme,
+ UseEuiTheme,
+ transparentize,
+} from '../../../../src/services';
+
+export const flexItemHiglightStyles = ({ euiTheme }: UseEuiTheme) => {
+ // TODO: DRY this out when removing $guideDemoHighlightColor / all src-docs Sass
+ const guideDemoHighlightColor = transparentize(euiTheme.colors.primary, 0.1);
+
+ return css`
+ .euiFlexItem {
+ background: ${guideDemoHighlightColor};
+ padding: ${euiTheme.size.base};
+ }
+ `;
+};
+
+export const FlexItemHighlightWrapper: React.FC = ({ children }) => {
+ const euiTheme = useEuiTheme();
+ return {children}
;
+};
diff --git a/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap b/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap
index 8256fdeda7a..907f7e46a2b 100644
--- a/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap
+++ b/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap
@@ -1412,10 +1412,10 @@ exports[`EuiBasicTable with initial selection 1`] = `
class="euiTableHeaderMobile"
>
diff --git a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
index 6d70ca75102..efec1cda816 100644
--- a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
+++ b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
@@ -11,13 +11,13 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
class="euiTableHeaderMobile"
>
@@ -108,10 +108,10 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
class="euiSpacer euiSpacer--m emotion-euiSpacer-m"
/>
@@ -759,10 +759,10 @@ exports[`EuiInMemoryTable with pagination and "show all" page size 1`] = `
class="euiSpacer euiSpacer--m emotion-euiSpacer-m"
/>
diff --git a/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap b/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap
index 3c08b541045..e489a2eb575 100644
--- a/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap
+++ b/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap
@@ -39,10 +39,10 @@ exports[`EuiCollapsibleNavGroup props iconProps renders data-test-subj 1`] = `
class="euiCollapsibleNavGroup__heading"
>