Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled tab styling #258

Merged
merged 2 commits into from
Jan 3, 2018
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
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,
};