Skip to content

Commit

Permalink
Merge pull request #3051 from onumossn/rippled-tabs
Browse files Browse the repository at this point in the history
[Tabs] Use flat buttons for tabs
  • Loading branch information
newoga committed Feb 1, 2016
2 parents e331d45 + 5d848a8 commit 5f47b3d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 34 deletions.
7 changes: 7 additions & 0 deletions src/enhanced-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ const EnhancedButton = React.createClass({
cursor: disabled ? 'default' : 'pointer',
textDecoration: 'none',
outline: 'none',
/*
This is needed so that ripples do not bleed
past border radius.
See: http://stackoverflow.com/questions/17298739/
css-overflow-hidden-not-working-in-chrome-when-parent-has-border-radius-and-chil
*/
transform: disableTouchRipple && disableFocusRipple ? null : 'translate3d(0, 0, 0)',
}, style);

if (disabled && linkButton) {
Expand Down
3 changes: 0 additions & 3 deletions src/flat-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ const FlatButton = React.createClass({
minWidth: buttonMinWidth,
padding: 0,
margin: 0,
//This is need so that ripples do not bleed past border radius.
//See: http://stackoverflow.com/questions/17298739
transform: 'translate3d(0, 0, 0)',
}, style);

let iconCloned;
Expand Down
7 changes: 0 additions & 7 deletions src/floating-action-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,6 @@ const FloatingActionButton = React.createClass({
borderRadius: '50%',
textAlign: 'center',
verticalAlign: 'bottom',
/*
This is need so that ripples do not bleed
past border radius.
See: http://stackoverflow.com/questions/17298739/
css-overflow-hidden-not-working-in-chrome-when-parent-has-border-radius-and-chil
*/
transform: 'translate3d(0, 0, 0)',
},
containerWhenMini: {
height: themeVariables.miniSize,
Expand Down
7 changes: 0 additions & 7 deletions src/raised-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,6 @@ const RaisedButton = React.createClass({
borderRadius: 2,
transition: Transitions.easeOut(),
backgroundColor: this._getBackgroundColor(),
/*
This is need so that ripples do not bleed
past border radius.
See: http://stackoverflow.com/questions/17298739/
css-overflow-hidden-not-working-in-chrome-when-parent-has-border-radius-and-chil
*/
transform: 'translate3d(0, 0, 0)',
},
label: {
position: 'relative',
Expand Down
2 changes: 1 addition & 1 deletion src/styles/getMuiTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export default function getMuiTheme(baseTheme, muiTheme) {
},
tabs: {
backgroundColor: palette.primary1Color,
textColor: ColorManipulator.fade(palette.alternateTextColor, 0.6),
textColor: ColorManipulator.fade(palette.alternateTextColor, 0.7),
selectedTextColor: palette.alternateTextColor,
},
textField: {
Expand Down
29 changes: 15 additions & 14 deletions src/tabs/tab.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import StylePropable from '../mixins/style-propable';
import getMuiTheme from '../styles/getMuiTheme';
import EnhancedButton from '../enhanced-button';

const Tab = React.createClass({

Expand Down Expand Up @@ -110,28 +111,21 @@ const Tab = React.createClass({
const textColor = selected ? this.state.muiTheme.tabs.selectedTextColor : this.state.muiTheme.tabs.textColor;

const styles = this.mergeStyles({
display: 'table-cell',
cursor: 'pointer',
textAlign: 'center',
verticalAlign: 'middle',
paddingTop: (icon && !label) ? 4 : 0,
padding: '0px 12px',
height: (label && icon) ? 72 : 48,
color: textColor,
outline: 'none',
fontSize: 14,
fontWeight: 500,
whiteSpace: 'initial',
fontFamily: this.state.muiTheme.rawTheme.fontFamily,
boxSizing: 'border-box',
fontSize: 14,
width: width,
textTransform: 'uppercase',
}, style);

let iconElement;
if (icon && React.isValidElement(icon)) {
const params = {
style: {
fontSize: 24,
marginBottom: (label) ? 4 : 0,
marginBottom: (label) ? 5 : 0,
display: label ? 'block' : 'inline-block',
color: textColor,
},
Expand All @@ -143,15 +137,22 @@ const Tab = React.createClass({
iconElement = React.cloneElement(icon, params);
}

const rippleColor = styles.color;
const rippleOpacity = 0.3;

return (
<div
<EnhancedButton
{...other}
style={this.prepareStyles(styles)}
style={styles}
focusRippleColor={rippleColor}
touchRippleColor={rippleColor}
focusRippleOpacity={rippleOpacity}
touchRippleOpacity={rippleOpacity}
onTouchTap={this._handleTouchTap}
>
{iconElement}
{label}
</div>
</EnhancedButton>
);
},

Expand Down
2 changes: 0 additions & 2 deletions src/tabs/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,8 @@ const Tabs = React.createClass({
margin: 0,
padding: 0,
width: '100%',
height: 48,
backgroundColor: themeVariables.backgroundColor,
whiteSpace: 'nowrap',
display: 'table',
},
};

Expand Down

0 comments on commit 5f47b3d

Please sign in to comment.