Skip to content

Commit

Permalink
revert wrong code removing fd40643
Browse files Browse the repository at this point in the history
  • Loading branch information
ddcat1115 committed Sep 28, 2017
1 parent 9b68ce0 commit 3b6dc3f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions components/layout/Sider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
// matchMedia polyfill for
// https://github.com/WickyNilliams/enquire.js/issues/82
if (typeof window !== 'undefined') {
const matchMediaPolyfill = (mediaQuery: string): MediaQueryList => {
return {
media: mediaQuery,
matches: false,
addListener() {
},
removeListener() {
},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
}

import React from 'react';
import classNames from 'classnames';
import omit from 'omit.js';
import PropTypes from 'prop-types';
import Icon from '../icon';

const dimensionMap = {
xs: '480px',
sm: '768px',
md: '992px',
lg: '1200px',
xl: '1600px',
};

export interface SiderProps {
style?: React.CSSProperties;
prefixCls?: string;
Expand Down Expand Up @@ -40,6 +64,13 @@ export default class Sider extends React.Component<SiderProps, any> {

constructor(props) {
super(props);
let matchMedia;
if (typeof window !== 'undefined') {
matchMedia = window.matchMedia;
}
if (matchMedia && props.breakpoint && props.breakpoint in dimensionMap) {
this.mql = matchMedia(`(max-width: ${dimensionMap[props.breakpoint]})`);
}
let collapsed;
if ('collapsed' in props) {
collapsed = props.collapsed;
Expand Down

0 comments on commit 3b6dc3f

Please sign in to comment.