Skip to content
Open
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
10 changes: 9 additions & 1 deletion docs/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -22538,7 +22538,9 @@
var _props = this.props,
className = _props.className,
_icons = _props.icons,
inputProps = _objectWithoutProperties(_props, ['className', 'icons']);
ariaLabel = _props['aria-label'],
ariaLabelledBy = _props['aria-labelledby'],
inputProps = _objectWithoutProperties(_props, ['className', 'icons', 'aria-label', 'aria-labelledby']);

var classes = (0, _classnames2.default)('react-toggle', {
'react-toggle--checked': this.state.checked,
Expand All @@ -22549,6 +22551,11 @@
return _react2.default.createElement(
'div',
{ className: classes,
role: 'switch',
'aria-checked': inputProps.checked,
'aria-disabled': this.props.disabled,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
onClick: this.handleClick,
onTouchStart: this.handleTouchStart,
onTouchMove: this.handleTouchMove,
Expand All @@ -22574,6 +22581,7 @@
},
onFocus: this.handleFocus,
onBlur: this.handleBlur,
hidden: 'hidden',
className: 'react-toggle-screenreader-only',
type: 'checkbox' }))
);
Expand Down
2 changes: 1 addition & 1 deletion docs/bundle.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions spec/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Object.keys(document.defaultView).forEach((property) => {
}
})

global.navigator = {
userAgent: 'node.js',
}
// global.navigator = {
// userAgent: 'node.js',
// }
20 changes: 16 additions & 4 deletions src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ export default class Toggle extends PureComponent {
}

render () {
const { className, icons: _icons, ...inputProps } = this.props
const {
className,
icons: _icons,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
...inputProps
} = this.props
const classes = classNames('react-toggle', {
'react-toggle--checked': this.state.checked,
'react-toggle--focus': this.state.hasFocus,
Expand All @@ -142,7 +148,14 @@ export default class Toggle extends PureComponent {

return (
<div className={classes}
role='switch'
aria-checked={inputProps.checked}
aria-disabled={this.props.disabled}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
onClick={this.handleClick}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
onTouchStart={this.handleTouchStart}
onTouchMove={this.handleTouchMove}
onTouchEnd={this.handleTouchEnd}>
Expand All @@ -159,9 +172,8 @@ export default class Toggle extends PureComponent {
<input
{...inputProps}
ref={ref => { this.input = ref }}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
className='react-toggle-screenreader-only'
hidden='hidden'
className='react-toggle-hidden-input'
type='checkbox' />
</div>
)
Expand Down
11 changes: 2 additions & 9 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@
-webkit-tap-highlight-color: transparent;
}

.react-toggle-screenreader-only {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
.react-toggle-hidden-input {
display: none;
}

.react-toggle--disabled {
Expand Down