From a3b0ac99620ada25345b5d4e502a21e8de550072 Mon Sep 17 00:00:00 2001 From: Neil Gabbadon Date: Thu, 14 Jan 2016 00:58:40 -0500 Subject: [PATCH] Removes style-resizable mixin from src The styles-resizable mixin is only used in one component: `snackbar.jsx`. It's used to see if the window.innerWidth is less than 768. This commit makes snackbar do a manual check against window to remove the mixin. Signed-off-by: Neil Gabbadon --- src/mixins/index.js | 3 -- src/mixins/style-resizable.js | 53 ----------------------------------- src/snackbar.jsx | 4 +-- 3 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 src/mixins/style-resizable.js diff --git a/src/mixins/index.js b/src/mixins/index.js index 2802fb9f091e27..31b2851d82f90d 100644 --- a/src/mixins/index.js +++ b/src/mixins/index.js @@ -1,16 +1,13 @@ import ClickAwayable from './click-awayable'; import WindowListenable from './window-listenable'; import StylePropable from './style-propable'; -import StyleResizable from './style-resizable'; export {ClickAwayable}; export {WindowListenable}; export {StylePropable}; -export {StyleResizable}; export default { ClickAwayable, WindowListenable, StylePropable, - StyleResizable, }; diff --git a/src/mixins/style-resizable.js b/src/mixins/style-resizable.js deleted file mode 100644 index 8cbb12097f5886..00000000000000 --- a/src/mixins/style-resizable.js +++ /dev/null @@ -1,53 +0,0 @@ -import Events from '../utils/events'; - -const Sizes = { - SMALL: 1, - MEDIUM: 2, - LARGE: 3, -}; - -export default { - - statics: { - Sizes: Sizes, - }, - - getInitialState() { - return { - deviceSize: Sizes.SMALL, - }; - }, - - componentDidMount() { - this._updateDeviceSize(); - if (!this.manuallyBindResize) this._bindResize(); - }, - - componentWillUnmount() { - this._unbindResize(); - }, - - isDeviceSize(desiredSize) { - return this.state.deviceSize >= desiredSize; - }, - - _updateDeviceSize() { - const width = window.innerWidth; - - if (width >= 992) { - this.setState({deviceSize: Sizes.LARGE}); - } else if (width >= 768) { - this.setState({deviceSize: Sizes.MEDIUM}); - } else { // width < 768 - this.setState({deviceSize: Sizes.SMALL}); - } - }, - - _bindResize() { - Events.on(window, 'resize', this._updateDeviceSize); - }, - - _unbindResize() { - Events.off(window, 'resize', this._updateDeviceSize); - }, -}; diff --git a/src/snackbar.jsx b/src/snackbar.jsx index 42418f28e1edc1..7fabcd5e46c2bd 100644 --- a/src/snackbar.jsx +++ b/src/snackbar.jsx @@ -6,7 +6,6 @@ import FlatButton from './flat-button'; import DefaultRawTheme from './styles/raw-themes/light-raw-theme'; import ThemeManager from './styles/theme-manager'; import ContextPure from './mixins/context-pure'; -import StyleResizable from './mixins/style-resizable'; import warning from 'warning'; import deprecated from './utils/deprecatedPropType'; @@ -102,7 +101,6 @@ const Snackbar = React.createClass({ mixins: [ StylePropable, - StyleResizable, ClickAwayable, ContextPure, ], @@ -236,7 +234,7 @@ const Snackbar = React.createClass({ actionColor, } = this.constructor.getRelevantContextKeys(this.state.muiTheme); - const isSmall = this.state.deviceSize === this.constructor.Sizes.SMALL; + const isSmall = window.innerWidth < 768; const styles = { root: {