mirror of
https://github.com/maputnik/editor.git
synced 2025-12-26 08:00:01 +00:00
Move accessibility checks into module.
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import Collapse from 'react-collapse'
|
||||
import lodash from 'lodash'
|
||||
import accessibility from '../../libs/accessibility'
|
||||
|
||||
|
||||
// Wait 3 seconds so when a user enables it they don't have to refresh the page.
|
||||
const isReduceMotionEnabled = lodash.throttle(() => {
|
||||
return window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||
}, 3000);
|
||||
|
||||
export default class CollapseReducedMotion extends React.Component {
|
||||
static propTypes = {
|
||||
isActive: PropTypes.bool.isRequired,
|
||||
@@ -16,7 +11,7 @@ export default class CollapseReducedMotion extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (isReduceMotionEnabled()) {
|
||||
if (accessibility.reducedMotionEnabled()) {
|
||||
return (
|
||||
<div style={{display: this.props.isActive ? "block" : "none"}}>
|
||||
{this.props.children}
|
||||
|
||||
Reference in New Issue
Block a user