Skip to content

Commit

Permalink
Disabled tab styling (#258)
Browse files Browse the repository at this point in the history
Tabs now have a proper disabled state.
  • Loading branch information
snide authored Jan 3, 2018
1 parent e869da8 commit 7e95424
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**Bug fixes**

- Disabled tab styling. [(#258)[https://github.com/elastic/eui/pull/258]]
- Proper classname for flexGroup alignItems prop. [(#257)[https://github.com/elastic/eui/pull/257]]
- Clicking the downArrow icon in `EuiSelect` now triggers selection. [(#255)[https://github.com/elastic/eui/pull/255]]
- Fixed `euiFormRow` id's from being the same as the containing input and label. [(#251)[https://github.com/elastic/eui/pull/251]]
Expand Down
5 changes: 5 additions & 0 deletions src-docs/src/views/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ class EuiTabsExample extends React.Component {
this.tabs = [{
id: 'cobalt',
name: 'Cobalt',
disabled: false,
}, {
id: 'dextrose',
name: 'Dextrose',
disabled: false,
}, {
id: 'hydrogen',
name: 'Hydrogen',
disabled: true,
}, {
id: 'monosodium_glutammate',
name: 'Monosodium Glutamate',
disabled: false,
}];

this.state = {
Expand All @@ -40,6 +44,7 @@ class EuiTabsExample extends React.Component {
<EuiTab
onClick={() => this.onSelectedTabChanged(tab.id)}
isSelected={tab.id === this.state.selectedTabId}
disabled={tab.disabled}
key={index}
>
{tab.name}
Expand Down
10 changes: 10 additions & 0 deletions src/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
text-decoration: underline;
}

&.euiTab-isDisabled {
color: $euiColorMediumShade;

&:hover {
cursor: not-allowed;
text-decoration: none;
color: $euiColorMediumShade;
}
}

&.euiTab-isSelected {
cursor: default;
color: $euiColorPrimary;
Expand Down
7 changes: 6 additions & 1 deletion src/components/tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ export const EuiTab = ({
onClick,
children,
className,
disabled,
...rest
}) => {
const classes = classNames('euiTab', className, {
'euiTab-isSelected': isSelected
'euiTab-isSelected': isSelected,
'euiTab-isDisabled': disabled,
});

return (
Expand All @@ -20,6 +22,7 @@ export const EuiTab = ({
type="button"
className={classes}
onClick={onClick}
disabled={disabled}
{...rest}
>
<span className="euiTab__content">
Expand All @@ -31,11 +34,13 @@ export const EuiTab = ({

EuiTab.defaultProps = {
isSelected: false,
disabled: false,
};

EuiTab.propTypes = {
isSelected: PropTypes.bool,
onClick: PropTypes.func.isRequired,
children: PropTypes.node,
className: PropTypes.string,
disabled: PropTypes.bool,
};

0 comments on commit 7e95424

Please sign in to comment.