Skip to content

Commit

Permalink
Toggle:
Browse files Browse the repository at this point in the history
- customize toggle element width along with track width;
- update thumb switched on/off position styles with more flexible ones;
- customize toggle ripple styles;
- restore default toggle element width;
- restore breaking change in namespacing.
  • Loading branch information
misha-panyushkin committed Jun 16, 2015
1 parent 1bb3cef commit 2b4d95d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/toggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ var Toggle = React.createClass({
var toggleTrackWidth = 36;
var styles = {
icon: {
width: 36,
padding: '4px 0px 6px 2px'
},
toggleElemet: {
width: toggleTrackWidth
},
track: {
transition: Transitions.easeOut(),
width: toggleTrackWidth,
width: '100%',
height: 14,
borderRadius: 30,
backgroundColor: this.getTheme().trackOffColor
Expand All @@ -51,7 +55,7 @@ var Toggle = React.createClass({
transition: Transitions.easeOut(),
position: 'absolute',
top: 1,
left: 2,
left: 0,
width: toggleSize,
height: toggleSize,
lineHeight: '24px',
Expand All @@ -63,7 +67,7 @@ var Toggle = React.createClass({
},
thumbWhenSwitched: {
backgroundColor: this.getTheme().thumbOnColor,
left: 18
left: '100%'
},
trackWhenDisabled: {
backgroundColor: this.getTheme().trackDisabledColor
Expand Down Expand Up @@ -97,17 +101,23 @@ var Toggle = React.createClass({
this.props.disabled && styles.thumbWhenDisabled
);

if (this.state.switched) {
thumbStyles.marginLeft = '-' + thumbStyles.width;
}

var toggleElemetStyles = this.mergeAndPrefix(styles.toggleElemet, this.props.elementStyle);

var toggleElement = (
<div style={this.mergeAndPrefix(this.props.elementStyle)}>
<div style={toggleElemetStyles}>
<div style={trackStyles} />
<Paper style={thumbStyles} circle={true} zDepth={1} />
</div>
);

var customRippleStyle = {
var customRippleStyle = this.mergeAndPrefix({
top: '-10',
left: '-10'
};
}, this.props.rippleStyle);

var rippleColor = this.state.switched ?
this.getTheme().thumbOnColor : this.context.muiTheme.component.textColor;
Expand Down

0 comments on commit 2b4d95d

Please sign in to comment.