Skip to content

Commit

Permalink
size prop added to tabs, small tabs added
Browse files Browse the repository at this point in the history
  • Loading branch information
snide authored and bevacqua committed Nov 8, 2017
1 parent 9fb5a41 commit 45f26ca
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
15 changes: 12 additions & 3 deletions src-docs/src/views/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import {
EuiTabs,
EuiTab,
EuiSpacer,
} from '../../../../src/components';

class EuiTabsExample extends React.Component {
Expand Down Expand Up @@ -48,9 +49,17 @@ class EuiTabsExample extends React.Component {

render() {
return (
<EuiTabs>
{this.renderTabs()}
</EuiTabs>
<div>
<EuiTabs>
{this.renderTabs()}
</EuiTabs>

<EuiSpacer />

<EuiTabs size="s">
{this.renderTabs()}
</EuiTabs>
</div>
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src-docs/src/views/tabs/tabs_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export default props => (
}]}
text={
<p>
The <EuiCode>EuiTabs</EuiCode> component should have <EuiCode>EuiTab</EuiCode>
components as children.
<EuiCode>EuiTabs</EuiCode> allow a <EuiCode>size</EuiCode> prop. In general
you should always use the default size, but in rare cases (like putting tabs
within a popover of other small menu) it is OK to use the smaller sizing.
</p>
}
demo={
Expand Down
10 changes: 10 additions & 0 deletions src/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
.euiTabs {
display: flex;
border-bottom: $euiBorderThin;

&.euiTabs--small {
.euiTab {
@include euiFontSizeS;
padding: $euiSizeXS $euiSizeS;
}
}
}

.euiTab {
Expand Down Expand Up @@ -38,8 +45,11 @@
animation: euiTab $euiAnimSpeedFast $euiAnimSlightResistance;
}
}

}



.euiTab__content {
display: block;
transition: transform $euiAnimSpeedFast $euiAnimSlightBounce;
Expand Down
16 changes: 14 additions & 2 deletions src/components/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

const sizeToClassNameMap = {
s: 'euiTabs--small',
};

export const SIZES = Object.keys(sizeToClassNameMap);

export const EuiTabs = ({
size,
children,
className,
...rest
}) => {
const classes = classNames('euiTabs', className);
const classes = classNames(
'euiTabs',
sizeToClassNameMap[size],
className
);

return (
<div
Expand All @@ -22,5 +33,6 @@ export const EuiTabs = ({

EuiTabs.propTypes = {
children: PropTypes.node,
className: PropTypes.string
className: PropTypes.string,
size: PropTypes.oneOf(SIZES),
};

0 comments on commit 45f26ca

Please sign in to comment.