Skip to content

Commit

Permalink
[DatePicker][Checkbox][IconButton][ListItem][MenuItem][EnhancedButton…
Browse files Browse the repository at this point in the history
…][TextField][RadioButton][Stepper][Table][Toggle] added 'cursor': 'not-allowed' for disabled state

[SelectField] pass "disabled" to TextField to proper handle "disabled" state
  • Loading branch information
Nikita Shulipa committed May 5, 2016
1 parent 0390140 commit 68f895b
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function getStyles(props, context) {
},
checkWhenDisabled: {
fill: checkbox.disabledColor,
cursor: 'not-allowed',
},
boxWhenDisabled: {
fill: props.checked ? 'transparent' : checkbox.disabledColor,
Expand Down
1 change: 1 addition & 0 deletions src/DatePicker/CalendarMonth.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CalendarMonth extends Component {
onTouchTap={this.handleTouchTap}
selected={selected}
disabled={disabled}
style={Object.assign({}, disabled && {cursor: 'not-allowed'})}
/>
);
}, this);
Expand Down
15 changes: 11 additions & 4 deletions src/DatePicker/CalendarToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class CalendarToolbar extends Component {
const nextButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronRight /> : <NavigationChevronLeft />;
const prevButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronLeft /> : <NavigationChevronRight />;

const isToolbarIconLeftDisabled = !this.props.prevMonth;
const isToolbarIconRightDisabled = !this.props.nextMonth;
const stylesToolbarIcons = {
left: Object.assign({}, styles.button, isToolbarIconLeftDisabled && {cursor: 'not-allowed'}),
right: Object.assign({}, styles.button, isToolbarIconRightDisabled && {cursor: 'not-allowed'}),
};

return (
<Toolbar style={styles.root} noGutter={true}>
<SlideInTransitionGroup
Expand All @@ -89,17 +96,17 @@ class CalendarToolbar extends Component {
</SlideInTransitionGroup>
<ToolbarGroup key={0} float="left">
<IconButton
style={styles.button}
disabled={!this.props.prevMonth}
style={stylesToolbarIcons.left}
disabled={isToolbarIconLeftDisabled}
onTouchTap={this.handleTouchTapPrevMonth}
>
{nextButtonIcon}
</IconButton>
</ToolbarGroup>
<ToolbarGroup key={1} float="right">
<IconButton
style={styles.button}
disabled={!this.props.nextMonth}
style={stylesToolbarIcons.right}
disabled={isToolbarIconRightDisabled}
onTouchTap={this.handleTouchTapNextMonth}
>
{prevButtonIcon}
Expand Down
2 changes: 1 addition & 1 deletion src/DatePicker/DateDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getStyles(props, context, state) {
marginBottom: 10,
},
yearTitle: {
cursor: (!selectedYear && !props.disableYearSelection) ? 'pointer' : 'default',
cursor: props.disableYearSelection ? 'not-allowed' : (!selectedYear ? 'pointer' : 'default'),
},
};

Expand Down
1 change: 1 addition & 0 deletions src/IconButton/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function getStyles(props, context) {
disabled: {
color: baseTheme.palette.disabledColor,
fill: baseTheme.palette.disabledColor,
cursor: 'not-allowed',
},
};
}
Expand Down
6 changes: 4 additions & 2 deletions src/List/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,13 @@ class ListItem extends Component {
style,
} = this.props;

const mergedDivStyles = Object.assign({},
const mergedDivStyles = Object.assign(
{},
styles.root,
styles.innerDiv,
innerDivStyle,
style
{cursor: 'not-allowed'},
style,
);

return (
Expand Down
1 change: 1 addition & 0 deletions src/MenuItem/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function getStyles(props, context) {
const styles = {
root: {
color: props.disabled ? disabledColor : textColor,
cursor: props.disabled ? 'not-allowed' : 'inherit',
lineHeight: props.desktop ? '32px' : '48px',
fontSize: props.desktop ? 15 : 16,
whiteSpace: 'nowrap',
Expand Down
2 changes: 2 additions & 0 deletions src/RadioButton/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ function getStyles(props, context) {
},
targetWhenDisabled: {
fill: radioButton.disabledColor,
cursor: 'not-allowed',
},
fillWhenDisabled: {
fill: radioButton.disabledColor,
cursor: 'not-allowed',
},
label: {
color: props.disabled ? radioButton.labelDisabledColor : radioButton.labelColor,
Expand Down
1 change: 1 addition & 0 deletions src/SelectField/SelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class SelectField extends Component {
return (
<TextField
style={style}
disabled={disabled}
floatingLabelText={floatingLabelText}
floatingLabelStyle={floatingLabelStyle}
hintStyle={hintStyle}
Expand Down
1 change: 1 addition & 0 deletions src/Stepper/StepLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const getStyles = ({active, completed, disabled}, {muiTheme, stepper}) => {
if (disabled) {
styles.icon.color = inactiveIconColor;
styles.root.color = disabledTextColor;
styles.root.cursor = 'not-allowed';
}

return styles;
Expand Down
5 changes: 3 additions & 2 deletions src/Table/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@ class TableBody extends Component {
if (!this.props.displayRowCheckbox) return null;

const key = `${rowProps.rowNumber}-cb`;
const isDisabled = !this.props.selectable;
const checkbox = (
<Checkbox
ref="rowSelectCB"
name={key}
value="selected"
disabled={!this.props.selectable}
disabled={isDisabled}
checked={rowProps.selected}
/>
);
Expand All @@ -204,7 +205,7 @@ class TableBody extends Component {
<TableRowColumn
key={key}
columnNumber={0}
style={{width: 24}}
style={Object.assing({width: 24}, isDisabled && {cursor: 'not-allowed'})}
>
{checkbox}
</TableRowColumn>
Expand Down
8 changes: 6 additions & 2 deletions src/Table/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,24 @@ class TableHeader extends Component {
getSelectAllCheckboxColumn(props) {
if (!this.props.displaySelectAll) return this.getCheckboxPlaceholder(props);

const isDisabled = !this.props.enableSelectAll;
const checkbox = (
<Checkbox
key="selectallcb"
name="selectallcb"
value="selected"
disabled={!this.props.enableSelectAll}
disabled={isDisabled}
checked={this.props.selectAllSelected}
onCheck={this.handleCheckAll}
/>
);

const key = `hpcb${props.rowNumber}`;
return (
<TableHeaderColumn key={key} style={{width: 24}}>
<TableHeaderColumn
key={key}
style={Object.assign({width: 24}, isDisabled && {cursor: 'not-allowed'})}
>
{checkbox}
</TableHeaderColumn>
);
Expand Down
2 changes: 1 addition & 1 deletion src/TextField/EnhancedTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getStyles(props, context, state) {
resize: 'none',
font: 'inherit',
padding: 0,
cursor: props.disabled ? 'default' : 'initial',
cursor: props.disabled ? 'not-allowed' : 'initial',
},
shadow: {
resize: 'none',
Expand Down
1 change: 1 addition & 0 deletions src/TextField/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const getStyles = (props, context, state) => {
outline: 'none',
backgroundColor: 'rgba(0,0,0,0)',
color: props.disabled ? disabledTextColor : textColor,
cursor: props.disabled ? 'not-allowed' : 'initial',
font: 'inherit',
},
textarea: {},
Expand Down
2 changes: 1 addition & 1 deletion src/TextField/TextFieldLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function getStyles(props) {
top: 38,
transition: transitions.easeOut(),
zIndex: 1, // Needed to display label above Chrome's autocomplete field background
cursor: props.disabled ? 'default' : 'text',
cursor: props.disabled ? 'not-allowed' : 'text',
transform: 'scale(1) translate3d(0, 0, 0)',
transformOrigin: 'left top',
pointerEvents: 'auto',
Expand Down
1 change: 1 addition & 0 deletions src/TextField/TextFieldUnderline.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const TextFieldUnderline = (props) => {
disabled: {
borderBottom: 'dotted 2px',
borderColor: disabledTextColor,
cursor: 'not-allowed',
},
focus: {
borderBottom: 'solid 2px',
Expand Down
3 changes: 3 additions & 0 deletions src/Toggle/Toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ function getStyles(props, context, state) {
},
trackWhenDisabled: {
backgroundColor: toggle.trackDisabledColor,
cursor: 'not-allowed',
},
thumbWhenDisabled: {
backgroundColor: toggle.thumbDisabledColor,
cursor: 'not-allowed',
},
label: {
color: disabled ? toggle.labelDisabledColor : toggle.labelColor,
cursor: disabled ? 'not-allowed' : 'initial',
width: `calc(100% - ${(toggleTrackWidth + 10)}px)`,
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/internal/EnhancedButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class EnhancedButton extends Component {
display: 'inline-block',
fontFamily: this.context.muiTheme.baseTheme.fontFamily,
WebkitTapHighlightColor: enhancedButton.tapHighlightColor, // Remove mobile color flashing (deprecated)
cursor: disabled ? 'default' : 'pointer',
cursor: disabled ? 'not-allowed' : 'pointer',
textDecoration: 'none',
outline: 'none',
fontSize: 'inherit',
Expand Down

0 comments on commit 68f895b

Please sign in to comment.