Skip to content

Commit

Permalink
New icons, new sizes for EmptyButton and HRs, un-responsive FlexGroups (
Browse files Browse the repository at this point in the history
#126)

* Adds a few new icons.
* Adds `xs` size to our empty buttons (I don't want this applied to regular buttons, which is why I didn't add it there).
* Adds `xs` margin to horizontal rules.
* Adds a responsive prop to `EuiFlexGroup` which disables responsiveness (useful when you use flexgroup more for alignment rather than gridding). Added the prop to a few places that make sense.
  • Loading branch information
snide authored Nov 8, 2017
1 parent 22afbed commit b0e113b
Show file tree
Hide file tree
Showing 23 changed files with 212 additions and 31 deletions.
30 changes: 17 additions & 13 deletions src-docs/src/components/guide_page/guide_page_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import {
EuiSideNav,
EuiIcon,
EuiButtonEmpty,
EuiSideNavItem,
EuiSideNavTitle,
EuiFieldSearch,
Expand Down Expand Up @@ -62,20 +63,22 @@ export class GuidePageChrome extends Component {
);

return (
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexGroup alignItems="center" gutterSize="s" responsive={false}>
<EuiFlexItem grow={false}>
{homeLink}
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiText size="s">
<button
<EuiButtonEmpty
size="xs"
onClick={this.props.onToggleTheme}
className="euiLink"
iconSide="right"
color="text"
iconType="invert"
>
Theme
</button>
</EuiText>
Flip theme
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down Expand Up @@ -163,20 +166,21 @@ export class GuidePageChrome extends Component {
<div>
{this.renderIdentity()}

<EuiSpacer size="m" />

<EuiFieldSearch
placeholder="Search..."
value={this.state.search}
onChange={this.onSearchChange}
/>

<EuiSpacer size="m" />

<EuiSideNav
mobileTitle="Navigate components"
toggleOpenOnMobile={this.toggleOpenOnMobile.bind(this)}
isOpenOnMobile={this.state.isSideNavOpenOnMobile}
>
<EuiFieldSearch
placeholder="Search..."
value={this.state.search}
onChange={this.onSearchChange}
/>

<EuiSpacer size="m" />

<EuiSideNavTitle>
Components
Expand Down
40 changes: 40 additions & 0 deletions src-docs/src/views/button/button_empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export default () => (
small
</EuiButtonEmpty>

&nbsp;&nbsp;

<EuiButtonEmpty
size="xs"
onClick={() => window.alert('Button clicked')}
>
extra small
</EuiButtonEmpty>

<br/><br/>

<EuiButtonEmpty
Expand Down Expand Up @@ -80,6 +89,16 @@ export default () => (
small
</EuiButtonEmpty>

&nbsp;&nbsp;

<EuiButtonEmpty
color="danger"
size="xs"
onClick={() => window.alert('Button clicked')}
>
extra small
</EuiButtonEmpty>

<br/><br/>

<EuiButtonEmpty
Expand Down Expand Up @@ -143,6 +162,16 @@ export default () => (
small
</EuiButtonEmpty>

&nbsp;&nbsp;

<EuiButtonEmpty
color="text"
size="xs"
onClick={() => window.alert('Button clicked')}
>
extra small
</EuiButtonEmpty>

<br/><br/>

<EuiButtonEmpty
Expand Down Expand Up @@ -208,6 +237,17 @@ export default () => (
small
</EuiButtonEmpty>

&nbsp;&nbsp;

<EuiButtonEmpty
color="danger"
size="xs"
onClick={() => window.alert('Button clicked')}
isDisabled
>
extra small
</EuiButtonEmpty>

<br/><br/>

<EuiButtonEmpty
Expand Down
26 changes: 26 additions & 0 deletions src-docs/src/views/flex/flex_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ import FlexItemPanel from './flex_item_panel';
const flexItemPanelSource = require('!!raw-loader!./flex_item_panel');
const flexItemPanelHtml = renderToHtml(FlexItemPanel);

import FlexGroupResponsive from './flex_responsive';
const flexItemResponsiveSource = require('!!raw-loader!./flex_responsive');
const flexItemResonsiveHtml = renderToHtml(FlexGroupResponsive);

export default props => (
<GuidePage title={props.route.name}>
<EuiCallOut
Expand Down Expand Up @@ -253,5 +257,27 @@ export default props => (
<div className="guideDemo__highlightGrid"><FlexGutter /></div>
}
/>

<GuideSection
title="FlexGroups can turn off responsive layouts"
source={[{
type: GuideSectionTypes.JS,
code: flexGutterSource,
}, {
type: GuideSectionTypes.HTML,
code: flexGutterHtml,
}]}
text={
<p>
By default <EuiCode>EuiFlexGroup</EuiCode> is responsive. 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>
}
demo={
<div className="guideDemo__highlightGrid"><FlexGroupResponsive /></div>
}
/>
</GuidePage>
);
24 changes: 24 additions & 0 deletions src-docs/src/views/flex/flex_responsive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';

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

export default () => (
<div>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}><EuiIcon type="faceSad" /></EuiFlexItem>
<EuiFlexItem grow={false}>On mobile, the icon will show above this text.</EuiFlexItem>
</EuiFlexGroup>

<EuiSpacer />

<EuiFlexGroup responsive={false} alignItems="center">
<EuiFlexItem grow={false}><EuiIcon type="faceHappy" /></EuiFlexItem>
<EuiFlexItem grow={false}>On mobile, the icon will stay to the left of this text.</EuiFlexItem>
</EuiFlexGroup>
</div>
);
13 changes: 7 additions & 6 deletions src-docs/src/views/horizontal_rule/horizontal_rule_margin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import {

export default () => (
<div>
<p>Small</p>
<p>xs</p>
<EuiHorizontalRule margin="xs" />
<p>s</p>
<EuiHorizontalRule margin="s" />
<p>Medium</p>
<p>m</p>
<EuiHorizontalRule margin="m" />
<p>Large</p>
<p>l (default)</p>
<EuiHorizontalRule margin="l" />
<p>XLarge</p>
<p>xl</p>
<EuiHorizontalRule margin="xl" />
<p>XXLarge</p>
<p>xxl</p>
<EuiHorizontalRule margin="xxl" />
</div>
);

3 changes: 3 additions & 0 deletions src-docs/src/views/icon/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ const iconTypes = [
'gear',
'grid',
'help',
'invert',
'link',
'list',
'listAdd',
'lock',
'mapMarker',
'minusInCircle',
'node',
'pencil',
'pin',
'plusInCircle',
'search',
'shard',
Expand Down
18 changes: 15 additions & 3 deletions src-docs/src/views/side_nav/side_nav_complicated.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export default class extends Component {
{/* Elasticsearch section */}

<EuiSideNavTitle>
<EuiFlexGroup gutterSize="s" alignItems="center">
<EuiFlexGroup
gutterSize="s"
alignItems="center"
responsive={false}
>
<EuiFlexItem grow={false}>
<EuiIcon type="logoElasticSearch" />
</EuiFlexItem>
Expand Down Expand Up @@ -82,7 +86,11 @@ export default class extends Component {
{/* Kibana section */}

<EuiSideNavTitle>
<EuiFlexGroup gutterSize="s" alignItems="center">
<EuiFlexGroup
gutterSize="s"
alignItems="center"
responsive={false}
>
<EuiFlexItem grow={false}>
<EuiIcon type="logoKibana" />
</EuiFlexItem>
Expand Down Expand Up @@ -153,7 +161,11 @@ export default class extends Component {
{/* Logstash section */}

<EuiSideNavTitle>
<EuiFlexGroup gutterSize="s" alignItems="center">
<EuiFlexGroup
gutterSize="s"
alignItems="center"
responsive={false}
>
<EuiFlexItem grow={false}>
<EuiIcon type="logoLogstash" />
</EuiFlexItem>
Expand Down
4 changes: 2 additions & 2 deletions src/components/accordion/__snapshots__/accordion.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`EuiAccordion is rendered 1`] = `
data-test-subj="test subject string"
>
<div
class="euiFlexGroup euiFlexGroup--alignItemsCenter"
class="euiFlexGroup euiFlexGroup--alignItemsCenter euiFlexGroup--responsive"
>
<div
class="euiFlexItem"
Expand All @@ -18,7 +18,7 @@ exports[`EuiAccordion is rendered 1`] = `
class="euiAccordion__button"
>
<div
class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter"
class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--responsive"
>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
Expand Down
5 changes: 5 additions & 0 deletions src/components/button/button_empty/_button_empty.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
height: $euiButtonHeightSmall;
}

&.euiButtonEmpty--xSmall {
height: $euiSizeL;
font-size: $euiFontSizeS;
}

&.euiButtonEmpty--iconRight {
.euiButtonEmpty__content {
@include euiButtonContent($isReverse: true);
Expand Down
1 change: 1 addition & 0 deletions src/components/button/button_empty/button_empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const colorToClassNameMap = {
export const COLORS = Object.keys(colorToClassNameMap);

const sizeToClassNameMap = {
xs: 'euiButtonEmpty--xSmall',
s: 'euiButtonEmpty--small',
l: 'euiButtonEmpty--large',
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/flex/__snapshots__/flex_group.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`EuiFlexGroup is rendered 1`] = `
<div
aria-label="aria-label"
class="euiFlexGroup euiFlexGroup--gutterLarge testClass1 testClass2"
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--responsive testClass1 testClass2"
data-test-subj="test subject string"
/>
`;
2 changes: 1 addition & 1 deletion src/components/flex/_flex_group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@


@include screenXSmall {
.euiFlexGroup {
.euiFlexGroup--responsive {
flex-wrap: wrap;
}
}
2 changes: 1 addition & 1 deletion src/components/flex/_flex_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// On mobile we force them to stack and act the same.
@include screenXSmall {
.euiFlexItem {
.euiFlexGroup--responsive .euiFlexItem {
width: 100% !important;
flex-basis: 100% !important;
margin-left: 0 !important;
Expand Down
7 changes: 6 additions & 1 deletion src/components/flex/flex_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ const justifyContentToClassNameMap = {

export const JUSTIFY_CONTENTS = Object.keys(justifyContentToClassNameMap);

export const EuiFlexGroup = ({ children, className, gutterSize, alignItems, justifyContent, ...rest }) => {
export const EuiFlexGroup = ({ children, className, gutterSize, alignItems, responsive, justifyContent, ...rest }) => {
const classes = classNames(
'euiFlexGroup',
gutterSizeToClassNameMap[gutterSize],
alignItemsToClassNameMap[alignItems],
justifyContentToClassNameMap[justifyContent],
{
'euiFlexGroup--responsive': responsive,
},
className
);

Expand All @@ -53,6 +56,7 @@ export const EuiFlexGroup = ({ children, className, gutterSize, alignItems, just
EuiFlexGroup.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
responsive: PropTypes.bool,
gutterSize: PropTypes.oneOf(GUTTER_SIZES),
alignItems: PropTypes.oneOf(ALIGN_ITEMS),
justifyContent: PropTypes.oneOf(JUSTIFY_CONTENTS),
Expand All @@ -61,5 +65,6 @@ EuiFlexGroup.propTypes = {
EuiFlexGroup.defaultProps = {
gutterSize: 'l',
alignItems: 'stretch',
responsive: true,
justifyContent: 'flexStart',
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`EuiHeaderAlert is rendered 1`] = `
class="euiHeaderAlert__text"
/>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--justifyContentSpaceBetween"
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--justifyContentSpaceBetween euiFlexGroup--responsive"
>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
Expand Down
5 changes: 3 additions & 2 deletions src/components/horizontal_rule/_horizontal_rule.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
}

$ruleMargins: (
marginSmall: $euiSizeS,
marginMedium: $euiSizeM,
marginXSmall: $euiSizeS,
marginSmall: $euiSizeM,
marginMedium: $euiSize,
marginLarge: $euiSizeL,
marginXLarge: $euiSizeXL,
marginXXLarge: $euiSizeXXL,
Expand Down
Loading

0 comments on commit b0e113b

Please sign in to comment.