Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src-docs/src/components/guide_section/guide_section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,15 @@ export const GuideSection: FunctionComponent<GuideSectionProps> = ({
config,
setGhostBackground,
playgroundClassName,
playgroundCssStyles,
playgroundPanelProps,
} = playground();

return playgroundService({
config,
setGhostBackground,
playgroundClassName,
playgroundCssStyles,
playgroundPanelProps,
playgroundToggle: renderPlaygroundToggle(),
tabs: renderTabs(),
Expand Down
6 changes: 5 additions & 1 deletion src-docs/src/services/playground/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ 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';

export default ({
config,
setGhostBackground,
playgroundClassName,
playgroundCssStyles,
playgroundPanelProps,
}) => {
const getSnippet = (code) => {
Expand Down Expand Up @@ -50,6 +52,7 @@ export default ({
};

const Playground = () => {
const euiTheme = useEuiTheme();
const [isGhost, setGhost] = useState(false);
const params = useView(config);

Expand Down Expand Up @@ -87,6 +90,7 @@ export default ({
<Compiler
{...params.compilerProps}
placeholder={Placeholder}
css={playgroundCssStyles?.(euiTheme)}
className={classNames('playground__demo', playgroundClassName)}
/>
</EuiPanel>
Expand Down
1 change: 0 additions & 1 deletion src-docs/src/views/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 0 additions & 5 deletions src-docs/src/views/flex/_flex.scss

This file was deleted.

2 changes: 1 addition & 1 deletion src-docs/src/views/flex/component_span.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components';

export default () => (
<button>
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/flex/direction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components';

export default () => (
<EuiFlexGroup direction="column">
Expand Down
169 changes: 98 additions & 71 deletions src-docs/src/views/flex/flex_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -126,6 +131,15 @@ const flexGridColumnFirstSnippet = `<EuiFlexGrid columns={2} direction="column">
</EuiFlexItem>
</EuiFlexGrid>`;

const flexGridResponsiveSnippet = `<EuiFlexGrid responsive={false} columns={isMobile ? 2 : 4}>
<EuiFlexItem>
<!-- Item in FlexGrid-->
</EuiFlexItem>
<EuiFlexItem>
<!-- Item in FlexGrid-->
</EuiFlexItem>
</EuiFlexGrid>`;

const flexNestSnippet = `<EuiFlexGroup>
<EuiFlexItem>
<EuiFlexGroup>
Expand Down Expand Up @@ -183,9 +197,9 @@ export const FlexExample = {
</p>
),
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexGroup />
</div>
</FlexItemHighlightWrapper>
),
playground: flexGroupConfig,
props: { EuiFlexGroup, EuiFlexItem },
Expand Down Expand Up @@ -226,9 +240,9 @@ export const FlexExample = {
</EuiFlexItem>
</EuiFlexGroup>`,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexItem />
</div>
</FlexItemHighlightWrapper>
),
},
{
Expand All @@ -248,9 +262,9 @@ export const FlexExample = {
),
snippet: componentSpanSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<ComponentSpan />
</div>
</FlexItemHighlightWrapper>
),
},
{
Expand Down Expand Up @@ -290,9 +304,9 @@ export const FlexExample = {
),
snippet: flexGrowZeroSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexGrowZero />
</div>
</FlexItemHighlightWrapper>
),
},
{
Expand All @@ -312,9 +326,9 @@ export const FlexExample = {
),
snippet: flexGrowNumericSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexGrowNumeric />
</div>
</FlexItemHighlightWrapper>
),
},
{
Expand Down Expand Up @@ -343,9 +357,9 @@ export const FlexExample = {
<EuiFlexItem grow={false}><!-- FlexItem content --></EuiFlexItem>
</EuiFlexGroup>`,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexJustify />
</div>
</FlexItemHighlightWrapper>
),
},
{
Expand All @@ -365,9 +379,9 @@ export const FlexExample = {
),
snippet: flexGroupWrap,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexGroupWrap />
</div>
</FlexItemHighlightWrapper>
),
},
{
Expand All @@ -378,9 +392,9 @@ export const FlexExample = {
},
],
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexJustifyBetween />
</div>
</FlexItemHighlightWrapper>
),
snippet: `<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}><!-- FlexItem content --></EuiFlexItem>
Expand All @@ -395,9 +409,9 @@ export const FlexExample = {
},
],
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexJustifyEvenly />
</div>
</FlexItemHighlightWrapper>
),
snippet: `<EuiFlexGroup justifyContent="spaceEvenly">
<EuiFlexItem grow={false}><!-- FlexItem content --></EuiFlexItem>
Expand All @@ -412,9 +426,9 @@ export const FlexExample = {
},
],
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexAlignCenter />
</div>
</FlexItemHighlightWrapper>
),
snippet: `<EuiFlexGroup alignItems="center">
<EuiFlexItem><!-- FlexItem content --></EuiFlexItem>
Expand All @@ -436,9 +450,33 @@ export const FlexExample = {
),
snippet: directionSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<Direction />
</div>
</FlexItemHighlightWrapper>
),
},
{
title: 'Responsive flex groups',
source: [
{
type: GuideSectionTypes.JS,
code: flexGroupResponsiveSource,
},
],
text: (
<p>
By default <strong>EuiFlexGroup</strong> 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 <EuiCode>responsive={'{false}'}</EuiCode> prop to retain a
single row layout for the group.
</p>
),
snippet: flexGroupResponsiveSnippet,
demo: (
<FlexItemHighlightWrapper>
<FlexGroupResponsive />
</FlexItemHighlightWrapper>
),
},
{
Expand All @@ -461,9 +499,9 @@ export const FlexExample = {
playground: flexGridConfig,
snippet: flexGridColumnsSnippet,
demo: (
<div className="guideDemo__highlightGridWrap">
<FlexItemHighlightWrapper>
<FlexGridColumns />
</div>
</FlexItemHighlightWrapper>
),
},

Expand All @@ -484,9 +522,34 @@ export const FlexExample = {
),
snippet: flexGridColumnFirstSnippet,
demo: (
<div className="guideDemo__highlightGridWrap">
<FlexItemHighlightWrapper>
<FlexGridColumnFirst />
</div>
</FlexItemHighlightWrapper>
),
},
{
title: 'Responsive flex grids',
source: [
{
type: GuideSectionTypes.JS,
code: flexGridResponsiveSource,
},
],
text: (
<p>
<strong>EuiFlexGrid</strong> 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{' '}
<EuiCode>responsive={'{false}'}</EuiCode> prop and then conditionally
pass a column number based on the current breakpoint.
</p>
),
snippet: flexGridResponsiveSnippet,
demo: (
<FlexItemHighlightWrapper>
<FlexGridResponsive />
</FlexItemHighlightWrapper>
),
},
{
Expand Down Expand Up @@ -518,9 +581,9 @@ export const FlexExample = {
),
snippet: flexNestSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexItemHighlightWrapper>
<FlexNest />
</div>
</FlexItemHighlightWrapper>
),
},
{
Expand All @@ -531,54 +594,18 @@ export const FlexExample = {
code: flexGutterSource,
},
],
text: (
<>
<p>
The <EuiCode>gutterSize</EuiCode> prop can be applied to either a{' '}
<strong>EuiFlexGroup</strong> or a <strong>EuiFlexGrid</strong> to
adjust the spacing between <strong>EuiFlexItems</strong>.
</p>
<EuiCallOut
color="warning"
title="Gutters are created with using negative margin"
>
<p>
If the parent container of a flex group or grid doesn&apos;t have
sufficient padding to account for the negative margins, it may
cause overflow scrolling.
</p>
</EuiCallOut>
</>
),
snippet: flexGutterSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexGutter />
</div>
),
},
{
title: 'Responsive layouts',
source: [
{
type: GuideSectionTypes.JS,
code: flexGroupResponsiveSource,
},
],
text: (
<p>
By default <strong>EuiFlexGroup</strong> 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 <EuiCode>responsive={'{false}'}</EuiCode> prop to retain a
single row layout for the group.
The <EuiCode>gutterSize</EuiCode> prop can be applied to either a{' '}
<strong>EuiFlexGroup</strong> or a <strong>EuiFlexGrid</strong> to
adjust the spacing between <strong>EuiFlexItems</strong>.
</p>
),
snippet: flexGroupResponsiveSnippet,
snippet: flexGutterSnippet,
demo: (
<div className="guideDemo__highlightGrid">
<FlexGroupResponsive />
</div>
<FlexItemHighlightWrapper>
<FlexGutter />
</FlexItemHighlightWrapper>
),
},
],
Expand Down
Loading